diff --git a/eeschema/tools/ee_actions.cpp b/eeschema/tools/ee_actions.cpp index 74155ec2ea..1be0436102 100644 --- a/eeschema/tools/ee_actions.cpp +++ b/eeschema/tools/ee_actions.cpp @@ -269,8 +269,7 @@ TOOL_ACTION EE_ACTIONS::drawSymbolTextBox( TOOL_ACTION_ARGS() .MenuText( _( "Add Text Box" ) ) .Tooltip( _( "Add a text box item" ) ) .Icon( BITMAPS::add_textbox ) - .Flags( AF_ACTIVATE ) - .Parameter( LIB_TEXTBOX_T ) ); + .Flags( AF_ACTIVATE ) ); TOOL_ACTION EE_ACTIONS::drawSymbolLines( TOOL_ACTION_ARGS() .Name( "eeschema.SymbolDrawing.drawSymbolLines" ) diff --git a/eeschema/tools/symbol_editor_drawing_tools.cpp b/eeschema/tools/symbol_editor_drawing_tools.cpp index 38a05683c2..80d2a140d8 100644 --- a/eeschema/tools/symbol_editor_drawing_tools.cpp +++ b/eeschema/tools/symbol_editor_drawing_tools.cpp @@ -23,6 +23,7 @@ */ #include +#include #include #include #include @@ -332,13 +333,28 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent ) int SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent ) { + SHAPE_T requestedShape = aEvent.Parameter(); + + return doDrawShape( aEvent, requestedShape ); +} + + +int SYMBOL_EDITOR_DRAWING_TOOLS::DrawSymbolTextBox( const TOOL_EVENT& aEvent ) +{ + return doDrawShape( aEvent, std::nullopt /* Draw text box */ ); +} + + +int SYMBOL_EDITOR_DRAWING_TOOLS::doDrawShape( const TOOL_EVENT& aEvent, std::optional aDrawingShape ) +{ + bool isTextBox = !aDrawingShape.has_value(); + SHAPE_T toolType = aDrawingShape.value_or( SHAPE_T::SEGMENT ); + SETTINGS_MANAGER& settingsMgr = Pgm().GetSettingsManager(); SYMBOL_EDITOR_SETTINGS* settings = settingsMgr.GetAppSettings(); - SHAPE_T toolType = aEvent.Parameter(); SHAPE_T shapeType = toolType == SHAPE_T::SEGMENT ? SHAPE_T::POLY : toolType; LIB_SYMBOL* symbol = m_frame->GetCurSymbol(); LIB_SHAPE* item = nullptr; - bool isTextBox = aEvent.IsAction( &EE_ACTIONS::drawSymbolTextBox ); wxString description; if( m_inDrawShape ) @@ -666,14 +682,14 @@ int SYMBOL_EDITOR_DRAWING_TOOLS::RepeatDrawItem( const TOOL_EVENT& aEvent ) void SYMBOL_EDITOR_DRAWING_TOOLS::setTransitions() { - Go( &SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace, EE_ACTIONS::placeSymbolPin.MakeEvent() ); - Go( &SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace, EE_ACTIONS::placeSymbolText.MakeEvent() ); - Go( &SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape, EE_ACTIONS::drawRectangle.MakeEvent() ); - Go( &SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape, EE_ACTIONS::drawCircle.MakeEvent() ); - Go( &SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape, EE_ACTIONS::drawArc.MakeEvent() ); - Go( &SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape, EE_ACTIONS::drawSymbolLines.MakeEvent() ); - Go( &SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape, EE_ACTIONS::drawSymbolPolygon.MakeEvent() ); - Go( &SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape, EE_ACTIONS::drawSymbolTextBox.MakeEvent() ); - Go( &SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor, EE_ACTIONS::placeSymbolAnchor.MakeEvent() ); - Go( &SYMBOL_EDITOR_DRAWING_TOOLS::RepeatDrawItem, EE_ACTIONS::repeatDrawItem.MakeEvent() ); + Go( &SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace, EE_ACTIONS::placeSymbolPin.MakeEvent() ); + Go( &SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace, EE_ACTIONS::placeSymbolText.MakeEvent() ); + Go( &SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape, EE_ACTIONS::drawRectangle.MakeEvent() ); + Go( &SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape, EE_ACTIONS::drawCircle.MakeEvent() ); + Go( &SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape, EE_ACTIONS::drawArc.MakeEvent() ); + Go( &SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape, EE_ACTIONS::drawSymbolLines.MakeEvent() ); + Go( &SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape, EE_ACTIONS::drawSymbolPolygon.MakeEvent() ); + Go( &SYMBOL_EDITOR_DRAWING_TOOLS::DrawSymbolTextBox, EE_ACTIONS::drawSymbolTextBox.MakeEvent() ); + Go( &SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor, EE_ACTIONS::placeSymbolAnchor.MakeEvent() ); + Go( &SYMBOL_EDITOR_DRAWING_TOOLS::RepeatDrawItem, EE_ACTIONS::repeatDrawItem.MakeEvent() ); } diff --git a/eeschema/tools/symbol_editor_drawing_tools.h b/eeschema/tools/symbol_editor_drawing_tools.h index 9ff4cf42a6..0abc7f61ac 100644 --- a/eeschema/tools/symbol_editor_drawing_tools.h +++ b/eeschema/tools/symbol_editor_drawing_tools.h @@ -25,6 +25,8 @@ #ifndef SYMBOL_EDITOR_DRAWING_TOOLS_H #define SYMBOL_EDITOR_DRAWING_TOOLS_H +#include + #include @@ -48,6 +50,7 @@ public: int TwoClickPlace( const TOOL_EVENT& aEvent ); int DrawShape( const TOOL_EVENT& aEvent ); + int DrawSymbolTextBox( const TOOL_EVENT& aEvent ); int PlaceAnchor( const TOOL_EVENT& aEvent ); int RepeatDrawItem( const TOOL_EVENT& aEvent ); @@ -62,6 +65,8 @@ public: bool GetDrawSpecificUnit() const { return m_drawSpecificUnit; } private: + int doDrawShape( const TOOL_EVENT& aEvent, std::optional aDrawingShape ); + void setTransitions() override; private: