annotate Source/Mappings/Control/TouchkeyControlMappingShortEditor.cpp @ 20:dfff66c07936

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