ChatListItem.cpp 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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 "Constants.h"
  20. #include "ChatList.h"
  21. //[/Headers]
  22. #include "ChatListItem.h"
  23. //[MiscUserDefs] You can add your own user definitions and misc code here...
  24. //[/MiscUserDefs]
  25. //==============================================================================
  26. ChatListItem::ChatListItem (ValueTree chatter_store)
  27. : chatterStore(chatter_store)
  28. {
  29. addAndMakeVisible (banButton = new TextButton ("banButton"));
  30. banButton->setButtonText (TRANS("X"));
  31. banButton->addListener (this);
  32. banButton->setColour (TextButton::buttonColourId, Colour (0xff400000));
  33. banButton->setColour (TextButton::buttonOnColourId, Colours::maroon);
  34. banButton->setColour (TextButton::textColourOnId, Colours::red);
  35. banButton->setColour (TextButton::textColourOffId, Colours::red);
  36. addAndMakeVisible (nickLabel = new Label ("nickLabel",
  37. TRANS("(connecting)")));
  38. nickLabel->setFont (Font (15.00f, Font::plain));
  39. nickLabel->setJustificationType (Justification::centredLeft);
  40. nickLabel->setEditable (false, false, false);
  41. nickLabel->setColour (Label::textColourId, Colours::white);
  42. nickLabel->setColour (TextEditor::textColourId, Colours::black);
  43. nickLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
  44. //[UserPreSize]
  45. //[/UserPreSize]
  46. setSize (104, 24);
  47. //[Constructor] You can add your own custom stuff here..
  48. String nick = STRING(this->chatterStore[CONFIG::CHAT_NICK_ID]) ;
  49. String user_id = String(chatter_store.getType()) ;
  50. this->banButton->setVisible(false) ;
  51. this->nickLabel->setText(nick , juce::dontSendNotification) ;
  52. setName(user_id) ; setSize(GUI::CHATLIST_ITEM_W , GUI::CHATLIST_ITEM_H) ;
  53. //[/Constructor]
  54. }
  55. ChatListItem::~ChatListItem()
  56. {
  57. //[Destructor_pre]. You can add your own custom destruction code here..
  58. //[/Destructor_pre]
  59. banButton = nullptr;
  60. nickLabel = nullptr;
  61. //[Destructor]. You can add your own custom destruction code here..
  62. //[/Destructor]
  63. }
  64. //==============================================================================
  65. void ChatListItem::paint (Graphics& g)
  66. {
  67. //[UserPrePaint] Add your own custom painting code here..
  68. //[/UserPrePaint]
  69. g.setColour (Colour (0xff303030));
  70. g.fillRoundedRectangle (1.0f, 1.0f, 102.0f, 22.0f, 10.000f);
  71. g.setColour (Colours::white);
  72. g.drawRoundedRectangle (1.0f, 1.0f, 102.0f, 22.0f, 10.000f, 1.000f);
  73. //[UserPaint] Add your own custom painting code here..
  74. //[/UserPaint]
  75. }
  76. void ChatListItem::resized()
  77. {
  78. //[UserPreResize] Add your own custom resize code here..
  79. //[/UserPreResize]
  80. banButton->setBounds (4, 4, 15, 16);
  81. nickLabel->setBounds (24, 4, 72, 16);
  82. //[UserResized] Add your own custom resize handling here..
  83. //[/UserResized]
  84. }
  85. void ChatListItem::buttonClicked (Button* buttonThatWasClicked)
  86. {
  87. //[UserbuttonClicked_Pre]
  88. //[/UserbuttonClicked_Pre]
  89. if (buttonThatWasClicked == banButton)
  90. {
  91. //[UserButtonCode_banButton] -- add your button handler code here..
  92. //[/UserButtonCode_banButton]
  93. }
  94. //[UserbuttonClicked_Post]
  95. //[/UserbuttonClicked_Post]
  96. }
  97. //[MiscUserCode] You can add your own definitions of your custom methods or any other code here...
  98. //[/MiscUserCode]
  99. //==============================================================================
  100. #if 0
  101. /* -- Introjucer information section --
  102. This is where the Introjucer stores the metadata that describe this GUI layout, so
  103. make changes in here at your peril!
  104. BEGIN_JUCER_METADATA
  105. <JUCER_COMPONENT documentType="Component" className="ChatListItem" componentName=""
  106. parentClasses="public Component" constructorParams="ValueTree chatter_store"
  107. variableInitialisers="chatterStore(chatter_store)" snapPixels="4"
  108. snapActive="1" snapShown="1" overlayOpacity="0.330" fixedSize="1"
  109. initialWidth="104" initialHeight="24">
  110. <BACKGROUND backgroundColour="0">
  111. <ROUNDRECT pos="1 1 102 22" cornerSize="10" fill="solid: ff303030" hasStroke="1"
  112. stroke="1, mitered, butt" strokeColour="solid: ffffffff"/>
  113. </BACKGROUND>
  114. <TEXTBUTTON name="banButton" id="5ea28eb29c334aeb" memberName="banButton"
  115. virtualName="" explicitFocusOrder="0" pos="4 4 15 16" bgColOff="ff400000"
  116. bgColOn="ff800000" textCol="ffff0000" textColOn="ffff0000" buttonText="X"
  117. connectedEdges="0" needsCallback="1" radioGroupId="0"/>
  118. <LABEL name="nickLabel" id="4316b113334d5ced" memberName="nickLabel"
  119. virtualName="" explicitFocusOrder="0" pos="24 4 72 16" textCol="ffffffff"
  120. edTextCol="ff000000" edBkgCol="0" labelText="(connecting)" editableSingleClick="0"
  121. editableDoubleClick="0" focusDiscardsChanges="0" fontname="Default font"
  122. fontsize="15" bold="0" italic="0" justification="33"/>
  123. </JUCER_COMPONENT>
  124. END_JUCER_METADATA
  125. */
  126. #endif
  127. //[EndFile] You can add extra defines here...
  128. //[/EndFile]