StylePainter.h 3.3 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 <LibGfx/Forward.h>
  9. #include <LibGfx/Orientation.h>
  10. #include <LibGfx/TabPosition.h>
  11. namespace Gfx {
  12. enum class ButtonStyle {
  13. Normal,
  14. ThickCap,
  15. Coolbar,
  16. Tray,
  17. };
  18. enum class FrameStyle {
  19. NoFrame,
  20. Window,
  21. Plain,
  22. RaisedBox,
  23. SunkenBox,
  24. RaisedContainer,
  25. SunkenContainer,
  26. RaisedPanel,
  27. SunkenPanel,
  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, TabPosition position, bool in_active_window, bool accented) = 0;
  35. virtual void paint_frame(Painter&, IntRect const&, Palette const&, FrameStyle, 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, TabPosition position, bool in_active_window, bool accented);
  51. static void paint_frame(Painter&, IntRect const&, Palette const&, FrameStyle, 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. }