1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 18:27:35 +00:00

LibGfx: Add 'IsDark' flag to SystemTheme and Palette

This explicitly states whether a given theme is a dark theme, so that
applications not using the system palette colors can still attempt to
match the overall theme.
This commit is contained in:
Sam Atkins 2021-10-26 14:30:52 +01:00 committed by Linus Groh
parent 2eaed880b1
commit 4f42e4ba90
4 changed files with 48 additions and 0 deletions

View file

@ -1,5 +1,6 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2021, Sam Atkins <atkinssj@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -30,6 +31,12 @@ public:
return Color::from_rgba(theme().color[(int)role]);
}
bool flag(FlagRole role) const
{
VERIFY((int)role < (int)FlagRole::__Count);
return theme().flag[(int)role];
}
int metric(MetricRole) const;
String path(PathRole) const;
const SystemTheme& theme() const { return *m_theme_buffer.data<SystemTheme>(); }
@ -118,6 +125,8 @@ public:
Color syntax_preprocessor_statement() const { return color(ColorRole::SyntaxPreprocessorStatement); }
Color syntax_preprocessor_value() const { return color(ColorRole::SyntaxPreprocessorValue); }
bool is_dark() const { return flag(FlagRole::IsDark); }
int window_title_height() const { return metric(MetricRole::TitleHeight); }
int window_title_button_width() const { return metric(MetricRole::TitleButtonWidth); }
int window_title_button_height() const { return metric(MetricRole::TitleButtonHeight); }
@ -130,10 +139,12 @@ public:
String tooltip_shadow_path() const { return path(PathRole::TooltipShadow); }
Color color(ColorRole role) const { return m_impl->color(role); }
bool flag(FlagRole role) const { return m_impl->flag(role); }
int metric(MetricRole role) const { return m_impl->metric(role); }
String path(PathRole role) const { return m_impl->path(role); }
void set_color(ColorRole, Color);
void set_flag(FlagRole, bool);
void set_metric(MetricRole, int);
void set_path(PathRole, String);