StylePainter.h 3.1 KB

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