//==============================================================================
void JuceticeLookAndFeel::drawToggleButton (Graphics& g,
                                            ToggleButton& button,
                                            bool isMouseOverButton,
                                            bool isButtonDown)
{
    const int tickWidth = jmin (20, button.getHeight() - 4);

    drawTickBox (g, button, 4, (button.getHeight() - tickWidth) / 2,
                 tickWidth, tickWidth,
                 button.getToggleState(),
                 button.isEnabled(),
                 isMouseOverButton,
                 isButtonDown);

    g.setColour (button.findColour (ToggleButton::textColourId));
    g.setFont (jmin (15.0f, button.getHeight() * 0.6f));

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

    const int textX = tickWidth + 5;

    g.drawFittedText (button.getButtonText(),
                      textX, 4,
                      button.getWidth() - textX - 2, button.getHeight() - 8,
                      Justification::centredLeft, 10);
}
void OldSchoolLookAndFeel::drawToggleButton (Graphics& g,
                                             ToggleButton& button,
                                             bool isMouseOverButton,
                                             bool isButtonDown)
{
    if (button.hasKeyboardFocus (true))
    {
        g.setColour (button.findColour (TextEditor::focusedOutlineColourId));
        g.drawRect (0, 0, button.getWidth(), button.getHeight());
    }

    const int tickWidth = jmin (20, button.getHeight() - 4);

    drawTickBox (g, button, 4.0f, (button.getHeight() - tickWidth) * 0.5f,
                 (float) tickWidth, (float) tickWidth,
                 button.getToggleState(),
                 button.isEnabled(),
                 isMouseOverButton,
                 isButtonDown);

    g.setColour (button.findColour (ToggleButton::textColourId));
    g.setFont (jmin (15.0f, button.getHeight() * 0.6f));

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

    const int textX = tickWidth + 5;

    g.drawFittedText (button.getButtonText(),
                      textX, 4,
                      button.getWidth() - textX - 2, button.getHeight() - 8,
                      Justification::centredLeft, 10);
}
void NTLookAndFeel::drawToggleButton (Graphics& g, ToggleButton& button, bool isMouseOverButton, bool isButtonDown){
    
    float fontSize = jmin (15.0f, button.getHeight() * 0.75f);
    const int tickWidth = fontSize * 1.6f;
    
    drawTickBox (g, button, 4.0f, (button.getHeight() - tickWidth) * 0.5f,
                 tickWidth, tickWidth,
                 button.getToggleState(),
                 button.isEnabled(),
                 isMouseOverButton,
                 isButtonDown);
    
    g.setColour (button.findColour (ToggleButton::textColourId));
    g.setFont (fontSize);
    
    if (! button.isEnabled())
        g.setOpacity (0.5f);
    
    const int textX = (int) tickWidth + 10;
    
    g.drawFittedText (button.getButtonText(),
                      textX, 0,
                      button.getWidth() - textX - 2, button.getHeight(),
                      Justification::centredLeft, 10);
}
void mlrVSTLookAndFeel::drawToggleButton (Graphics& g,
                                             ToggleButton& button,
                                             bool /*isMouseOverButton*/,
                                             bool /*isButtonDown*/)
{
    if (button.getToggleState())
    {
        g.setColour(button.findColour(ToggleButton::textColourId));
        g.fillRect(0, 0, button.getWidth(), button.getHeight());
        g.setColour(Colours::white);
    }
    else
    {
        g.setColour(Colours::white);
        g.fillRect(0, 0, button.getWidth(), button.getHeight());
        g.setColour(button.findColour(ToggleButton::textColourId));
    }

    g.setFont(defaultFont);

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

    g.drawFittedText (button.getButtonText(), 4, 4,
                      button.getWidth() - 2, button.getHeight() - 8,
                      Justification::centredLeft, 10);
}
Beispiel #5
0
    void updatePreviewBoxText()
    {
        Font* f = fonts [listBox->getSelectedRow()];

        if (f != 0)
        {
            Font font (*f);

            font.setHeight ((float) sizeSlider->getValue());
            font.setBold (boldButton->getToggleState());
            font.setItalic (italicButton->getToggleState());
            font.setExtraKerningFactor ((float) kerningSlider->getValue());
            font.setHorizontalScale ((float) horizontalScaleSlider->getValue());

            textBox->applyFontToAllText (font);
        }
    }
