1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 09:17:45 +00:00

LibGUI+Applications: Move abstract ThemeEditor preview to LibGUI

This allows most of the theme preview code to be reused by similar
theme preview widgets.
This commit is contained in:
Ben Maxwell 2022-04-02 02:24:51 +01:00 committed by Andreas Kling
parent 0f2c1f804e
commit 3fbefb82ac
5 changed files with 256 additions and 167 deletions

View file

@ -9,6 +9,7 @@
#pragma once
#include <LibGUI/AbstractThemePreview.h>
#include <LibGUI/Frame.h>
#include <LibGfx/Bitmap.h>
#include <LibGfx/Filters/ColorBlindnessFilter.h>
@ -18,59 +19,24 @@ namespace ThemeEditor {
class MiniWidgetGallery;
class PreviewWidget final : public GUI::Frame {
class PreviewWidget final : public GUI::AbstractThemePreview {
C_OBJECT(PreviewWidget);
public:
virtual ~PreviewWidget() override = default;
Gfx::Palette const& preview_palette() const { return m_preview_palette; }
void set_preview_palette(Gfx::Palette const&);
void set_theme_from_file(Core::File&);
void set_color_filter(OwnPtr<Gfx::ColorBlindnessFilter>);
Function<void(String const&)> on_theme_load_from_file;
private:
explicit PreviewWidget(Gfx::Palette const&);
void load_theme_bitmaps();
virtual void paint_event(GUI::PaintEvent&) override;
virtual void paint_preview(GUI::PaintEvent&) override;
virtual void second_paint_event(GUI::PaintEvent&) override;
virtual void resize_event(GUI::ResizeEvent&) override;
virtual void drop_event(GUI::DropEvent&) override;
Gfx::Palette m_preview_palette;
OwnPtr<Gfx::ColorBlindnessFilter> m_color_filter = nullptr;
RefPtr<Gfx::Bitmap> m_active_window_icon;
RefPtr<Gfx::Bitmap> m_inactive_window_icon;
RefPtr<MiniWidgetGallery> m_gallery;
RefPtr<Gfx::Bitmap> m_default_close_bitmap;
RefPtr<Gfx::Bitmap> m_default_maximize_bitmap;
RefPtr<Gfx::Bitmap> m_default_minimize_bitmap;
RefPtr<Gfx::Bitmap> m_close_bitmap;
RefPtr<Gfx::Bitmap> m_maximize_bitmap;
RefPtr<Gfx::Bitmap> m_minimize_bitmap;
String m_last_close_path;
String m_last_maximize_path;
String m_last_minimize_path;
RefPtr<Gfx::Bitmap> m_active_window_shadow;
RefPtr<Gfx::Bitmap> m_inactive_window_shadow;
RefPtr<Gfx::Bitmap> m_menu_shadow;
RefPtr<Gfx::Bitmap> m_taskbar_shadow;
RefPtr<Gfx::Bitmap> m_tooltip_shadow;
String m_last_active_window_shadow_path;
String m_last_inactive_window_shadow_path;
String m_last_menu_shadow_path;
String m_last_taskbar_shadow_path;
String m_last_tooltip_shadow_path;
};
}