forked from rorywalsh/cabbage
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCabbageGroupBox.cpp
More file actions
executable file
·101 lines (81 loc) · 5.24 KB
/
CabbageGroupBox.cpp
File metadata and controls
executable file
·101 lines (81 loc) · 5.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
Copyright (C) 2016 Rory Walsh
Cabbage is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
Cabbage is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU General Public
License along with Csound; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA
*/
#include "CabbageGroupBox.h"
#include "../Audio/Plugins/CabbagePluginEditor.h"
CabbageGroupBox::CabbageGroupBox (ValueTree wData, CabbagePluginEditor* _owner)
: GroupComponent (CabbageWidgetData::getStringProp (wData, CabbageIdentifierIds::name)),
outlineThickness (CabbageWidgetData::getNumProp (wData, CabbageIdentifierIds::outlinethickness)),
lineThickness (CabbageWidgetData::getNumProp (wData, CabbageIdentifierIds::linethickness)),
corners (CabbageWidgetData::getNumProp (wData, CabbageIdentifierIds::corners)),
text (CabbageWidgetData::getStringProp (wData, CabbageIdentifierIds::text)),
colour (CabbageWidgetData::getStringProp (wData, CabbageIdentifierIds::colour)),
fontColour (CabbageWidgetData::getStringProp (wData, CabbageIdentifierIds::fontcolour)),
justification (CabbageWidgetData::getStringProp (wData, CabbageIdentifierIds::align)),
outlineColour (CabbageWidgetData::getStringProp (wData, CabbageIdentifierIds::outlinecolour)),
owner (_owner),
widgetData (wData),
lookAndFeel(),
CabbageWidgetBase(_owner)
{
setName (CabbageWidgetData::getStringProp (wData, CabbageIdentifierIds::name));
widgetData.addListener (this); //add listener to valueTree so it gets notified when a widget's property changes
initialiseCommonAttributes (this, wData); //initialise common attributes such as bounds, name, rotation, etc..
setColour (TextButton::buttonColourId, Colour::fromString (colour));
setColour (GroupComponent::textColourId, Colour::fromString (fontColour));
setColour (GroupComponent::outlineColourId, Colour::fromString (outlineColour));
setName (CabbageWidgetData::getStringProp (wData, CabbageIdentifierIds::name));
setText (text);
setWantsKeyboardFocus (false);
setTextLabelPosition (CabbageUtilities::getJustification (justification));
getProperties().set ("outlinethickness", outlineThickness);
getProperties().set ("linethickness", lineThickness);
getProperties().set ("cornersize", corners);
auto csdPath = owner->getProcessor().getCsdFile().getFullPathName();
setImgProperties (*this, wData, csdPath, "groupbox");
lookAndFeel.customFont = owner->customFont;
setLookAndFeel(&lookAndFeel);
}
void CabbageGroupBox::changeListenerCallback (ChangeBroadcaster* source)
{
CabbageWidgetData::setNumProp (widgetData, CabbageIdentifierIds::visible, 0);
}
void CabbageGroupBox::valueTreePropertyChanged (ValueTree& valueTree, const Identifier& prop)
{
if (CabbagePluginEditor::PopupDocumentWindow* parentComp = dynamic_cast<CabbagePluginEditor::PopupDocumentWindow*> (getParentComponent()))
{
const int parentIsVisible = CabbageWidgetData::getNumProp (valueTree, CabbageIdentifierIds::visible);
owner->addChangeListener (this);
if (parentIsVisible == 1)
{
parentComp->setVisible (true);
parentComp->toFront (true);
}
else
parentComp->setVisible (false);
}
getProperties().set ("groupLine", var (CabbageWidgetData::getNumProp (valueTree, CabbageIdentifierIds::linethickness)));
getProperties().set ("cornersize", CabbageWidgetData::getNumProp (valueTree, CabbageIdentifierIds::corners));
setTextLabelPosition (CabbageUtilities::getJustification (CabbageWidgetData::getStringProp (valueTree, CabbageIdentifierIds::align)));
setColour (TextButton::buttonColourId, Colour::fromString (CabbageWidgetData::getStringProp (valueTree, CabbageIdentifierIds::colour)));
setColour (GroupComponent::textColourId, Colour::fromString (CabbageWidgetData::getStringProp (valueTree, CabbageIdentifierIds::fontcolour)));
setColour (GroupComponent::outlineColourId, Colour::fromString (CabbageWidgetData::getStringProp (valueTree, CabbageIdentifierIds::outlinecolour)));
setText (CabbageWidgetData::getStringProp (valueTree, CabbageIdentifierIds::text));
getProperties().set ("cornersize", CabbageWidgetData::getNumProp (valueTree, CabbageIdentifierIds::corners));
getProperties().set ("outlinethickness", CabbageWidgetData::getNumProp (valueTree, CabbageIdentifierIds::outlinethickness));
getProperties().set ("linethickness", CabbageWidgetData::getNumProp (valueTree, CabbageIdentifierIds::linethickness));
isVisible = CabbageWidgetData::getNumProp (valueTree, CabbageIdentifierIds::visible);
handleCommonUpdates (this, valueTree, prop); //handle comon updates such as bounds, alpha, rotation, visible, etc
}