void DropShadow::drawForRectangle (Graphics& g, const Rectangle<int>& targetArea) const
{
    ColourGradient cg (colour, 0, 0, colour.withAlpha (0.0f), 0, 0, false);

    for (float i = 0.05f; i < 1.0f; i += 0.1f)
        cg.addColour (1.0 - i, colour.withMultipliedAlpha (i * i));

    const float radiusInset = radius / 2.0f;
    const float expandedRadius = radius + radiusInset;

    auto area = targetArea.toFloat().reduced (radiusInset) + offset.toFloat();

    auto r = area.expanded (expandedRadius);
    auto top = r.removeFromTop (expandedRadius);
    auto bottom = r.removeFromBottom (expandedRadius);

    drawShadowSection (g, cg, top.removeFromLeft  (expandedRadius), true, 1.0f, 1.0f, 0, 1.0f);
    drawShadowSection (g, cg, top.removeFromRight (expandedRadius), true, 0, 1.0f, 1.0f, 1.0f);
    drawShadowSection (g, cg, top, false, 0, 1.0f, 0, 0);

    drawShadowSection (g, cg, bottom.removeFromLeft  (expandedRadius), true, 1.0f, 0, 0, 0);
    drawShadowSection (g, cg, bottom.removeFromRight (expandedRadius), true, 0, 0, 1.0f, 0);
    drawShadowSection (g, cg, bottom, false, 0, 0, 0, 1.0f);

    drawShadowSection (g, cg, r.removeFromLeft  (expandedRadius), false, 1.0f, 0, 0, 0);
    drawShadowSection (g, cg, r.removeFromRight (expandedRadius), false, 0, 0, 1.0f, 0);

    g.setColour (colour);
    g.fillRect (area);
}
Esempio n. 2
0
    void resized() override
    {
        auto bounds = getLocalBounds();
        auto buttonWidth = owner.getSidePanel().getTitleBarHeight();

        bounds.removeFromLeft (10);
        homeButton.setBounds (bounds.removeFromLeft (buttonWidth).reduced (7));
        settingsButton.setBounds (bounds.removeFromLeft (buttonWidth).reduced (7));
        bounds.removeFromLeft (10);

        bounds.removeFromRight (10);
        titleLabel.setBounds (bounds);
    }
