LMMS
Loading...
Searching...
No Matches
juce_BooleanPropertyComponent.cpp
Go to the documentation of this file.
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
12
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
15
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
18
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 DISCLAIMED.
22
23 ==============================================================================
24*/
25
26namespace juce
27{
28
30 const String& buttonTextWhenTrue,
31 const String& buttonTextWhenFalse)
33 onText (buttonTextWhenTrue),
34 offText (buttonTextWhenFalse)
35{
37 button.setClickingTogglesState (false);
38 button.onClick = [this] { setState (! getState()); };
39}
40
42 const String& name,
43 const String& buttonText)
45 onText (buttonText),
46 offText (buttonText)
47{
49 button.setClickingTogglesState (false);
50 button.setButtonText (buttonText);
51 button.getToggleStateValue().referTo (valueToControl);
52 button.setClickingTogglesState (true);
53}
54
58
59void BooleanPropertyComponent::setState (const bool newState)
60{
61 button.setToggleState (newState, sendNotification);
62}
63
65{
66 return button.getToggleState();
67}
68
70{
72
73 g.setColour (findColour (backgroundColourId));
74 g.fillRect (button.getBounds());
75
76 g.setColour (findColour (outlineColourId));
77 g.drawRect (button.getBounds());
78}
79
81{
82 button.setToggleState (getState(), dontSendNotification);
83 button.setButtonText (button.getToggleState() ? onText : offText);
84}
85
86} // namespace juce
virtual void setState(bool newState)
Definition juce_BooleanPropertyComponent.cpp:59
void paint(Graphics &) override
Definition juce_BooleanPropertyComponent.cpp:69
~BooleanPropertyComponent() override
Definition juce_BooleanPropertyComponent.cpp:55
void refresh() override
Definition juce_BooleanPropertyComponent.cpp:80
String onText
Definition juce_BooleanPropertyComponent.h:104
BooleanPropertyComponent(const String &propertyName, const String &buttonTextWhenTrue, const String &buttonTextWhenFalse)
Definition juce_BooleanPropertyComponent.cpp:29
virtual bool getState() const
Definition juce_BooleanPropertyComponent.cpp:64
String offText
Definition juce_BooleanPropertyComponent.h:104
ToggleButton button
Definition juce_BooleanPropertyComponent.h:103
@ backgroundColourId
Definition juce_BooleanPropertyComponent.h:92
@ outlineColourId
Definition juce_BooleanPropertyComponent.h:93
void addAndMakeVisible(Component *child, int zOrder=-1)
Definition juce_Component.cpp:1554
Colour findColour(int colourID, bool inheritFromParent=false) const
Definition juce_Component.cpp:2219
Definition juce_GraphicsContext.h:45
PropertyComponent(const String &propertyName, int preferredHeight=25)
Definition juce_PropertyComponent.cpp:29
void paint(Graphics &) override
Definition juce_PropertyComponent.cpp:37
Definition juce_String.h:53
Definition juce_Value.h:51
int g
Definition inflate.c:1573
static const char * name
Definition pugl.h:1582
Definition carla_juce.cpp:31
@ sendNotification
Definition juce_NotificationType.h:34
@ dontSendNotification
Definition juce_NotificationType.h:33