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); } }
void MyLookAndFeel::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 (*Topaz); const int textX = tickWidth + 5; g.drawFittedText (button.getButtonText(), textX, 4, button.getWidth() - textX - 2, button.getHeight() - 8, Justification::centredLeft, 10); }