123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- /*\
- |*| Copyright 2015 bill-auger <https://github.com/bill-auger/av-caster/issues>
- |*|
- |*| This file is part of the AvCaster program.
- |*|
- |*| AvCaster is free software: you can redistribute it and/or modify
- |*| it under the terms of the GNU Lesser General Public License version 3
- |*| as published by the Free Software Foundation.
- |*|
- |*| AvCaster is distributed in the hope that it will be useful,
- |*| but WITHOUT ANY WARRANTY; without even the implied warranty of
- |*| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- |*| GNU Lesser General Public License for more details.
- |*|
- |*| You should have received a copy of the GNU Lesser General Public License
- |*| along with AvCaster. If not, see <http://www.gnu.org/licenses/>.
- \*/
- //[Headers] You can add your own extra header files here...
- #include "Constants.h"
- #include "ChatList.h"
- //[/Headers]
- #include "ChatListItem.h"
- //[MiscUserDefs] You can add your own user definitions and misc code here...
- //[/MiscUserDefs]
- //==============================================================================
- ChatListItem::ChatListItem (ValueTree chatter_store)
- : chatterStore(chatter_store)
- {
- addAndMakeVisible (banButton = new TextButton ("banButton"));
- banButton->setButtonText (TRANS("X"));
- banButton->addListener (this);
- banButton->setColour (TextButton::buttonColourId, Colour (0xff400000));
- banButton->setColour (TextButton::buttonOnColourId, Colours::maroon);
- banButton->setColour (TextButton::textColourOnId, Colours::red);
- banButton->setColour (TextButton::textColourOffId, Colours::red);
- addAndMakeVisible (nickLabel = new Label ("nickLabel",
- TRANS("(connecting)")));
- nickLabel->setFont (Font (15.00f, Font::plain));
- nickLabel->setJustificationType (Justification::centredLeft);
- nickLabel->setEditable (false, false, false);
- nickLabel->setColour (Label::textColourId, Colours::white);
- nickLabel->setColour (TextEditor::textColourId, Colours::black);
- nickLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000));
- //[UserPreSize]
- //[/UserPreSize]
- setSize (104, 24);
- //[Constructor] You can add your own custom stuff here..
- String nick = STRING(this->chatterStore[CONFIG::CHAT_NICK_ID]) ;
- String user_id = String(chatter_store.getType()) ;
- this->banButton->setVisible(false) ;
- this->nickLabel->setText(nick , juce::dontSendNotification) ;
- setName(user_id) ; setSize(GUI::CHATLIST_ITEM_W , GUI::CHATLIST_ITEM_H) ;
- //[/Constructor]
- }
- ChatListItem::~ChatListItem()
- {
- //[Destructor_pre]. You can add your own custom destruction code here..
- //[/Destructor_pre]
- banButton = nullptr;
- nickLabel = nullptr;
- //[Destructor]. You can add your own custom destruction code here..
- //[/Destructor]
- }
- //==============================================================================
- void ChatListItem::paint (Graphics& g)
- {
- //[UserPrePaint] Add your own custom painting code here..
- //[/UserPrePaint]
- g.setColour (Colour (0xff303030));
- g.fillRoundedRectangle (1.0f, 1.0f, 102.0f, 22.0f, 10.000f);
- g.setColour (Colours::white);
- g.drawRoundedRectangle (1.0f, 1.0f, 102.0f, 22.0f, 10.000f, 1.000f);
- //[UserPaint] Add your own custom painting code here..
- //[/UserPaint]
- }
- void ChatListItem::resized()
- {
- //[UserPreResize] Add your own custom resize code here..
- //[/UserPreResize]
- banButton->setBounds (4, 4, 15, 16);
- nickLabel->setBounds (24, 4, 72, 16);
- //[UserResized] Add your own custom resize handling here..
- //[/UserResized]
- }
- void ChatListItem::buttonClicked (Button* buttonThatWasClicked)
- {
- //[UserbuttonClicked_Pre]
- //[/UserbuttonClicked_Pre]
- if (buttonThatWasClicked == banButton)
- {
- //[UserButtonCode_banButton] -- add your button handler code here..
- //[/UserButtonCode_banButton]
- }
- //[UserbuttonClicked_Post]
- //[/UserbuttonClicked_Post]
- }
- //[MiscUserCode] You can add your own definitions of your custom methods or any other code here...
- //[/MiscUserCode]
- //==============================================================================
- #if 0
- /* -- Introjucer information section --
- This is where the Introjucer stores the metadata that describe this GUI layout, so
- make changes in here at your peril!
- BEGIN_JUCER_METADATA
- <JUCER_COMPONENT documentType="Component" className="ChatListItem" componentName=""
- parentClasses="public Component" constructorParams="ValueTree chatter_store"
- variableInitialisers="chatterStore(chatter_store)" snapPixels="4"
- snapActive="1" snapShown="1" overlayOpacity="0.330" fixedSize="1"
- initialWidth="104" initialHeight="24">
- <BACKGROUND backgroundColour="0">
- <ROUNDRECT pos="1 1 102 22" cornerSize="10" fill="solid: ff303030" hasStroke="1"
- stroke="1, mitered, butt" strokeColour="solid: ffffffff"/>
- </BACKGROUND>
- <TEXTBUTTON name="banButton" id="5ea28eb29c334aeb" memberName="banButton"
- virtualName="" explicitFocusOrder="0" pos="4 4 15 16" bgColOff="ff400000"
- bgColOn="ff800000" textCol="ffff0000" textColOn="ffff0000" buttonText="X"
- connectedEdges="0" needsCallback="1" radioGroupId="0"/>
- <LABEL name="nickLabel" id="4316b113334d5ced" memberName="nickLabel"
- virtualName="" explicitFocusOrder="0" pos="24 4 72 16" textCol="ffffffff"
- edTextCol="ff000000" edBkgCol="0" labelText="(connecting)" editableSingleClick="0"
- editableDoubleClick="0" focusDiscardsChanges="0" fontname="Default font"
- fontsize="15" bold="0" italic="0" justification="33"/>
- </JUCER_COMPONENT>
- END_JUCER_METADATA
- */
- #endif
- //[EndFile] You can add extra defines here...
- //[/EndFile]
|