From 8052fe6d6170ccbec9052b89e331ae786c69ee05 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 21 May 2018 11:05:43 +0200 Subject: Add channel selection --- src/ChannelSidePanel.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3