PaintContext.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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/Vector.h>
  8. #include <LibGfx/Forward.h>
  9. #include <LibGfx/Palette.h>
  10. #include <LibGfx/Rect.h>
  11. #include <LibWeb/SVG/SVGContext.h>
  12. namespace Web {
  13. class PaintContext {
  14. public:
  15. explicit PaintContext(Gfx::Painter& painter, const Palette& palette, const Gfx::IntPoint& scroll_offset)
  16. : m_painter(painter)
  17. , m_palette(palette)
  18. , m_scroll_offset(scroll_offset)
  19. {
  20. }
  21. Gfx::Painter& painter() const { return m_painter; }
  22. const Palette& palette() const { return m_palette; }
  23. bool has_svg_context() const { return m_svg_context.has_value(); }
  24. SVGContext& svg_context() { return m_svg_context.value(); }
  25. void set_svg_context(SVGContext context) { m_svg_context = context; }
  26. bool should_show_line_box_borders() const { return m_should_show_line_box_borders; }
  27. void set_should_show_line_box_borders(bool value) { m_should_show_line_box_borders = value; }
  28. Gfx::IntRect viewport_rect() const { return m_viewport_rect; }
  29. void set_viewport_rect(const Gfx::IntRect& rect) { m_viewport_rect = rect; }
  30. const Gfx::IntPoint& scroll_offset() const { return m_scroll_offset; }
  31. bool has_focus() const { return m_focus; }
  32. void set_has_focus(bool focus) { m_focus = focus; }
  33. private:
  34. Gfx::Painter& m_painter;
  35. Palette m_palette;
  36. Optional<SVGContext> m_svg_context;
  37. Gfx::IntRect m_viewport_rect;
  38. Gfx::IntPoint m_scroll_offset;
  39. bool m_should_show_line_box_borders { false };
  40. bool m_focus { false };
  41. };
  42. }