ConfigBlacklist.cpp 8.6 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 "Blacklist.h"
  16. //[/Headers]
  17. #include "ConfigBlacklist.h"
  18. //[MiscUserDefs] You can add your own user definitions and misc code here...
  19. //[/MiscUserDefs]
  20. //==============================================================================
  21. ConfigBlacklist::ConfigBlacklist (ValueTree blacklist_store)
  22. : blacklistStore(blacklist_store)
  23. {
  24. //[Constructor_pre] You can add your own custom stuff here..
  25. //[/Constructor_pre]
  26. addAndMakeVisible (subscribeButton = new ToggleButton ("subscribeButton"));
  27. subscribeButton->setExplicitFocusOrder (1);
  28. subscribeButton->setButtonText (TRANS("auto-receive"));
  29. subscribeButton->addListener (this);
  30. subscribeButton->setToggleState (true, dontSendNotification);
  31. subscribeButton->setColour (ToggleButton::textColourId, Colours::white);
  32. addAndMakeVisible (ignoreButton = new ToggleButton ("ignoreButton"));
  33. ignoreButton->setExplicitFocusOrder (2);
  34. ignoreButton->setButtonText (TRANS("auto-ignore"));
  35. ignoreButton->addListener (this);
  36. ignoreButton->setToggleState (true, dontSendNotification);
  37. ignoreButton->setColour (ToggleButton::textColourId, Colours::white);
  38. addAndMakeVisible (bansLabel = new Label ("bansLabel",
  39. TRANS("ignored users")));
  40. bansLabel->setFont (Font (15.00f, Font::plain));
  41. bansLabel->setJustificationType (Justification::centredTop);
  42. bansLabel->setEditable (false, false, false);
  43. bansLabel->setColour (Label::textColourId, Colours::white);
  44. bansLabel->setColour (TextEditor::textColourId, Colours::black);
  45. bansLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
  46. addAndMakeVisible (blacklistViewport = new Viewport ("blacklistViewport"));
  47. blacklistViewport->setExplicitFocusOrder (3);
  48. blacklistViewport->setScrollBarsShown (true, false);
  49. blacklistViewport->setScrollBarThickness (12);
  50. blacklistViewport->setViewedComponent (new Blacklist (blacklist_store));
  51. //[UserPreSize]
  52. //[/UserPreSize]
  53. setSize (614, 434);
  54. //[Constructor] You can add your own custom stuff here..
  55. int auto_subscribe_mode = int(this->blacklistStore[CONFIG::SUBSCRIBE_MODE_KEY]) ;
  56. bool should_sub = auto_subscribe_mode != (int)NJClient::SUBSCRIBE_ALLOW ;
  57. bool should_ban = auto_subscribe_mode == (int)NJClient::SUBSCRIBE_DENY ;
  58. this->subscribeButton ->setToggleState(should_sub , dontSendNotification) ;
  59. this->ignoreButton ->setToggleState(should_ban , dontSendNotification) ;
  60. this->blacklistViewport->setScrollBarThickness(GUI::CONFIG_SCROLLBAR_W) ;
  61. this->blacklistViewport->setBounds(GUI::BLACKLIST_X , GUI::BLACKLIST_Y ,
  62. GUI::BLACKLIST_W , GUI::BLACKLIST_H ) ;
  63. //[/Constructor]
  64. }
  65. ConfigBlacklist::~ConfigBlacklist()
  66. {
  67. //[Destructor_pre]. You can add your own custom destruction code here..
  68. //[/Destructor_pre]
  69. subscribeButton = nullptr;
  70. ignoreButton = nullptr;
  71. bansLabel = nullptr;
  72. blacklistViewport = nullptr;
  73. //[Destructor]. You can add your own custom destruction code here..
  74. //[/Destructor]
  75. }
  76. //==============================================================================
  77. void ConfigBlacklist::paint (Graphics& g)
  78. {
  79. //[UserPrePaint] Add your own custom painting code here..
  80. //[/UserPrePaint]
  81. g.setColour (Colour (0xff200000));
  82. g.fillRoundedRectangle (0.0f, 0.0f, 192.0f, 172.0f, 10.000f);
  83. g.setColour (Colour (0xff101010));
  84. g.fillRoundedRectangle (20.0f, 64.0f, 152.0f, 84.0f, 10.000f);
  85. g.setColour (Colours::white);
  86. g.drawRoundedRectangle (20.0f, 64.0f, 152.0f, 84.0f, 10.000f, 1.000f);
  87. //[UserPaint] Add your own custom painting code here..
  88. //[/UserPaint]
  89. }
  90. void ConfigBlacklist::resized()
  91. {
  92. //[UserPreResize] Add your own custom resize code here..
  93. //[/UserPreResize]
  94. subscribeButton->setBounds (20, 20, 74, 16);
  95. ignoreButton->setBounds (98, 20, 74, 16);
  96. bansLabel->setBounds (20, 44, 152, 16);
  97. blacklistViewport->setBounds (24, 68, 144, 76);
  98. //[UserResized] Add your own custom resize handling here..
  99. //[/UserResized]
  100. }
  101. void ConfigBlacklist::buttonClicked (Button* buttonThatWasClicked)
  102. {
  103. //[UserbuttonClicked_Pre]
  104. //[/UserbuttonClicked_Pre]
  105. if (buttonThatWasClicked == subscribeButton)
  106. {
  107. //[UserButtonCode_subscribeButton] -- add your button handler code here..
  108. //[/UserButtonCode_subscribeButton]
  109. }
  110. else if (buttonThatWasClicked == ignoreButton)
  111. {
  112. //[UserButtonCode_ignoreButton] -- add your button handler code here..
  113. //[/UserButtonCode_ignoreButton]
  114. }
  115. //[UserbuttonClicked_Post]
  116. bool should_subscribe = this->subscribeButton->getToggleState() ;
  117. bool should_ignore = this->ignoreButton ->getToggleState() ;
  118. int subscribe_mode = (should_ignore) ? NJClient::SUBSCRIBE_DENY :
  119. (should_subscribe) ? NJClient::SUBSCRIBE_ALL :
  120. NJClient::SUBSCRIBE_NONE ;
  121. setConfig(CONFIG::SUBSCRIBE_MODE_KEY , var(subscribe_mode)) ;
  122. //[/UserbuttonClicked_Post]
  123. }
  124. //[MiscUserCode] You can add your own definitions of your custom methods or any other code here...
  125. void ConfigBlacklist::setConfig(Identifier a_key , var a_value)
  126. {
  127. this->blacklistStore.setProperty(a_key , a_value , nullptr) ;
  128. }
  129. //[/MiscUserCode]
  130. //==============================================================================
  131. #if 0
  132. /* -- Introjucer information section --
  133. This is where the Introjucer stores the metadata that describe this GUI layout, so
  134. make changes in here at your peril!
  135. BEGIN_JUCER_METADATA
  136. <JUCER_COMPONENT documentType="Component" className="ConfigBlacklist" componentName=""
  137. parentClasses="public Component" constructorParams="ValueTree blacklist_store"
  138. variableInitialisers="blacklistStore(blacklist_store)" snapPixels="8"
  139. snapActive="1" snapShown="1" overlayOpacity="0.330" fixedSize="1"
  140. initialWidth="614" initialHeight="434">
  141. <BACKGROUND backgroundColour="0">
  142. <ROUNDRECT pos="0 0 192 172" cornerSize="10" fill="solid: ff200000" hasStroke="0"/>
  143. <ROUNDRECT pos="20 64 152 84" cornerSize="10" fill="solid: ff101010" hasStroke="1"
  144. stroke="1, mitered, butt" strokeColour="solid: ffffffff"/>
  145. </BACKGROUND>
  146. <TOGGLEBUTTON name="subscribeButton" id="a9eb5bfc0df5b172" memberName="subscribeButton"
  147. virtualName="" explicitFocusOrder="1" pos="20 20 74 16" txtcol="ffffffff"
  148. buttonText="auto-receive" connectedEdges="0" needsCallback="1"
  149. radioGroupId="0" state="1"/>
  150. <TOGGLEBUTTON name="ignoreButton" id="fdc09180d037febb" memberName="ignoreButton"
  151. virtualName="" explicitFocusOrder="2" pos="98 20 74 16" txtcol="ffffffff"
  152. buttonText="auto-ignore" connectedEdges="0" needsCallback="1"
  153. radioGroupId="0" state="1"/>
  154. <LABEL name="bansLabel" id="a67b459c94aba72e" memberName="bansLabel"
  155. virtualName="" explicitFocusOrder="0" pos="20 44 152 16" textCol="ffffffff"
  156. edTextCol="ff000000" edBkgCol="0" labelText="ignored users" editableSingleClick="0"
  157. editableDoubleClick="0" focusDiscardsChanges="0" fontname="Default font"
  158. fontsize="15" bold="0" italic="0" justification="12"/>
  159. <VIEWPORT name="blacklistViewport" id="1da1a4f83d3dffa2" memberName="blacklistViewport"
  160. virtualName="" explicitFocusOrder="3" pos="24 68 144 76" vscroll="1"
  161. hscroll="0" scrollbarThickness="12" contentType="2" jucerFile=""
  162. contentClass="Blacklist" constructorParams="blacklist_store"/>
  163. </JUCER_COMPONENT>
  164. END_JUCER_METADATA
  165. */
  166. #endif
  167. //[EndFile] You can add extra defines here...
  168. //[/EndFile]