2026-05-11 23:06:39 +03:00
/*
* InfiniPaint
* Copyright ( C ) 2025 - 2026 Yousef Khadadeh
*
* This program is free software : you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation , either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program . If not , see < https : //www.gnu.org/licenses/>.
*/
2025-07-06 20:43:53 +03:00
# pragma once
# include <include/core/SkCanvas.h>
2025-12-26 10:40:58 +03:00
# include "../../DrawData.hpp"
2025-08-02 20:10:33 +03:00
# include "DrawingProgramToolBase.hpp"
2025-07-06 20:43:53 +03:00
class DrawingProgram ;
2025-08-02 20:10:33 +03:00
class EraserTool : public DrawingProgramToolBase {
2025-07-06 20:43:53 +03:00
public :
EraserTool ( DrawingProgram & initDrawP ) ;
2025-08-02 20:10:33 +03:00
virtual DrawingProgramToolType get_type ( ) override ;
2026-04-12 12:36:00 +03:00
virtual void gui_toolbox ( Toolbar & t ) override ;
2026-04-30 12:09:03 +03:00
virtual void gui_phone_toolbox ( PhoneDrawingProgramScreen & t ) override ;
2026-04-12 12:36:00 +03:00
virtual void right_click_popup_gui ( Toolbar & t , Vector2f popupPos ) override ;
2025-12-30 19:46:08 +03:00
virtual void erase_component ( CanvasComponentContainer : : ObjInfo * erasedComp ) override ;
2025-08-02 20:10:33 +03:00
virtual void tool_update ( ) override ;
2025-08-02 20:39:21 +03:00
virtual void switch_tool ( DrawingProgramToolType newTool ) override ;
2025-08-02 20:10:33 +03:00
virtual void draw ( SkCanvas * canvas , const DrawData & drawData ) override ;
virtual bool prevent_undo_or_redo ( ) override ;
2026-03-03 12:06:48 +03:00
virtual void input_mouse_button_on_canvas_callback ( const InputManager : : MouseButtonCallbackArgs & button ) override ;
virtual void input_mouse_motion_callback ( const InputManager : : MouseMotionCallbackArgs & motion ) override ;
2025-07-27 16:53:22 +03:00
2026-05-24 20:32:21 +03:00
std : : unordered_map < CanvasComponentContainer : : ObjInfo * , std : : unique_ptr < CanvasComponent > > updatedComponents ;
2025-12-30 19:46:08 +03:00
std : : unordered_set < CanvasComponentContainer : : ObjInfo * > erasedComponents ; // Pointers will be erased from this set if theyre erased in the main list (done by callback)
2026-03-03 12:06:48 +03:00
private :
2026-05-24 11:58:52 +03:00
SkPath erasePath ;
SkPath eraseBorderPath ;
Vector2f start ;
Vector2f end ;
void erase_between_points ( ) ;
2026-03-03 12:06:48 +03:00
bool isErasing = false ;
2025-07-06 20:43:53 +03:00
} ;