aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2018-05-21 11:05:43 +0200
committerdec05eba <dec05eba@protonmail.com>2018-05-21 11:05:45 +0200
commit8052fe6d6170ccbec9052b89e331ae786c69ee05 (patch)
treebd8c500726264e094eaf440187b62b5c902b4626
parent1d7a7c84707e4ad349c3795acd723616aa3046e1 (diff)
Add channel selection
-rw-r--r--src/ChannelSidePanel.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/ChannelSidePanel.cpp b/src/ChannelSidePanel.cpp
index 58cb9bc..3e01e94 100644
--- a/src/ChannelSidePanel.cpp
+++ b/src/ChannelSidePanel.cpp
@@ -43,15 +43,30 @@ namespace dchat
const float fontHeight = font->getLineSpacing(fontSize);
const float channelBoxHeight = floor(fontHeight * CHANNEL_NAME_BOX_HEIGHT_RATIO);
+ auto mousePos = sf::Mouse::getPosition(window);
+
sf::Vector2f position(10.0f, posY);
for(Channel *channel : channels)
{
+ sf::FloatRect box(0.0f, position.y, getWidth(), channelBoxHeight);
if(channel == Channel::getCurrent())
{
rect.setFillColor(ColorScheme::getBackgroundColor() + sf::Color(15, 15, 15));
- rect.setSize(sf::Vector2f(getWidth(), channelBoxHeight));
+ rect.setSize(sf::Vector2f(box.width, box.height));
+ rect.setPosition(sf::Vector2f(0.0f, position.y));
+ window.draw(rect);
+ }
+ else if(box.contains(mousePos.x, mousePos.y))
+ {
+ rect.setFillColor(ColorScheme::getBackgroundColor() + sf::Color(5, 5, 5));
+ rect.setSize(sf::Vector2f(box.width, box.height));
rect.setPosition(sf::Vector2f(0.0f, position.y));
window.draw(rect);
+
+ if(sf::Mouse::isButtonPressed(sf::Mouse::Button::Left))
+ {
+ Channel::setCurrent(channel);
+ }
}
// TODO: Remove this shit