ProgressPaintable.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * Copyright (c) 2018-2022, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibGfx/StylePainter.h>
  7. #include <LibWeb/Painting/ProgressPaintable.h>
  8. namespace Web::Painting {
  9. NonnullRefPtr<ProgressPaintable> ProgressPaintable::create(Layout::Progress const& layout_box)
  10. {
  11. return adopt_ref(*new ProgressPaintable(layout_box));
  12. }
  13. ProgressPaintable::ProgressPaintable(Layout::Progress const& layout_box)
  14. : PaintableBox(layout_box)
  15. {
  16. }
  17. Layout::Progress const& ProgressPaintable::layout_box() const
  18. {
  19. return static_cast<Layout::Progress const&>(layout_node());
  20. }
  21. void ProgressPaintable::paint(PaintContext& context, PaintPhase phase) const
  22. {
  23. if (!is_visible())
  24. return;
  25. if (phase == PaintPhase::Foreground) {
  26. // FIXME: This does not support floating point value() and max()
  27. Gfx::StylePainter::paint_progressbar(context.painter(), enclosing_int_rect(absolute_rect()), context.palette(), 0, layout_box().dom_node().max(), layout_box().dom_node().value(), "");
  28. }
  29. }
  30. }