void Button::sendStateMessage()
{
    Component::BailOutChecker checker (this);

    buttonStateChanged();

    if (! checker.shouldBailOut())
        buttonListeners.callChecked (checker, &ButtonListener::buttonStateChanged, this);
}
void Button::sendStateMessage()
{
    Component::BailOutChecker checker (this);

    buttonStateChanged();

    if (checker.shouldBailOut())
        return;

    buttonListeners.callChecked (checker, [this] (Listener& l) { l.buttonStateChanged (this); });

    if (checker.shouldBailOut())
        return;

    if (onStateChange != nullptr)
        onStateChange();
}
//==============================================================================
void Button::setToggleState (const bool shouldBeOn, const NotificationType notification)
{
    if (shouldBeOn != lastToggleState)
    {
        WeakReference<Component> deletionWatcher (this);

        if (shouldBeOn)
        {
            turnOffOtherButtonsInGroup (notification);

            if (deletionWatcher == nullptr)
                return;
        }

        // This test is done so that if the value is void rather than explicitly set to
        // false, the value won't be changed unless the required value is true.
        if (getToggleState() != shouldBeOn)
        {
            isOn = shouldBeOn;

            if (deletionWatcher == nullptr)
                return;
        }

        lastToggleState = shouldBeOn;
        repaint();

        if (notification != dontSendNotification)
        {
            // async callbacks aren't possible here
            jassert (notification != sendNotificationAsync);

            sendClickMessage (ModifierKeys::getCurrentModifiers());

            if (deletionWatcher == nullptr)
                return;
        }

        if (notification != dontSendNotification)
            sendStateMessage();
        else
            buttonStateChanged();
    }
}
void DrawableButton::setImages (const Drawable* normal,
                                const Drawable* over,
                                const Drawable* down,
                                const Drawable* disabled,
                                const Drawable* normalOn,
                                const Drawable* overOn,
                                const Drawable* downOn,
                                const Drawable* disabledOn)
{
    jassert (normal != nullptr); // you really need to give it at least a normal image..

    normalImage     = copyDrawableIfNotNull (normal);
    overImage       = copyDrawableIfNotNull (over);
    downImage       = copyDrawableIfNotNull (down);
    disabledImage   = copyDrawableIfNotNull (disabled);
    normalImageOn   = copyDrawableIfNotNull (normalOn);
    overImageOn     = copyDrawableIfNotNull (overOn);
    downImageOn     = copyDrawableIfNotNull (downOn);
    disabledImageOn = copyDrawableIfNotNull (disabledOn);

    buttonStateChanged();
}
//==============================================================================
void DrawableButton::setImages (const Drawable* normal,
                                const Drawable* over,
                                const Drawable* down,
                                const Drawable* disabled,
                                const Drawable* normalOn,
                                const Drawable* overOn,
                                const Drawable* downOn,
                                const Drawable* disabledOn)
{
    jassert (normal != nullptr); // you really need to give it at least a normal image..

    if (normal != nullptr)        normalImage = normal->createCopy();
    if (over != nullptr)          overImage = over->createCopy();
    if (down != nullptr)          downImage = down->createCopy();
    if (disabled != nullptr)      disabledImage = disabled->createCopy();
    if (normalOn != nullptr)      normalImageOn = normalOn->createCopy();
    if (overOn != nullptr)        overImageOn = overOn->createCopy();
    if (downOn != nullptr)        downImageOn = downOn->createCopy();
    if (disabledOn != nullptr)    disabledImageOn = disabledOn->createCopy();

    buttonStateChanged();
}
Exemple #6
0
void ToolbarButton::contentAreaChanged (const Rectangle<int>&)
{
    buttonStateChanged();
}
Exemple #7
0
 void applyInvertedStyle()
 {
     aux->setHoverTextColor("inverted.text");
     buttonStateChanged(*aux, aux->state());
 }
Exemple #8
0
 void applyNormalStyle()
 {
     aux->setHoverTextColor("text");
     buttonStateChanged(*aux, aux->state());
 }
Exemple #9
0
void DrawableButton::enablementChanged()
{
    Button::enablementChanged();
    buttonStateChanged();
}