mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 18:27:35 +00:00
PaintBrush: Add a "line" tool for drawing straight lines
This implements "preview" of the line by allowing tool subclasses to hook the second_paint_event on the PaintableWidget. Work towards #375.
This commit is contained in:
parent
f04394b9f3
commit
4e6cd541c9
8 changed files with 137 additions and 9 deletions
27
Applications/PaintBrush/LineTool.h
Normal file
27
Applications/PaintBrush/LineTool.h
Normal file
|
@ -0,0 +1,27 @@
|
|||
#pragma once
|
||||
|
||||
#include "Tool.h"
|
||||
#include <LibDraw/Point.h>
|
||||
|
||||
class GMenu;
|
||||
|
||||
class LineTool final : public Tool {
|
||||
public:
|
||||
LineTool();
|
||||
virtual ~LineTool() override;
|
||||
|
||||
virtual void on_mousedown(GMouseEvent&) override;
|
||||
virtual void on_mousemove(GMouseEvent&) override;
|
||||
virtual void on_mouseup(GMouseEvent&) override;
|
||||
virtual void on_contextmenu(GContextMenuEvent&) override;
|
||||
virtual void on_second_paint(GPaintEvent&) override;
|
||||
|
||||
private:
|
||||
virtual const char* class_name() const override { return "LineTool"; }
|
||||
|
||||
GMouseButton m_drawing_button { GMouseButton::None };
|
||||
Point m_line_start_position;
|
||||
Point m_line_end_position;
|
||||
OwnPtr<GMenu> m_context_menu;
|
||||
int m_thickness { 1 };
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue