summaryrefslogtreecommitdiff
path: root/Userland/Applications/ThemeEditor
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2022-04-29 12:07:06 +0100
committerAndreas Kling <kling@serenityos.org>2022-04-29 20:06:39 +0200
commit6c572006a307c06abce828d5093d17ca5f513217 (patch)
tree0d61921b7a33377044a1ab8f05d89ad14833f1d4 /Userland/Applications/ThemeEditor
parent5fd014077203b38e819a8a195c2c40b62c33c11b (diff)
downloadserenity-6c572006a307c06abce828d5093d17ca5f513217.zip
LibGUI+ThemeEditor: Split preview-widget palette-change callback
There are two different things in ThemeEditor that want to know when a palette changes: 1. The PreviewWidget subclass, so it can update its preview. 2. The ThemeEditor itself, so we know that the palette is modified. Using a protected virtual function for 1 means that we can do 2 without them fighting over the same on_palette_change callback.
Diffstat (limited to 'Userland/Applications/ThemeEditor')
-rw-r--r--Userland/Applications/ThemeEditor/PreviewWidget.cpp12
-rw-r--r--Userland/Applications/ThemeEditor/PreviewWidget.h3
2 files changed, 9 insertions, 6 deletions
diff --git a/Userland/Applications/ThemeEditor/PreviewWidget.cpp b/Userland/Applications/ThemeEditor/PreviewWidget.cpp
index af2eea8a61..85505e6726 100644
--- a/Userland/Applications/ThemeEditor/PreviewWidget.cpp
+++ b/Userland/Applications/ThemeEditor/PreviewWidget.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
- * Copyright (c) 2021, Sam Atkins <atkinssj@serenityos.org>
+ * Copyright (c) 2021-2022, Sam Atkins <atkinssj@serenityos.org>
* Copyright (c) 2021, Antonio Di Stefano <tonio9681@gmail.com>
* Copyright (c) 2022, the SerenityOS developers.
*
@@ -82,14 +82,16 @@ private:
PreviewWidget::PreviewWidget(Gfx::Palette const& initial_preview_palette)
: GUI::AbstractThemePreview(initial_preview_palette)
{
- on_palette_change = [&] {
- m_gallery->set_preview_palette(preview_palette());
- update_preview_window_locations();
- };
m_gallery = add<MiniWidgetGallery>();
set_greedy_for_hits(true);
}
+void PreviewWidget::palette_changed()
+{
+ m_gallery->set_preview_palette(preview_palette());
+ update_preview_window_locations();
+}
+
void PreviewWidget::set_color_filter(OwnPtr<Gfx::ColorBlindnessFilter> color_filter)
{
m_color_filter = move(color_filter);
diff --git a/Userland/Applications/ThemeEditor/PreviewWidget.h b/Userland/Applications/ThemeEditor/PreviewWidget.h
index 0e11f433db..0009f9c71e 100644
--- a/Userland/Applications/ThemeEditor/PreviewWidget.h
+++ b/Userland/Applications/ThemeEditor/PreviewWidget.h
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
- * Copyright (c) 2021, Sam Atkins <atkinssj@serenityos.org>
+ * Copyright (c) 2021-2022, Sam Atkins <atkinssj@serenityos.org>
* Copyright (c) 2021, Antonio Di Stefano <tonio9681@gmail.com>
* Copyright (c) 2022, the SerenityOS developers.
*
@@ -34,6 +34,7 @@ private:
virtual void second_paint_event(GUI::PaintEvent&) override;
virtual void resize_event(GUI::ResizeEvent&) override;
virtual void drop_event(GUI::DropEvent&) override;
+ virtual void palette_changed() override;
void paint_hightlight_window();
void update_preview_window_locations();