Beispiel #1
0
void ChannelSelector::buttonClicked(Button* button)
{
    //checkChannelSelectors();
    if (button == paramsButton)
    {
        // make sure param buttons are visible
        allButton->setState(true);
        desiredOffset = parameterOffset;
        startTimer(20);
        return;
    }
    else if (button == audioButton)
    {
        // make sure audio buttons are visible

        if (audioButton->getState())
        {
            allButton->setState(false);

            desiredOffset = audioOffset;
            startTimer(20);
        }
        else
        {
            paramsButton->setToggleState(true, false);
        }
        return;
    }
    else if (button == recordButton)
    {
        // make sure record buttons are visible;
        if (recordButton->getState())
        {
            allButton->setState(true);
            desiredOffset = recordOffset;
            startTimer(20);
        }
        else
        {
            paramsButton->setToggleState(true, false);
        }
        return;
    }
    else if (button == allButton)
    {
        // select all active buttons
        if (offsetLR == recordOffset)
        {


            for (int i = 0; i < recordButtons.size(); i++)
            {
                recordButtons[i]->setToggleState(true, true);
            }

        }
        else if (offsetLR == parameterOffset)
        {


            for (int i = 0; i < parameterButtons.size(); i++)
            {
                parameterButtons[i]->setToggleState(true, true);
            }
        }
        else if (offsetLR == audioOffset)
        {
            // do nothing--> button is disabled
        }
    }
    else if (button == noneButton)
    {
        // deselect all active buttons
        if (offsetLR == recordOffset)
        {
            for (int i = 0; i < recordButtons.size(); i++)
            {
                recordButtons[i]->setToggleState(false, true);
            }
        }
        else if (offsetLR == parameterOffset)
        {
            for (int i = 0; i < parameterButtons.size(); i++)
            {
                parameterButtons[i]->setToggleState(false, true);
            }
        }
        else if (offsetLR == audioOffset)
        {
            for (int i = 0; i < audioButtons.size(); i++)
            {
                audioButtons[i]->setToggleState(false, true);
            }
        }
    }
    else
    {

        ChannelSelectorButton* b = (ChannelSelectorButton*) button;

        if (b->getType() == AUDIO)
        {
            // get audio node, and inform it of the change
            GenericEditor* editor = (GenericEditor*) getParentComponent();

            Channel* ch = editor->getChannel(b->getChannel()-1);
            //int channelNum = editor->getStartChannel() + b->getChannel() - 1;
            bool status = b->getToggleState();

            if (acquisitionIsActive) // use setParameter to change parameter safely
            {
                editor->getProcessorGraph()->
                getAudioNode()->
                setChannelStatus(ch, status);
            }
            else     // change parameter directly
            {
                ch->isMonitored = status;
            }


        }
        else if (b->getType() == RECORD)
        {
            // get record node, and inform it of the change
            GenericEditor* editor = (GenericEditor*) getParentComponent();

            Channel* ch = editor->getChannel(b->getChannel()-1);
            //int channelNum = editor->getStartChannel() + b->getChannel() - 1;
            bool status = b->getToggleState();

            if (acquisitionIsActive) // use setParameter to change parameter safely
            {
                editor->getProcessorGraph()->
                getRecordNode()->
                setChannelStatus(ch, status);
            }
            else     // change parameter directly
            {
                ch->isRecording = status;
            }

        }
        else
        {
            // do nothing
            if (radioStatus) // if radio buttons are active
            {
                // send a message to parent
                GenericEditor* editor = (GenericEditor*) getParentComponent();
                editor->channelChanged(b->getChannel());
            }
        }

    }

}
void ChannelSelector::buttonClicked(Button* button)
{
    //checkChannelSelectors();
    if (button == paramsButton)
    {
        // make sure param buttons are visible
        allButton->setState(true);
        desiredOffset = parameterOffset;
        startTimer(20);
        return;
    }
    else if (button == audioButton)
    {
        // make sure audio buttons are visible

        if (audioButton->getState())
        {
            allButton->setState(false);

            desiredOffset = audioOffset;
            startTimer(20);
        }
        else
        {
            paramsButton->setToggleState(true, dontSendNotification);
        }
        return;
    }
    else if (button == recordButton)
    {
        // make sure record buttons are visible;
        if (recordButton->getState())
        {
            allButton->setState(true);
            desiredOffset = recordOffset;
            startTimer(20);
        }
        else
        {
            paramsButton->setToggleState(true, dontSendNotification);
        }
        return;
    }
    else if (button == allButton)
    {
        // select all active buttons
        if (offsetLR == recordOffset)
        {
            for (int i = 0; i < recordButtonsManager.getNumButtons(); ++i)
            {
                recordButtonsManager.getButtonAt (i)->setToggleState (true, sendNotification);
            }

        }
        else if (offsetLR == parameterOffset)
        {
            for (int i = 0; i < parameterButtonsManager.getNumButtons(); ++i)
            {
                parameterButtonsManager.getButtonAt (i)->setToggleState (true, sendNotification);
            }
        }
        else if (offsetLR == audioOffset)
        {
            // do nothing--> button is disabled
        }
    }
    else if (button == noneButton)
    {
        // deselect all active buttons
        if (offsetLR == recordOffset)
        {
            for (int i = 0; i < recordButtonsManager.getNumButtons(); ++i)
            {
                recordButtonsManager.getButtonAt (i)->setToggleState (false, sendNotification);
            }
        }
        else if (offsetLR == parameterOffset)
        {
            for (int i = 0; i < parameterButtonsManager.getNumButtons(); ++i)
            {
                parameterButtonsManager.getButtonAt (i)->setToggleState (false, sendNotification);
            }
        }
        else if (offsetLR == audioOffset)
        {
            for (int i = 0; i < audioButtonsManager.getNumButtons(); ++i)
            {
                audioButtonsManager.getButtonAt (i)->setToggleState (false, sendNotification);
            }
        }

        if (radioStatus) // if radio buttons are active
        {
            // send a message to parent
            GenericEditor* editor = (GenericEditor*) getParentComponent();
            editor->channelChanged (-1, false);
        }
    }
    else
    {
        ChannelSelectorButton* b = (ChannelSelectorButton*)button;

        if (b->getType() == AUDIO)
        {
            // get audio node, and inform it of the change
            GenericEditor* editor = (GenericEditor*)getParentComponent();

            Channel* ch = editor->getChannel(b->getChannel() - 1);
            //int channelNum = editor->getStartChannel() + b->getChannel() - 1;
            bool status = b->getToggleState();

            std::cout << "Requesting audio monitor for channel " << ch->nodeIndex + 1 << std::endl;

            if (acquisitionIsActive) // use setParameter to change parameter safely
            {
                AccessClass::getProcessorGraph()->
                getAudioNode()->setChannelStatus(ch, status);
            }
            else     // change parameter directly
            {
                ch->isMonitored = status;
            }
        }
        else if (b->getType() == RECORD)
        {
            // get record node, and inform it of the change
            GenericEditor* editor = (GenericEditor*)getParentComponent();

            Channel* ch = editor->getChannel(b->getChannel() - 1);
            //int channelNum = editor->getStartChannel() + b->getChannel() - 1;
            bool status = b->getToggleState();

            if (acquisitionIsActive) // use setParameter to change parameter safely
            {
                AccessClass::getProcessorGraph()->
                getRecordNode()->
                setChannelStatus(ch, status);
            }
            else     // change parameter directly
            {
                //std::cout << "Setting record status for channel " << b->getChannel() << std::endl;
                ch->setRecordState(status);
            }

            AccessClass::getGraphViewer()->repaint();

        }
        else // parameter type
        {
            GenericEditor* editor = (GenericEditor*) getParentComponent();
            editor->channelChanged (b->getChannel() - 1, b->getToggleState());

            // do nothing
            if (radioStatus) // if radio buttons are active
            {
                // send a message to parent
                GenericEditor* editor = (GenericEditor*) getParentComponent();
                editor->channelChanged (b->getChannel(), b->getToggleState());
            }
        }

    }
    refreshParameterColors();
}