Add hotkey (Insert) for zone create corner
Adds a hotkey to the TOOL_ACTION, and also checks for action validity prior to running the actions (previously implicitly gated by the enablement of the menu item).
This commit is contained in:
parent
7c04d8be1c
commit
a1e0735853
|
@ -310,6 +310,9 @@ static EDA_HOTKEY HkToggleCursor( _HKI( "Toggle Cursor Display (Modern Toolset o
|
|||
static EDA_HOTKEY HkMeasureTool( _HKI( "Measure Distance (Modern Toolset only)" ),
|
||||
HK_MEASURE_TOOL, 'M' + GR_KB_SHIFTCTRL );
|
||||
|
||||
static EDA_HOTKEY HkInsertCorner( _HKI( "Insert Corner (Modern Toolset only)" ),
|
||||
HK_INSERT_CORNER, WXK_INSERT );
|
||||
|
||||
// List of common hotkey descriptors
|
||||
EDA_HOTKEY* common_Hotkey_List[] =
|
||||
{
|
||||
|
@ -384,6 +387,9 @@ EDA_HOTKEY* board_edit_Hotkey_List[] =
|
|||
&HkZoneFillOrRefill,
|
||||
&HkZoneRemoveFilled,
|
||||
|
||||
// Point editor (zones and segments)
|
||||
&HkInsertCorner,
|
||||
|
||||
// Highlight and display
|
||||
&HkSelectConnection,
|
||||
&HkSelectCopper,
|
||||
|
|
|
@ -133,7 +133,8 @@ enum hotkey_id_commnand {
|
|||
HK_DP_DIMENSIONS,
|
||||
HK_VIA_SIZE_INC,
|
||||
HK_VIA_SIZE_DEC,
|
||||
HK_HIGHLIGHT_NET_SELECTION
|
||||
HK_HIGHLIGHT_NET_SELECTION,
|
||||
HK_INSERT_CORNER
|
||||
};
|
||||
|
||||
// Full list of hotkey descriptors for board editor and footprint editor
|
||||
|
|
|
@ -50,7 +50,7 @@ using namespace std::placeholders;
|
|||
|
||||
// Point editor
|
||||
TOOL_ACTION PCB_ACTIONS::pointEditorAddCorner( "pcbnew.PointEditor.addCorner",
|
||||
AS_GLOBAL, 0,
|
||||
AS_GLOBAL, WXK_INSERT,
|
||||
_( "Create Corner" ), _( "Create a corner" ), add_corner_xpm );
|
||||
|
||||
TOOL_ACTION PCB_ACTIONS::pointEditorRemoveCorner( "pcbnew.PointEditor.removeCorner",
|
||||
|
@ -850,17 +850,25 @@ void POINT_EDITOR::setTransitions()
|
|||
}
|
||||
|
||||
|
||||
bool POINT_EDITOR::canAddCorner( const EDA_ITEM& aItem )
|
||||
{
|
||||
const auto type = aItem.Type();
|
||||
|
||||
// Works only for zones and line segments
|
||||
return type == PCB_ZONE_AREA_T ||
|
||||
( ( type == PCB_LINE_T || type == PCB_MODULE_EDGE_T ) &&
|
||||
static_cast<const DRAWSEGMENT&>( aItem ).GetShape() == S_SEGMENT );
|
||||
}
|
||||
|
||||
|
||||
bool POINT_EDITOR::addCornerCondition( const SELECTION& aSelection )
|
||||
{
|
||||
if( aSelection.Size() != 1 )
|
||||
return false;
|
||||
|
||||
auto item = aSelection.Front();
|
||||
const EDA_ITEM* item = aSelection.Front();
|
||||
|
||||
// Works only for zones and line segments
|
||||
return item->Type() == PCB_ZONE_AREA_T ||
|
||||
( ( item->Type() == PCB_LINE_T || item->Type() == PCB_MODULE_EDGE_T ) &&
|
||||
static_cast<DRAWSEGMENT*>( item )->GetShape() == S_SEGMENT );
|
||||
return ( item != nullptr ) && canAddCorner( *item );
|
||||
}
|
||||
|
||||
|
||||
|
@ -916,9 +924,17 @@ bool POINT_EDITOR::removeCornerCondition( const SELECTION& )
|
|||
|
||||
int POINT_EDITOR::addCorner( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
if( !m_editPoints )
|
||||
return 0;
|
||||
|
||||
EDA_ITEM* item = m_editPoints->GetParent();
|
||||
PCB_BASE_EDIT_FRAME* frame = getEditFrame<PCB_BASE_EDIT_FRAME>();
|
||||
const VECTOR2I& cursorPos = getViewControls()->GetCursorPosition();
|
||||
|
||||
// called without an active edited polygon
|
||||
if( !item || !canAddCorner( *item ) )
|
||||
return 0;
|
||||
|
||||
BOARD_COMMIT commit( frame );
|
||||
|
||||
if( item->Type() == PCB_ZONE_AREA_T )
|
||||
|
|
|
@ -129,6 +129,9 @@ private:
|
|||
///> Condition to display "Create corner" context menu entry.
|
||||
static bool addCornerCondition( const SELECTION& aSelection );
|
||||
|
||||
///> Determine if the tool can currently add a corner to the given item
|
||||
static bool canAddCorner( const EDA_ITEM& aItem );
|
||||
|
||||
///> Condition to display "Remove corner" context menu entry.
|
||||
bool removeCornerCondition( const SELECTION& aSelection );
|
||||
|
||||
|
|
Loading…
Reference in New Issue