LineTool.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. * Copyright (c) 2022, the SerenityOS developers.
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause
  6. */
  7. #pragma once
  8. #include "Tool.h"
  9. #include <LibGUI/ActionGroup.h>
  10. #include <LibGfx/Point.h>
  11. namespace PixelPaint {
  12. class LineTool final : public Tool {
  13. public:
  14. LineTool() = default;
  15. virtual ~LineTool() override = default;
  16. virtual void on_mousedown(Layer*, MouseEvent&) override;
  17. virtual void on_mousemove(Layer*, MouseEvent&) override;
  18. virtual void on_mouseup(Layer*, MouseEvent&) override;
  19. virtual void on_second_paint(Layer const*, GUI::PaintEvent&) override;
  20. virtual void on_keydown(GUI::KeyEvent&) override;
  21. virtual GUI::Widget* get_properties_widget() override;
  22. virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> cursor() override { return Gfx::StandardCursor::Crosshair; }
  23. void draw_using(GUI::Painter&, Gfx::IntPoint const& start_position, Gfx::IntPoint const& end_position, Color color, int thickness);
  24. private:
  25. RefPtr<GUI::Widget> m_properties_widget;
  26. GUI::MouseButton m_drawing_button { GUI::MouseButton::None };
  27. Gfx::IntPoint m_drag_start_position;
  28. Gfx::IntPoint m_line_start_position;
  29. Gfx::IntPoint m_line_end_position;
  30. int m_thickness { 1 };
  31. bool m_antialias_enabled { false };
  32. };
  33. }