MainContent.cpp 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. #include "Constants.h"
  2. #include "LinJam.h"
  3. #include "MainContent.h"
  4. MainContent::MainContent(DocumentWindow* main_window , TextButton* config_button)
  5. {
  6. // background
  7. this->background = new Background() ;
  8. this->addChildAndSetID(this->background , GUI::BACKGROUND_GUI_ID) ;
  9. this->background->toFront(true) ;
  10. // login
  11. this->login = new Login() ;
  12. this->addChildAndSetID(this->login , GUI::LOGIN_GUI_ID) ;
  13. this->login->toBack() ;
  14. // license
  15. this->license = new License() ;
  16. this->addChildAndSetID(this->license , GUI::LICENSE_GUI_ID) ;
  17. this->license->toBack() ;
  18. // chat
  19. this->chat = new Chat() ;
  20. this->addChildAndSetID(this->chat , GUI::CHAT_GUI_ID) ;
  21. this->chat->toBack() ;
  22. // mixer
  23. this->mixer = new Mixer() ;
  24. this->addChildAndSetID(this->mixer , GUI::MIXER_GUI_ID) ;
  25. this->mixer->toBack() ;
  26. // statusbar
  27. this->statusbar = new StatusBar() ;
  28. this->addChildAndSetID(this->statusbar , GUI::STATUS_GUI_ID) ;
  29. this->statusbar->setAlwaysOnTop(true) ;
  30. this->statusbar->setStatusL(GUI::DISCONNECTED_STATUS_TEXT) ;
  31. // loop
  32. this->loop = new Loop() ;
  33. this->addChildAndSetID(this->loop , GUI::LOOP_GUI_ID) ;
  34. this->loop->setAlwaysOnTop(true) ;
  35. this->loop->toFront(false) ;
  36. // MainWindow
  37. this->mainWindow = main_window ;
  38. this->configButton = config_button ;
  39. this->configButton->setButtonText(TRANS("?")) ;
  40. this->configButton->setColour(TextButton::buttonColourId , Colour(0xff404000)) ;
  41. this->configButton->setColour(TextButton::buttonOnColourId , Colours::olive) ;
  42. this->configButton->setColour(TextButton::textColourOnId , Colours::yellow) ;
  43. this->configButton->setColour(TextButton::textColourOffId , Colours::yellow) ;
  44. this->configButton->addListener(this) ;
  45. // MainContent
  46. setName("MainContent") ;
  47. setSize(GUI::CONTENT_W , GUI::CONTENT_H) ;
  48. }
  49. MainContent::~MainContent()
  50. {
  51. this->background = nullptr ;
  52. this->login = nullptr ;
  53. this->license = nullptr ;
  54. this->chat = nullptr ;
  55. this->mixer = nullptr ;
  56. this->statusbar = nullptr ;
  57. this->loop = nullptr ;
  58. this->config = nullptr ;
  59. }
  60. void MainContent::paint(Graphics& g)
  61. {
  62. g.fillAll (Colour (0xff202020));
  63. g.setFont (Font (16.0f));
  64. g.setColour (Colours::black);
  65. }
  66. void MainContent::resized()
  67. {
  68. if (this->background == nullptr || this->login == nullptr ||
  69. this->license == nullptr || this->chat == nullptr ||
  70. this->mixer == nullptr || this->statusbar == nullptr ||
  71. this->loop == nullptr || this->config == nullptr ) return ;
  72. int window_w = getWidth() ;
  73. int window_h = getHeight() ;
  74. // content div
  75. int content_w = window_w - GUI::PAD2 ;
  76. int content_h = window_h - GUI::STATUSBAR_H - GUI::PAD3 ;
  77. // bg
  78. int bg_x = 0 ;
  79. int bg_y = 0 ;
  80. int bg_w = window_w ;
  81. int bg_h = window_h ;
  82. // login
  83. int login_x = GUI::PAD ;
  84. int login_y = GUI::PAD ;
  85. int login_w = content_w ;
  86. int login_h = content_h ;
  87. // license
  88. int license_x = GUI::PAD ;
  89. int license_y = GUI::PAD ;
  90. int license_w = content_w ;
  91. int license_h = content_h ;
  92. // mixer div
  93. int mixer_x = GUI::PAD ;
  94. int mixer_y = window_h - GUI::STATUSBAR_H - GUI::MIXER_H - GUI::PAD2 ;
  95. int mixer_w = content_w ;
  96. int mixer_h = GUI::MIXER_H ;
  97. // chat
  98. int chat_x = GUI::PAD ;
  99. int chat_y = GUI::PAD ;
  100. int chat_w = content_w ;
  101. int chat_h = content_h - GUI::MIXER_H - GUI::PAD ;
  102. // status div
  103. int status_x = GUI::PAD ;
  104. int status_y = window_h - GUI::STATUSBAR_H - GUI::PAD ;
  105. int status_w = content_w ;
  106. int status_h = GUI::STATUSBAR_H ;
  107. // loop
  108. int loop_x = GUI::LOOP_X ;
  109. int loop_y = status_y + GUI::PAD ;
  110. int loop_w = content_w - GUI::PAD4 - (GUI::STATUS_W * 2) ;
  111. int loop_h = GUI::LOOP_H ;
  112. // config
  113. int config_x = GUI::PAD ;
  114. int config_y = GUI::PAD ;
  115. int config_w = content_w ;
  116. int config_h = content_h ;
  117. // config button
  118. #ifdef _MAC
  119. int cfg_btn_x = getWidth() - GUI::CONFIG_BTN_X - GUI::CONFIG_BTN_W ;
  120. #else // _MAC
  121. int cfg_btn_x = GUI::CONFIG_BTN_X ;
  122. #endif // _MAC
  123. int cfg_btn_y = GUI::CONFIG_BTN_Y ;
  124. int cfg_btn_w = GUI::CONFIG_BTN_W ;
  125. int cfg_btn_h = GUI::CONFIG_BTN_H ;
  126. this->background ->setBounds(bg_x , bg_y , bg_w , bg_h) ;
  127. this->login ->setBounds(login_x , login_y , login_w , login_h) ;
  128. this->license ->setBounds(license_x , license_y , license_w , license_h) ;
  129. this->chat ->setBounds(chat_x , chat_y , chat_w , chat_h) ;
  130. this->mixer ->setBounds(mixer_x , mixer_y , mixer_w , mixer_h) ;
  131. this->statusbar ->setBounds(status_x , status_y , status_w , status_h) ;
  132. this->loop ->setBounds(loop_x , loop_y , loop_w , loop_h) ;
  133. this->config ->setBounds(config_x , config_y , config_w , config_h) ;
  134. this->configButton->setBounds(cfg_btn_x , cfg_btn_y , cfg_btn_w , cfg_btn_h) ;
  135. }
  136. void MainContent::buttonClicked(Button* a_button)
  137. {
  138. if (a_button == this->configButton) LinJam::ConfigPending() ;
  139. }
  140. void MainContent::instantiateConfig(ValueTree audio_store ,
  141. ValueTree client_store ,
  142. ValueTree subscriptions_store)
  143. {
  144. this->config = new Config(audio_store , client_store , subscriptions_store) ;
  145. this->addChildAndSetID(this->config , GUI::CONFIG_GUI_ID) ;
  146. this->config->toBack() ;
  147. resized() ;
  148. }
  149. void MainContent::setTitle(String title_text)
  150. {
  151. this->mainWindow->setName(GUI::APP_NAME + " - " + title_text) ;
  152. }