Config.cpp 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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.0
  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 "LinJam.h"
  16. #include "ConfigAudio.h"
  17. #include "ConfigClient.h"
  18. #include "ConfigSubscriptions.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 subscriptions_store)
  25. {
  26. addAndMakeVisible (configTabs = new TabbedComponent (TabbedButtonBar::TabsAtTop));
  27. configTabs->setExplicitFocusOrder (1);
  28. configTabs->setTabBarDepth (24);
  29. configTabs->addTab (TRANS("audio"), Colour (0xff002000), new ConfigAudio (audio_store), true);
  30. configTabs->addTab (TRANS("client"), Colour (0xff202000), new ConfigClient (client_store), true);
  31. configTabs->addTab (TRANS("ignores"), Colour (0xff200000), new ConfigSubscriptions (subscriptions_store), true);
  32. configTabs->setCurrentTabIndex (0);
  33. addAndMakeVisible (dismissButton = new TextButton ("dismissButton"));
  34. dismissButton->setExplicitFocusOrder (4);
  35. dismissButton->setButtonText (TRANS("done"));
  36. dismissButton->addListener (this);
  37. dismissButton->setColour (TextButton::buttonColourId, Colour (0xff004000));
  38. dismissButton->setColour (TextButton::buttonOnColourId, Colours::green);
  39. dismissButton->setColour (TextButton::textColourOnId, Colours::lime);
  40. dismissButton->setColour (TextButton::textColourOffId, Colours::lime);
  41. //[UserPreSize]
  42. //[/UserPreSize]
  43. setSize (622, 442);
  44. //[Constructor] You can add your own custom stuff here..
  45. this->configTabs->setOutline(0) ;
  46. this->configTabs->setIndent(0) ;
  47. //[/Constructor]
  48. }
  49. Config::~Config()
  50. {
  51. //[Destructor_pre]. You can add your own custom destruction code here..
  52. //[/Destructor_pre]
  53. configTabs = nullptr;
  54. dismissButton = nullptr;
  55. //[Destructor]. You can add your own custom destruction code here..
  56. //[/Destructor]
  57. }
  58. //==============================================================================
  59. void Config::paint (Graphics& g)
  60. {
  61. //[UserPrePaint] Add your own custom painting code here..
  62. //[/UserPrePaint]
  63. g.setColour (Colour (0xff202020));
  64. g.fillRoundedRectangle (0.0f, 0.0f, static_cast<float> (getWidth() - 0), static_cast<float> (getHeight() - 0), 10.000f);
  65. g.setColour (Colours::white);
  66. g.drawRoundedRectangle (0.0f, 0.0f, static_cast<float> (getWidth() - 0), static_cast<float> (getHeight() - 0), 10.000f, 1.000f);
  67. //[UserPaint] Add your own custom painting code here..
  68. //[/UserPaint]
  69. }
  70. void Config::resized()
  71. {
  72. configTabs->setBounds (4, 0, getWidth() - 8, getHeight() - 4);
  73. dismissButton->setBounds (getWidth() - 64, 0, 64, 24);
  74. //[UserResized] Add your own custom resize handling here..
  75. //[/UserResized]
  76. }
  77. void Config::buttonClicked (Button* buttonThatWasClicked)
  78. {
  79. //[UserbuttonClicked_Pre]
  80. //[/UserbuttonClicked_Pre]
  81. if (buttonThatWasClicked == dismissButton)
  82. {
  83. //[UserButtonCode_dismissButton] -- add your button handler code here..
  84. LinJam::ConfigDismissed() ;
  85. //[/UserButtonCode_dismissButton]
  86. }
  87. //[UserbuttonClicked_Post]
  88. //[/UserbuttonClicked_Post]
  89. }
  90. //[MiscUserCode] You can add your own definitions of your custom methods or any other code here...
  91. void Config::valueChanged(Value& a_value)
  92. {
  93. bool is_enabled = bool(a_value.getValue()) ;
  94. Colour button_out_color = (is_enabled)? Colour(0xff004000) : Colour(0xff400000) ;
  95. Colour button_in_color = (is_enabled)? Colours::green : Colours::maroon ;
  96. Colour text_out_color = (is_enabled)? Colours::lime : Colours::red ;
  97. Colour text_in_color = (is_enabled)? Colours::lime : Colours::red ;
  98. String button_text = (is_enabled)? GUI::DISMISS_BTN_TEXT : GUI::DISMISS_BTN_ERROR_TEXT ;
  99. this->dismissButton->setColour(TextButton::buttonColourId , button_out_color) ;
  100. this->dismissButton->setColour(TextButton::buttonOnColourId , button_in_color) ;
  101. this->dismissButton->setColour(TextButton::textColourOnId , text_in_color) ;
  102. this->dismissButton->setColour(TextButton::textColourOffId , text_out_color) ;
  103. this->dismissButton->setEnabled(is_enabled) ;
  104. this->dismissButton->setButtonText(button_text) ;
  105. if (!is_enabled) this->configTabs->setCurrentTabIndex(0 , false) ;
  106. }
  107. //[/MiscUserCode]
  108. //==============================================================================
  109. #if 0
  110. /* -- Introjucer information section --
  111. This is where the Introjucer stores the metadata that describe this GUI layout, so
  112. make changes in here at your peril!
  113. BEGIN_JUCER_METADATA
  114. <JUCER_COMPONENT documentType="Component" className="Config" componentName=""
  115. parentClasses="public Component, public ValueListener" constructorParams="ValueTree audio_store, ValueTree client_store, ValueTree subscriptions_store"
  116. variableInitialisers="" snapPixels="8" snapActive="1" snapShown="1"
  117. overlayOpacity="0.330" fixedSize="0" initialWidth="622" initialHeight="442">
  118. <BACKGROUND backgroundColour="0">
  119. <ROUNDRECT pos="0 0 0M 0M" cornerSize="10" fill="solid: ff202020" hasStroke="1"
  120. stroke="1, mitered, butt" strokeColour="solid: ffffffff"/>
  121. </BACKGROUND>
  122. <TABBEDCOMPONENT name="configTabs" id="72016394fc1784e9" memberName="configTabs"
  123. virtualName="" explicitFocusOrder="1" pos="4 0 8M 4M" orientation="top"
  124. tabBarDepth="24" initialTab="0">
  125. <TAB name="audio" colour="ff002000" useJucerComp="0" contentClassName="ConfigAudio"
  126. constructorParams="audio_store" jucerComponentFile=""/>
  127. <TAB name="client" colour="ff202000" useJucerComp="0" contentClassName="ConfigClient"
  128. constructorParams="client_store" jucerComponentFile=""/>
  129. <TAB name="ignores" colour="ff200000" useJucerComp="0" contentClassName="ConfigSubscriptions"
  130. constructorParams="subscriptions_store" jucerComponentFile=""/>
  131. </TABBEDCOMPONENT>
  132. <TEXTBUTTON name="dismissButton" id="becd368b728d32c0" memberName="dismissButton"
  133. virtualName="" explicitFocusOrder="4" pos="64R 0 64 24" bgColOff="ff004000"
  134. bgColOn="ff008000" textCol="ff00ff00" textColOn="ff00ff00" buttonText="done"
  135. connectedEdges="0" needsCallback="1" radioGroupId="0"/>
  136. </JUCER_COMPONENT>
  137. END_JUCER_METADATA
  138. */
  139. #endif
  140. //[EndFile] You can add extra defines here...
  141. //[/EndFile]