AbstractThemePreview.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
  3. * Copyright (c) 2021, 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. #pragma once
  10. #include <LibGUI/Frame.h>
  11. #include <LibGfx/Bitmap.h>
  12. #include <LibGfx/Palette.h>
  13. #include <LibGfx/WindowTheme.h>
  14. namespace GUI {
  15. class AbstractThemePreview : public GUI::Frame {
  16. C_OBJECT_ABSTRACT(AbstractThemePreview);
  17. public:
  18. virtual ~AbstractThemePreview() override = default;
  19. Gfx::Palette const& preview_palette() const { return m_preview_palette; }
  20. void set_preview_palette(Gfx::Palette const&);
  21. void set_theme_from_file(Core::File&);
  22. void paint_window(StringView title, Gfx::IntRect const& rect, Gfx::WindowTheme::WindowState, Gfx::Bitmap const& icon, int button_count = 3);
  23. Function<void(String const&)> on_theme_load_from_file;
  24. Function<void()> on_palette_change;
  25. protected:
  26. explicit AbstractThemePreview(Gfx::Palette const&);
  27. inline Gfx::Bitmap const& active_window_icon() const
  28. {
  29. VERIFY(m_active_window_icon);
  30. return *m_active_window_icon;
  31. }
  32. inline Gfx::Bitmap const& inactive_window_icon() const
  33. {
  34. VERIFY(m_inactive_window_icon);
  35. return *m_inactive_window_icon;
  36. }
  37. private:
  38. virtual void paint_preview(GUI::PaintEvent&) = 0;
  39. void load_theme_bitmaps();
  40. virtual void paint_event(GUI::PaintEvent&) override;
  41. Gfx::Palette m_preview_palette;
  42. RefPtr<Gfx::Bitmap> m_active_window_icon;
  43. RefPtr<Gfx::Bitmap> m_inactive_window_icon;
  44. RefPtr<Gfx::Bitmap> m_default_close_bitmap;
  45. RefPtr<Gfx::Bitmap> m_default_maximize_bitmap;
  46. RefPtr<Gfx::Bitmap> m_default_minimize_bitmap;
  47. RefPtr<Gfx::Bitmap> m_close_bitmap;
  48. RefPtr<Gfx::Bitmap> m_maximize_bitmap;
  49. RefPtr<Gfx::Bitmap> m_minimize_bitmap;
  50. String m_last_close_path;
  51. String m_last_maximize_path;
  52. String m_last_minimize_path;
  53. RefPtr<Gfx::Bitmap> m_active_window_shadow;
  54. RefPtr<Gfx::Bitmap> m_inactive_window_shadow;
  55. RefPtr<Gfx::Bitmap> m_menu_shadow;
  56. RefPtr<Gfx::Bitmap> m_taskbar_shadow;
  57. RefPtr<Gfx::Bitmap> m_tooltip_shadow;
  58. String m_last_active_window_shadow_path;
  59. String m_last_inactive_window_shadow_path;
  60. String m_last_menu_shadow_path;
  61. String m_last_taskbar_shadow_path;
  62. String m_last_tooltip_shadow_path;
  63. };
  64. }