/*******************************************************************************
 **
 ** The source file for the Jahshaka animation interface module
 ** The Jahshaka Project
 ** Copyright (C) 2000-2005 The Jahshaka Project
 ** Released under the GNU General Public License
 **
 *******************************************************************************/

#include "tracker.h"
#include "qslider.h"
#include "qpalette.h"
#include <jahformatter.h>
#include <valueFormatters.h>
#include <jahtranslate.h>
#include <InputLCD.h>
#include <supergrangecontrol.h>
#include <qframe.h>
#include <qhbox.h>
#include <qlistview.h>
#include <qcombobox.h>
#include <qtoolbutton.h>
#include <qlabel.h>
#include <widget.h>
#include <openmedialib.h>

void GLTracker::buildInterfaceMenus( QHBox* , QHBox* rightcontroller) 
{
   	// Container widget
	QWidget *container = new QWidget( rightcontroller, "container" );
	QVBoxLayout *container_layout = new QVBoxLayout( container, 0, 0, "container_layout");

	container_layout->addStretch( );
 
    //moving ui elements after zoom
    tooltranslate = new JahToolButton( container, "translate" );
    JahFormatter::addJahPlayerButton( tooltranslate, JahBasePath+"Pixmaps/desktop/transtool.png", JahBasePath+"Pixmaps/desktop/transtool.png" );
	container_layout->addWidget( tooltranslate );
    
    toolrotate =   new JahToolButton( container, "rotate" );
    JahFormatter::addJahPlayerButton( toolrotate, JahBasePath+"Pixmaps/desktop/rotatetool.png", JahBasePath+"Pixmaps/desktop/rotatetool.png" );
	container_layout->addWidget( toolrotate );
    
    toolscale =   new JahToolButton( container, "scale" );
    JahFormatter::addJahPlayerButton( toolscale,  JahBasePath+"Pixmaps/desktop/scaletool.png", JahBasePath+"Pixmaps/desktop/scaletool.png" );
	container_layout->addWidget( toolscale );

	container_layout->addSpacing( 10 );
    
    scrubrender = new JahToolButton( container, "controllerrewindbutton" );
    JahFormatter::addJahPlayerButton( scrubrender, JahBasePath+"Pixmaps/desktop/phototool.png", JahBasePath+"Pixmaps/desktop/phototool.png" );
    connect( scrubrender,  SIGNAL(clicked()), SLOT(Render())  );
	container_layout->addWidget( scrubrender );
    
    scrubrenderAll = new JahToolButton( container, "controllerpreviousbutton" );
    JahFormatter::addJahPlayerButton( scrubrenderAll, JahBasePath+"Pixmaps/desktop/rendertool.png", JahBasePath+"Pixmaps/desktop/rendertool.png" );
    connect( scrubrenderAll,  SIGNAL(clicked()), SLOT(RenderScene())  );
	container_layout->addWidget( scrubrenderAll );
    
    //connect tools to object and add object to display widget
    connect( tooltranslate,  SIGNAL(clicked()), this, SLOT(toolTranslate() )  );
    connect( toolscale,      SIGNAL(clicked()), this, SLOT(toolScale() )  );
    connect( toolrotate,     SIGNAL(clicked()), this, SLOT(toolRotate() )  );
    
	container_layout->addStretch( );
}

