Mercurial > hg > touchkeys
comparison Source/Mappings/Control/TouchkeyControlMappingShortEditor.cpp @ 0:3580ffe87dc8
First commit of TouchKeys public pre-release.
author | Andrew McPherson <andrewm@eecs.qmul.ac.uk> |
---|---|
date | Mon, 11 Nov 2013 18:19:35 +0000 |
parents | |
children | dfff66c07936 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:3580ffe87dc8 |
---|---|
1 /* | |
2 ============================================================================== | |
3 | |
4 This is an automatically generated GUI class created by the Introjucer! | |
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 Introjucer version: 3.1.0 | |
11 | |
12 ------------------------------------------------------------------------------ | |
13 | |
14 The Introjucer is part of the JUCE library - "Jules' Utility Class Extensions" | |
15 Copyright 2004-13 by Raw Material Software Ltd. | |
16 | |
17 ============================================================================== | |
18 */ | |
19 | |
20 //[Headers] You can add your own extra header files here... | |
21 //[/Headers] | |
22 | |
23 #include "TouchkeyControlMappingShortEditor.h" | |
24 | |
25 | |
26 //[MiscUserDefs] You can add your own user definitions and misc code here... | |
27 //[/MiscUserDefs] | |
28 | |
29 //============================================================================== | |
30 TouchkeyControlMappingShortEditor::TouchkeyControlMappingShortEditor (TouchkeyControlMappingFactory& factory) | |
31 : factory_(factory) | |
32 { | |
33 addAndMakeVisible (inputRangeLowEditor = new TextEditor ("range low text editor")); | |
34 inputRangeLowEditor->setMultiLine (false); | |
35 inputRangeLowEditor->setReturnKeyStartsNewLine (false); | |
36 inputRangeLowEditor->setReadOnly (false); | |
37 inputRangeLowEditor->setScrollbarsShown (true); | |
38 inputRangeLowEditor->setCaretVisible (true); | |
39 inputRangeLowEditor->setPopupMenuEnabled (true); | |
40 inputRangeLowEditor->setText (String::empty); | |
41 | |
42 addAndMakeVisible (rangeLabel = new Label ("range label", | |
43 "Input Range:")); | |
44 rangeLabel->setFont (Font (15.00f, Font::plain)); | |
45 rangeLabel->setJustificationType (Justification::centredLeft); | |
46 rangeLabel->setEditable (false, false, false); | |
47 rangeLabel->setColour (TextEditor::textColourId, Colours::black); | |
48 rangeLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000)); | |
49 | |
50 addAndMakeVisible (controlLabel = new Label ("control label", | |
51 "Control:")); | |
52 controlLabel->setFont (Font (15.00f, Font::plain)); | |
53 controlLabel->setJustificationType (Justification::centredLeft); | |
54 controlLabel->setEditable (false, false, false); | |
55 controlLabel->setColour (TextEditor::textColourId, Colours::black); | |
56 controlLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000)); | |
57 | |
58 addAndMakeVisible (controlComboBox = new ComboBox ("control combo box")); | |
59 controlComboBox->setEditableText (false); | |
60 controlComboBox->setJustificationType (Justification::centredLeft); | |
61 controlComboBox->setTextWhenNothingSelected (String::empty); | |
62 controlComboBox->setTextWhenNoChoicesAvailable ("(no choices)"); | |
63 controlComboBox->addListener (this); | |
64 | |
65 addAndMakeVisible (controlLabel2 = new Label ("control label", | |
66 "Parameter:")); | |
67 controlLabel2->setFont (Font (15.00f, Font::plain)); | |
68 controlLabel2->setJustificationType (Justification::centredLeft); | |
69 controlLabel2->setEditable (false, false, false); | |
70 controlLabel2->setColour (TextEditor::textColourId, Colours::black); | |
71 controlLabel2->setColour (TextEditor::backgroundColourId, Colour (0x00000000)); | |
72 | |
73 addAndMakeVisible (parameterComboBox = new ComboBox ("parameter combo box")); | |
74 parameterComboBox->setEditableText (false); | |
75 parameterComboBox->setJustificationType (Justification::centredLeft); | |
76 parameterComboBox->setTextWhenNothingSelected (String::empty); | |
77 parameterComboBox->setTextWhenNoChoicesAvailable ("(no choices)"); | |
78 parameterComboBox->addListener (this); | |
79 | |
80 addAndMakeVisible (controlLabel3 = new Label ("control label", | |
81 "Type:")); | |
82 controlLabel3->setFont (Font (15.00f, Font::plain)); | |
83 controlLabel3->setJustificationType (Justification::centredLeft); | |
84 controlLabel3->setEditable (false, false, false); | |
85 controlLabel3->setColour (TextEditor::textColourId, Colours::black); | |
86 controlLabel3->setColour (TextEditor::backgroundColourId, Colour (0x00000000)); | |
87 | |
88 addAndMakeVisible (typeComboBox = new ComboBox ("type combo box")); | |
89 typeComboBox->setEditableText (false); | |
90 typeComboBox->setJustificationType (Justification::centredLeft); | |
91 typeComboBox->setTextWhenNothingSelected (String::empty); | |
92 typeComboBox->setTextWhenNoChoicesAvailable ("(no choices)"); | |
93 typeComboBox->addListener (this); | |
94 | |
95 addAndMakeVisible (inputRangeHighEditor = new TextEditor ("range hi text editor")); | |
96 inputRangeHighEditor->setMultiLine (false); | |
97 inputRangeHighEditor->setReturnKeyStartsNewLine (false); | |
98 inputRangeHighEditor->setReadOnly (false); | |
99 inputRangeHighEditor->setScrollbarsShown (true); | |
100 inputRangeHighEditor->setCaretVisible (true); | |
101 inputRangeHighEditor->setPopupMenuEnabled (true); | |
102 inputRangeHighEditor->setText (String::empty); | |
103 | |
104 addAndMakeVisible (rangeLabel2 = new Label ("range label", | |
105 "-")); | |
106 rangeLabel2->setFont (Font (15.00f, Font::plain)); | |
107 rangeLabel2->setJustificationType (Justification::centredLeft); | |
108 rangeLabel2->setEditable (false, false, false); | |
109 rangeLabel2->setColour (TextEditor::textColourId, Colours::black); | |
110 rangeLabel2->setColour (TextEditor::backgroundColourId, Colour (0x00000000)); | |
111 | |
112 | |
113 //[UserPreSize] | |
114 parameterComboBox->addItem("X Position", TouchkeyControlMapping::kInputParameterXPosition); | |
115 parameterComboBox->addItem("Y Position", TouchkeyControlMapping::kInputParameterYPosition); | |
116 parameterComboBox->addItem("Contact Area", TouchkeyControlMapping::kInputParameterTouchSize); | |
117 parameterComboBox->addItem("2-Finger Mean", TouchkeyControlMapping::kInputParameter2FingerMean); | |
118 parameterComboBox->addItem("2-Finger Distance", TouchkeyControlMapping::kInputParameter2FingerDistance); | |
119 | |
120 typeComboBox->addItem("Absolute", TouchkeyControlMapping::kTypeAbsolute); | |
121 typeComboBox->addItem("1st Touch Relative", TouchkeyControlMapping::kTypeFirstTouchRelative); | |
122 typeComboBox->addItem("Note Onset Relative", TouchkeyControlMapping::kTypeNoteOnsetRelative); | |
123 | |
124 for(int i = 1; i <= 119; i++) { | |
125 controlComboBox->addItem(String(i), i); | |
126 } | |
127 controlComboBox->addItem("Pitch Wheel", MidiKeyboardSegment::kControlPitchWheel); | |
128 controlComboBox->addItem("Channel Pressure", MidiKeyboardSegment::kControlChannelAftertouch); | |
129 controlComboBox->addItem("Poly Aftertouch", MidiKeyboardSegment::kControlPolyphonicAftertouch); | |
130 //[/UserPreSize] | |
131 | |
132 setSize (328, 71); | |
133 | |
134 | |
135 //[Constructor] You can add your own custom stuff here.. | |
136 inputRangeLowEditor->addListener(this); | |
137 inputRangeHighEditor->addListener(this); | |
138 //[/Constructor] | |
139 } | |
140 | |
141 TouchkeyControlMappingShortEditor::~TouchkeyControlMappingShortEditor() | |
142 { | |
143 //[Destructor_pre]. You can add your own custom destruction code here.. | |
144 //[/Destructor_pre] | |
145 | |
146 inputRangeLowEditor = nullptr; | |
147 rangeLabel = nullptr; | |
148 controlLabel = nullptr; | |
149 controlComboBox = nullptr; | |
150 controlLabel2 = nullptr; | |
151 parameterComboBox = nullptr; | |
152 controlLabel3 = nullptr; | |
153 typeComboBox = nullptr; | |
154 inputRangeHighEditor = nullptr; | |
155 rangeLabel2 = nullptr; | |
156 | |
157 | |
158 //[Destructor]. You can add your own custom destruction code here.. | |
159 //[/Destructor] | |
160 } | |
161 | |
162 //============================================================================== | |
163 void TouchkeyControlMappingShortEditor::paint (Graphics& g) | |
164 { | |
165 //[UserPrePaint] Add your own custom painting code here.. | |
166 //[/UserPrePaint] | |
167 | |
168 g.fillAll (Colours::white); | |
169 | |
170 //[UserPaint] Add your own custom painting code here.. | |
171 //[/UserPaint] | |
172 } | |
173 | |
174 void TouchkeyControlMappingShortEditor::resized() | |
175 { | |
176 inputRangeLowEditor->setBounds (80, 40, 40, 24); | |
177 rangeLabel->setBounds (0, 40, 80, 24); | |
178 controlLabel->setBounds (176, 8, 56, 24); | |
179 controlComboBox->setBounds (232, 8, 88, 24); | |
180 controlLabel2->setBounds (0, 8, 72, 24); | |
181 parameterComboBox->setBounds (72, 8, 104, 24); | |
182 controlLabel3->setBounds (184, 40, 56, 24); | |
183 typeComboBox->setBounds (232, 40, 88, 24); | |
184 inputRangeHighEditor->setBounds (136, 40, 40, 24); | |
185 rangeLabel2->setBounds (120, 40, 16, 24); | |
186 //[UserResized] Add your own custom resize handling here.. | |
187 //[/UserResized] | |
188 } | |
189 | |
190 void TouchkeyControlMappingShortEditor::comboBoxChanged (ComboBox* comboBoxThatHasChanged) | |
191 { | |
192 //[UsercomboBoxChanged_Pre] | |
193 //[/UsercomboBoxChanged_Pre] | |
194 | |
195 if (comboBoxThatHasChanged == controlComboBox) | |
196 { | |
197 //[UserComboBoxCode_controlComboBox] -- add your combo box handling code here.. | |
198 int controller = controlComboBox->getSelectedId(); | |
199 factory_.setController(controller); | |
200 //[/UserComboBoxCode_controlComboBox] | |
201 } | |
202 else if (comboBoxThatHasChanged == parameterComboBox) | |
203 { | |
204 //[UserComboBoxCode_parameterComboBox] -- add your combo box handling code here.. | |
205 int param = parameterComboBox->getSelectedId(); | |
206 factory_.setInputParameter(param); | |
207 //[/UserComboBoxCode_parameterComboBox] | |
208 } | |
209 else if (comboBoxThatHasChanged == typeComboBox) | |
210 { | |
211 //[UserComboBoxCode_typeComboBox] -- add your combo box handling code here.. | |
212 int type = typeComboBox->getSelectedId(); | |
213 factory_.setInputType(type); | |
214 //[/UserComboBoxCode_typeComboBox] | |
215 } | |
216 | |
217 //[UsercomboBoxChanged_Post] | |
218 //[/UsercomboBoxChanged_Post] | |
219 } | |
220 | |
221 | |
222 | |
223 //[MiscUserCode] You can add your own definitions of your custom methods or any other code here... | |
224 | |
225 void TouchkeyControlMappingShortEditor::textEditorReturnKeyPressed(TextEditor &editor) | |
226 { | |
227 if(&editor == inputRangeLowEditor) { | |
228 float range = atof(inputRangeLowEditor->getText().toUTF8()); | |
229 factory_.setRangeInputMin(range); | |
230 factory_.setRangeInputCenter(range); | |
231 } | |
232 else if(&editor == inputRangeHighEditor) { | |
233 float range = atof(inputRangeHighEditor->getText().toUTF8()); | |
234 factory_.setRangeInputMax(range); | |
235 } | |
236 } | |
237 | |
238 void TouchkeyControlMappingShortEditor::textEditorEscapeKeyPressed(TextEditor &editor) | |
239 { | |
240 | |
241 } | |
242 | |
243 void TouchkeyControlMappingShortEditor::textEditorFocusLost(TextEditor &editor) | |
244 { | |
245 textEditorReturnKeyPressed(editor); | |
246 } | |
247 | |
248 void TouchkeyControlMappingShortEditor::synchronize() | |
249 { | |
250 // Update the editors to reflect the current status | |
251 if(!inputRangeLowEditor->hasKeyboardFocus(true)) { | |
252 float value = factory_.getRangeInputMin(); | |
253 char st[16]; | |
254 snprintf(st, 16, "%.2f", value); | |
255 | |
256 inputRangeLowEditor->setText(st); | |
257 } | |
258 | |
259 if(!inputRangeHighEditor->hasKeyboardFocus(true)) { | |
260 float value = factory_.getRangeInputMax(); | |
261 char st[16]; | |
262 snprintf(st, 16, "%.2f", value); | |
263 | |
264 inputRangeHighEditor->setText(st); | |
265 } | |
266 | |
267 parameterComboBox->setSelectedId(factory_.getInputParameter(), dontSendNotification); | |
268 typeComboBox->setSelectedId(factory_.getInputType(), dontSendNotification); | |
269 controlComboBox->setSelectedId(factory_.getController(), dontSendNotification); | |
270 } | |
271 //[/MiscUserCode] | |
272 | |
273 | |
274 //============================================================================== | |
275 #if 0 | |
276 /* -- Introjucer information section -- | |
277 | |
278 This is where the Introjucer stores the metadata that describe this GUI layout, so | |
279 make changes in here at your peril! | |
280 | |
281 BEGIN_JUCER_METADATA | |
282 | |
283 <JUCER_COMPONENT documentType="Component" className="TouchkeyControlMappingShortEditor" | |
284 componentName="" parentClasses="public MappingEditorComponent, public TextEditor::Listener" | |
285 constructorParams="TouchkeyControlMappingFactory& factory" | |
286 variableInitialisers="factory_(factory)" snapPixels="8" snapActive="1" | |
287 snapShown="1" overlayOpacity="0.330000013" fixedSize="1" initialWidth="328" | |
288 initialHeight="71"> | |
289 <BACKGROUND backgroundColour="ffffffff"/> | |
290 <TEXTEDITOR name="range low text editor" id="db0f62c03a58af03" memberName="inputRangeLowEditor" | |
291 virtualName="" explicitFocusOrder="0" pos="80 40 40 24" initialText="" | |
292 multiline="0" retKeyStartsLine="0" readonly="0" scrollbars="1" | |
293 caret="1" popupmenu="1"/> | |
294 <LABEL name="range label" id="1ca2d422f4c37b7f" memberName="rangeLabel" | |
295 virtualName="" explicitFocusOrder="0" pos="0 40 80 24" edTextCol="ff000000" | |
296 edBkgCol="0" labelText="Input Range:" editableSingleClick="0" | |
297 editableDoubleClick="0" focusDiscardsChanges="0" fontname="Default font" | |
298 fontsize="15" bold="0" italic="0" justification="33"/> | |
299 <LABEL name="control label" id="f953b12999632418" memberName="controlLabel" | |
300 virtualName="" explicitFocusOrder="0" pos="176 8 56 24" edTextCol="ff000000" | |
301 edBkgCol="0" labelText="Control:" editableSingleClick="0" editableDoubleClick="0" | |
302 focusDiscardsChanges="0" fontname="Default font" fontsize="15" | |
303 bold="0" italic="0" justification="33"/> | |
304 <COMBOBOX name="control combo box" id="f1c84bb5fd2730fb" memberName="controlComboBox" | |
305 virtualName="" explicitFocusOrder="0" pos="232 8 88 24" editable="0" | |
306 layout="33" items="" textWhenNonSelected="" textWhenNoItems="(no choices)"/> | |
307 <LABEL name="control label" id="5ef7c1b78fdcf616" memberName="controlLabel2" | |
308 virtualName="" explicitFocusOrder="0" pos="0 8 72 24" edTextCol="ff000000" | |
309 edBkgCol="0" labelText="Parameter:" editableSingleClick="0" editableDoubleClick="0" | |
310 focusDiscardsChanges="0" fontname="Default font" fontsize="15" | |
311 bold="0" italic="0" justification="33"/> | |
312 <COMBOBOX name="parameter combo box" id="f12f6f6e31042be1" memberName="parameterComboBox" | |
313 virtualName="" explicitFocusOrder="0" pos="72 8 104 24" editable="0" | |
314 layout="33" items="" textWhenNonSelected="" textWhenNoItems="(no choices)"/> | |
315 <LABEL name="control label" id="9ded92e82db31777" memberName="controlLabel3" | |
316 virtualName="" explicitFocusOrder="0" pos="184 40 56 24" edTextCol="ff000000" | |
317 edBkgCol="0" labelText="Type:" editableSingleClick="0" editableDoubleClick="0" | |
318 focusDiscardsChanges="0" fontname="Default font" fontsize="15" | |
319 bold="0" italic="0" justification="33"/> | |
320 <COMBOBOX name="type combo box" id="82d38054016f6c4f" memberName="typeComboBox" | |
321 virtualName="" explicitFocusOrder="0" pos="232 40 88 24" editable="0" | |
322 layout="33" items="" textWhenNonSelected="" textWhenNoItems="(no choices)"/> | |
323 <TEXTEDITOR name="range hi text editor" id="c34ac3e87db289d1" memberName="inputRangeHighEditor" | |
324 virtualName="" explicitFocusOrder="0" pos="136 40 40 24" initialText="" | |
325 multiline="0" retKeyStartsLine="0" readonly="0" scrollbars="1" | |
326 caret="1" popupmenu="1"/> | |
327 <LABEL name="range label" id="19e0ad80306cc4c0" memberName="rangeLabel2" | |
328 virtualName="" explicitFocusOrder="0" pos="120 40 16 24" edTextCol="ff000000" | |
329 edBkgCol="0" labelText="-" editableSingleClick="0" editableDoubleClick="0" | |
330 focusDiscardsChanges="0" fontname="Default font" fontsize="15" | |
331 bold="0" italic="0" justification="33"/> | |
332 </JUCER_COMPONENT> | |
333 | |
334 END_JUCER_METADATA | |
335 */ | |
336 #endif | |
337 | |
338 | |
339 //[EndFile] You can add extra defines here... | |
340 //[/EndFile] |