mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 20:22:45 +00:00 
			
		
		
		
	 413618454b
			
		
	
	
		413618454b
		
	
	
	
	
		
			
			Holding Shift key will constrain the LineTool's line angle to 15 degrees increments. Many graphics editors have similar feature.
		
			
				
	
	
		
			30 lines
		
	
	
	
		
			857 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			30 lines
		
	
	
	
		
			857 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| #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;
 | |
|     virtual void on_keydown(GKeyEvent&) override;
 | |
|     virtual void on_keyup(GKeyEvent&) 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;
 | |
|     RefPtr<GMenu> m_context_menu;
 | |
|     int m_thickness { 1 };
 | |
|     bool m_constrain_angle { false };
 | |
| };
 |