Debian Codegraph @

protolib/examples/juce/juceProtoExample/Source/ControlWindow.cpp

raw
1 /*
2 ==============================================================================
3
4 This is an automatically generated GUI class created by the Projucer!
5
6 Be careful when adding custom code to these files, as only the code within
7 the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded
8 and re-saved.
9
10 Created with Projucer version: 5.3.2
11
12 ------------------------------------------------------------------------------
13
14 The Projucer is part of the JUCE library.
15 Copyright (c) 2017 - ROLI Ltd.
16
17 ==============================================================================
18 */
19
20 //[Headers] You can add your own extra header files here...
21 #include "protoDebug.h"
22 //[/Headers]
23
24 #include "ControlWindow.h"
25
26
27 //[MiscUserDefs] You can add your own user definitions and misc code here...
28 //[/MiscUserDefs]
29
30 //==============================================================================
31 ControlWindow::ControlWindow ()
32 {
33 //[Constructor_pre] You can add your own custom stuff here..
34 //[/Constructor_pre]
35
36 startButton.reset (new ToggleButton ("startButton"));
37 addAndMakeVisible (startButton.get());
38 startButton->setTooltip (TRANS("start stop audio loop"));
39 startButton->setButtonText (TRANS("Do Something"));
40 startButton->addListener (this);
41 startButton->setColour (ToggleButton::textColourId, Colours::white);
42
43 helloLabel.reset (new Label ("helloLabel",
44 TRANS("Hello, ProtoWorld")));
45 addAndMakeVisible (helloLabel.get());
46 helloLabel->setFont (Font (18.00f, Font::plain).withTypefaceStyle ("Regular"));
47 helloLabel->setJustificationType (Justification::centred);
48 helloLabel->setEditable (false, false, false);
49 helloLabel->setColour (Label::backgroundColourId, Colours::white);
50 helloLabel->setColour (Label::textColourId, Colour (0xff1e2d75));
51 helloLabel->setColour (TextEditor::textColourId, Colours::black);
52 helloLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
53
54 viewport.reset (new Viewport ("viewport"));
55 addAndMakeVisible (viewport.get());
56
57 drawable1.reset (Drawable::createFromImageData (BinaryData::proteanWave_png, BinaryData::proteanWave_pngSize));
58
59 //[UserPreSize]
60 //addAndMakeVisible(drawable1.get());
61 activity_icon = new IvoxActivityComponent();
62 activity_icon->SetBackgroundColour(Colour(0xff283f88));
63 viewport.get()->setViewedComponent(activity_icon);
64 //[/UserPreSize]
65
66 setSize (600, 400);
67
68
69 //[Constructor] You can add your own custom stuff here..
70 //[/Constructor]
71 }
72
73 ControlWindow::~ControlWindow()
74 {
75 //[Destructor_pre]. You can add your own custom destruction code here..
76 //[/Destructor_pre]
77
78 startButton = nullptr;
79 helloLabel = nullptr;
80 viewport = nullptr;
81 drawable1 = nullptr;
82
83
84 //[Destructor]. You can add your own custom destruction code here..
85 //[/Destructor]
86 }
87
88 //==============================================================================
89 void ControlWindow::paint (Graphics& g)
90 {
91 //[UserPrePaint] Add your own custom painting code here..
92 //[/UserPrePaint]
93
94 g.fillAll (Colour (0xff283f88));
95
96 {
97 int x = 0, y = 0, width = proportionOfWidth (1.0000f), height = proportionOfHeight (0.2500f);
98 //[UserPaintCustomArguments] Customize the painting arguments here..
99 //[/UserPaintCustomArguments]
100 g.setColour (Colours::black);
101 jassert (drawable1 != 0);
102 if (drawable1 != 0)
103 drawable1->drawWithin (g, Rectangle<float> (x, y, width, height),
104 RectanglePlacement::centred, 1.000f);
105 }
106
107 //[UserPaint] Add your own custom painting code here..
108 //[/UserPaint]
109 }
110
111 void ControlWindow::resized()
112 {
113 //[UserPreResize] Add your own custom resize code here..
114 //[/UserPreResize]
115
116 startButton->setBounds (0, proportionOfHeight (0.2500f), 120, 32);
117 helloLabel->setBounds (0 + 120, proportionOfHeight (0.2500f), getWidth() - 240, 40);
118 viewport->setBounds ((0 + 120) + 0, proportionOfHeight (0.3994f), roundToInt ((getWidth() - 240) * 1.0000f), proportionOfHeight (0.5000f));
119 //[UserResized] Add your own custom resize handling here..
120 activity_icon->setSize(viewport->getWidth(), viewport->getHeight());
121 //[/UserResized]
122 }
123
124 void ControlWindow::buttonClicked (Button* buttonThatWasClicked)
125 {
126 //[UserbuttonClicked_Pre]
127 //[/UserbuttonClicked_Pre]
128
129 if (buttonThatWasClicked == startButton.get())
130 {
131 IvoxActivityComponent::Status status = activity_icon->GetStatus();
132 if (status < IvoxActivityComponent::PLAY)
133 activity_icon->SetStatus((IvoxActivityComponent::Status)(status + 1), true);
134 else
135 activity_icon->SetStatus(IvoxActivityComponent::DEAD);
136 }
137 else
138 {
139 //[UserButtonCode_startButton] -- add your button handler code here ...
140 if (buttonThatWasClicked->getToggleState())
141 {
142 activity_icon->SetStatus(IvoxActivityComponent::IDLE);
143 }
144 else
145 {
146 activity_icon->SetStatus(IvoxActivityComponent::DEAD);
147 }
148 //[/UserButtonCode_startButton]
149 }
150
151 //[UserbuttonClicked_Post]
152 //[/UserbuttonClicked_Post]
153 }
154
155
156
157 //[MiscUserCode] You can add your own definitions of your custom methods or any other code here...
158 //[/MiscUserCode]
159
160
161 //==============================================================================
162 #if 0
163 /* -- Projucer information section --
164
165 This is where the Projucer stores the metadata that describe this GUI layout, so
166 make changes in here at your peril!
167
168 BEGIN_JUCER_METADATA
169
170 <JUCER_COMPONENT documentType="Component" className="ControlWindow" componentName=""
171 parentClasses="public Component" constructorParams="" variableInitialisers=""
172 snapPixels="8" snapActive="1" snapShown="1" overlayOpacity="0.330"
173 fixedSize="0" initialWidth="600" initialHeight="400">
174 <BACKGROUND backgroundColour="ff283f88">
175 <IMAGE pos="0 0 100% 25%" resource="BinaryData::proteanWave_png" opacity="1.00000000000000000000"
176 mode="1"/>
177 </BACKGROUND>
178 <TOGGLEBUTTON name="startButton" id="ff7ec14cd3f75e5e" memberName="startButton"
179 virtualName="" explicitFocusOrder="0" pos="0 25% 120 32" tooltip="start stop audio loop"
180 txtcol="ffffffff" buttonText="Do Something" connectedEdges="0"
181 needsCallback="1" radioGroupId="0" state="0"/>
182 <LABEL name="helloLabel" id="cdff1eb1ab965714" memberName="helloLabel"
183 virtualName="" explicitFocusOrder="0" pos="0R 25% 240M 40" posRelativeX="ff7ec14cd3f75e5e"
184 bkgCol="ffffffff" textCol="ff1e2d75" edTextCol="ff000000" edBkgCol="0"
185 labelText="Hello, ProtoWorld" editableSingleClick="0" editableDoubleClick="0"
186 focusDiscardsChanges="0" fontname="Default font" fontsize="18.00000000000000000000"
187 kerning="0.00000000000000000000" bold="0" italic="0" justification="36"/>
188 <VIEWPORT name="viewport" id="e9ab86ac3963528" memberName="viewport" virtualName=""
189 explicitFocusOrder="0" pos="0 39.943% 100% 50%" posRelativeX="cdff1eb1ab965714"
190 posRelativeW="cdff1eb1ab965714" vscroll="1" hscroll="1" scrollbarThickness="8"
191 contentType="0" jucerFile="" contentClass="" constructorParams=""/>
192 </JUCER_COMPONENT>
193
194 END_JUCER_METADATA
195 */
196 #endif
197
198
199 //[EndFile] You can add extra defines here...
200 //[/EndFile]