forked from NaiJi/project-kyoku
Fix color palette
This commit is contained in:
parent
76422b1e1f
commit
4093963706
|
@ -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.setFillColor(sf::Color::Black);
|
||||||
_button_text.setCharacterSize(font_size);
|
_button_text.setCharacterSize(font_size);
|
||||||
_button_text.setFont(*_font);
|
_button_text.setFont(*_font);
|
||||||
_button_content.setFillColor(sf::Color::White);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Button::update()
|
void Button::update()
|
||||||
|
|
|
@ -3,7 +3,11 @@
|
||||||
|
|
||||||
CascadeMenuButton::CascadeMenuButton(const std::string& text, const std::shared_ptr<sf::Font> &font, unsigned int font_size) :
|
CascadeMenuButton::CascadeMenuButton(const std::string& text, const std::shared_ptr<sf::Font> &font, unsigned int font_size) :
|
||||||
Button(text, font, 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)
|
void CascadeMenuButton::input(const sf::Event& event)
|
||||||
{
|
{
|
||||||
|
@ -18,14 +22,17 @@ void CascadeMenuButton::input(const sf::Event& event)
|
||||||
case sf::Event::MouseMoved:
|
case sf::Event::MouseMoved:
|
||||||
if (isUnderMouse(event.mouseMove.x, event.mouseMove.y))
|
if (isUnderMouse(event.mouseMove.x, event.mouseMove.y))
|
||||||
{
|
{
|
||||||
_button_content.setFillColor(sf::Color(84, 158, 253));
|
_button_content.setFillColor(_color_hover);
|
||||||
_submenu->lock();
|
_submenu->lock();
|
||||||
_submenu->setVisibility(true);
|
_submenu->setVisibility(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_button_content.setFillColor(sf::Color::White);
|
|
||||||
_submenu->unlock();
|
_submenu->unlock();
|
||||||
|
if (!_submenu->isVisible())
|
||||||
|
{
|
||||||
|
_button_content.setFillColor(sf::Color(_color_idle));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -56,3 +63,9 @@ void CascadeMenuButton::resetRect(const std::shared_ptr<MenuDrop>& submenu)
|
||||||
_button_content.getPosition().y});
|
_button_content.getPosition().y});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CascadeMenuButton::setFillColors(sf::Color&& idle_color, sf::Color&& hover_color)
|
||||||
|
{
|
||||||
|
_color_idle = idle_color;
|
||||||
|
_color_hover = hover_color;
|
||||||
|
}
|
||||||
|
|
|
@ -14,8 +14,12 @@ public:
|
||||||
void setSubmenu(const std::shared_ptr<MenuDrop>& submenu);
|
void setSubmenu(const std::shared_ptr<MenuDrop>& submenu);
|
||||||
const std::shared_ptr<MenuDrop> submenu() const;
|
const std::shared_ptr<MenuDrop> submenu() const;
|
||||||
void resetRect(const std::shared_ptr<MenuDrop>& submenu);
|
void resetRect(const std::shared_ptr<MenuDrop>& submenu);
|
||||||
|
void setFillColors(sf::Color&& idle_color, sf::Color&& hover_color);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<MenuDrop> _submenu;
|
std::shared_ptr<MenuDrop> _submenu;
|
||||||
|
|
||||||
|
sf::Color _color_idle;
|
||||||
|
sf::Color _color_hover;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ PushButton::PushButton(const std::string& text, const std::shared_ptr<sf::Font>
|
||||||
{
|
{
|
||||||
_color_idle = sf::Color(230, 230, 230);
|
_color_idle = sf::Color(230, 230, 230);
|
||||||
_color_pressed = sf::Color(200, 200, 200);
|
_color_pressed = sf::Color(200, 200, 200);
|
||||||
|
_button_content.setFillColor(_color_idle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PushButton::input(const sf::Event& event)
|
void PushButton::input(const sf::Event& event)
|
||||||
|
|
|
@ -30,6 +30,11 @@ void Widget::setVisibility(bool is_visible)
|
||||||
child->setVisibility(_is_visible);
|
child->setVisibility(_is_visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Widget::isVisible() const
|
||||||
|
{
|
||||||
|
return _is_visible;
|
||||||
|
}
|
||||||
|
|
||||||
void Widget::addChild(const std::shared_ptr<Widget>& child)
|
void Widget::addChild(const std::shared_ptr<Widget>& child)
|
||||||
{
|
{
|
||||||
child->setParent(shared_from_this());
|
child->setParent(shared_from_this());
|
||||||
|
|
|
@ -19,8 +19,11 @@ public:
|
||||||
virtual bool isUnderMouse(int mouse_x, int mouse_y) const = 0;
|
virtual bool isUnderMouse(int mouse_x, int mouse_y) const = 0;
|
||||||
|
|
||||||
virtual void setVisibility(bool is_visible = true);
|
virtual void setVisibility(bool is_visible = true);
|
||||||
|
bool isVisible() const;
|
||||||
|
|
||||||
void addChild(const std::shared_ptr<Widget>& child);
|
void addChild(const std::shared_ptr<Widget>& child);
|
||||||
void setParent(const std::shared_ptr<Widget>& parent);
|
void setParent(const std::shared_ptr<Widget>& parent);
|
||||||
|
|
||||||
void blockBy(const std::shared_ptr<Widget>& blocker);
|
void blockBy(const std::shared_ptr<Widget>& blocker);
|
||||||
void unblock();
|
void unblock();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue