float ofxDOMLayoutHelper::getDesiredWidth(DOM::Element* e){
	if(e->parent()){
		return getDesiredWidth(e, e->parent()->getWidth()-getPaddingHorizontal(e->parent()));
	}else{
		return getDesiredWidth(e, ofGetWindowWidth());
	}

}
Exemplo n.º 2
0
ChannelSelector::ChannelSelector(bool createButtons, Font& titleFont_) :
    eventsOnly(false), paramsToggled(true), paramsActive(true),
    radioStatus(false), isNotSink(createButtons), moveRight(false),
    moveLeft(false), offsetLR(0), offsetUD(0), desiredOffset(0),
    titleFont(titleFont_), acquisitionIsActive(false)
{

    // initialize buttons
    audioButton = new EditorButton("AUDIO", titleFont);
    audioButton->addListener(this);
    addAndMakeVisible(audioButton);
    if (!createButtons)
        audioButton->setState(false);

    recordButton = new EditorButton("REC", titleFont);
    recordButton->addListener(this);
    addAndMakeVisible(recordButton);
    if (!createButtons)
        recordButton->setState(false);

    paramsButton = new EditorButton("PARAM", titleFont);
    paramsButton->addListener(this);
    addAndMakeVisible(paramsButton);

    paramsButton->setToggleState(true, dontSendNotification);

    audioButtons.clear();
    recordButtons.clear();

    // set button layout parameters
    parameterOffset = 0;
    recordOffset = getDesiredWidth();
    audioOffset = getDesiredWidth()*2;

    parameterButtons.clear();

    allButton = new EditorButton("all", titleFont);
    allButton->addListener(this);
    addAndMakeVisible(allButton);

    noneButton = new EditorButton("none", titleFont);
    noneButton->addListener(this);
    addAndMakeVisible(noneButton);

    channelSelectorRegion = new ChannelSelectorRegion(this);
    //channelSelectorRegion->setBounds(0,20,0,getHeight()-35);
    addAndMakeVisible(channelSelectorRegion);
    channelSelectorRegion->toBack();

}
Exemplo n.º 3
0
void ChannelSelector::refreshButtonBoundaries()
{

    channelSelectorRegion->setBounds(0,20,getWidth(),getHeight()-35);

    int nColumns = 8;
    int columnWidth = getDesiredWidth()/(nColumns + 1);
    int rowHeight = 14;

    for (int i = 0; i < parameterButtons.size(); i++)
    {

        parameterButtons[i]->setBounds(columnWidth/2 + offsetLR +
                                       columnWidth*((i)%nColumns),
                                       floor(double(i)/nColumns)*rowHeight+(int) offsetUD,
                                       columnWidth, rowHeight);

        if (isNotSink)
        {
            recordButtons[i]->setBounds(columnWidth/2 + offsetLR +
                                        columnWidth*((i)%nColumns) - getDesiredWidth(),
                                        floor(double(i)/nColumns)*rowHeight+(int) offsetUD,
                                        columnWidth, rowHeight);
            audioButtons[i]->setBounds(columnWidth/2 + offsetLR +
                                       columnWidth*((i)%nColumns) -
                                       getDesiredWidth()*2,
                                       floor(double(i)/nColumns)*rowHeight+(int) offsetUD,
                                       columnWidth, rowHeight);
        }

    }

    int w = getWidth()/3;
    int h = 15;

    audioButton->setBounds(0, 0, w, h);
    recordButton->setBounds(w, 0, w, h);
    paramsButton->setBounds(w*2, 0, w, h);

    allButton->setBounds(0, getHeight()-15, getWidth()/2, 15);
    noneButton->setBounds(getWidth()/2, getHeight()-15, getWidth()/2, 15);

}
Exemplo n.º 4
0
void ChannelSelector::paint(Graphics& g)
{
    ColourGradient grad1 = ColourGradient(Colours::black.withAlpha(0.8f),0.0,0.0,
                                          Colours::black.withAlpha(0.1f),0.0,25.0f,
                                          false);
    g.setGradientFill(grad1);
    g.fillRect(0, 15, getWidth(), getHeight()-30);

    ColourGradient grad2 = ColourGradient(Colours::black.withAlpha(0.2f),0.0,0.0,
                                          Colours::black.withAlpha(0.0f),5.0f,0.0f,
                                          false);
    g.setGradientFill(grad2);
    g.fillRect(0, 15, getWidth(), getHeight()-30);

    ColourGradient grad3 = ColourGradient(Colours::black.withAlpha(0.2f),(float) getDesiredWidth(),0.0,
                                          Colours::black.withAlpha(0.0f),(float) getDesiredWidth()-5.0f,0.0f,
                                          false);
    g.setGradientFill(grad3);
    g.fillRect(0, 15, getWidth(), getHeight()-30);
}
ChannelSelector::ChannelSelector(bool createButtons, Font& titleFont_) :
    eventsOnly(false)
    , parameterSlicerChannelSelector (Channels::PARAM_CHANNELS,  "Parameter slicer channel selector component")
    , audioSlicerChannelSelector     (Channels::AUDIO_CHANNELS,  "Audio slicer channel selector component")
    , recordSlicerChannelSelector    (Channels::RECORD_CHANNELS, "Record slicer channel selector component")
    , paramsToggled(true), paramsActive(true), recActive(true), radioStatus(false), isNotSink(createButtons)
    , moveRight(false), moveLeft(false), offsetLR(0), offsetUD(0), desiredOffset(0), titleFont(titleFont_), acquisitionIsActive(false)
{
    // initialize buttons
    audioButton = new EditorButton("AUDIO", titleFont);
    audioButton->addListener(this);
    addAndMakeVisible(audioButton);
    if (!createButtons)
        audioButton->setState(false);

    recordButton = new EditorButton("REC", titleFont);
    recordButton->addListener(this);
    addAndMakeVisible(recordButton);
    if (!createButtons)
        recordButton->setState(false);

    paramsButton = new EditorButton("PARAM", titleFont);
    paramsButton->addListener(this);
    addAndMakeVisible(paramsButton);

    paramsButton->setToggleState(true, dontSendNotification);

    // set button layout parameters
    parameterOffset = 0;
    recordOffset = getDesiredWidth();
    audioOffset = getDesiredWidth() * 2;

    allButton = new EditorButton("all", titleFont);
    allButton->addListener(this);
    addAndMakeVisible(allButton);

    noneButton = new EditorButton("none", titleFont);
    noneButton->addListener(this);
    addAndMakeVisible(noneButton);

    // Buttons managers
    // ====================================================================
    addAndMakeVisible (audioButtonsManager);
    addAndMakeVisible (recordButtonsManager);
    addAndMakeVisible (parameterButtonsManager);

    // Enable fast mode selection for buttons
    audioButtonsManager.setFastSelectionModeEnabled     (true);
    recordButtonsManager.setFastSelectionModeEnabled    (true);
    parameterButtonsManager.setFastSelectionModeEnabled (true);

    audioButtonsManager.setMinPaddingBetweenButtons     (0);
    recordButtonsManager.setMinPaddingBetweenButtons    (0);
    parameterButtonsManager.setMinPaddingBetweenButtons (0);

    audioButtonsManager.setColour       (ButtonGroupManager::outlineColourId, Colour (0x0));
    recordButtonsManager.setColour      (ButtonGroupManager::outlineColourId, Colour (0x0));
    parameterButtonsManager.setColour   (ButtonGroupManager::outlineColourId, Colour (0x0));

    // Register listeners for buttons
    audioButtonsManager.setButtonListener      (this);
    recordButtonsManager.setButtonListener     (this);
    parameterButtonsManager.setButtonListener  (this);
    // ====================================================================

    // Slicer channels selectors
    // ====================================================================
    audioSlicerChannelSelector.setListener      (this);
    recordSlicerChannelSelector.setListener     (this);
    parameterSlicerChannelSelector.setListener  (this);

    // Set just initial y for each slicer
    const int slicerChannelSelectorY = 10;
    audioSlicerChannelSelector.setBounds        (audioSlicerChannelSelector.getBounds().withY (slicerChannelSelectorY));
    recordSlicerChannelSelector.setBounds       (recordSlicerChannelSelector.getBounds().withY (slicerChannelSelectorY));
    parameterSlicerChannelSelector.setBounds    (parameterSlicerChannelSelector.getBounds().withY (slicerChannelSelectorY));

    addAndMakeVisible (audioSlicerChannelSelector);
    addAndMakeVisible (recordSlicerChannelSelector);
    addAndMakeVisible (parameterSlicerChannelSelector);

    audioSlicerChannelSelector.toBack();
    recordSlicerChannelSelector.toBack();
    parameterSlicerChannelSelector.toBack();
    // ====================================================================


    numColumnsLessThan100 = 8;
    numColumnsGreaterThan100 = 6;
}
void ChannelSelector::refreshButtonBoundaries()
{
    const int columnWidth   = getDesiredWidth() / (numColumnsGreaterThan100 + 1) + 1;
    const int rowHeight     = 14;

    audioButtonsManager.setButtonSize      (columnWidth, rowHeight);
    recordButtonsManager.setButtonSize     (columnWidth, rowHeight);
    parameterButtonsManager.setButtonSize  (columnWidth, rowHeight);

    const int xLoc = offsetLR + 3;

    juce::Rectangle<int> slicerSelectorBounds (xLoc - 2, 0, getDesiredWidth(), 0);
    parameterSlicerChannelSelector.setBounds (slicerSelectorBounds
                                              .withY (parameterSlicerChannelSelector.getY())
                                              .withHeight (parameterSlicerChannelSelector.getHeight()));
    slicerSelectorBounds.translate (- getDesiredWidth(), 0);
    recordSlicerChannelSelector.setBounds (slicerSelectorBounds
                                           .withY (recordSlicerChannelSelector.getY())
                                           .withHeight (recordSlicerChannelSelector.getHeight()));
    slicerSelectorBounds.translate (- getDesiredWidth(), 0);
    audioSlicerChannelSelector.setBounds (slicerSelectorBounds
                                          .withY (audioSlicerChannelSelector.getY())
                                          .withHeight (audioSlicerChannelSelector.getHeight()));

    // Set bounds for buttons managers
    // ===================================================================================================
    const int headerHeight              = 25;
    const int tabButtonHeight           = 15;
    const int buttonsManagerWidth       = getDesiredWidth() - 6;
    const int defaultButtonsManagerY    = headerHeight;

    // We will use just some hacks to set initial y and height if height is zero,
    // otherwise we will use the same bounds for buttons maangers
    int buttonsManagerX = xLoc;
    parameterButtonsManager.setBounds   (buttonsManagerX,
                                         parameterButtonsManager.getHeight() == 0 ? defaultButtonsManagerY : parameterButtonsManager.getY(),
                                         buttonsManagerWidth,
                                         getHeight() - parameterButtonsManager.getY() - tabButtonHeight);
    buttonsManagerX -= getDesiredWidth();
    recordButtonsManager.setBounds      (buttonsManagerX,
                                         recordButtonsManager.getHeight() == 0 ? defaultButtonsManagerY : recordButtonsManager.getY(),
                                         buttonsManagerWidth,
                                         getHeight() - recordButtonsManager.getY() - tabButtonHeight);
    buttonsManagerX -= getDesiredWidth();
    audioButtonsManager.setBounds       (buttonsManagerX,
                                         audioButtonsManager.getHeight() == 0 ? defaultButtonsManagerY : audioButtonsManager.getY(),
                                         buttonsManagerWidth,
                                         getHeight() - audioButtonsManager.getY() - tabButtonHeight);
    // ===================================================================================================

    /*
      audio,record and param tabs
    */
    const int tabButtonWidth = getWidth() / 3;
    audioButton->setBounds  (0, 0, tabButtonWidth, tabButtonHeight);
    recordButton->setBounds (tabButtonWidth, 0, tabButtonWidth, tabButtonHeight);
    paramsButton->setBounds (tabButtonWidth * 2, 0, tabButtonWidth, tabButtonHeight);

    /*
      All and None buttons
    */
    allButton->setBounds (0, getHeight() - 15, getWidth() / 2, tabButtonHeight);
    noneButton->setBounds (getWidth() / 2, getHeight() - 15, getWidth() / 2, tabButtonHeight);
}