Exemplo n.º 1
0
djvFileEdit::djvFileEdit(QWidget * parent) :
    QWidget(parent),
    _p(new P)
{
    // Create the widgets.

    _p->edit = new QLineEdit;

    QPushButton * button = new QPushButton(tr("&Browse"));

    // Layout the widgets.

    QHBoxLayout * layout = new QHBoxLayout(this);
    layout->setMargin(0);
    layout->addWidget(_p->edit, 1);
    layout->addWidget(button);

    // Initialize.

    widgetUpdate();

    // Setup the callbacks.

    connect(_p->edit, SIGNAL(editingFinished()), SLOT(editCallback()));
    
    connect(button, SIGNAL(clicked()), SLOT(buttonCallback()));
}
Exemplo n.º 2
0
//*********************************************************************************************************
void checkButtons()
{
	// last time the respective button was pressed; used for debouncing;
static unsigned long timeBtnMenu;
static unsigned long timeBtnSet;
static unsigned long timeBtnPlus;

  if (but_1.capSense(30)  > CapThreshold) 
  {
    if (abs(millis() - timeBtnMenu) < BOUNCE_TIME_BUTTON)  return;

    if(buttonCallback != NULL)
      buttonCallback(BUTTON_MENU);

    timeBtnMenu	=	millis();
  }	

  if (but_2.capSense(30) > CapThreshold) 
  {
    // debouncing;
    if (abs(millis() - timeBtnSet) < BOUNCE_TIME_BUTTON)  return;

    if(buttonCallback != NULL)
      buttonCallback(BUTTON_SET);

    timeBtnSet	=	millis();
  }

  if (but_3.capSense(30) > CapThreshold) 
  {

    // debouncing;
    if (abs(millis() - timeBtnPlus) < BOUNCE_TIME_BUTTON)  return;
    if(buttonCallback != NULL)
      buttonCallback(BUTTON_PLUS);
    timeBtnPlus	=	millis();
  }

}	
int Button::Click(int x, int y, int* clickLocation) {
	
	int windowBounds[4];

	this->rendering->GetWindowBounds(this, windowBounds);

	if (x < windowBounds[1]
		&& x > windowBounds[0]
		&& y < windowBounds[3]
		&& y > windowBounds[2]) {

		clickLocation[0] = x - windowBounds[0];
		clickLocation[1] = y - windowBounds[2];

		std::cout << "I was clicked!" << std::endl;

		buttonCallback();	
		
		return 1;
	}
	return 0;
}
Exemplo n.º 4
0
void VisualizerEditor::buttonEvent(Button* button)
{

    int gId = button->getRadioGroupId();

    if (gId > 0)
    {
        if (canvas != nullptr)
        {
            canvas->setParameter(gId-1, button->getName().getFloatValue());
        }

    }
    else
    {

        if (canvas == nullptr)
        {

            canvas = createNewCanvas();
            canvas->update();

            if (isPlaying)
                canvas->beginAnimation();
        }

        if (button == windowSelector)
        {

            if (tabSelector->getToggleState() && windowSelector->getToggleState())
            {
                tabSelector->setToggleState(false, false);
                getDataViewport()->destroyTab(tabIndex);
                tabIndex = -1;
            }

            if (dataWindow == nullptr)
            {

                dataWindow = new DataWindow(windowSelector, tabText);
                dataWindow->setContentNonOwned(canvas, false);
                dataWindow->setVisible(true);
                canvas->refreshState();

            }
            else
            {

                dataWindow->setVisible(windowSelector->getToggleState());

                if (windowSelector->getToggleState())
                {
                    dataWindow->setContentNonOwned(canvas, false);
                    canvas->setBounds(0,0,canvas->getParentWidth(), canvas->getParentHeight());
                    canvas->refreshState();
                }
                else
                {
                    dataWindow->setContentNonOwned(0, false);
                }

            }

        }
        else if (button == tabSelector)
        {
            if (tabSelector->getToggleState() && tabIndex < 0)
            {

                if (windowSelector->getToggleState())
                {
                    dataWindow->setContentNonOwned(0, false);
                    windowSelector->setToggleState(false, false);
                    dataWindow->setVisible(false);
                }

                tabIndex = getDataViewport()->addTabToDataViewport(tabText, canvas, this);


            }
            else if (!tabSelector->getToggleState() && tabIndex > -1)
            {
                getDataViewport()->destroyTab(tabIndex);
                tabIndex = -1;

            }
        }

    }

    buttonCallback(button);

    if (button == drawerButton)
    {
        std::cout<<"Drawer button clicked"<<std::endl;
        windowSelector->setBounds(desiredWidth - 40,7,14,10);
        tabSelector->setBounds(desiredWidth - 20,7,15,10);

    }

}