StylePainter.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/Forward.h>
  8. #include <LibGfx/Forward.h>
  9. #include <LibGfx/Orientation.h>
  10. namespace Gfx {
  11. enum class ButtonStyle {
  12. Normal,
  13. ThickCap,
  14. Coolbar,
  15. Tray,
  16. };
  17. enum class FrameShadow {
  18. Plain,
  19. Raised,
  20. Sunken
  21. };
  22. enum class FrameShape {
  23. NoFrame,
  24. Box,
  25. Container,
  26. Panel,
  27. Window,
  28. };
  29. // FIXME: should this be in its own header?
  30. class BaseStylePainter {
  31. public:
  32. virtual ~BaseStylePainter() = default;
  33. virtual void paint_button(Painter&, IntRect const&, Palette const&, ButtonStyle, bool pressed, bool hovered = false, bool checked = false, bool enabled = true, bool focused = false, bool default_button = false) = 0;
  34. virtual void paint_tab_button(Painter&, IntRect const&, Palette const&, bool active, bool hovered, bool enabled, bool top, bool in_active_window) = 0;
  35. virtual void paint_frame(Painter&, IntRect const&, Palette const&, FrameShape, FrameShadow, int thickness, bool skip_vertical_lines = false) = 0;
  36. virtual void paint_window_frame(Painter&, IntRect const&, Palette const&) = 0;
  37. virtual void paint_progressbar(Painter&, IntRect const&, Palette const&, int min, int max, int value, StringView text, Orientation = Orientation::Horizontal) = 0;
  38. virtual void paint_radio_button(Painter&, IntRect const&, Palette const&, bool is_checked, bool is_being_pressed) = 0;
  39. virtual void paint_check_box(Painter&, IntRect const&, Palette const&, bool is_enabled, bool is_checked, bool is_being_pressed) = 0;
  40. virtual void paint_transparency_grid(Painter&, IntRect const&, Palette const&) = 0;
  41. virtual void paint_simple_rect_shadow(Painter&, IntRect const&, Bitmap const& shadow_bitmap, bool shadow_includes_frame = false, bool fill_content = false) = 0;
  42. protected:
  43. BaseStylePainter() = default;
  44. };
  45. class StylePainter {
  46. public:
  47. static BaseStylePainter& current();
  48. // FIXME: These are here for API compatibility, we should probably remove them and move BaseStylePainter into here
  49. static void paint_button(Painter&, IntRect const&, Palette const&, ButtonStyle, bool pressed, bool hovered = false, bool checked = false, bool enabled = true, bool focused = false, bool default_button = false);
  50. static void paint_tab_button(Painter&, IntRect const&, Palette const&, bool active, bool hovered, bool enabled, bool top, bool in_active_window);
  51. static void paint_frame(Painter&, IntRect const&, Palette const&, FrameShape, FrameShadow, int thickness, bool skip_vertical_lines = false);
  52. static void paint_window_frame(Painter&, IntRect const&, Palette const&);
  53. static void paint_progressbar(Painter&, IntRect const&, Palette const&, int min, int max, int value, StringView text, Orientation = Orientation::Horizontal);
  54. static void paint_radio_button(Painter&, IntRect const&, Palette const&, bool is_checked, bool is_being_pressed);
  55. static void paint_check_box(Painter&, IntRect const&, Palette const&, bool is_enabled, bool is_checked, bool is_being_pressed);
  56. static void paint_transparency_grid(Painter&, IntRect const&, Palette const&);
  57. static void paint_simple_rect_shadow(Painter&, IntRect const&, Bitmap const& shadow_bitmap, bool shadow_includes_frame = false, bool fill_content = false);
  58. };
  59. }