Fix color palette

This commit is contained in:
NaiJi ✨ 2021-08-26 21:36:09 +03:00
parent 76422b1e1f
commit 4093963706
6 changed files with 29 additions and 5 deletions

View File

@ -7,8 +7,6 @@ Button::Button(const std::string &text, const std::shared_ptr<sf::Font>& font, u
_button_text.setFillColor(sf::Color::Black);
_button_text.setCharacterSize(font_size);
_button_text.setFont(*_font);
_button_content.setFillColor(sf::Color::White);
}
void Button::update()

View File

@ -3,7 +3,11 @@
CascadeMenuButton::CascadeMenuButton(const std::string& text, const std::shared_ptr<sf::Font> &font, unsigned int font_size) :
Button(text, font, font_size)
{}
{
_color_idle = sf::Color(230, 230, 230);
_color_hover = sf::Color(84, 158, 253);
_button_content.setFillColor(_color_idle);
}
void CascadeMenuButton::input(const sf::Event& event)
{
@ -18,14 +22,17 @@ void CascadeMenuButton::input(const sf::Event& event)
case sf::Event::MouseMoved:
if (isUnderMouse(event.mouseMove.x, event.mouseMove.y))
{
_button_content.setFillColor(sf::Color(84, 158, 253));
_button_content.setFillColor(_color_hover);
_submenu->lock();
_submenu->setVisibility(true);
}
else
{
_button_content.setFillColor(sf::Color::White);
_submenu->unlock();
if (!_submenu->isVisible())
{
_button_content.setFillColor(sf::Color(_color_idle));
}
}
break;
}
@ -56,3 +63,9 @@ void CascadeMenuButton::resetRect(const std::shared_ptr<MenuDrop>& submenu)
_button_content.getPosition().y});
}
}
void CascadeMenuButton::setFillColors(sf::Color&& idle_color, sf::Color&& hover_color)
{
_color_idle = idle_color;
_color_hover = hover_color;
}

View File

@ -14,8 +14,12 @@ public:
void setSubmenu(const std::shared_ptr<MenuDrop>& submenu);
const std::shared_ptr<MenuDrop> submenu() const;
void resetRect(const std::shared_ptr<MenuDrop>& submenu);
void setFillColors(sf::Color&& idle_color, sf::Color&& hover_color);
private:
std::shared_ptr<MenuDrop> _submenu;
sf::Color _color_idle;
sf::Color _color_hover;
};

View File

@ -6,6 +6,7 @@ PushButton::PushButton(const std::string& text, const std::shared_ptr<sf::Font>
{
_color_idle = sf::Color(230, 230, 230);
_color_pressed = sf::Color(200, 200, 200);
_button_content.setFillColor(_color_idle);
}
void PushButton::input(const sf::Event& event)

View File

@ -30,6 +30,11 @@ void Widget::setVisibility(bool is_visible)
child->setVisibility(_is_visible);
}
bool Widget::isVisible() const
{
return _is_visible;
}
void Widget::addChild(const std::shared_ptr<Widget>& child)
{
child->setParent(shared_from_this());

View File

@ -19,8 +19,11 @@ public:
virtual bool isUnderMouse(int mouse_x, int mouse_y) const = 0;
virtual void setVisibility(bool is_visible = true);
bool isVisible() const;
void addChild(const std::shared_ptr<Widget>& child);
void setParent(const std::shared_ptr<Widget>& parent);
void blockBy(const std::shared_ptr<Widget>& blocker);
void unblock();