Mercurial > hg > touchkeys
comparison Source/Mappings/PitchBend/TouchkeyPitchBendMappingShortEditor.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 "TouchkeyPitchBendMappingShortEditor.h" | |
24 | |
25 | |
26 //[MiscUserDefs] You can add your own user definitions and misc code here... | |
27 //[/MiscUserDefs] | |
28 | |
29 //============================================================================== | |
30 TouchkeyPitchBendMappingShortEditor::TouchkeyPitchBendMappingShortEditor (TouchkeyPitchBendMappingFactory& factory) | |
31 : factory_(factory) | |
32 { | |
33 addAndMakeVisible (rangeEditor = new TextEditor ("range text editor")); | |
34 rangeEditor->setMultiLine (false); | |
35 rangeEditor->setReturnKeyStartsNewLine (false); | |
36 rangeEditor->setReadOnly (false); | |
37 rangeEditor->setScrollbarsShown (true); | |
38 rangeEditor->setCaretVisible (true); | |
39 rangeEditor->setPopupMenuEnabled (true); | |
40 rangeEditor->setText (String::empty); | |
41 | |
42 addAndMakeVisible (rangeLabel = new Label ("range label", | |
43 "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 (thresholdEditor = new TextEditor ("threshold text editor")); | |
51 thresholdEditor->setMultiLine (false); | |
52 thresholdEditor->setReturnKeyStartsNewLine (false); | |
53 thresholdEditor->setReadOnly (false); | |
54 thresholdEditor->setScrollbarsShown (true); | |
55 thresholdEditor->setCaretVisible (true); | |
56 thresholdEditor->setPopupMenuEnabled (true); | |
57 thresholdEditor->setText (String::empty); | |
58 | |
59 addAndMakeVisible (thresholdLabel = new Label ("threshold label", | |
60 "Threshold:")); | |
61 thresholdLabel->setFont (Font (15.00f, Font::plain)); | |
62 thresholdLabel->setJustificationType (Justification::centredLeft); | |
63 thresholdLabel->setEditable (false, false, false); | |
64 thresholdLabel->setColour (TextEditor::textColourId, Colours::black); | |
65 thresholdLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000)); | |
66 | |
67 addAndMakeVisible (controlLabel = new Label ("control label", | |
68 "Endpoints:")); | |
69 controlLabel->setFont (Font (15.00f, Font::plain)); | |
70 controlLabel->setJustificationType (Justification::centredLeft); | |
71 controlLabel->setEditable (false, false, false); | |
72 controlLabel->setColour (TextEditor::textColourId, Colours::black); | |
73 controlLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000)); | |
74 | |
75 addAndMakeVisible (endpointsComboBox = new ComboBox ("control combo box")); | |
76 endpointsComboBox->setEditableText (false); | |
77 endpointsComboBox->setJustificationType (Justification::centredLeft); | |
78 endpointsComboBox->setTextWhenNothingSelected (String::empty); | |
79 endpointsComboBox->setTextWhenNoChoicesAvailable ("(no choices)"); | |
80 endpointsComboBox->addListener (this); | |
81 | |
82 | |
83 //[UserPreSize] | |
84 endpointsComboBox->addItem("Variable", TouchkeyPitchBendMapping::kPitchBendModeVariableEndpoints); | |
85 endpointsComboBox->addItem("Fixed", TouchkeyPitchBendMapping::kPitchBendModeFixedEndpoints); | |
86 //[/UserPreSize] | |
87 | |
88 setSize (328, 71); | |
89 | |
90 | |
91 //[Constructor] You can add your own custom stuff here.. | |
92 rangeEditor->addListener(this); | |
93 thresholdEditor->addListener(this); | |
94 //[/Constructor] | |
95 } | |
96 | |
97 TouchkeyPitchBendMappingShortEditor::~TouchkeyPitchBendMappingShortEditor() | |
98 { | |
99 //[Destructor_pre]. You can add your own custom destruction code here.. | |
100 //[/Destructor_pre] | |
101 | |
102 rangeEditor = nullptr; | |
103 rangeLabel = nullptr; | |
104 thresholdEditor = nullptr; | |
105 thresholdLabel = nullptr; | |
106 controlLabel = nullptr; | |
107 endpointsComboBox = nullptr; | |
108 | |
109 | |
110 //[Destructor]. You can add your own custom destruction code here.. | |
111 //[/Destructor] | |
112 } | |
113 | |
114 //============================================================================== | |
115 void TouchkeyPitchBendMappingShortEditor::paint (Graphics& g) | |
116 { | |
117 //[UserPrePaint] Add your own custom painting code here.. | |
118 //[/UserPrePaint] | |
119 | |
120 g.fillAll (Colours::white); | |
121 | |
122 //[UserPaint] Add your own custom painting code here.. | |
123 //[/UserPaint] | |
124 } | |
125 | |
126 void TouchkeyPitchBendMappingShortEditor::resized() | |
127 { | |
128 rangeEditor->setBounds (80, 8, 80, 24); | |
129 rangeLabel->setBounds (8, 8, 56, 24); | |
130 thresholdEditor->setBounds (240, 8, 80, 24); | |
131 thresholdLabel->setBounds (168, 8, 72, 24); | |
132 controlLabel->setBounds (8, 40, 72, 24); | |
133 endpointsComboBox->setBounds (80, 40, 80, 24); | |
134 //[UserResized] Add your own custom resize handling here.. | |
135 //[/UserResized] | |
136 } | |
137 | |
138 void TouchkeyPitchBendMappingShortEditor::comboBoxChanged (ComboBox* comboBoxThatHasChanged) | |
139 { | |
140 //[UsercomboBoxChanged_Pre] | |
141 //[/UsercomboBoxChanged_Pre] | |
142 | |
143 if (comboBoxThatHasChanged == endpointsComboBox) | |
144 { | |
145 //[UserComboBoxCode_endpointsComboBox] -- add your combo box handling code here.. | |
146 int control = endpointsComboBox->getSelectedId(); | |
147 if(control == TouchkeyPitchBendMapping::kPitchBendModeVariableEndpoints) | |
148 factory_.setBendVariableEndpoints(); | |
149 else if(control == TouchkeyPitchBendMapping::kPitchBendModeFixedEndpoints) | |
150 factory_.setBendFixedEndpoints(factory_.getBendThresholdKeyLength(), 0); | |
151 //[/UserComboBoxCode_endpointsComboBox] | |
152 } | |
153 | |
154 //[UsercomboBoxChanged_Post] | |
155 //[/UsercomboBoxChanged_Post] | |
156 } | |
157 | |
158 | |
159 | |
160 //[MiscUserCode] You can add your own definitions of your custom methods or any other code here... | |
161 | |
162 void TouchkeyPitchBendMappingShortEditor::textEditorReturnKeyPressed(TextEditor &editor) | |
163 { | |
164 if(&editor == rangeEditor) { | |
165 float range = atof(rangeEditor->getText().toUTF8()); | |
166 factory_.setBendRange(range); | |
167 } | |
168 else if(&editor == thresholdEditor) { | |
169 float threshold = atof(thresholdEditor->getText().toUTF8()); | |
170 factory_.setBendThresholdKeyLength(threshold); | |
171 } | |
172 } | |
173 | |
174 void TouchkeyPitchBendMappingShortEditor::textEditorEscapeKeyPressed(TextEditor &editor) | |
175 { | |
176 | |
177 } | |
178 | |
179 void TouchkeyPitchBendMappingShortEditor::textEditorFocusLost(TextEditor &editor) | |
180 { | |
181 textEditorReturnKeyPressed(editor); | |
182 } | |
183 | |
184 void TouchkeyPitchBendMappingShortEditor::synchronize() | |
185 { | |
186 // Update the editors to reflect the current status | |
187 if(!rangeEditor->hasKeyboardFocus(true)) { | |
188 float value = factory_.getBendRange(); | |
189 char st[16]; | |
190 snprintf(st, 16, "%.2f", value); | |
191 | |
192 rangeEditor->setText(st); | |
193 } | |
194 | |
195 if(!thresholdEditor->hasKeyboardFocus(true)) { | |
196 float value = factory_.getBendThresholdKeyLength(); | |
197 char st[16]; | |
198 snprintf(st, 16, "%.2f", value); | |
199 | |
200 thresholdEditor->setText(st); | |
201 } | |
202 | |
203 endpointsComboBox->setSelectedId(factory_.getBendMode(), dontSendNotification); | |
204 } | |
205 //[/MiscUserCode] | |
206 | |
207 | |
208 //============================================================================== | |
209 #if 0 | |
210 /* -- Introjucer information section -- | |
211 | |
212 This is where the Introjucer stores the metadata that describe this GUI layout, so | |
213 make changes in here at your peril! | |
214 | |
215 BEGIN_JUCER_METADATA | |
216 | |
217 <JUCER_COMPONENT documentType="Component" className="TouchkeyPitchBendMappingShortEditor" | |
218 componentName="" parentClasses="public MappingEditorComponent, public TextEditor::Listener" | |
219 constructorParams="TouchkeyPitchBendMappingFactory& factory" | |
220 variableInitialisers="factory_(factory)" snapPixels="8" snapActive="1" | |
221 snapShown="1" overlayOpacity="0.330000013" fixedSize="1" initialWidth="328" | |
222 initialHeight="71"> | |
223 <BACKGROUND backgroundColour="ffffffff"/> | |
224 <TEXTEDITOR name="range text editor" id="db0f62c03a58af03" memberName="rangeEditor" | |
225 virtualName="" explicitFocusOrder="0" pos="80 8 80 24" initialText="" | |
226 multiline="0" retKeyStartsLine="0" readonly="0" scrollbars="1" | |
227 caret="1" popupmenu="1"/> | |
228 <LABEL name="range label" id="1ca2d422f4c37b7f" memberName="rangeLabel" | |
229 virtualName="" explicitFocusOrder="0" pos="8 8 56 24" edTextCol="ff000000" | |
230 edBkgCol="0" labelText="Range:" editableSingleClick="0" editableDoubleClick="0" | |
231 focusDiscardsChanges="0" fontname="Default font" fontsize="15" | |
232 bold="0" italic="0" justification="33"/> | |
233 <TEXTEDITOR name="threshold text editor" id="854a054d84eaf552" memberName="thresholdEditor" | |
234 virtualName="" explicitFocusOrder="0" pos="240 8 80 24" initialText="" | |
235 multiline="0" retKeyStartsLine="0" readonly="0" scrollbars="1" | |
236 caret="1" popupmenu="1"/> | |
237 <LABEL name="threshold label" id="864de4f55b5481ee" memberName="thresholdLabel" | |
238 virtualName="" explicitFocusOrder="0" pos="168 8 72 24" edTextCol="ff000000" | |
239 edBkgCol="0" labelText="Threshold:" editableSingleClick="0" editableDoubleClick="0" | |
240 focusDiscardsChanges="0" fontname="Default font" fontsize="15" | |
241 bold="0" italic="0" justification="33"/> | |
242 <LABEL name="control label" id="f953b12999632418" memberName="controlLabel" | |
243 virtualName="" explicitFocusOrder="0" pos="8 40 72 24" edTextCol="ff000000" | |
244 edBkgCol="0" labelText="Endpoints:" editableSingleClick="0" editableDoubleClick="0" | |
245 focusDiscardsChanges="0" fontname="Default font" fontsize="15" | |
246 bold="0" italic="0" justification="33"/> | |
247 <COMBOBOX name="control combo box" id="f1c84bb5fd2730fb" memberName="endpointsComboBox" | |
248 virtualName="" explicitFocusOrder="0" pos="80 40 80 24" editable="0" | |
249 layout="33" items="" textWhenNonSelected="" textWhenNoItems="(no choices)"/> | |
250 </JUCER_COMPONENT> | |
251 | |
252 END_JUCER_METADATA | |
253 */ | |
254 #endif | |
255 | |
256 | |
257 //[EndFile] You can add extra defines here... | |
258 //[/EndFile] |