Beispiel #6
0
    void buttonClicked (Button* button) override
    {
        if (button == &nativeButton)
        {
            getLookAndFeel().setUsingNativeAlertWindows (nativeButton.getToggleState());

            return;
        }

        for (int i = windowButtons.size(); --i >= 0;)
            if (button == windowButtons.getUnchecked (i))
                return showWindow (*button, static_cast<DialogType> (i));
    }
Beispiel #7
0
    void refreshPreviewBoxFont()
    {
        const bool bold = boldToggle.getToggleState();
        const bool italic = italicToggle.getToggleState();
        const bool useStyle = ! (bold || italic);

        Font font (fonts [listBox.getSelectedRow()]);

        font = font.withPointHeight ((float) heightSlider.getValue())
                   .withExtraKerningFactor ((float) kerningSlider.getValue())
                   .withHorizontalScale ((float) scaleSlider.getValue());

        if (bold)    font = font.boldened();
        if (italic)  font = font.italicised();

        updateStylesList (font);

        styleBox.setEnabled (useStyle);

        if (useStyle)
            font = font.withTypefaceStyle (styleBox.getText());

        demoTextBox.applyFontToAllText (font);
    }
Beispiel #8
0
 void buttonClicked (Button* buttonThatWasClicked) override
 {
     if (buttonThatWasClicked == &startStopButton)
     {
         if (transportSource.isPlaying())
         {
             transportSource.stop();
         }
         else
         {
             transportSource.setPosition (0);
             transportSource.start();
         }
     }
     else if (buttonThatWasClicked == &followTransportButton)
     {
         thumbnail->setFollowsTransport (followTransportButton.getToggleState());
     }
 }
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);
    }
}
Beispiel #10
0
void TextLookAndFeel::drawToggleButton(Graphics& g, ToggleButton& button,
                                       bool isMouseOverButton, bool isButtonDown) {
  if (button.getToggleState())
    g.setColour(Colour(0xffffc400));
  else
    g.setColour(Colour(0xff313131));
  g.fillRect(button.getLocalBounds());

  g.setColour(Colour(0xff565656));
  g.drawRect(button.getLocalBounds());

  if (isButtonDown) {
    g.setColour(Colour(0x11000000));
    g.fillRect(button.getLocalBounds());
  }
  else if (isMouseOverButton) {
    g.setColour(Colour(0x11ffffff));
    g.fillRect(button.getLocalBounds());
  }
}
void DefaultLookAndFeel::drawToggleButton(Graphics& g, ToggleButton& button,
                                          bool isMouseOverButton, bool isButtonDown) {
  static const DropShadow shadow(Colour(0x88000000), 1.0f, Point<int>(0, 0));
  static float stroke_percent = 0.1;
  static float padding = 3.0f;
  static float hover_padding = 1.0f;

  float full_radius = std::min(button.getWidth(), button.getHeight()) / 2.0;
  float stroke_width = 2.0f * full_radius * stroke_percent;
  PathStrokeType stroke_type(stroke_width, PathStrokeType::beveled, PathStrokeType::rounded);
  float outer_radius = full_radius - stroke_width - padding;
  Path outer;
  outer.addCentredArc(full_radius, full_radius, outer_radius, outer_radius,
                      mopo::PI, -POWER_ARC_ANGLE, POWER_ARC_ANGLE, true);

  Path shadow_path;
  stroke_type.createStrokedPath(shadow_path, outer);
  shadow.drawForPath(g, shadow_path);
  Rectangle<int> bar_shadow_rect(full_radius - 1.0f, padding, 2.0f, full_radius - padding);
  shadow.drawForRectangle(g, bar_shadow_rect);

  if (button.getToggleState())
    g.setColour(Colours::white);
  else
    g.setColour(Colours::grey);

  g.strokePath(outer, stroke_type);
  g.fillRoundedRectangle(full_radius - 1.0f, padding, 2.0f, full_radius - padding, 1.0f);

  if (isButtonDown) {
    g.setColour(Colour(0x11000000));
    g.fillEllipse(hover_padding, hover_padding,
                  button.getWidth() - 2 * hover_padding, button.getHeight() - 2 * hover_padding);
  }
  else if (isMouseOverButton) {
    g.setColour(Colour(0x11ffffff));
    g.fillEllipse(hover_padding, hover_padding,
                  button.getWidth() - 2 * hover_padding, button.getHeight() - 2 * hover_padding);  }
}
bool
SettingsWindow::fieldsAreValid(void)
{
    ODL_ENTER(); //####
    int    badCount = 0;
    String badArgs;
    String primaryChannel;

    // Counterintuitively, we check the values from the descriptors first, before checking the
    // endpoint, port or tag values.
    _argsToUse.clear();
    for (size_t ii = 0, maxf = _standardFields.size(); maxf > ii; ++ii)
    {
        FormField * aField = _standardFields[static_cast<int>(ii)];

        if (aField && (! aField->validateField(_argsToUse)))
        {
            if (0 < badArgs.length())
            {
                badArgs += "\n";
            }
            badArgs += aField->getName();
            ++badCount;
        }
    }
    if (0 == badCount)
    {
        // Add the extra arguments here.
        for (size_t ii = 0, maxf = _extraFields.size(); maxf > ii; ++ii)
        {
            FormField * aField = _extraFields[static_cast<int>(ii)];

            _argsToUse.add(aField->getText());
        }
    }
    if (_canSetEndpoint)
    {
        if (_endpointField->validateField())
        {
            _endpointToUse = _endpointField->getText();
        }
        else
        {
            if (0 < badArgs.length())
            {
                badArgs += "\n";
            }
            badArgs += "Endpoint";
            ++badCount;
        }
    }
    if (_canSetPort)
    {
        if (_portField->validateField())
        {
            _portToUse = _portField->getText();
        }
        else
        {
            if (0 < badArgs.length())
            {
                badArgs += "\n";
            }
            badArgs += "Port";
            ++badCount;
        }
    }
    if (_canSetTag)
    {
        _tagToUse = _tagField->getText();
    }
    if (_canUseModifier)
    {
        // Determine which of the radio buttons has been selected.
        for (int ii = 0, maxb = _tagModifierGroup->getNumChildComponents(); maxb > ii; ++ii)
        {
            ToggleButton * tb =
                        reinterpret_cast<ToggleButton *>(_tagModifierGroup->getChildComponent(ii));

            if (tb && tb->getToggleState())
            {
                string       id(tb->getComponentID().toStdString());
                const char * startPtr = id.c_str();
                char *       endPtr;
                int          intValue = static_cast<int>(strtol(startPtr, &endPtr, 10));

                if ((startPtr != endPtr) && (! *endPtr))
                {
                    _tagModifierCount = intValue;
                }
                else
                {
                    _tagModifierCount = 0;
                }
            }
        }
    }
    if (0 < badCount)
    {
        String message1((1 < badCount) ? "arguments are" : "argument is");
        String message2((1 < badCount) ? "arguments" : "argument");

        AlertWindow::showMessageBox(AlertWindow::WarningIcon, getName(),
                                    String("The following ") + message1 + " invalid:\n" + badArgs +
                                    "\n" + String("Please correct the ") + message2 + " to the " +
                                    _execType + " and try again.", String::empty, this);
    }
    ODL_EXIT_B(0 == badCount); //####
    return (0 == badCount);
} // SettingsWindow::fieldsAreValid
Beispiel #13
0
 void updateLayoutMode()
 {
     multiDocumentPanel.setLayoutMode (showInTabsButton.getToggleState() ? MultiDocumentPanel::MaximisedWindowsWithTabs
                                                                         : MultiDocumentPanel::FloatingWindows);
 }
