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