Fix incorrect parameter passing in symbol editor drawing
The text box used a different enum than the shapes, so this leads to a possibility of clashing. The new action framework flagged this problem, so modify the tool to handle the shape types properly. Fixes KICAD-2CJ
This commit is contained in:
parent
107c79484d
commit
c3674e6858
|
@ -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" )
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
*/
|
||||
|
||||
#include <ee_actions.h>
|
||||
#include <optional>
|
||||
#include <symbol_edit_frame.h>
|
||||
#include <sch_commit.h>
|
||||
#include <tools/symbol_editor_drawing_tools.h>
|
||||
|
@ -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<SHAPE_T>();
|
||||
|
||||
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<SHAPE_T> 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<SYMBOL_EDITOR_SETTINGS>();
|
||||
SHAPE_T toolType = aEvent.Parameter<SHAPE_T>();
|
||||
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 )
|
||||
|
@ -673,7 +689,7 @@ void SYMBOL_EDITOR_DRAWING_TOOLS::setTransitions()
|
|||
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::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() );
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
#ifndef SYMBOL_EDITOR_DRAWING_TOOLS_H
|
||||
#define SYMBOL_EDITOR_DRAWING_TOOLS_H
|
||||
|
||||
#include <optional>
|
||||
|
||||
#include <tools/ee_tool_base.h>
|
||||
|
||||
|
||||
|
@ -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<SHAPE_T> aDrawingShape );
|
||||
|
||||
void setTransitions() override;
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in New Issue