mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:57:44 +00:00
Flood: Get the color scheme from the system theme
This commit is contained in:
parent
800c292be8
commit
1a68977457
7 changed files with 41 additions and 112 deletions
|
@ -8,12 +8,28 @@
|
|||
|
||||
#include <LibGUI/Menu.h>
|
||||
#include <LibGUI/Painter.h>
|
||||
#include <LibGfx/Palette.h>
|
||||
|
||||
BoardWidget::BoardWidget(size_t rows, size_t columns, Vector<Color> colors, Color background_color)
|
||||
BoardWidget::BoardWidget(size_t rows, size_t columns)
|
||||
: m_board(make<Board>(rows, columns))
|
||||
, m_background_color(background_color)
|
||||
{
|
||||
m_board->set_color_scheme(move(colors));
|
||||
update_color_scheme();
|
||||
}
|
||||
|
||||
void BoardWidget::update_color_scheme()
|
||||
{
|
||||
auto const& palette = GUI::Widget::palette();
|
||||
m_board->set_color_scheme({
|
||||
palette.bright_black(),
|
||||
palette.bright_red(),
|
||||
palette.bright_green(),
|
||||
palette.bright_yellow(),
|
||||
palette.bright_blue(),
|
||||
palette.bright_magenta(),
|
||||
palette.bright_cyan(),
|
||||
palette.bright_white(),
|
||||
});
|
||||
m_background_color = palette.background();
|
||||
}
|
||||
|
||||
void BoardWidget::resize_board(size_t rows, size_t columns)
|
||||
|
@ -23,11 +39,6 @@ void BoardWidget::resize_board(size_t rows, size_t columns)
|
|||
m_board->resize(rows, columns);
|
||||
}
|
||||
|
||||
void BoardWidget::set_background_color(Color const background)
|
||||
{
|
||||
m_background_color = background;
|
||||
}
|
||||
|
||||
int BoardWidget::get_cell_size() const
|
||||
{
|
||||
int width = rect().width() / m_board->columns();
|
||||
|
@ -45,6 +56,13 @@ Gfx::IntSize BoardWidget::get_board_offset() const
|
|||
};
|
||||
}
|
||||
|
||||
void BoardWidget::event(Core::Event& event)
|
||||
{
|
||||
if (event.type() == GUI::Event::ThemeChange)
|
||||
update_color_scheme();
|
||||
GUI::Frame::event(event);
|
||||
}
|
||||
|
||||
void BoardWidget::paint_event(GUI::PaintEvent& event)
|
||||
{
|
||||
GUI::Widget::paint_event(event);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue