annotate Source/GUI/PreferencesComponent.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@41 1 /*
andrewm@41 2 ==============================================================================
andrewm@41 3
andrewm@41 4 This is an automatically generated GUI class created by the Introjucer!
andrewm@41 5
andrewm@41 6 Be careful when adding custom code to these files, as only the code within
andrewm@41 7 the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded
andrewm@41 8 and re-saved.
andrewm@41 9
andrewm@41 10 Created with Introjucer version: 3.1.0
andrewm@41 11
andrewm@41 12 ------------------------------------------------------------------------------
andrewm@41 13
andrewm@41 14 The Introjucer is part of the JUCE library - "Jules' Utility Class Extensions"
andrewm@41 15 Copyright 2004-13 by Raw Material Software Ltd.
andrewm@41 16
andrewm@41 17 ==============================================================================
andrewm@41 18 */
andrewm@41 19
andrewm@41 20 //[Headers] You can add your own extra header files here...
andrewm@50 21 #ifndef TOUCHKEYS_NO_GUI
andrewm@41 22 #include "../MainApplicationController.h"
andrewm@41 23 //[/Headers]
andrewm@41 24
andrewm@41 25 #include "PreferencesComponent.h"
andrewm@41 26
andrewm@41 27
andrewm@41 28 //[MiscUserDefs] You can add your own user definitions and misc code here...
andrewm@41 29 //[/MiscUserDefs]
andrewm@41 30
andrewm@41 31 //==============================================================================
andrewm@41 32 PreferencesComponent::PreferencesComponent ()
andrewm@41 33 : controller_(0)
andrewm@41 34 {
andrewm@41 35 addAndMakeVisible (startupPresetComboBox = new ComboBox ("Startup preset combo box"));
andrewm@41 36 startupPresetComboBox->setEditableText (false);
andrewm@41 37 startupPresetComboBox->setJustificationType (Justification::centredLeft);
andrewm@41 38 startupPresetComboBox->setTextWhenNothingSelected (String::empty);
andrewm@41 39 startupPresetComboBox->setTextWhenNoChoicesAvailable ("(no choices)");
andrewm@41 40 startupPresetComboBox->addListener (this);
andrewm@41 41
andrewm@41 42 addAndMakeVisible (label4 = new Label ("new label",
andrewm@41 43 "Load preset on startup:"));
andrewm@41 44 label4->setFont (Font (15.00f, Font::plain));
andrewm@41 45 label4->setJustificationType (Justification::centredLeft);
andrewm@41 46 label4->setEditable (false, false, false);
andrewm@41 47 label4->setColour (TextEditor::textColourId, Colours::black);
andrewm@41 48 label4->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
andrewm@41 49
andrewm@41 50 addAndMakeVisible (startTouchKeysButton = new ToggleButton ("auto start TouchKeys button"));
andrewm@41 51 startTouchKeysButton->setButtonText ("Start TouchKeys on startup");
andrewm@41 52 startTouchKeysButton->addListener (this);
andrewm@41 53
andrewm@41 54 addAndMakeVisible (autodetectButton = new ToggleButton ("Autodetect button"));
andrewm@41 55 autodetectButton->setButtonText ("Autodetect TouchKeys octave on each start");
andrewm@41 56 autodetectButton->addListener (this);
andrewm@41 57
andrewm@41 58 addAndMakeVisible (defaultsButton = new TextButton ("new button"));
andrewm@41 59 defaultsButton->setButtonText ("Reset to Defaults...");
andrewm@41 60 defaultsButton->addListener (this);
andrewm@41 61
andrewm@41 62
andrewm@41 63 //[UserPreSize]
andrewm@41 64 //[/UserPreSize]
andrewm@41 65
andrewm@41 66 setSize (296, 152);
andrewm@41 67
andrewm@41 68
andrewm@41 69 //[Constructor] You can add your own custom stuff here..
andrewm@41 70
andrewm@41 71 // Initialise the combo box
andrewm@41 72 startupPresetComboBox->addItem("None", kStartupPresetNone);
andrewm@41 73 startupPresetComboBox->addItem("Vibrato and Pitch Bend", kStartupPresetVibratoPitchBend);
andrewm@41 74 startupPresetComboBox->addItem("Last Saved", kStartupPresetLastSaved);
andrewm@41 75 startupPresetComboBox->addItem("Choose...", kStartupPresetChoose);
andrewm@41 76
andrewm@41 77 //[/Constructor]
andrewm@41 78 }
andrewm@41 79
andrewm@41 80 PreferencesComponent::~PreferencesComponent()
andrewm@41 81 {
andrewm@41 82 //[Destructor_pre]. You can add your own custom destruction code here..
andrewm@41 83 //[/Destructor_pre]
andrewm@41 84
andrewm@41 85 startupPresetComboBox = nullptr;
andrewm@41 86 label4 = nullptr;
andrewm@41 87 startTouchKeysButton = nullptr;
andrewm@41 88 autodetectButton = nullptr;
andrewm@41 89 defaultsButton = nullptr;
andrewm@41 90
andrewm@41 91
andrewm@41 92 //[Destructor]. You can add your own custom destruction code here..
andrewm@41 93 //[/Destructor]
andrewm@41 94 }
andrewm@41 95
andrewm@41 96 //==============================================================================
andrewm@41 97 void PreferencesComponent::paint (Graphics& g)
andrewm@41 98 {
andrewm@41 99 //[UserPrePaint] Add your own custom painting code here..
andrewm@41 100 //[/UserPrePaint]
andrewm@41 101
andrewm@41 102 g.fillAll (Colour (0xffd2d2d2));
andrewm@41 103
andrewm@41 104 //[UserPaint] Add your own custom painting code here..
andrewm@41 105 //[/UserPaint]
andrewm@41 106 }
andrewm@41 107
andrewm@41 108 void PreferencesComponent::resized()
andrewm@41 109 {
andrewm@41 110 startupPresetComboBox->setBounds (16, 32, 264, 24);
andrewm@41 111 label4->setBounds (16, 8, 160, 24);
andrewm@41 112 startTouchKeysButton->setBounds (16, 64, 208, 24);
andrewm@41 113 autodetectButton->setBounds (16, 88, 272, 24);
andrewm@41 114 defaultsButton->setBounds (16, 120, 144, 24);
andrewm@41 115 //[UserResized] Add your own custom resize handling here..
andrewm@41 116 //[/UserResized]
andrewm@41 117 }
andrewm@41 118
andrewm@41 119 void PreferencesComponent::comboBoxChanged (ComboBox* comboBoxThatHasChanged)
andrewm@41 120 {
andrewm@41 121 //[UsercomboBoxChanged_Pre]
andrewm@41 122 if(controller_ == 0)
andrewm@41 123 return;
andrewm@41 124 //[/UsercomboBoxChanged_Pre]
andrewm@41 125
andrewm@41 126 if (comboBoxThatHasChanged == startupPresetComboBox)
andrewm@41 127 {
andrewm@41 128 //[UserComboBoxCode_startupPresetComboBox] -- add your combo box handling code here..
andrewm@41 129 int selection = startupPresetComboBox->getSelectedId();
andrewm@41 130 if(selection == kStartupPresetNone) {
andrewm@41 131 controller_->setPrefsStartupPresetNone();
andrewm@41 132 }
andrewm@41 133 else if(selection == kStartupPresetVibratoPitchBend) {
andrewm@41 134 controller_->setPrefsStartupPresetVibratoPitchBend();
andrewm@41 135 }
andrewm@41 136 else if(selection == kStartupPresetLastSaved) {
andrewm@41 137 controller_->setPrefsStartupPresetLastSaved();
andrewm@41 138 }
andrewm@41 139 else if(selection == kStartupPresetChoose) {
andrewm@41 140 // Bring up window to choose a preset
andrewm@41 141 FileChooser myChooser ("Select a preset...",
andrewm@41 142 File::nonexistent, // File::getSpecialLocation (File::userHomeDirectory),
andrewm@41 143 "*.tkpreset");
andrewm@41 144 if(myChooser.browseForFileToOpen()) {
andrewm@41 145 controller_->setPrefsStartupPreset(myChooser.getResult().getFullPathName());
andrewm@41 146 }
andrewm@41 147 // Otherwise user clicked cancel and we go back to whatever was there before
andrewm@41 148 }
andrewm@41 149 //[/UserComboBoxCode_startupPresetComboBox]
andrewm@41 150 }
andrewm@41 151
andrewm@41 152 //[UsercomboBoxChanged_Post]
andrewm@41 153 //[/UsercomboBoxChanged_Post]
andrewm@41 154 }
andrewm@41 155
andrewm@41 156 void PreferencesComponent::buttonClicked (Button* buttonThatWasClicked)
andrewm@41 157 {
andrewm@41 158 //[UserbuttonClicked_Pre]
andrewm@41 159 if(controller_ == 0)
andrewm@41 160 return;
andrewm@41 161 //[/UserbuttonClicked_Pre]
andrewm@41 162
andrewm@41 163 if (buttonThatWasClicked == startTouchKeysButton)
andrewm@41 164 {
andrewm@41 165 //[UserButtonCode_startTouchKeysButton] -- add your button handler code here..
andrewm@41 166 controller_->setPrefsAutoStartTouchKeys(startTouchKeysButton->getToggleState());
andrewm@41 167 //[/UserButtonCode_startTouchKeysButton]
andrewm@41 168 }
andrewm@41 169 else if (buttonThatWasClicked == autodetectButton)
andrewm@41 170 {
andrewm@41 171 //[UserButtonCode_autodetectButton] -- add your button handler code here..
andrewm@41 172 controller_->setPrefsAutodetectOctave(autodetectButton->getToggleState());
andrewm@41 173 //[/UserButtonCode_autodetectButton]
andrewm@41 174 }
andrewm@41 175 else if (buttonThatWasClicked == defaultsButton)
andrewm@41 176 {
andrewm@41 177 //[UserButtonCode_defaultsButton] -- add your button handler code here..
andrewm@41 178 controller_->resetPreferences();
andrewm@41 179 //[/UserButtonCode_defaultsButton]
andrewm@41 180 }
andrewm@41 181
andrewm@41 182 //[UserbuttonClicked_Post]
andrewm@41 183 //[/UserbuttonClicked_Post]
andrewm@41 184 }
andrewm@41 185
andrewm@41 186
andrewm@41 187
andrewm@41 188 //[MiscUserCode] You can add your own definitions of your custom methods or any other code here...
andrewm@41 189
andrewm@41 190 // Synchronize the UI state with the underlying state of the controller
andrewm@41 191 void PreferencesComponent::synchronize(bool forceUpdates) {
andrewm@41 192 if(controller_ == 0)
andrewm@41 193 return;
andrewm@41 194
andrewm@41 195 startTouchKeysButton->setToggleState(controller_->getPrefsAutoStartTouchKeys(), dontSendNotification);
andrewm@41 196 autodetectButton->setToggleState(controller_->getPrefsAutodetectOctave(), dontSendNotification);
andrewm@41 197
andrewm@41 198 if(controller_->getPrefsStartupPresetNone())
andrewm@41 199 startupPresetComboBox->setSelectedId(kStartupPresetNone);
andrewm@41 200 else if(controller_->getPrefsStartupPresetVibratoPitchBend())
andrewm@41 201 startupPresetComboBox->setSelectedId(kStartupPresetVibratoPitchBend);
andrewm@41 202 else if(controller_->getPrefsStartupPresetLastSaved())
andrewm@41 203 startupPresetComboBox->setSelectedId(kStartupPresetLastSaved);
andrewm@41 204 else {
andrewm@41 205 String path = controller_->getPrefsStartupPreset();
andrewm@41 206 startupPresetComboBox->setText(path);
andrewm@41 207 }
andrewm@41 208 }
andrewm@41 209
andrewm@41 210 //[/MiscUserCode]
andrewm@41 211
andrewm@41 212
andrewm@41 213 //==============================================================================
andrewm@41 214 #if 0
andrewm@41 215 /* -- Introjucer information section --
andrewm@41 216
andrewm@41 217 This is where the Introjucer stores the metadata that describe this GUI layout, so
andrewm@41 218 make changes in here at your peril!
andrewm@41 219
andrewm@41 220 BEGIN_JUCER_METADATA
andrewm@41 221
andrewm@41 222 <JUCER_COMPONENT documentType="Component" className="PreferencesComponent" componentName=""
andrewm@41 223 parentClasses="public Component" constructorParams="" variableInitialisers="controller_(0)"
andrewm@41 224 snapPixels="8" snapActive="1" snapShown="1" overlayOpacity="0.330"
andrewm@41 225 fixedSize="1" initialWidth="296" initialHeight="152">
andrewm@41 226 <BACKGROUND backgroundColour="ffd2d2d2"/>
andrewm@41 227 <COMBOBOX name="Startup preset combo box" id="244410f02f6c1c72" memberName="startupPresetComboBox"
andrewm@41 228 virtualName="" explicitFocusOrder="0" pos="16 32 264 24" editable="0"
andrewm@41 229 layout="33" items="" textWhenNonSelected="" textWhenNoItems="(no choices)"/>
andrewm@41 230 <LABEL name="new label" id="e9b3daa69a8ac5c" memberName="label4" virtualName=""
andrewm@41 231 explicitFocusOrder="0" pos="16 8 160 24" edTextCol="ff000000"
andrewm@41 232 edBkgCol="0" labelText="Load preset on startup:" editableSingleClick="0"
andrewm@41 233 editableDoubleClick="0" focusDiscardsChanges="0" fontname="Default font"
andrewm@41 234 fontsize="15" bold="0" italic="0" justification="33"/>
andrewm@41 235 <TOGGLEBUTTON name="auto start TouchKeys button" id="62c82600413ca060" memberName="startTouchKeysButton"
andrewm@41 236 virtualName="" explicitFocusOrder="0" pos="16 64 208 24" buttonText="Start TouchKeys on startup"
andrewm@41 237 connectedEdges="0" needsCallback="1" radioGroupId="0" state="0"/>
andrewm@41 238 <TOGGLEBUTTON name="Autodetect button" id="69a491dfca4ea997" memberName="autodetectButton"
andrewm@41 239 virtualName="" explicitFocusOrder="0" pos="16 88 272 24" buttonText="Autodetect TouchKeys octave on each start"
andrewm@41 240 connectedEdges="0" needsCallback="1" radioGroupId="0" state="0"/>
andrewm@41 241 <TEXTBUTTON name="new button" id="89690e14d6bf00c0" memberName="defaultsButton"
andrewm@41 242 virtualName="" explicitFocusOrder="0" pos="16 120 144 24" buttonText="Reset to Defaults..."
andrewm@41 243 connectedEdges="0" needsCallback="1" radioGroupId="0"/>
andrewm@41 244 </JUCER_COMPONENT>
andrewm@41 245
andrewm@41 246 END_JUCER_METADATA
andrewm@41 247 */
andrewm@41 248 #endif
andrewm@41 249
andrewm@41 250
andrewm@41 251 //[EndFile] You can add extra defines here...
andrewm@50 252 #endif // TOUCHKEYS_NO_GUI
andrewm@41 253 //[/EndFile]