When using ToggleButton::changeWidthToFitText() I get a button with a width too small to avoid horizontal text scaling. To me it seems that:
void LookAndFeel_V2::changeToggleButtonWidthToFitText (ToggleButton& button)
{
Font font (jmin (15.0f, button.getHeight() * 0.6f));
const int tickWidth = jmin (24, button.getHeight());
button.setSize (font.getStringWidth (button.getButtonText()) + tickWidth + 8,
button.getHeight());
}
does not match:
void LookAndFeel_V4::drawToggleButton (Graphics& g, ToggleButton& button,
bool isMouseOverButton, bool isButtonDown)
{
const auto fontSize = jmin (15.0f, button.getHeight() * 0.75f);
const auto tickWidth = fontSize * 1.1f;
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);
g.drawFittedText (button.getButtonText(),
button.getLocalBounds().withTrimmedLeft (roundToInt (tickWidth) + 10)
.withTrimmedRight (2),
Justification::centredLeft, 10);
}
It does not match LookAndFeel_V2::drawToggleButton() either.
Wouldn’t:
void LookAndFeel_V4::changeToggleButtonWidthToFitText(ToggleButton& button)
{
const float fontSize = jmin(15.0f, button.getHeight() * 0.75f);
Font font(fontSize);
const float tickWidth = fontSize * 1.1f;
button.setSize(font.getStringWidth(button.getButtonText()) + roundToInt(tickWidth) + 10 + 2, button.getHeight());
}
be better? And of course something similar for LookAndFeel_V2::changeToggleButtonWidthToFitText().