void ResourceEditorPanel::resized()
{
    auto bounds = getLocalBounds();

    auto buttonSlice = bounds.removeFromBottom (40).reduced (5, 5);

    addButton.setBounds (buttonSlice.removeFromLeft (125));
    buttonSlice.removeFromLeft (10);

    reloadAllButton.setBounds (buttonSlice.removeFromLeft (125));

    delButton.setBounds (buttonSlice.removeFromRight (125));

    listBox->setBounds (bounds);
}
Esempio n. 4
0
void PlaybackPane::resized() {
    scroll_bar.setBounds(getLocalBounds().removeFromBottom(20));

    auto bounds = getLocalBounds();
    auto top = bounds.removeFromTop(40);
    top.reduce(2, 2);
    ruler.setBounds(bounds.removeFromTop(20));
    renderer.setBounds(bounds);

    transport.setBounds(top.removeFromLeft(200));
    follow_playback_button.setBounds(top.removeFromRight(150));
    bypass_button.setBounds(top.removeFromRight(150));

    load_different_button.setBounds(top.removeFromLeft(150));
}
Esempio n. 5
0
//==============================================================================
void ResizableWindow::activeWindowStatusChanged()
{
    auto border = getContentComponentBorder();
    auto area = getLocalBounds();

    repaint (area.removeFromTop (border.getTop()));
    repaint (area.removeFromLeft (border.getLeft()));
    repaint (area.removeFromRight (border.getRight()));
    repaint (area.removeFromBottom (border.getBottom()));
}
Esempio n. 6
0
void ProjucerLookAndFeel::drawToggleButton (Graphics& g, ToggleButton& button, bool isMouseOverButton, bool isButtonDown)
{
    ignoreUnused (isMouseOverButton, isButtonDown);

    if (! button.isEnabled())
        g.setOpacity (0.5f);

    bool isTextEmpty = button.getButtonText().isEmpty();
    bool isPropertyComponentChild = (dynamic_cast<BooleanPropertyComponent*> (button.getParentComponent()) != nullptr);

    auto bounds = button.getLocalBounds();

    auto sideLength = isPropertyComponentChild ? 25 : bounds.getHeight();

    auto rectBounds = isTextEmpty ? bounds
                                  : bounds.removeFromLeft (jmin (sideLength, bounds.getWidth() / 3));

    rectBounds = rectBounds.withSizeKeepingCentre (sideLength, sideLength).reduced (4);

    g.setColour (button.findColour (ToggleButton::tickDisabledColourId));
    g.drawRoundedRectangle (rectBounds.toFloat(), 2.0f, 1.0f);

    if (button.getToggleState())
    {
        g.setColour (button.findColour (ToggleButton::tickColourId));
        const auto tick = getTickShape (0.75f);
        g.fillPath (tick, tick.getTransformToScaleToFit (rectBounds.reduced (2).toFloat(), false));
    }

    if (! isTextEmpty)
    {
        bounds.removeFromLeft (5);

        const auto fontSize = jmin (15.0f, button.getHeight() * 0.75f);

        g.setFont (fontSize);
        g.setColour (isPropertyComponentChild ? findColour (widgetTextColourId)
                                              : button.findColour (ToggleButton::textColourId));

        g.drawFittedText (button.getButtonText(), bounds, Justification::centredLeft, 2);
    }
}
void ProjectContentComponent::resized()
{
    auto r = getLocalBounds();

    r.removeFromRight (10);
    r.removeFromLeft (15);
    r.removeFromBottom (40);
    r.removeFromTop (5);

    if (header != nullptr)
        header->setBounds (r.removeFromTop (40));

    r.removeFromTop (10);

    auto sidebarArea = r.removeFromLeft (sidebarTabs.getWidth() != 0 ? sidebarTabs.getWidth()
                                                                     : r.getWidth() / 4);

    if (sidebarTabs.isVisible())
        sidebarTabs.setBounds (sidebarArea);

    if (resizerBar != nullptr)
        resizerBar->setBounds (r.withWidth (4));

    if (auto* h = dynamic_cast<HeaderComponent*> (header.get()))
    {
        h->sidebarTabsWidthChanged (sidebarTabs.getWidth());
        r.removeFromRight (h->getUserButtonWidth());
    }

    if (contentView != nullptr)
    {
        if (fileNameLabel != nullptr && fileNameLabel->isVisible())
            fileNameLabel->setBounds (r.removeFromTop (15));

        contentView->setBounds (r);
    }

    if (logo != nullptr)
        logo->setBounds (r.reduced (r.getWidth() / 6, r.getHeight() / 6));
}
Esempio n. 8
0
//======================================================================
void HeaderComponent::resized()
{
    auto bounds = getLocalBounds();
    configLabel.setFont ({ bounds.getHeight() / 3.0f });

    //======================================================================
    {
        auto headerBounds = bounds.removeFromLeft (tabsWidth);

        const int buttonSize = 25;
        auto buttonBounds = headerBounds.removeFromRight (buttonSize);

        projectSettingsButton->setBounds (buttonBounds.removeFromBottom (buttonSize).reduced (2));

        juceIcon->setBounds (headerBounds.removeFromLeft (headerBounds.getHeight()).reduced (2));

        headerBounds.removeFromRight (5);
        projectNameLabel.setBounds (headerBounds);
    }

    //======================================================================
    auto exporterWidth = jmin (400, bounds.getWidth() / 2);
    Rectangle<int> exporterBounds (0, 0, exporterWidth, bounds.getHeight());

    exporterBounds.setCentre (bounds.getCentre());

    runAppButton->setBounds (exporterBounds.removeFromRight (exporterBounds.getHeight()).reduced (2));
    saveAndOpenInIDEButton->setBounds (exporterBounds.removeFromRight (exporterBounds.getHeight()).reduced (2));

    exporterBounds.removeFromRight (5);
    exporterBox.setBounds (exporterBounds.removeFromBottom (roundToInt (exporterBounds.getHeight() / 1.8f)));
    configLabel.setBounds (exporterBounds);

    bounds.removeFromRight (5);
    userSettingsButton->setBounds (bounds.removeFromRight (bounds.getHeight()).reduced (2));
}
Esempio n. 9
0
void ProjucerLookAndFeel::layoutFileBrowserComponent (FileBrowserComponent& browserComp,
                                                      DirectoryContentsDisplayComponent* fileListComponent,
                                                      FilePreviewComponent* previewComp,
                                                      ComboBox* currentPathBox,
                                                      TextEditor* filenameBox,
                                                      Button* goUpButton)
{
    const auto sectionHeight = 22;
    const auto buttonWidth = 50;

    auto b = browserComp.getLocalBounds().reduced (20, 5);

    auto topSlice    = b.removeFromTop (sectionHeight);
    auto bottomSlice = b.removeFromBottom (sectionHeight);

    currentPathBox->setBounds (topSlice.removeFromLeft (topSlice.getWidth() - buttonWidth));
    currentPathBox->setColour (ComboBox::backgroundColourId,    findColour (backgroundColourId));
    currentPathBox->setColour (ComboBox::textColourId,          findColour (defaultTextColourId));
    currentPathBox->setColour (ComboBox::arrowColourId,         findColour (defaultTextColourId));

    topSlice.removeFromLeft (6);
    goUpButton->setBounds (topSlice);

    bottomSlice.removeFromLeft (50);
    filenameBox->setBounds (bottomSlice);
    filenameBox->setColour (TextEditor::backgroundColourId, findColour (backgroundColourId));
    filenameBox->setColour (TextEditor::textColourId,       findColour (defaultTextColourId));
    filenameBox->setColour (TextEditor::outlineColourId,    findColour (defaultTextColourId));
    filenameBox->applyFontToAllText (filenameBox->getFont());

    if (previewComp != nullptr)
        previewComp->setBounds (b.removeFromRight (b.getWidth() / 3));

    if (auto listAsComp = dynamic_cast<Component*> (fileListComponent))
        listAsComp->setBounds (b.reduced (0, 10));
}
Esempio n. 10
0
void MainComponent::resized()
{
    auto bounds = getLocalBounds();

    showDemosButton.setBounds (0, 0, 150, contentComponent->getTabBarDepth());

    if (isShowingHeavyweightDemo)
    {
        bounds.removeFromLeft (sidePanelWidth);

        contentComponent->setTabBarIndent (jmax (0, 150 - sidePanelWidth));
    }
    else
    {
        contentComponent->setTabBarIndent (150);
    }

    contentComponent->setBounds (bounds);
}
void ConvolutionMatrixComponent::resized() {
    auto matrix_height = optimum_routing_size * model.get_num_inputs();
    auto matrix_width = optimum_routing_size * model.get_num_outputs();

    auto input_width = getWidth() - matrix_width;

    auto bounds = getLocalBounds();
    auto left = bounds.removeFromLeft(input_width);
    auto input_area = left.removeFromTop(matrix_height);

    hrtf_component.setBounds(left.reduced(4, 4));

    auto matrix_area = bounds.removeFromTop(matrix_height);
    auto output_area = bounds;

    for (auto i = 0u; i != routings.size(); ++i) {
        auto y = i * optimum_routing_size;
        for (auto j = 0u; j != routings[i].size(); ++j) {
            auto x = j * optimum_routing_size;
            routings[i][j]->setSize(optimum_routing_size, optimum_routing_size);
            routings[i][j]->setTopLeftPosition(matrix_area.getTopLeft() +
                                               juce::Point<int>(x, y));
        }
    }

    for (auto i = 0u; i != inputs.size(); ++i) {
        inputs[i]->setSize(input_area.getWidth(), optimum_routing_size);
        inputs[i]->setTopLeftPosition(
                input_area.getTopLeft() +
                juce::Point<int>(0, i * optimum_routing_size));
    }

    for (auto i = 0u; i != outputs.size(); ++i) {
        outputs[i]->setSize(optimum_routing_size, output_area.getHeight());
        outputs[i]->setTopLeftPosition(
                output_area.getTopLeft() +
                juce::Point<int>(i * optimum_routing_size, 0));
    }
}
void MidiKeyboardComponent::resized()
{
    auto w = getWidth();
    auto h = getHeight();

    if (w > 0 && h > 0)
    {
        if (orientation != horizontalKeyboard)
            std::swap (w, h);

        auto kx2 = getKeyPos (rangeEnd).getEnd();

        if ((int) firstKey != rangeStart)
        {
            auto kx1 = getKeyPos (rangeStart).getStart();

            if (kx2 - kx1 <= w)
            {
                firstKey = (float) rangeStart;
                sendChangeMessage();
                repaint();
            }
        }

        scrollDown->setVisible (canScroll && firstKey > (float) rangeStart);

        xOffset = 0;

        if (canScroll)
        {
            auto scrollButtonW = jmin (scrollButtonWidth, w / 2);
            auto r = getLocalBounds();

            if (orientation == horizontalKeyboard)
            {
                scrollDown->setBounds (r.removeFromLeft  (scrollButtonW));
                scrollUp  ->setBounds (r.removeFromRight (scrollButtonW));
            }
            else if (orientation == verticalKeyboardFacingLeft)
            {
                scrollDown->setBounds (r.removeFromTop    (scrollButtonW));
                scrollUp  ->setBounds (r.removeFromBottom (scrollButtonW));
            }
            else
            {
                scrollDown->setBounds (r.removeFromBottom (scrollButtonW));
                scrollUp  ->setBounds (r.removeFromTop    (scrollButtonW));
            }

            auto endOfLastKey = getKeyPos (rangeEnd).getEnd();

            float mousePositionVelocity;
            auto spaceAvailable = w;
            auto lastStartKey = remappedXYToNote ({ endOfLastKey - spaceAvailable, 0 }, mousePositionVelocity) + 1;

            if (lastStartKey >= 0 && ((int) firstKey) > lastStartKey)
            {
                firstKey = (float) jlimit (rangeStart, rangeEnd, lastStartKey);
                sendChangeMessage();
            }

            xOffset = getKeyPos ((int) firstKey).getStart();
        }
        else
        {
            firstKey = (float) rangeStart;
        }

        scrollUp->setVisible (canScroll && getKeyPos (rangeEnd).getStart() > w);
        repaint();
    }
}