You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

207 lines
7.8KB

  1. /*
  2. ==============================================================================
  3. This is an automatically generated GUI class created by the Projucer!
  4. Be careful when adding custom code to these files, as only the code within
  5. the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded
  6. and re-saved.
  7. Created with Projucer version: 6.0.8
  8. ------------------------------------------------------------------------------
  9. The Projucer is part of the JUCE library.
  10. Copyright (c) 2020 - Raw Material Software Limited.
  11. ==============================================================================
  12. */
  13. //[Headers] You can add your own extra header files here...
  14. //[/Headers]
  15. #include "SetPresetNameWindow.h"
  16. //[MiscUserDefs] You can add your own user definitions and misc code here...
  17. //[/MiscUserDefs]
  18. //==============================================================================
  19. SetPresetNameWindow::SetPresetNameWindow ()
  20. {
  21. //[Constructor_pre] You can add your own custom stuff here..
  22. //[/Constructor_pre]
  23. nameTextEditor.reset (new juce::TextEditor ("nameTextEditor"));
  24. addAndMakeVisible (nameTextEditor.get());
  25. nameTextEditor->setMultiLine (false);
  26. nameTextEditor->setReturnKeyStartsNewLine (false);
  27. nameTextEditor->setReadOnly (false);
  28. nameTextEditor->setScrollbarsShown (true);
  29. nameTextEditor->setCaretVisible (true);
  30. nameTextEditor->setPopupMenuEnabled (false);
  31. nameTextEditor->setColour (juce::TextEditor::backgroundColourId, juce::Colours::black);
  32. nameTextEditor->setColour (juce::CaretComponent::caretColourId, juce::Colours::white);
  33. nameTextEditor->setText (juce::String());
  34. cancel.reset (new juce::TextButton ("cancel"));
  35. addAndMakeVisible (cancel.get());
  36. cancel->setButtonText (TRANS("Cancel"));
  37. cancel->addListener (this);
  38. cancel->setColour (juce::TextButton::buttonColourId, juce::Colours::black);
  39. Ok.reset (new juce::TextButton ("Ok"));
  40. addAndMakeVisible (Ok.get());
  41. Ok->setButtonText (TRANS("OK"));
  42. Ok->addListener (this);
  43. Ok->setColour (juce::TextButton::buttonColourId, juce::Colours::black);
  44. //[UserPreSize]
  45. cancel->setColour (juce::ComboBox::ColourIds::outlineColourId, juce::Colours::white);
  46. Ok->setColour (juce::ComboBox::ColourIds::outlineColourId, juce::Colours::white);
  47. //[/UserPreSize]
  48. setSize (300, 150);
  49. //[Constructor] You can add your own custom stuff here..
  50. //[/Constructor]
  51. }
  52. SetPresetNameWindow::~SetPresetNameWindow()
  53. {
  54. //[Destructor_pre]. You can add your own custom destruction code here..
  55. //[/Destructor_pre]
  56. nameTextEditor = nullptr;
  57. cancel = nullptr;
  58. Ok = nullptr;
  59. //[Destructor]. You can add your own custom destruction code here..
  60. //[/Destructor]
  61. }
  62. //==============================================================================
  63. void SetPresetNameWindow::paint (juce::Graphics& g)
  64. {
  65. //[UserPrePaint] Add your own custom painting code here..
  66. //[/UserPrePaint]
  67. g.fillAll (juce::Colours::black);
  68. {
  69. int x = 0, y = proportionOfHeight (0.0000f), width = proportionOfWidth (1.0000f), height = proportionOfHeight (1.0000f);
  70. juce::Colour fillColour = juce::Colours::black;
  71. juce::Colour strokeColour = juce::Colour (0xff666666);
  72. //[UserPaintCustomArguments] Customize the painting arguments here..
  73. //[/UserPaintCustomArguments]
  74. g.setColour (fillColour);
  75. g.fillRect (x, y, width, height);
  76. g.setColour (strokeColour);
  77. g.drawRect (x, y, width, height, 1);
  78. }
  79. {
  80. int x = proportionOfWidth (0.0000f), y = proportionOfHeight (0.1000f), width = proportionOfWidth (1.0000f), height = proportionOfHeight (0.2000f);
  81. juce::String text (TRANS("Preset Name"));
  82. juce::Colour fillColour = juce::Colours::white;
  83. //[UserPaintCustomArguments] Customize the painting arguments here..
  84. //[/UserPaintCustomArguments]
  85. g.setColour (fillColour);
  86. g.setFont (juce::Font (15.00f, juce::Font::plain).withTypefaceStyle ("Regular"));
  87. g.drawText (text, x, y, width, height,
  88. juce::Justification::centred, true);
  89. }
  90. //[UserPaint] Add your own custom painting code here..
  91. //[/UserPaint]
  92. }
  93. void SetPresetNameWindow::resized()
  94. {
  95. //[UserPreResize] Add your own custom resize code here..
  96. //[/UserPreResize]
  97. nameTextEditor->setBounds (proportionOfWidth (0.1500f), proportionOfHeight (0.3467f), proportionOfWidth (0.7000f), proportionOfHeight (0.1733f));
  98. cancel->setBounds (proportionOfWidth (0.2000f), proportionOfHeight (0.7000f), proportionOfWidth (0.2500f), proportionOfHeight (0.1600f));
  99. Ok->setBounds (proportionOfWidth (0.5500f), proportionOfHeight (0.7000f), proportionOfWidth (0.2500f), proportionOfHeight (0.1600f));
  100. //[UserResized] Add your own custom resize handling here..
  101. //[/UserResized]
  102. }
  103. void SetPresetNameWindow::buttonClicked (juce::Button* buttonThatWasClicked)
  104. {
  105. //[UserbuttonClicked_Pre]
  106. //[/UserbuttonClicked_Pre]
  107. if (buttonThatWasClicked == cancel.get())
  108. {
  109. //[UserButtonCode_cancel] -- add your button handler code here..
  110. callback(0, nameTextEditor->getText());
  111. //[/UserButtonCode_cancel]
  112. }
  113. else if (buttonThatWasClicked == Ok.get())
  114. {
  115. //[UserButtonCode_Ok] -- add your button handler code here..
  116. callback(1, nameTextEditor->getText());
  117. //[/UserButtonCode_Ok]
  118. }
  119. //[UserbuttonClicked_Post]
  120. //[/UserbuttonClicked_Post]
  121. }
  122. //[MiscUserCode] You can add your own definitions of your custom methods or any other code here...
  123. void SetPresetNameWindow::grabTextEditorFocus()
  124. {
  125. nameTextEditor->grabKeyboardFocus();
  126. };
  127. //[/MiscUserCode]
  128. //==============================================================================
  129. #if 0
  130. /* -- Projucer information section --
  131. This is where the Projucer stores the metadata that describe this GUI layout, so
  132. make changes in here at your peril!
  133. BEGIN_JUCER_METADATA
  134. <JUCER_COMPONENT documentType="Component" className="SetPresetNameWindow" componentName=""
  135. parentClasses="public juce::Component" constructorParams="" variableInitialisers=""
  136. snapPixels="8" snapActive="1" snapShown="1" overlayOpacity="0.330"
  137. fixedSize="1" initialWidth="300" initialHeight="150">
  138. <BACKGROUND backgroundColour="ff000000">
  139. <RECT pos="0 0% 100% 100%" fill="solid: ff000000" hasStroke="1" stroke="1, mitered, butt"
  140. strokeColour="solid: ff666666"/>
  141. <TEXT pos="0% 10% 100% 20%" fill="solid: ffffffff" hasStroke="0" text="Preset Name"
  142. fontname="Default font" fontsize="15.0" kerning="0.0" bold="0"
  143. italic="0" justification="36"/>
  144. </BACKGROUND>
  145. <TEXTEDITOR name="nameTextEditor" id="13e287a1045d7d6d" memberName="nameTextEditor"
  146. virtualName="" explicitFocusOrder="0" pos="15% 34.667% 70% 17.333%"
  147. bkgcol="ff000000" caretcol="ffffffff" initialText="" multiline="0"
  148. retKeyStartsLine="0" readonly="0" scrollbars="1" caret="1" popupmenu="0"/>
  149. <TEXTBUTTON name="cancel" id="873979f2630a3992" memberName="cancel" virtualName=""
  150. explicitFocusOrder="0" pos="20% 70% 25% 16%" bgColOff="ff000000"
  151. buttonText="Cancel" connectedEdges="0" needsCallback="1" radioGroupId="0"/>
  152. <TEXTBUTTON name="Ok" id="2874357d53dac91e" memberName="Ok" virtualName=""
  153. explicitFocusOrder="0" pos="55% 70% 25% 16%" bgColOff="ff000000"
  154. buttonText="OK" connectedEdges="0" needsCallback="1" radioGroupId="0"/>
  155. </JUCER_COMPONENT>
  156. END_JUCER_METADATA
  157. */
  158. #endif
  159. //[EndFile] You can add extra defines here...
  160. //[/EndFile]