StylePainter.h 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 <LibGUI/TabWidget.h>
  9. #include <LibGfx/Forward.h>
  10. #include <LibGfx/Orientation.h>
  11. namespace Gfx {
  12. enum class ButtonStyle {
  13. Normal,
  14. ThickCap,
  15. Coolbar,
  16. Tray,
  17. };
  18. enum class FrameShadow {
  19. Plain,
  20. Raised,
  21. Sunken
  22. };
  23. enum class FrameShape {
  24. NoFrame,
  25. Box,
  26. Container,
  27. Panel,
  28. Window,
  29. };
  30. // FIXME: should this be in its own header?
  31. class BaseStylePainter {
  32. public:
  33. virtual ~BaseStylePainter() = default;
  34. 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;
  35. virtual void paint_tab_button(Painter&, IntRect const&, Palette const&, bool active, bool hovered, bool enabled, GUI::TabWidget::TabPosition position, bool in_active_window, bool accented) = 0;
  36. virtual void paint_frame(Painter&, IntRect const&, Palette const&, FrameShape, FrameShadow, int thickness, bool skip_vertical_lines = false) = 0;
  37. virtual void paint_window_frame(Painter&, IntRect const&, Palette const&) = 0;
  38. virtual void paint_progressbar(Painter&, IntRect const&, Palette const&, int min, int max, int value, StringView text, Orientation = Orientation::Horizontal) = 0;
  39. virtual void paint_radio_button(Painter&, IntRect const&, Palette const&, bool is_checked, bool is_being_pressed) = 0;
  40. virtual void paint_check_box(Painter&, IntRect const&, Palette const&, bool is_enabled, bool is_checked, bool is_being_pressed) = 0;
  41. virtual void paint_transparency_grid(Painter&, IntRect const&, Palette const&) = 0;
  42. virtual void paint_simple_rect_shadow(Painter&, IntRect const&, Bitmap const& shadow_bitmap, bool shadow_includes_frame = false, bool fill_content = false) = 0;
  43. protected:
  44. BaseStylePainter() = default;
  45. };
  46. class StylePainter {
  47. public:
  48. static BaseStylePainter& current();
  49. // FIXME: These are here for API compatibility, we should probably remove them and move BaseStylePainter into here
  50. 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);
  51. static void paint_tab_button(Painter&, IntRect const&, Palette const&, bool active, bool hovered, bool enabled, GUI::TabWidget::TabPosition position, bool in_active_window, bool accented);
  52. static void paint_frame(Painter&, IntRect const&, Palette const&, FrameShape, FrameShadow, int thickness, bool skip_vertical_lines = false);
  53. static void paint_window_frame(Painter&, IntRect const&, Palette const&);
  54. static void paint_progressbar(Painter&, IntRect const&, Palette const&, int min, int max, int value, StringView text, Orientation = Orientation::Horizontal);
  55. static void paint_radio_button(Painter&, IntRect const&, Palette const&, bool is_checked, bool is_being_pressed);
  56. static void paint_check_box(Painter&, IntRect const&, Palette const&, bool is_enabled, bool is_checked, bool is_being_pressed);
  57. static void paint_transparency_grid(Painter&, IntRect const&, Palette const&);
  58. static void paint_simple_rect_shadow(Painter&, IntRect const&, Bitmap const& shadow_bitmap, bool shadow_includes_frame = false, bool fill_content = false);
  59. };
  60. }