void GLTracker::buildInterface( QHBox* f ) 
{
    JahPrefs& jprefs = JahPrefs::getInstance();
    
    JahFormatter::setMarginSmall( f->layout() );
    JahFormatter::setSpacing( f->layout() );

    /////////////////////////////////////////////////////////
    //this is the list-view
    m_layer_listview = new QListView( f );

    m_layer_listview->setRootIsDecorated(true);
    m_layer_listview->addColumn( (jt->tr("EFFECTS")), -1 );
    m_layer_listview->setSorting( -1,1 );   // disables the autosort    
    //effects currently only works in single selection mode
    m_layer_listview->setSelectionMode (QListView::Single );
    
    JahFormatter::setListViewAsSingleColumn( m_layer_listview );

    connect( m_layer_listview, SIGNAL( clicked( QListViewItem* ) ), this, SLOT( layerClicked( QListViewItem* ) ) );
    
    /////////////////////////////////////////////////////////
    //Set up tabbed interface
    
    tabframe = new QTabWidget( f, "axiscontrols" );  
    
    tabframe->setTabShape( QTabWidget::Triangular );
    tabframe->setAutoMask( FALSE );
    
    //this has become the settings panel need to update variable names
    moduleOptionsUI[0] = new QHBox( f, "encoderUI0" ); //scenecontrols
    tabframe->insertTab( moduleOptionsUI[0], tr( "  "+jt->tr("SCENE")+"  " ) );
    
    moduleOptionsUI[1] = new QHBox( f, "axiscontrols" ); //axiscontrols
    tabframe->insertTab( moduleOptionsUI[1], tr( "  "+jt->tr("CONTROLS")+"  " ) );
    
    moduleOptionsUI[2] = new QHBox( f, "texturecontrols" ); //texturecontrols
    tabframe->insertTab( moduleOptionsUI[2], tr( "    "+jt->tr("CLIP")+"    " ) );
    
    //this has become the settings panel need to update variable names
    moduleOptionsUI[3] = new QHBox( f, "keysettings" ); //keycontrols
    tabframe->insertTab( moduleOptionsUI[3], tr( "  "+jt->tr("KEYFRAMES")+"  " ) );
    
    /////////////////////////////////////////////////////////////////////
    // the layout boxes for different types of layers
    // the object control tab bar
    // this is the object control panel
    
    ///////////////////////////////////////////////////////////////////
    // the scene control tab bar
    
    //mover this into the layers...
    {
        ControlFrameUI[0][0] = new QFrame( moduleOptionsUI[0], "ControlFrame3" ); //scenecontrols
        QBoxLayout* outer = new QVBoxLayout( ControlFrameUI[0][0] );
        QBoxLayout* top = new QHBoxLayout();
        JahFormatter::setMarginAndSpacing( top );
        outer->addLayout( top );

        QBoxLayout* buttons = new QVBoxLayout();
        top->addLayout( buttons );

        LoadButton = new QPushButton( ControlFrameUI[0][0], "LoadButton" );
        buttons->addWidget( LoadButton );
        LoadButton->setText( jt->tr("Load") );
        connect( LoadButton,  SIGNAL(clicked()), this, SLOT( SceneLoad())  );
    
        SaveButton = new QPushButton( ControlFrameUI[0][0], "SaveButton" );
        buttons->addWidget( SaveButton );
        SaveButton->setText( jt->tr("Save") );
        connect( SaveButton,  SIGNAL(clicked()), this, SLOT( sceneSave())  );
    
        ResetButton = new QPushButton( ControlFrameUI[0][0], "ResetButton" );
        buttons->addWidget( ResetButton );
        ResetButton->setText( jt->tr("Reset All") );
        connect( ResetButton,  SIGNAL(clicked()), this, SLOT( ResetAll())  );
    
        buttons->addStretch();

        QBoxLayout* framesAndRes = new QVBoxLayout();
        top->addLayout( framesAndRes );
        JahFormatter::setMarginAndSpacing( framesAndRes );

        //need to move this into the module
        //this is mandatory for all modules...
        QGridLayout* frames = new QGridLayout( 2, 2 );
        framesAndRes->addLayout( frames );
        
        QLabel* sframetext = new QLabel( ControlFrameUI[0][0], "sframetext" );
        frames->addWidget( sframetext, 0, 0 );
        sframetext->setText( tr( jt->tr("STARTFRAME") ) );
        sframetext->setAlignment( int( QLabel::AlignRight ) );
    
        startFrameControl = new SupergRangeControl( ControlFrameUI[0][0], "startframe" );
        frames->addWidget( startFrameControl, 0, 1 );
        startFrameControl->setFormatter( TimecodeValueFormatter() );
        JahFormatter::configure( startFrameControl, Astartframe, Astartframe );
        connect( startFrameControl, SIGNAL(valueChanged(int)),   SLOT(updatesliderStartframe(int)) );
    
        QLabel* eframetext = new QLabel( ControlFrameUI[0][0], "eframetext" );
        frames->addWidget( eframetext, 1, 0 );
        eframetext->setText( tr( jt->tr("ENDFRAME")  ) );
        eframetext->setAlignment( int( QLabel::AlignRight ) );
    
        endFrameControl = new SupergRangeControl( ControlFrameUI[0][0], "endframe" );
        frames->addWidget( endFrameControl, 1, 1 );
        endFrameControl->setFormatter( TimecodeValueFormatter() );
        JahFormatter::configure( endFrameControl, Aendframe, Astartframe );
        connect( endFrameControl, SIGNAL(valueChanged(int)),   SLOT(updatesliderEndframe(int)) );
    
        QBoxLayout* resolution = new QVBoxLayout();
        framesAndRes->addLayout( resolution );
        
        jahreslabel = new QLabel( ControlFrameUI[0][0], "languagelabel" );
        resolution->addWidget( jahreslabel );
        jahreslabel->setAlignment( int( QLabel::AlignCenter ) );
        jahreslabel->setText( jt->tr( "Resolution" ) );
    
        JahresCombo = new QComboBox( FALSE, ControlFrameUI[0][0], "JahresCombo" );
        resolution->addWidget( JahresCombo );
        projectData thedata;
        thedata.buildComboBox(JahresCombo);
        int defaultRes = jprefs.getJahResolution();
        JahresCombo->setCurrentItem(defaultRes); //should be set to appdefault
        connect( JahresCombo,  SIGNAL(activated(int)), this, SLOT(setResolution(int))  );
        hasResMenu = true;

        framesAndRes->addStretch();
        top->addStretch();
        outer->addStretch();
    }
    
    
    ///////////////////////////////////////////////////////////////
    // object layer options sub control set
    
    ControlFrameUI[1][0] = new QFrame( moduleOptionsUI[1], "ControlFrame1" ); //ControlFrame1
    
    //createAxisPanel ( ControlFrameUI[1][0] );
    
    int x_position = 10;
    int y_position = 20;
    
    m_x_position_slider = new QSlider( ControlFrameUI[1][0] );
    m_x_position_lcd = new InputLCD( ControlFrameUI[1][0] );
    m_x_position_label = new QLabel( ControlFrameUI[1][0] );
    
    JahFormatter::addJahSliderGroup(  ControlFrameUI[1][0], m_x_position_slider, 
                                      x_position, y_position, 80, 21,  500, m_x_position_lcd,
                                      m_x_position_label, "X Position", 9);
    
    m_x_position_lcd->setMinInt(-500);
    m_x_position_lcd->setMaxInt(500);
    m_x_position_lcd->setValue(0);
    
    connect( m_x_position_slider, SIGNAL(valueChanged(int)), this, SLOT( setXRotation(int) ) );
    connect( m_x_position_lcd, SIGNAL(valueChanged(int)), m_x_position_slider, SLOT( setValue(int) ) );
    connect( m_x_position_slider, SIGNAL(valueChanged(int)), m_x_position_lcd, SLOT( setValue(int) ) );
    connect( m_x_position_slider, SIGNAL(valueChanged(int)), this, SLOT(captureTrackerPoint(int)) );
    
    
    y_position += 40;
    
    m_y_position_slider = new QSlider( ControlFrameUI[1][0] );
    m_y_position_lcd = new InputLCD( ControlFrameUI[1][0] );
    m_y_position_label = new QLabel( ControlFrameUI[1][0] );
    
    JahFormatter::addJahSliderGroup(  ControlFrameUI[1][0], m_y_position_slider, 
                                      x_position, y_position, 80, 21,  500, m_y_position_lcd,
                                      m_y_position_label, "Y Position", 9);
    
    m_y_position_lcd->setMinInt(-500);
    m_y_position_lcd->setMaxInt(500);
    m_y_position_lcd->setValue(0);
    
    connect( m_y_position_slider, SIGNAL(valueChanged(int)), this, SLOT( setYRotation(int) ) );
    connect( m_y_position_lcd, SIGNAL(valueChanged(int)), m_y_position_slider, SLOT( setValue(int) ) );
    connect( m_y_position_slider, SIGNAL(valueChanged(int)), m_y_position_lcd, SLOT( setValue(int) ) );
    connect( m_y_position_slider, SIGNAL(valueChanged(int)), this, SLOT(captureTrackerPoint(int)) );
    
    
    y_position += 40;
    
    m_point_radius_slider = new QSlider( ControlFrameUI[1][0] );
    m_point_radius_lcd = new InputLCD( ControlFrameUI[1][0] );
    m_point_radius_label = new QLabel( ControlFrameUI[1][0] );
    
    JahFormatter::addJahSliderGroup(  ControlFrameUI[1][0], m_point_radius_slider, 
                                      x_position, y_position, 80, 21,  500, m_point_radius_lcd,
                                      m_point_radius_label, "Point Radius", 9);
    
    m_point_radius_slider->setMinValue(0);
    m_point_radius_lcd->setMinInt(0);
    m_point_radius_lcd->setMaxInt(500);
    m_point_radius_lcd->setValue(0);
    
    connect( m_point_radius_slider, SIGNAL(valueChanged(int)), this, SLOT( setZRotation(int) ) );
    connect( m_point_radius_lcd, SIGNAL(valueChanged(int)), m_point_radius_slider, SLOT( setValue(int) ) );
    connect( m_point_radius_slider, SIGNAL(valueChanged(int)), m_point_radius_lcd, SLOT( setValue(int) ) );
    connect( m_point_radius_slider, SIGNAL(valueChanged(int)), this, SLOT(captureTrackerPoint(int)) );
    
    x_position += 230;
    y_position = 20;
    
    m_point_search_radius_slider = new QSlider( ControlFrameUI[1][0] );
    m_point_search_radius_lcd = new InputLCD( ControlFrameUI[1][0] );
    m_point_search_radius_label = new QLabel( ControlFrameUI[1][0] );
    
    JahFormatter::addJahSliderGroup(  ControlFrameUI[1][0], m_point_search_radius_slider, 
                                      x_position, y_position, 80, 21,  500, m_point_search_radius_lcd,
                                      m_point_search_radius_label, "Search Radius", 9);
    
    m_point_search_radius_slider->setMinValue(0);
    m_point_search_radius_lcd->setMinInt(0);
    m_point_search_radius_lcd->setMaxInt(500);
    m_point_search_radius_lcd->setValue(0);
    
    connect( m_point_search_radius_slider, SIGNAL(valueChanged(int)), this, SLOT( setXTrans(int) ) );
    connect( m_point_search_radius_lcd, SIGNAL(valueChanged(int)), m_point_search_radius_slider, SLOT( setValue(int) ) );
    connect( m_point_search_radius_slider, SIGNAL(valueChanged(int)), m_point_search_radius_lcd, SLOT( setValue(int) ) );
    connect( m_point_search_radius_slider, SIGNAL(valueChanged(int)), this, SLOT(captureTrackerPoint(int)) );
    
    y_position += 40;
    
    m_point_sensitivity_slider = new QSlider( ControlFrameUI[1][0] );
    m_point_sensitivity_lcd = new InputLCD( ControlFrameUI[1][0] );
    m_point_sensitivity_label = new QLabel( ControlFrameUI[1][0] );
    
    JahFormatter::addJahSliderGroup(  ControlFrameUI[1][0], m_point_sensitivity_slider, 
                                      x_position, y_position, 80, 21,  500, m_point_sensitivity_lcd,
                                      m_point_sensitivity_label, "Sensitivity", 9);
    
    m_point_sensitivity_lcd->setMinInt(-500);
    m_point_sensitivity_lcd->setMaxInt(500);
    m_point_sensitivity_lcd->setValue(0);
    
    connect( m_point_sensitivity_slider, SIGNAL(valueChanged(int)), this, SLOT( setYTrans(int) ) );
    connect( m_point_sensitivity_lcd, SIGNAL(valueChanged(int)), m_point_sensitivity_slider, SLOT( setValue(int) ) );
    connect( m_point_sensitivity_slider, SIGNAL(valueChanged(int)), m_point_sensitivity_lcd, SLOT( setValue(int) ) );
    connect( m_point_sensitivity_slider, SIGNAL(valueChanged(int)), this, SLOT(captureTrackerPoint(int)) );
    
    y_position += 40;
    
    m_point_checksum_tolerance_slider = new QSlider( ControlFrameUI[1][0] );
    m_point_checksum_tolerance_lcd = new InputLCD( ControlFrameUI[1][0] );
    m_point_checksum_tolerance_label = new QLabel( ControlFrameUI[1][0] );
    
    JahFormatter::addJahSliderGroup(  ControlFrameUI[1][0], m_point_checksum_tolerance_slider, 
                                      x_position, y_position, 80, 21,  500, m_point_checksum_tolerance_lcd,
                                      m_point_checksum_tolerance_label, "Checksum Tolerance", 9);
    
    m_point_checksum_tolerance_lcd->setMinInt(-500);
    m_point_checksum_tolerance_lcd->setMaxInt(500);
    m_point_checksum_tolerance_lcd->setValue(0);
    
    connect( m_point_checksum_tolerance_slider, SIGNAL(valueChanged(int)), this, SLOT( setZTrans(int) ) );
    connect( m_point_checksum_tolerance_lcd, SIGNAL(valueChanged(int)), m_point_checksum_tolerance_slider, SLOT( setValue(int) ) );
    connect( m_point_checksum_tolerance_slider, SIGNAL(valueChanged(int)), m_point_checksum_tolerance_lcd, SLOT( setValue(int) ) );
    connect( m_point_checksum_tolerance_slider, SIGNAL(valueChanged(int)), this, SLOT(captureTrackerPoint(int)) );
    
    
    m_stabilize_qcheckbox = new QCheckBox( ControlFrameUI[1][0], "Stabilize" );
    m_stabilize_qcheckbox->setGeometry( QRect( 500, 20, 210, 21 ) );
    m_stabilize_qcheckbox->setText( "Stabilize" );
    connect( m_stabilize_qcheckbox,  SIGNAL(clicked()), this, SLOT(setStabilize())  );
    
    m_use_gpu_qcheckbox = new QCheckBox( ControlFrameUI[1][0], "GPUSelect" );
    m_use_gpu_qcheckbox->setGeometry( QRect( 500, 40, 210, 21 ) );
    m_use_gpu_qcheckbox->setText( "Use GPU" );
    m_use_gpu_qcheckbox->toggle();
    connect( m_use_gpu_qcheckbox,  SIGNAL(clicked()), this, SLOT(setGpuSelect())  );
        
    //add the placeholders for plugins
    JahModuleOption[0] = new QCheckBox( ControlFrameUI[1][0], "Placeholder" );
    JahFormatter::addCheckButton( JahModuleOption[0], 520, 30, 145, 25, "Placeholder1" );
    connect( JahModuleOption[0],  SIGNAL(clicked()), this, SLOT(setOption1())  ); //for clip
    
    //increment the ui uption counter...
    numUiOptions +=1;
    
    //add the placeholders for plugins
    JahModuleOption[1] = new QCheckBox( ControlFrameUI[1][0], "Placeholder" );
    JahFormatter::addCheckButton( JahModuleOption[1], 520, 60, 145, 25, "Placeholder2" );
    connect( JahModuleOption[1],  SIGNAL(clicked()), this, SLOT(setOption2())  ); //for clip
    
    //increment the ui uption counter...
    numUiOptions +=1;
    
    //add the placeholders for plugins
    JahModuleOption[2] = new QCheckBox( ControlFrameUI[1][0], "Placeholder" );
    JahFormatter::addCheckButton( JahModuleOption[2], 520, 90, 145, 25, "Placeholder3" );
    connect( JahModuleOption[2],  SIGNAL(clicked()), this, SLOT(setOption3())  ); //for clip
    
    //increment the ui uption counter...
    numUiOptions +=1;
    
    //add the placeholders for plugins
    JahModuleOption[3] = new QCheckBox( ControlFrameUI[1][0], "Placeholder" );
    JahFormatter::addCheckButton( JahModuleOption[3], 520, 120, 145, 25, "Placeholder4" );
    connect( JahModuleOption[3],  SIGNAL(clicked()), this, SLOT(setOption4())  ); //for clip
    
    //increment the ui uption counter...
    numUiOptions +=1;
    
    hasButtons = true;
    
    
    ///////////////////////////////////////////////////////////////
    // texture layer options
    // need to add video-texture options here
    //image options
    
    ControlFrameUI[2][0] = new QFrame( moduleOptionsUI[2], "ControlFrame2" ); //was ControlFrame2
    
    ClipSelect = new QCheckBox( ControlFrameUI[2][0], "ClipSelect" );
    JahFormatter::addCheckButton( ClipSelect, 0, 30, 45, 25, jt->tr("Clip") );
    connect( ClipSelect,  SIGNAL(clicked()), this, SLOT(setClipStatus())  ); //for clip
    
    grabdesktopClip = new QPushButton( ControlFrameUI[2][0], "grabdesktop" );
    JahFormatter::addButton( grabdesktopClip, 45, 30, 110, 25, jt->tr("Grab Desktop") );
    //connect( grabdesktopClip,  SIGNAL(clicked()), this, SLOT(grabDesktop())  );
    
    keyimage_2 = new QPushButton( ControlFrameUI[2][0], "clipmapping" );
    JahFormatter::addButton( keyimage_2, 165, 30, 35, 25, "IM" );
    //connect( keyimage_2,  SIGNAL(clicked()), this, SLOT(keyCliplayer())  );
    
    
    KeySelect = new QCheckBox( ControlFrameUI[2][0], "KeySelect" );
    JahFormatter::addCheckButton( KeySelect, 0, 75, 45, 25, jt->tr("Key") );
    connect( KeySelect,  SIGNAL(clicked()), this, SLOT(setKeyStatus())  );
    
    grabdesktopKey = new QPushButton( ControlFrameUI[2][0], "grabdesktop" );
    JahFormatter::addButton( grabdesktopKey, 45, 75, 110, 25, jt->tr("Grab Desktop") );
    //connect( grabdesktopKey,  SIGNAL(clicked()), this, SLOT(grabDesktopKey())  ); //for key...
    
    keyimage_3 = new QPushButton( ControlFrameUI[2][0], "keyOne_3" );
    JahFormatter::addButton( keyimage_3, 165, 75, 35, 25, "KM" );
    //connect( keyimage_3,  SIGNAL(clicked()), this, SLOT(keyClipkey())  );
    
    keyStatusBox = new QPushButton( ControlFrameUI[2][0], "Select1" );
    JahFormatter::addButton( keyStatusBox, 220, 75, 35, 25, "Invert" );
    connect( keyStatusBox,  SIGNAL(clicked()), this, SLOT(InvertKeyData())  );
    
    // video options
    // need to hook this up now...
    
    VideoLabel = new QLabel( ControlFrameUI[2][0], "TranslateText_1" );
    JahFormatter::addLabel( VideoLabel, 380, 10, 110, 21, "VIDEO OPTIONS", 9);
    
    
    FramesLcd = new InputLCD( ControlFrameUI[2][0] );
    JahFormatter::addLabelLcd( ControlFrameUI[2][0], FramesLcd,       380, 30, 60, 21,  0,  "Frames", 8);
    FramesLcd->setActive    (false);
    
    inFramesLcd = new InputLCD( ControlFrameUI[2][0] );
    JahFormatter::addLcdLabel( ControlFrameUI[2][0], inFramesLcd,     460, 30, 30, 21,  0,  "In", 8);
    connect(inFramesLcd, SIGNAL(valueChanged(int)), this, SLOT(setinFrames(int)) );
    
    outFramesLcd = new InputLCD( ControlFrameUI[2][0] );
    JahFormatter::addLcdLabel( ControlFrameUI[2][0], outFramesLcd,    530, 30, 30, 21,  0,  "Out", 8);
    connect(outFramesLcd, SIGNAL(valueChanged(int)), this, SLOT(setoutFrames(int)) );
    
    KeyFramesLcd = new InputLCD( ControlFrameUI[2][0] );
    JahFormatter::addLabelLcd( ControlFrameUI[2][0], KeyFramesLcd,    380, 75, 60, 21,  0,  "Frames", 8);
    
    inKeyFramesLcd = new InputLCD( ControlFrameUI[2][0] );
    JahFormatter::addLcdLabel( ControlFrameUI[2][0], inKeyFramesLcd,  460, 75, 30, 21,  0,  "In", 8);
    connect(inKeyFramesLcd, SIGNAL(valueChanged(int)), this, SLOT(setinKeyFrames(int)) );
    
    outKeyFramesLcd = new InputLCD( ControlFrameUI[2][0] );
    JahFormatter::addLcdLabel( ControlFrameUI[2][0], outKeyFramesLcd, 530, 75, 30, 21,  0,  "Out", 8);
    connect(outKeyFramesLcd, SIGNAL(valueChanged(int)), this, SLOT(setoutKeyFrames(int)) );
    
    extendHeadTail = new QCheckBox( ControlFrameUI[2][0], "extendHeadTail" );
    JahFormatter::addCheckButton( extendHeadTail, 380, 95, 100, 25, "Extend Head-Tail" );
    connect( extendHeadTail,  SIGNAL(clicked()), this, SLOT(toggleExtendHeadTail())  );
    
    toggleTheLoop = new QCheckBox( ControlFrameUI[2][0], "toggleTheLoop" );
    JahFormatter::addCheckButton( toggleTheLoop, 480, 95, 100, 25, "Loop" );
    connect( toggleTheLoop,  SIGNAL(clicked()), this, SLOT(toggleLoop())  );
    
    togglePing = new QCheckBox( ControlFrameUI[2][0], "togglePing" );
    JahFormatter::addCheckButton( togglePing, 480, 130, 100, 25, "Ping Pong" );
    connect( togglePing,  SIGNAL(clicked()), this, SLOT(togglePingPong())  );
    
    //what is this used for?
    //need to make the icon a lock... 3x current height as well for links
    lockicon    = new QToolButton(ControlFrameUI[2][0],"lockicon");
    lockicon->setGeometry( QRect( 600, 55, 18, 26 ) );
    lockicon->setFixedSize(18, 26);     //lighticon->setUsesBigPixmap(true);
    lockicon->setAutoRaise(true);
    
    
}

void GLTracker::createMenuItem( QPopupMenu * themenu )
{
    Q_CHECK_PTR(themenu);
    //themenu->insertItem("&"+jt->tr("Name Object"),this,SLOT(nameLayer()) );
    //themenu->insertItem("&"+jt->tr("Delete Object"),this,SLOT(delLayer()) );
    themenu->insertSeparator();
    //make this a popup 'Move'
    //themenu->insertItem("&"+jt->tr("Move Up"),this, SLOT(moveLayerUp()) );
    //themenu->insertItem("&"+jt->tr("Move Down"),this, SLOT(moveLayerDown()) ); 
}
