Config.cpp 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. /*
  2. ==============================================================================
  3. This is an automatically generated GUI class created by the Introjucer!
  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 Introjucer version: 3.1.1
  8. ------------------------------------------------------------------------------
  9. The Introjucer is part of the JUCE library - "Jules' Utility Class Extensions"
  10. Copyright 2004-13 by Raw Material Software Ltd.
  11. ==============================================================================
  12. */
  13. //[Headers] You can add your own extra header files here...
  14. #include "Constants.h"
  15. #include "ConfigAudio.h"
  16. #include "ConfigClient.h"
  17. #include "ConfigGui.h"
  18. #include "ConfigBlacklist.h"
  19. //[/Headers]
  20. #include "Config.h"
  21. //[MiscUserDefs] You can add your own user definitions and misc code here...
  22. //[/MiscUserDefs]
  23. //==============================================================================
  24. Config::Config (ValueTree audio_store, ValueTree client_store, ValueTree gui_store, ValueTree blacklist_store, Value linjam_status)
  25. : linjamStatus(linjam_status)
  26. {
  27. //[Constructor_pre] You can add your own custom stuff here..
  28. //[/Constructor_pre]
  29. addAndMakeVisible (configTabs = new TabbedComponent (TabbedButtonBar::TabsAtTop));
  30. configTabs->setExplicitFocusOrder (1);
  31. configTabs->setTabBarDepth (24);
  32. addAndMakeVisible (dismissButton = new TextButton ("dismissButton"));
  33. dismissButton->setExplicitFocusOrder (4);
  34. dismissButton->setButtonText (TRANS("done"));
  35. dismissButton->addListener (this);
  36. dismissButton->setColour (TextButton::buttonColourId, Colour (0xff004000));
  37. dismissButton->setColour (TextButton::buttonOnColourId, Colours::green);
  38. dismissButton->setColour (TextButton::textColourOnId, Colours::lime);
  39. dismissButton->setColour (TextButton::textColourOffId, Colours::lime);
  40. //[UserPreSize]
  41. //[/UserPreSize]
  42. setSize (622, 442);
  43. //[Constructor] You can add your own custom stuff here..
  44. // populate config tabs
  45. this->configAudio = new ConfigAudio( audio_store ) ;
  46. this->configClient = new ConfigClient( client_store ) ;
  47. this->configGui = new ConfigGui( gui_store ) ;
  48. this->configBlacklist = new ConfigBlacklist(blacklist_store) ;
  49. this->configTabs->addTab(TRANS("audio") , GUI::AUDIO_TAB_COLOR ,
  50. this->configAudio , false , GUI::AUDIO_TAB_IDX ) ;
  51. this->configTabs->addTab(TRANS("client") , GUI::CLIENT_TAB_COLOR ,
  52. this->configClient , false , GUI::CLIENT_TAB_IDX ) ;
  53. this->configTabs->addTab(TRANS("gui") , GUI::GUI_TAB_COLOR ,
  54. this->configGui , false , GUI::GUI_TAB_IDX ) ;
  55. this->configTabs->addTab(TRANS("ignores") , GUI::BLACKLIST_TAB_COLOR ,
  56. this->configBlacklist , false , GUI::BLACKLIST_TAB_IDX) ;
  57. this->configTabs->setCurrentTabIndex(GUI::AUDIO_TAB_IDX) ;
  58. this->configTabs->setOutline(0) ;
  59. this->configTabs->setIndent(0) ;
  60. this->linjamStatus.addListener(this) ;
  61. //[/Constructor]
  62. }
  63. Config::~Config()
  64. {
  65. //[Destructor_pre]. You can add your own custom destruction code here..
  66. //[/Destructor_pre]
  67. configTabs = nullptr;
  68. dismissButton = nullptr;
  69. //[Destructor]. You can add your own custom destruction code here..
  70. //[/Destructor]
  71. }
  72. //==============================================================================
  73. void Config::paint (Graphics& g)
  74. {
  75. //[UserPrePaint] Add your own custom painting code here..
  76. //[/UserPrePaint]
  77. g.setColour (Colour (0xff202020));
  78. g.fillRoundedRectangle (0.0f, 0.0f, static_cast<float> (getWidth() - 0), static_cast<float> (getHeight() - 0), 10.000f);
  79. g.setColour (Colours::white);
  80. g.drawRoundedRectangle (0.0f, 0.0f, static_cast<float> (getWidth() - 0), static_cast<float> (getHeight() - 0), 10.000f, 1.000f);
  81. //[UserPaint] Add your own custom painting code here..
  82. //[/UserPaint]
  83. }
  84. void Config::resized()
  85. {
  86. //[UserPreResize] Add your own custom resize code here..
  87. //[/UserPreResize]
  88. configTabs->setBounds (4, 0, getWidth() - 8, getHeight() - 4);
  89. dismissButton->setBounds (getWidth() - 64, 0, 64, 24);
  90. //[UserResized] Add your own custom resize handling here..
  91. //[/UserResized]
  92. }
  93. void Config::buttonClicked (Button* buttonThatWasClicked)
  94. {
  95. //[UserbuttonClicked_Pre]
  96. //[/UserbuttonClicked_Pre]
  97. if (buttonThatWasClicked == dismissButton)
  98. {
  99. //[UserButtonCode_dismissButton] -- add your button handler code here..
  100. this->linjamStatus = APP::LINJAM_STATUS_READY ;
  101. //[/UserButtonCode_dismissButton]
  102. }
  103. //[UserbuttonClicked_Post]
  104. //[/UserbuttonClicked_Post]
  105. }
  106. //[MiscUserCode] You can add your own definitions of your custom methods or any other code here...
  107. void Config::valueChanged(Value& a_value)
  108. {
  109. int linjam_status = int(a_value.getValue()) ;
  110. if (!a_value.refersToSameSourceAs(this->linjamStatus) ||
  111. linjam_status < APP::LINJAM_STATUS_AUDIOINIT ||
  112. linjam_status > APP::LINJAM_STATUS_AUDIOERROR ) return ;
  113. bool is_audio_init = linjam_status == APP::LINJAM_STATUS_AUDIOINIT ;
  114. bool is_audio_error = linjam_status == APP::LINJAM_STATUS_AUDIOERROR ;
  115. Colour button_out_color = (is_audio_init ) ? GUI::DISMISS_BTN_OUT_INIT_COLOR :
  116. (is_audio_error) ? GUI::DISMISS_BTN_OUT_ERROR_COLOR :
  117. GUI::DISMISS_BTN_OUT_NORMAL_COLOR ;
  118. Colour button_in_color = (is_audio_init ) ? GUI::DISMISS_BTN_IN_INIT_COLOR :
  119. (is_audio_error) ? GUI::DISMISS_BTN_IN_ERROR_COLOR :
  120. GUI::DISMISS_BTN_IN_NORMAL_COLOR ;
  121. Colour text_out_color = (is_audio_init ) ? GUI::DISMISS_BTN_TEXT_INIT_COLOR :
  122. (is_audio_error) ? GUI::DISMISS_BTN_TEXT_ERROR_COLOR :
  123. GUI::DISMISS_BTN_TEXT_NORMAL_COLOR ;
  124. Colour text_in_color = (is_audio_init ) ? GUI::DISMISS_BTN_TEXT_INIT_COLOR :
  125. (is_audio_error) ? GUI::DISMISS_BTN_TEXT_ERROR_COLOR :
  126. GUI::DISMISS_BTN_TEXT_NORMAL_COLOR ;
  127. String button_text = (is_audio_init ) ? GUI::DISMISS_BTN_INIT_TEXT :
  128. (is_audio_error) ? GUI::DISMISS_BTN_ERROR_TEXT :
  129. GUI::DISMISS_BTN_NORMAL_TEXT ;
  130. // /disable/enable dismissButton
  131. this->dismissButton->setColour(TextButton::buttonColourId , button_out_color) ;
  132. this->dismissButton->setColour(TextButton::buttonOnColourId , button_in_color ) ;
  133. this->dismissButton->setColour(TextButton::textColourOnId , text_in_color ) ;
  134. this->dismissButton->setColour(TextButton::textColourOffId , text_out_color ) ;
  135. this->dismissButton->setEnabled(!is_audio_error) ;
  136. this->dismissButton->setButtonText(button_text) ;
  137. // set ConfigAudio tab state
  138. this->configTabs->setCurrentTabIndex(GUI::AUDIO_TAB_IDX , false) ;
  139. if (is_audio_init) this->configAudio->disableComponents() ;
  140. else this->configAudio->loadParams() ;
  141. }
  142. //[/MiscUserCode]
  143. //==============================================================================
  144. #if 0
  145. /* -- Introjucer information section --
  146. This is where the Introjucer stores the metadata that describe this GUI layout, so
  147. make changes in here at your peril!
  148. BEGIN_JUCER_METADATA
  149. <JUCER_COMPONENT documentType="Component" className="Config" componentName=""
  150. parentClasses="public Component, public ValueListener" constructorParams="ValueTree audio_store, ValueTree client_store, ValueTree gui_store, ValueTree blacklist_store, Value linjam_status"
  151. variableInitialisers="linjamStatus(linjam_status)" snapPixels="8"
  152. snapActive="1" snapShown="1" overlayOpacity="0.330" fixedSize="0"
  153. initialWidth="622" initialHeight="442">
  154. <BACKGROUND backgroundColour="0">
  155. <ROUNDRECT pos="0 0 0M 0M" cornerSize="10" fill="solid: ff202020" hasStroke="1"
  156. stroke="1, mitered, butt" strokeColour="solid: ffffffff"/>
  157. </BACKGROUND>
  158. <TABBEDCOMPONENT name="configTabs" id="72016394fc1784e9" memberName="configTabs"
  159. virtualName="" explicitFocusOrder="1" pos="4 0 8M 4M" orientation="top"
  160. tabBarDepth="24" initialTab="-1"/>
  161. <TEXTBUTTON name="dismissButton" id="becd368b728d32c0" memberName="dismissButton"
  162. virtualName="" explicitFocusOrder="4" pos="64R 0 64 24" bgColOff="ff004000"
  163. bgColOn="ff008000" textCol="ff00ff00" textColOn="ff00ff00" buttonText="done"
  164. connectedEdges="0" needsCallback="1" radioGroupId="0"/>
  165. </JUCER_COMPONENT>
  166. END_JUCER_METADATA
  167. */
  168. #endif
  169. //[EndFile] You can add extra defines here...
  170. //[/EndFile]