Beispiel #14
0
    void showWindow (Component& button, DialogType type)
    {
        if (type >= plainAlertWindow && type <= questionAlertWindow)
        {
            AlertWindow::AlertIconType icon = AlertWindow::NoIcon;

            switch (type)
            {
                case warningAlertWindow:    icon = AlertWindow::WarningIcon;    break;
                case infoAlertWindow:       icon = AlertWindow::InfoIcon;       break;
                case questionAlertWindow:   icon = AlertWindow::QuestionIcon;   break;
                default: break;
            }

            AlertWindow::showMessageBoxAsync (icon,
                                              "This is an AlertWindow",
                                              "And this is the AlertWindow's message. Blah blah blah blah blah blah blah blah blah blah blah blah blah.",
                                              "ok");
        }
        else if (type == okCancelAlertWindow)
        {
            AlertWindow::showOkCancelBox (AlertWindow::QuestionIcon,
                                          "This is an ok/cancel AlertWindow",
                                          "And this is the AlertWindow's message. Blah blah blah blah blah blah blah blah blah blah blah blah blah.",
                                          String::empty,
                                          String::empty,
                                          0,
                                          ModalCallbackFunction::forComponent (alertBoxResultChosen, this));
        }
        else if (type == calloutBoxWindow)
        {
            ColourSelector* colourSelector = new ColourSelector();
            colourSelector->setName ("background");
            colourSelector->setCurrentColour (findColour (TextButton::buttonColourId));
            colourSelector->setColour (ColourSelector::backgroundColourId, Colours::transparentBlack);
            colourSelector->setSize (300, 400);

            CallOutBox::launchAsynchronously (colourSelector, button.getScreenBounds(), nullptr);
        }
        else if (type == extraComponentsAlertWindow)
        {
           #if JUCE_MODAL_LOOPS_PERMITTED
            AlertWindow w ("AlertWindow demo..",
                           "This AlertWindow has a couple of extra components added to show how to add drop-down lists and text entry boxes.",
                           AlertWindow::QuestionIcon);

            w.addTextEditor ("text", "enter some text here", "text field:");

            const char* options[] = { "option 1", "option 2", "option 3", "option 4", nullptr };
            w.addComboBox ("option", StringArray (options), "some options");

            w.addButton ("ok",     1, KeyPress (KeyPress::returnKey, 0, 0));
            w.addButton ("cancel", 0, KeyPress (KeyPress::escapeKey, 0, 0));

            if (w.runModalLoop() != 0) // is they picked 'ok'
            {
                // this is the item they chose in the drop-down list..
                const int optionIndexChosen = w.getComboBoxComponent ("option")->getSelectedItemIndex();
                (void) optionIndexChosen; // (just avoids a compiler warning about unused variables)


                // this is the text they entered..
                String text = w.getTextEditorContents ("text");
            }
           #endif
        }
        else if (type == progressWindow)
        {
            // This will launch our ThreadWithProgressWindow in a modal state. (Our subclass
            // will take care of deleting the object when the task has finished)
            (new DemoBackgroundThread())->launchThread();
        }
        else if (type >= loadChooser && type <= saveChooser)
        {
           #if JUCE_MODAL_LOOPS_PERMITTED
            const bool useNativeVersion = nativeButton.getToggleState();

            if (type == loadChooser)
            {
                FileChooser fc ("Choose a file to open...",
                                File::getCurrentWorkingDirectory(),
                                "*",
                                useNativeVersion);

                if (fc.browseForMultipleFilesToOpen())
                {
                    String chosen;
                    for (int i = 0; i < fc.getResults().size(); ++i)
                        chosen << fc.getResults().getReference(i).getFullPathName() << "\n";

                    AlertWindow::showMessageBoxAsync (AlertWindow::InfoIcon,
                                                      "File Chooser...",
                                                      "You picked: " + chosen);
                }
            }
            else if (type == loadWithPreviewChooser)
            {
                ImagePreviewComponent imagePreview;
                imagePreview.setSize (200, 200);

                FileChooser fc ("Choose an image to open...",
                                File::getSpecialLocation (File::userPicturesDirectory),
                                "*.jpg;*.jpeg;*.png;*.gif",
                                useNativeVersion);

                if (fc.browseForMultipleFilesToOpen (&imagePreview))
                {
                    String chosen;
                    for (int i = 0; i < fc.getResults().size(); ++i)
                        chosen << fc.getResults().getReference (i).getFullPathName() << "\n";

                    AlertWindow::showMessageBoxAsync (AlertWindow::InfoIcon,
                                                      "File Chooser...",
                                                      "You picked: " + chosen);
                }
            }
            else if (type == saveChooser)
            {
                FileChooser fc ("Choose a file to save...",
                                File::getCurrentWorkingDirectory(),
                                "*",
                                useNativeVersion);

                if (fc.browseForFileToSave (true))
                {
                    File chosenFile = fc.getResult();

                    AlertWindow::showMessageBoxAsync (AlertWindow::InfoIcon,
                                                      "File Chooser...",
                                                      "You picked: " + chosenFile.getFullPathName());
                }
            }
            else if (type == directoryChooser)
            {
                FileChooser fc ("Choose a directory...",
                                File::getCurrentWorkingDirectory(),
                                "*",
                                useNativeVersion);

                if (fc.browseForDirectory())
                {
                    File chosenDirectory = fc.getResult();

                    AlertWindow::showMessageBoxAsync (AlertWindow::InfoIcon,
                                                      "File Chooser...",
                                                      "You picked: " + chosenDirectory.getFullPathName());
                }
            }
           #endif
        }
    }