MainContent.cpp 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. /*\
  2. |*| Copyright 2015 bill-auger <https://github.com/bill-auger/av-caster/issues>
  3. |*|
  4. |*| This file is part of the AvCaster program.
  5. |*|
  6. |*| AvCaster is free software: you can redistribute it and/or modify
  7. |*| it under the terms of the GNU Lesser General Public License version 3
  8. |*| as published by the Free Software Foundation.
  9. |*|
  10. |*| AvCaster is distributed in the hope that it will be useful,
  11. |*| but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. |*| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. |*| GNU Lesser General Public License for more details.
  14. |*|
  15. |*| You should have received a copy of the GNU Lesser General Public License
  16. |*| along with AvCaster. If not, see <http://www.gnu.org/licenses/>.
  17. \*/
  18. //[Headers] You can add your own extra header files here...
  19. #include "AvCaster.h"
  20. #include "Trace/Trace.h"
  21. //[/Headers]
  22. #include "MainContent.h"
  23. //[MiscUserDefs] You can add your own user definitions and misc code here...
  24. //[/MiscUserDefs]
  25. //==============================================================================
  26. MainContent::MainContent ()
  27. {
  28. addAndMakeVisible (background = new Background());
  29. background->setName ("background");
  30. addAndMakeVisible (controls = new Controls());
  31. controls->setName ("controls");
  32. addAndMakeVisible (chat = new Chat());
  33. chat->setName ("chat");
  34. addAndMakeVisible (preview = new Preview());
  35. preview->setName ("preview");
  36. addAndMakeVisible (presets = new Presets());
  37. presets->setName ("presets");
  38. addAndMakeVisible (config = new Config());
  39. config->setName ("config");
  40. addAndMakeVisible (statusbar = new Statusbar());
  41. statusbar->setName ("statusbar");
  42. //[UserPreSize]
  43. //[/UserPreSize]
  44. setSize (758, 694);
  45. //[Constructor] You can add your own custom stuff here..
  46. this->statusbar->setAlwaysOnTop(true) ;
  47. this->statusbar->setStatusL(GUI::INIT_STATUS_TEXT) ;
  48. //[/Constructor]
  49. }
  50. MainContent::~MainContent()
  51. {
  52. //[Destructor_pre]. You can add your own custom destruction code here..
  53. //[/Destructor_pre]
  54. background = nullptr;
  55. controls = nullptr;
  56. chat = nullptr;
  57. preview = nullptr;
  58. presets = nullptr;
  59. config = nullptr;
  60. statusbar = nullptr;
  61. //[Destructor]. You can add your own custom destruction code here..
  62. //[/Destructor]
  63. }
  64. //==============================================================================
  65. void MainContent::paint (Graphics& g)
  66. {
  67. //[UserPrePaint] Add your own custom painting code here..
  68. //[/UserPrePaint]
  69. g.fillAll (Colour (0xff101010));
  70. //[UserPaint] Add your own custom painting code here..
  71. //[/UserPaint]
  72. }
  73. void MainContent::resized()
  74. {
  75. //[UserPreResize] Add your own custom resize code here..
  76. //[/UserPreResize]
  77. background->setBounds (0, 0, getWidth() - 0, getHeight() - 0);
  78. controls->setBounds (0, 0, getWidth() - 0, 76);
  79. chat->setBounds (0, 76, getWidth() - 0, getHeight() - 100);
  80. preview->setBounds (0, 76, getWidth() - 0, getHeight() - 100);
  81. presets->setBounds (0, 0, getWidth() - 0, 76);
  82. config->setBounds (0, 76, getWidth() - 0, getHeight() - 100);
  83. statusbar->setBounds (0, getHeight() - 24, getWidth() - 0, 24);
  84. //[UserResized] Add your own custom resize handling here..
  85. //[/UserResized]
  86. }
  87. //[MiscUserCode] You can add your own definitions of your custom methods or any other code here...
  88. void MainContent::configureCombobox(ComboBox* a_combobox)
  89. {
  90. a_combobox->setColour(ComboBox::textColourId , GUI::TEXT_NORMAL_COLOR) ;
  91. a_combobox->setColour(ComboBox::backgroundColourId , GUI::TEXT_BG_COLOR ) ;
  92. a_combobox->setColour(TextEditor::highlightColourId , GUI::TEXT_HILITEBG_COLOR) ;
  93. a_combobox->setColour(TextEditor::highlightedTextColourId , GUI::TEXT_HILITE_COLOR ) ;
  94. a_combobox->setColour(CaretComponent::caretColourId , GUI::TEXT_CARET_COLOR ) ;
  95. }
  96. void MainContent::loadPresetsCombo(ComboBox* a_combobox)
  97. {
  98. ValueTree config_store = AvCaster::GetConfigStore() ;
  99. StringArray preset_names = AvCaster::GetPresetsNames() ;
  100. int preset_idx = AvCaster::GetPresetIdx() ;
  101. a_combobox->clear (juce::dontSendNotification) ;
  102. a_combobox->addItemList (preset_names , 1) ;
  103. a_combobox->setSelectedItemIndex(preset_idx , juce::dontSendNotification) ;
  104. }
  105. void MainContent::initialize(ValueTree servers_store)
  106. {
  107. this->chat->initialize(servers_store) ;
  108. }
  109. void MainContent::warning(String message_text)
  110. {
  111. if (JUCEApplicationBase::getInstance()->isInitialising()) return ;
  112. AlertWindow::showMessageBoxAsync(AlertWindow::InfoIcon , GUI::MODAL_WARNING_TITLE ,
  113. message_text , String::empty ,
  114. nullptr , AvCaster::GetModalCb() ) ;
  115. }
  116. void MainContent::error(String message_text)
  117. {
  118. if (JUCEApplicationBase::getInstance()->isInitialising()) return ;
  119. AlertWindow::showMessageBoxAsync(AlertWindow::WarningIcon , GUI::MODAL_ERROR_TITLE ,
  120. message_text , String::empty ,
  121. nullptr , AvCaster::GetModalCb() ) ;
  122. }
  123. Rectangle<int> MainContent::getPreviewBounds()
  124. {
  125. Rectangle<int> preview_bounds = this->preview->getBounds() ;
  126. Rectangle<int> group_bounds = this->preview->getChildComponent(0)->getBounds() ;
  127. preview_bounds.setX (group_bounds .getX() + GUI::PAD4) ;
  128. preview_bounds.setY (preview_bounds.getY() + GUI::PAD4 + GUI::PAD8) ;
  129. preview_bounds.setWidth (group_bounds .getWidth() - GUI::PAD8) ;
  130. preview_bounds.setHeight(group_bounds .getHeight() - GUI::PAD8) ;
  131. return preview_bounds ;
  132. }
  133. //[/MiscUserCode]
  134. //==============================================================================
  135. #if 0
  136. /* -- Introjucer information section --
  137. This is where the Introjucer stores the metadata that describe this GUI layout, so
  138. make changes in here at your peril!
  139. BEGIN_JUCER_METADATA
  140. <JUCER_COMPONENT documentType="Component" className="MainContent" componentName=""
  141. parentClasses="public Component" constructorParams="" variableInitialisers=""
  142. snapPixels="8" snapActive="1" snapShown="1" overlayOpacity="0.330"
  143. fixedSize="0" initialWidth="758" initialHeight="694">
  144. <BACKGROUND backgroundColour="ff101010"/>
  145. <GENERICCOMPONENT name="background" id="4d43eef09b00fdf4" memberName="background"
  146. virtualName="" explicitFocusOrder="0" pos="0 0 0M 0M" class="Background"
  147. params=""/>
  148. <GENERICCOMPONENT name="controls" id="7a0ffc87dbd1f2a3" memberName="controls" virtualName=""
  149. explicitFocusOrder="0" pos="0 0 0M 76" class="Controls" params=""/>
  150. <GENERICCOMPONENT name="chat" id="ac9a4042c98734e2" memberName="chat" virtualName=""
  151. explicitFocusOrder="0" pos="0 76 0M 100M" class="Chat" params=""/>
  152. <GENERICCOMPONENT name="preview" id="75e8b11c95e2efaf" memberName="preview" virtualName=""
  153. explicitFocusOrder="0" pos="0 76 0M 100M" class="Preview" params=""/>
  154. <GENERICCOMPONENT name="presets" id="c3256eaa517d34eb" memberName="presets" virtualName=""
  155. explicitFocusOrder="0" pos="0 0 0M 76" class="Presets" params=""/>
  156. <GENERICCOMPONENT name="config" id="4f3cab5613666ef6" memberName="config" virtualName=""
  157. explicitFocusOrder="0" pos="0 76 0M 100M" class="Config" params=""/>
  158. <GENERICCOMPONENT name="statusbar" id="2dc0514b582b96cb" memberName="statusbar"
  159. virtualName="" explicitFocusOrder="0" pos="0 0Rr 0M 24" class="Statusbar"
  160. params=""/>
  161. </JUCER_COMPONENT>
  162. END_JUCER_METADATA
  163. */
  164. #endif
  165. //[EndFile] You can add extra defines here...
  166. //[/EndFile]