42{
43
44
45 const auto button_height {button.getHeight()};
46 const auto button_width {button.getWidth()};
47 const auto font {juce::Component::getLookAndFeel().getTextButtonFont(button, button_height)};
48 g.setFont(font);
49 g.setColour(button
50 .findColour(button.getToggleState() ? juce::TextButton::textColourOnId
51 : juce::TextButton::textColourOffId)
52 .withMultipliedAlpha(button.isEnabled() ? 1.0F : 0.5F));
53
54 const auto y_indent {std::min(4, button.proportionOfHeight(0.3F))};
55 const auto min_height_width {std::min(button_height, button_width)};
56 MIDI2LR_ASSUME(min_height_width >= 0);
57 const auto corner_size {min_height_width / 2};
58 MIDI2LR_ASSUME(corner_size >= 0);
59 const auto font_height {gsl::narrow_cast<int>(font.getHeight() * 0.6F + 0.5F)};
60 const auto left_indent {
61 std::min(font_height, 2 + corner_size / (button.isConnectedOnLeft() ? 4 : 2))};
62 const auto right_indent {
63 std::min(font_height, 2 + corner_size / (button.isConnectedOnRight() ? 4 : 2))};
64
65 if (const auto text_width {button_width - left_indent - right_indent}; text_width > 0) {
66 g.drawFittedText(button.getButtonText(), left_indent, y_indent, text_width,
68 }
69}