mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
Themes: Support rubberband selection theming
This commit is contained in:
parent
56a2c21e0c
commit
123dcada05
Notes:
sideshowbarker
2024-07-19 10:18:02 +09:00
Author: https://github.com/0xtechnobabble 🔰 Commit: https://github.com/SerenityOS/serenity/commit/123dcada05c Pull-request: https://github.com/SerenityOS/serenity/pull/1024
9 changed files with 22 additions and 7 deletions
|
@ -29,3 +29,5 @@ ThreedShadow2=#2e2f30
|
|||
HoverHighlight=#696969
|
||||
Selection=#14141a
|
||||
SelectionText=white
|
||||
RubberBandFill=#8080803c
|
||||
RubberBandBorder=black
|
||||
|
|
|
@ -29,3 +29,5 @@ ThreedShadow2=#404040
|
|||
HoverHighlight=#e3dfdb
|
||||
Selection=#84351a
|
||||
SelectionText=white
|
||||
RubberBandFill=#f4ca9e3c
|
||||
RubberBandBorder=#6e2209
|
||||
|
|
|
@ -29,3 +29,5 @@ ThreedShadow2=#909090
|
|||
HoverHighlight=white
|
||||
Selection=black
|
||||
SelectionText=white
|
||||
RubberBandFill=#fad7653c
|
||||
RubberBandBorder=#f4ca9e
|
||||
|
|
|
@ -29,3 +29,5 @@ ThreedShadow2=#882d26
|
|||
HoverHighlight=#e6e5e2
|
||||
Selection=#84351a
|
||||
SelectionText=white
|
||||
RubberBandFill=#0466033c
|
||||
RubberBandBorder=#76943c
|
||||
|
|
|
@ -154,6 +154,6 @@ void CursorTool::on_second_paint(GPainter& painter, GPaintEvent&)
|
|||
if (!m_rubber_banding)
|
||||
return;
|
||||
auto rect = rubber_band_rect();
|
||||
painter.fill_rect(rect, Color(244, 202, 158, 60));
|
||||
painter.draw_rect(rect, Color(110, 34, 9));
|
||||
painter.fill_rect(rect, m_editor.palette().rubber_band_fill());
|
||||
painter.draw_rect(rect, m_editor.palette().rubber_band_border());
|
||||
}
|
||||
|
|
|
@ -60,8 +60,11 @@ public:
|
|||
Color threed_shadow1() const { return color(ColorRole::ThreedShadow1); }
|
||||
Color threed_shadow2() const { return color(ColorRole::ThreedShadow2); }
|
||||
Color hover_highlight() const { return color(ColorRole::ThreedHighlight); }
|
||||
Color rubber_band_fill() const { return color(ColorRole::RubberBandFill); }
|
||||
Color rubber_band_border() const { return color(ColorRole::RubberBandBorder); }
|
||||
|
||||
Color color(ColorRole role) const { return m_impl->color(role); }
|
||||
|
||||
void set_color(ColorRole, Color);
|
||||
|
||||
const SystemTheme& theme() const { return m_impl->theme(); }
|
||||
|
|
|
@ -32,17 +32,17 @@ RefPtr<SharedBuffer> load_system_theme(const String& path)
|
|||
|
||||
auto* data = (SystemTheme*)buffer->data();
|
||||
|
||||
auto get = [&](auto& name) {
|
||||
auto get_color = [&](auto& name) {
|
||||
auto color_string = file->read_entry("Colors", name);
|
||||
auto color = Color::from_string(color_string);
|
||||
if (!color.has_value())
|
||||
return Color(Color::Black);
|
||||
dbg() << "Parsed system color '" << name << "' = " << color.value();
|
||||
dbg() << "Parsed system theme color '" << name << "' = " << color.value();
|
||||
return color.value();
|
||||
};
|
||||
|
||||
#define DO_COLOR(x) \
|
||||
data->color[(int)ColorRole::x] = get(#x)
|
||||
data->color[(int)ColorRole::x] = get_color(#x)
|
||||
|
||||
DO_COLOR(DesktopBackground);
|
||||
DO_COLOR(ThreedHighlight);
|
||||
|
@ -75,6 +75,8 @@ RefPtr<SharedBuffer> load_system_theme(const String& path)
|
|||
DO_COLOR(MenuBaseText);
|
||||
DO_COLOR(MenuSelection);
|
||||
DO_COLOR(MenuSelectionText);
|
||||
DO_COLOR(RubberBandFill);
|
||||
DO_COLOR(RubberBandBorder);
|
||||
|
||||
buffer->seal();
|
||||
buffer->share_globally();
|
||||
|
|
|
@ -36,6 +36,8 @@ enum class ColorRole {
|
|||
HoverHighlight,
|
||||
Selection,
|
||||
SelectionText,
|
||||
RubberBandFill,
|
||||
RubberBandBorder,
|
||||
|
||||
__Count,
|
||||
|
||||
|
|
|
@ -260,8 +260,8 @@ void GItemView::second_paint_event(GPaintEvent& event)
|
|||
painter.add_clip_rect(event.rect());
|
||||
|
||||
auto rubber_band_rect = Rect::from_two_points(m_rubber_band_origin, m_rubber_band_current);
|
||||
painter.fill_rect(rubber_band_rect, Color(244, 202, 158, 60));
|
||||
painter.draw_rect(rubber_band_rect, Color(110, 34, 9));
|
||||
painter.fill_rect(rubber_band_rect, parent_widget()->palette().rubber_band_fill());
|
||||
painter.draw_rect(rubber_band_rect, parent_widget()->palette().rubber_band_border());
|
||||
}
|
||||
|
||||
void GItemView::paint_event(GPaintEvent& event)
|
||||
|
|
Loading…
Add table
Reference in a new issue