annotate Source/Mappings/MultiFingerTrigger/TouchkeyMultiFingerTriggerMappingShortEditor.cpp @ 56:b4a2d2ae43cf tip

merge
author Andrew McPherson <andrewm@eecs.qmul.ac.uk>
date Fri, 23 Nov 2018 15:48:14 +0000
parents 114427cb39f0
children
rev   line source
andrewm@42 1 /*
andrewm@42 2 ==============================================================================
andrewm@42 3
andrewm@42 4 This is an automatically generated GUI class created by the Introjucer!
andrewm@42 5
andrewm@42 6 Be careful when adding custom code to these files, as only the code within
andrewm@42 7 the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded
andrewm@42 8 and re-saved.
andrewm@42 9
andrewm@42 10 Created with Introjucer version: 3.1.0
andrewm@42 11
andrewm@42 12 ------------------------------------------------------------------------------
andrewm@42 13
andrewm@42 14 The Introjucer is part of the JUCE library - "Jules' Utility Class Extensions"
andrewm@42 15 Copyright 2004-13 by Raw Material Software Ltd.
andrewm@42 16
andrewm@42 17 ==============================================================================
andrewm@42 18 */
andrewm@42 19
andrewm@42 20 //[Headers] You can add your own extra header files here...
andrewm@50 21 #ifndef TOUCHKEYS_NO_GUI
andrewm@42 22 //[/Headers]
andrewm@42 23
andrewm@42 24 #include "TouchkeyMultiFingerTriggerMappingShortEditor.h"
andrewm@42 25
andrewm@42 26
andrewm@42 27 //[MiscUserDefs] You can add your own user definitions and misc code here...
andrewm@42 28 const int TouchkeyMultiFingerTriggerMappingShortEditor::kNoteSame = 256;
andrewm@42 29 const int TouchkeyMultiFingerTriggerMappingShortEditor::kNoteOffset = 1;
andrewm@42 30 //[/MiscUserDefs]
andrewm@42 31
andrewm@42 32 //==============================================================================
andrewm@42 33 TouchkeyMultiFingerTriggerMappingShortEditor::TouchkeyMultiFingerTriggerMappingShortEditor (TouchkeyMultiFingerTriggerMappingFactory& factory)
andrewm@42 34 : factory_(factory)
andrewm@42 35 {
andrewm@42 36 addAndMakeVisible (controlLabel = new Label ("control label",
andrewm@42 37 "Touches:"));
andrewm@42 38 controlLabel->setFont (Font (15.00f, Font::plain));
andrewm@42 39 controlLabel->setJustificationType (Justification::centredRight);
andrewm@42 40 controlLabel->setEditable (false, false, false);
andrewm@42 41 controlLabel->setColour (TextEditor::textColourId, Colours::black);
andrewm@42 42 controlLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
andrewm@42 43
andrewm@42 44 addAndMakeVisible (touchesComboBox = new ComboBox ("control combo box"));
andrewm@42 45 touchesComboBox->setEditableText (false);
andrewm@42 46 touchesComboBox->setJustificationType (Justification::centredLeft);
andrewm@42 47 touchesComboBox->setTextWhenNothingSelected (String::empty);
andrewm@42 48 touchesComboBox->setTextWhenNoChoicesAvailable ("(no choices)");
andrewm@42 49 touchesComboBox->addListener (this);
andrewm@42 50
andrewm@42 51 addAndMakeVisible (controlLabel2 = new Label ("control label",
andrewm@42 52 "Repeat Taps:"));
andrewm@42 53 controlLabel2->setFont (Font (15.00f, Font::plain));
andrewm@42 54 controlLabel2->setJustificationType (Justification::centredLeft);
andrewm@42 55 controlLabel2->setEditable (false, false, false);
andrewm@42 56 controlLabel2->setColour (TextEditor::textColourId, Colours::black);
andrewm@42 57 controlLabel2->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
andrewm@42 58
andrewm@42 59 addAndMakeVisible (tapsComboBox = new ComboBox ("control combo box"));
andrewm@42 60 tapsComboBox->setEditableText (false);
andrewm@42 61 tapsComboBox->setJustificationType (Justification::centredLeft);
andrewm@42 62 tapsComboBox->setTextWhenNothingSelected (String::empty);
andrewm@42 63 tapsComboBox->setTextWhenNoChoicesAvailable ("(no choices)");
andrewm@42 64 tapsComboBox->addListener (this);
andrewm@42 65
andrewm@42 66 addAndMakeVisible (controlLabel3 = new Label ("control label",
andrewm@42 67 "Note:"));
andrewm@42 68 controlLabel3->setFont (Font (15.00f, Font::plain));
andrewm@42 69 controlLabel3->setJustificationType (Justification::centredRight);
andrewm@42 70 controlLabel3->setEditable (false, false, false);
andrewm@42 71 controlLabel3->setColour (TextEditor::textColourId, Colours::black);
andrewm@42 72 controlLabel3->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
andrewm@42 73
andrewm@42 74 addAndMakeVisible (noteComboBox = new ComboBox ("control combo box"));
andrewm@42 75 noteComboBox->setEditableText (false);
andrewm@42 76 noteComboBox->setJustificationType (Justification::centredLeft);
andrewm@42 77 noteComboBox->setTextWhenNothingSelected (String::empty);
andrewm@42 78 noteComboBox->setTextWhenNoChoicesAvailable ("(no choices)");
andrewm@42 79 noteComboBox->addListener (this);
andrewm@42 80
andrewm@42 81 addAndMakeVisible (sendOnReleaseButton = new ToggleButton ("new toggle button"));
andrewm@42 82 sendOnReleaseButton->setButtonText ("Also send on release");
andrewm@42 83 sendOnReleaseButton->addListener (this);
andrewm@42 84
andrewm@42 85
andrewm@42 86 //[UserPreSize]
andrewm@42 87 for(int i = 1; i <= 3; i++) {
andrewm@42 88 touchesComboBox->addItem(String(i), i);
andrewm@42 89 }
andrewm@42 90 for(int i = 1; i <= 5; i++) {
andrewm@42 91 tapsComboBox->addItem(String(i), i);
andrewm@42 92 }
andrewm@42 93 noteComboBox->addItem("Same", kNoteSame);
andrewm@42 94 for(int i = 0; i <= 127; i++) {
andrewm@42 95 noteComboBox->addItem(String(i), i + kNoteOffset);
andrewm@42 96 }
andrewm@42 97 //[/UserPreSize]
andrewm@42 98
andrewm@42 99 setSize (328, 71);
andrewm@42 100
andrewm@42 101
andrewm@42 102 //[Constructor] You can add your own custom stuff here..
andrewm@42 103 //[/Constructor]
andrewm@42 104 }
andrewm@42 105
andrewm@42 106 TouchkeyMultiFingerTriggerMappingShortEditor::~TouchkeyMultiFingerTriggerMappingShortEditor()
andrewm@42 107 {
andrewm@42 108 //[Destructor_pre]. You can add your own custom destruction code here..
andrewm@42 109 //[/Destructor_pre]
andrewm@42 110
andrewm@42 111 controlLabel = nullptr;
andrewm@42 112 touchesComboBox = nullptr;
andrewm@42 113 controlLabel2 = nullptr;
andrewm@42 114 tapsComboBox = nullptr;
andrewm@42 115 controlLabel3 = nullptr;
andrewm@42 116 noteComboBox = nullptr;
andrewm@42 117 sendOnReleaseButton = nullptr;
andrewm@42 118
andrewm@42 119
andrewm@42 120 //[Destructor]. You can add your own custom destruction code here..
andrewm@42 121 //[/Destructor]
andrewm@42 122 }
andrewm@42 123
andrewm@42 124 //==============================================================================
andrewm@42 125 void TouchkeyMultiFingerTriggerMappingShortEditor::paint (Graphics& g)
andrewm@42 126 {
andrewm@42 127 //[UserPrePaint] Add your own custom painting code here..
andrewm@42 128 //[/UserPrePaint]
andrewm@42 129
andrewm@42 130 g.fillAll (Colours::white);
andrewm@42 131
andrewm@42 132 //[UserPaint] Add your own custom painting code here..
andrewm@42 133 //[/UserPaint]
andrewm@42 134 }
andrewm@42 135
andrewm@42 136 void TouchkeyMultiFingerTriggerMappingShortEditor::resized()
andrewm@42 137 {
andrewm@42 138 controlLabel->setBounds (8, 8, 64, 24);
andrewm@42 139 touchesComboBox->setBounds (72, 8, 80, 24);
andrewm@42 140 controlLabel2->setBounds (160, 8, 80, 24);
andrewm@42 141 tapsComboBox->setBounds (240, 8, 80, 24);
andrewm@42 142 controlLabel3->setBounds (8, 40, 64, 24);
andrewm@42 143 noteComboBox->setBounds (72, 40, 80, 24);
andrewm@42 144 sendOnReleaseButton->setBounds (168, 40, 152, 24);
andrewm@42 145 //[UserResized] Add your own custom resize handling here..
andrewm@42 146 //[/UserResized]
andrewm@42 147 }
andrewm@42 148
andrewm@42 149 void TouchkeyMultiFingerTriggerMappingShortEditor::comboBoxChanged (ComboBox* comboBoxThatHasChanged)
andrewm@42 150 {
andrewm@42 151 //[UsercomboBoxChanged_Pre]
andrewm@42 152 //[/UsercomboBoxChanged_Pre]
andrewm@42 153
andrewm@42 154 if (comboBoxThatHasChanged == touchesComboBox)
andrewm@42 155 {
andrewm@42 156 //[UserComboBoxCode_touchesComboBox] -- add your combo box handling code here..
andrewm@42 157 factory_.setTouchesForTrigger(touchesComboBox->getSelectedId());
andrewm@42 158 //[/UserComboBoxCode_touchesComboBox]
andrewm@42 159 }
andrewm@42 160 else if (comboBoxThatHasChanged == tapsComboBox)
andrewm@42 161 {
andrewm@42 162 //[UserComboBoxCode_tapsComboBox] -- add your combo box handling code here..
andrewm@42 163 factory_.setConsecutiveTapsForTrigger(tapsComboBox->getSelectedId());
andrewm@42 164 //[/UserComboBoxCode_tapsComboBox]
andrewm@42 165 }
andrewm@42 166 else if (comboBoxThatHasChanged == noteComboBox)
andrewm@42 167 {
andrewm@42 168 //[UserComboBoxCode_noteComboBox] -- add your combo box handling code here..
andrewm@42 169 int note = noteComboBox->getSelectedId();
andrewm@42 170 if(note == kNoteSame)
andrewm@42 171 note = -1;
andrewm@42 172 else
andrewm@42 173 note -= kNoteOffset;
andrewm@42 174 factory_.setTriggerOnNoteNumber(note);
andrewm@42 175 factory_.setTriggerOffNoteNumber(note);
andrewm@42 176 //[/UserComboBoxCode_noteComboBox]
andrewm@42 177 }
andrewm@42 178
andrewm@42 179 //[UsercomboBoxChanged_Post]
andrewm@42 180 //[/UsercomboBoxChanged_Post]
andrewm@42 181 }
andrewm@42 182
andrewm@42 183 void TouchkeyMultiFingerTriggerMappingShortEditor::buttonClicked (Button* buttonThatWasClicked)
andrewm@42 184 {
andrewm@42 185 //[UserbuttonClicked_Pre]
andrewm@42 186 //[/UserbuttonClicked_Pre]
andrewm@42 187
andrewm@42 188 if (buttonThatWasClicked == sendOnReleaseButton)
andrewm@42 189 {
andrewm@42 190 //[UserButtonCode_sendOnReleaseButton] -- add your button handler code here..
andrewm@42 191 if(sendOnReleaseButton->getToggleState()) {
andrewm@42 192 factory_.setTriggerOffAction(TouchkeyMultiFingerTriggerMapping::kActionNoteOn);
andrewm@42 193 }
andrewm@42 194 else {
andrewm@42 195 factory_.setTriggerOffAction(TouchkeyMultiFingerTriggerMapping::kActionNone);
andrewm@42 196 }
andrewm@42 197 //[/UserButtonCode_sendOnReleaseButton]
andrewm@42 198 }
andrewm@42 199
andrewm@42 200 //[UserbuttonClicked_Post]
andrewm@42 201 //[/UserbuttonClicked_Post]
andrewm@42 202 }
andrewm@42 203
andrewm@42 204
andrewm@42 205
andrewm@42 206 //[MiscUserCode] You can add your own definitions of your custom methods or any other code here...
andrewm@42 207 void TouchkeyMultiFingerTriggerMappingShortEditor::synchronize() {
andrewm@42 208 touchesComboBox->setSelectedId(factory_.getTouchesForTrigger(), dontSendNotification);
andrewm@42 209 tapsComboBox->setSelectedId(factory_.getConsecutiveTapsForTrigger(), dontSendNotification);
andrewm@42 210
andrewm@42 211 int note = factory_.getTriggerOnNoteNumber();
andrewm@42 212 if(note < 0)
andrewm@42 213 noteComboBox->setSelectedId(kNoteSame, dontSendNotification);
andrewm@42 214 else
andrewm@42 215 noteComboBox->setSelectedId(note + kNoteOffset, dontSendNotification);
andrewm@42 216
andrewm@42 217 if(factory_.getTriggerOffAction() == TouchkeyMultiFingerTriggerMapping::kActionNoteOn)
andrewm@42 218 sendOnReleaseButton->setToggleState(true, dontSendNotification);
andrewm@42 219 else
andrewm@42 220 sendOnReleaseButton->setToggleState(false, dontSendNotification);
andrewm@42 221 }
andrewm@42 222 //[/MiscUserCode]
andrewm@42 223
andrewm@42 224
andrewm@42 225 //==============================================================================
andrewm@42 226 #if 0
andrewm@42 227 /* -- Introjucer information section --
andrewm@42 228
andrewm@42 229 This is where the Introjucer stores the metadata that describe this GUI layout, so
andrewm@42 230 make changes in here at your peril!
andrewm@42 231
andrewm@42 232 BEGIN_JUCER_METADATA
andrewm@42 233
andrewm@42 234 <JUCER_COMPONENT documentType="Component" className="TouchkeyMultiFingerTriggerMappingShortEditor"
andrewm@42 235 componentName="" parentClasses="public MappingEditorComponent, public TextEditor::Listener"
andrewm@42 236 constructorParams="TouchkeyMultiFingerTriggerMappingFactory&amp; factory"
andrewm@42 237 variableInitialisers="factory_(factory)" snapPixels="8" snapActive="1"
andrewm@42 238 snapShown="1" overlayOpacity="0.330" fixedSize="1" initialWidth="328"
andrewm@42 239 initialHeight="71">
andrewm@42 240 <BACKGROUND backgroundColour="ffffffff"/>
andrewm@42 241 <LABEL name="control label" id="f953b12999632418" memberName="controlLabel"
andrewm@42 242 virtualName="" explicitFocusOrder="0" pos="8 8 64 24" edTextCol="ff000000"
andrewm@42 243 edBkgCol="0" labelText="Touches:" editableSingleClick="0" editableDoubleClick="0"
andrewm@42 244 focusDiscardsChanges="0" fontname="Default font" fontsize="15"
andrewm@42 245 bold="0" italic="0" justification="34"/>
andrewm@42 246 <COMBOBOX name="control combo box" id="f1c84bb5fd2730fb" memberName="touchesComboBox"
andrewm@42 247 virtualName="" explicitFocusOrder="0" pos="72 8 80 24" editable="0"
andrewm@42 248 layout="33" items="" textWhenNonSelected="" textWhenNoItems="(no choices)"/>
andrewm@42 249 <LABEL name="control label" id="e3b829a3e4774248" memberName="controlLabel2"
andrewm@42 250 virtualName="" explicitFocusOrder="0" pos="160 8 80 24" edTextCol="ff000000"
andrewm@42 251 edBkgCol="0" labelText="Repeat Taps:" editableSingleClick="0"
andrewm@42 252 editableDoubleClick="0" focusDiscardsChanges="0" fontname="Default font"
andrewm@42 253 fontsize="15" bold="0" italic="0" justification="33"/>
andrewm@42 254 <COMBOBOX name="control combo box" id="26848818ea1ea5ea" memberName="tapsComboBox"
andrewm@42 255 virtualName="" explicitFocusOrder="0" pos="240 8 80 24" editable="0"
andrewm@42 256 layout="33" items="" textWhenNonSelected="" textWhenNoItems="(no choices)"/>
andrewm@42 257 <LABEL name="control label" id="858bbbef4bfb2c55" memberName="controlLabel3"
andrewm@42 258 virtualName="" explicitFocusOrder="0" pos="8 40 64 24" edTextCol="ff000000"
andrewm@42 259 edBkgCol="0" labelText="Note:" editableSingleClick="0" editableDoubleClick="0"
andrewm@42 260 focusDiscardsChanges="0" fontname="Default font" fontsize="15"
andrewm@42 261 bold="0" italic="0" justification="34"/>
andrewm@42 262 <COMBOBOX name="control combo box" id="cb809b358724b54b" memberName="noteComboBox"
andrewm@42 263 virtualName="" explicitFocusOrder="0" pos="72 40 80 24" editable="0"
andrewm@42 264 layout="33" items="" textWhenNonSelected="" textWhenNoItems="(no choices)"/>
andrewm@42 265 <TOGGLEBUTTON name="new toggle button" id="f75c92be72563883" memberName="sendOnReleaseButton"
andrewm@42 266 virtualName="" explicitFocusOrder="0" pos="168 40 152 24" buttonText="Also send on release"
andrewm@42 267 connectedEdges="0" needsCallback="1" radioGroupId="0" state="0"/>
andrewm@42 268 </JUCER_COMPONENT>
andrewm@42 269
andrewm@42 270 END_JUCER_METADATA
andrewm@42 271 */
andrewm@42 272 #endif
andrewm@42 273
andrewm@42 274
andrewm@42 275 //[EndFile] You can add extra defines here...
andrewm@50 276 #endif // TOUCHKEYS_NO_GUI
andrewm@42 277 //[/EndFile]