aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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