本文整理汇总了C++中ToggleButton::getLocalBounds方法的典型用法代码示例。如果您正苦于以下问题:C++ ToggleButton::getLocalBounds方法的具体用法?C++ ToggleButton::getLocalBounds怎么用?C++ ToggleButton::getLocalBounds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ToggleButton
的用法示例。
在下文中一共展示了ToggleButton::getLocalBounds方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawToggleButton
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());
}
}
示例2: drawToggleButton
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);
}
}