Serenity Operating System
at master 89 lines 2.7 kB view raw
1/* 2 * Copyright (c) 2020, Andreas Kling <kling@serenityos.org> 3 * Copyright (c) 2021-2022, Sam Atkins <atkinssj@serenityos.org> 4 * Copyright (c) 2021, Antonio Di Stefano <tonio9681@gmail.com> 5 * Copyright (c) 2022, the SerenityOS developers. 6 * 7 * SPDX-License-Identifier: BSD-2-Clause 8 */ 9 10#pragma once 11 12#include <LibGUI/Frame.h> 13#include <LibGfx/Bitmap.h> 14#include <LibGfx/Palette.h> 15#include <LibGfx/WindowTheme.h> 16 17namespace GUI { 18 19class AbstractThemePreview : public GUI::Frame { 20 C_OBJECT_ABSTRACT(AbstractThemePreview); 21 22public: 23 virtual ~AbstractThemePreview() override = default; 24 25 Gfx::Palette& preview_palette() { return m_preview_palette; } 26 void set_preview_palette(Gfx::Palette&); 27 ErrorOr<void> set_theme_from_file(StringView path, NonnullOwnPtr<Core::File>); 28 void set_theme(Core::AnonymousBuffer const&); 29 30 void paint_window(StringView title, Gfx::IntRect const& rect, Gfx::WindowTheme::WindowState, Gfx::Bitmap const& icon, int button_count = 3); 31 32 Function<void()> on_palette_change; 33 34 struct Window { 35 Gfx::IntRect& rect; 36 }; 37 void center_window_group_within(Span<Window> windows, Gfx::IntRect const& bounds); 38 39protected: 40 explicit AbstractThemePreview(Gfx::Palette const&); 41 42 inline Gfx::Bitmap const& active_window_icon() const 43 { 44 VERIFY(m_active_window_icon); 45 return *m_active_window_icon; 46 } 47 inline Gfx::Bitmap const& inactive_window_icon() const 48 { 49 VERIFY(m_inactive_window_icon); 50 return *m_inactive_window_icon; 51 } 52 53 virtual void palette_changed() {}; 54 55private: 56 virtual void paint_preview(GUI::PaintEvent&) = 0; 57 58 void load_theme_bitmaps(); 59 60 virtual void paint_event(GUI::PaintEvent&) override; 61 62 Gfx::Palette m_preview_palette; 63 64 RefPtr<Gfx::Bitmap> m_active_window_icon; 65 RefPtr<Gfx::Bitmap> m_inactive_window_icon; 66 67 RefPtr<Gfx::Bitmap> m_default_close_bitmap; 68 RefPtr<Gfx::Bitmap> m_default_maximize_bitmap; 69 RefPtr<Gfx::Bitmap> m_default_minimize_bitmap; 70 RefPtr<Gfx::Bitmap> m_close_bitmap; 71 RefPtr<Gfx::Bitmap> m_maximize_bitmap; 72 RefPtr<Gfx::Bitmap> m_minimize_bitmap; 73 DeprecatedString m_last_close_path; 74 DeprecatedString m_last_maximize_path; 75 DeprecatedString m_last_minimize_path; 76 77 RefPtr<Gfx::Bitmap> m_active_window_shadow; 78 RefPtr<Gfx::Bitmap> m_inactive_window_shadow; 79 RefPtr<Gfx::Bitmap> m_menu_shadow; 80 RefPtr<Gfx::Bitmap> m_taskbar_shadow; 81 RefPtr<Gfx::Bitmap> m_tooltip_shadow; 82 DeprecatedString m_last_active_window_shadow_path; 83 DeprecatedString m_last_inactive_window_shadow_path; 84 DeprecatedString m_last_menu_shadow_path; 85 DeprecatedString m_last_taskbar_shadow_path; 86 DeprecatedString m_last_tooltip_shadow_path; 87}; 88 89}