Improve context menu consistency.
Also fixes some interactivity issues in the microwave tools around single-click tools that have initial properties dialogs. Those need to act kind of like a hybrid between single-click and two-click tools. Fixes: lp:1751381 * https://bugs.launchpad.net/kicad/+bug/1751381
This commit is contained in:
parent
d6c6322f95
commit
c655bffac1
|
@ -43,6 +43,7 @@
|
||||||
|
|
||||||
#include "length_tuner_tool.h"
|
#include "length_tuner_tool.h"
|
||||||
#include <bitmaps.h>
|
#include <bitmaps.h>
|
||||||
|
#include <tools/tool_event_utils.h>
|
||||||
|
|
||||||
using namespace KIGFX;
|
using namespace KIGFX;
|
||||||
|
|
||||||
|
@ -94,10 +95,9 @@ public:
|
||||||
SetIcon( router_len_tuner_xpm );
|
SetIcon( router_len_tuner_xpm );
|
||||||
DisplayTitle( true );
|
DisplayTitle( true );
|
||||||
|
|
||||||
//Add( ACT_StartTuning );
|
Add( ACTIONS::cancelInteractive );
|
||||||
//Add( ACT_EndTuning );
|
|
||||||
|
|
||||||
//AppendSeparator();
|
AppendSeparator();
|
||||||
|
|
||||||
Add( ACT_SpacingIncrease );
|
Add( ACT_SpacingIncrease );
|
||||||
Add( ACT_SpacingDecrease );
|
Add( ACT_SpacingDecrease );
|
||||||
|
@ -172,7 +172,7 @@ void LENGTH_TUNER_TOOL::performTuning()
|
||||||
|
|
||||||
while( OPT_TOOL_EVENT evt = Wait() )
|
while( OPT_TOOL_EVENT evt = Wait() )
|
||||||
{
|
{
|
||||||
if( evt->IsCancel() || evt->IsActivate() )
|
if( evt->IsCancel() || evt->IsActivate() || TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
||||||
break;
|
break;
|
||||||
else if( evt->IsMotion() )
|
else if( evt->IsMotion() )
|
||||||
{
|
{
|
||||||
|
@ -278,7 +278,7 @@ int LENGTH_TUNER_TOOL::mainLoop( PNS::ROUTER_MODE aMode )
|
||||||
// Main loop: keep receiving events
|
// Main loop: keep receiving events
|
||||||
while( OPT_TOOL_EVENT evt = Wait() )
|
while( OPT_TOOL_EVENT evt = Wait() )
|
||||||
{
|
{
|
||||||
if( evt->IsCancel() || evt->IsActivate() )
|
if( evt->IsCancel() || evt->IsActivate() || TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
||||||
{
|
{
|
||||||
break; // Finish
|
break; // Finish
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,8 +152,7 @@ DRAWING_TOOL::DRAWING_TOOL() :
|
||||||
PCB_TOOL( "pcbnew.InteractiveDrawing" ),
|
PCB_TOOL( "pcbnew.InteractiveDrawing" ),
|
||||||
m_view( nullptr ), m_controls( nullptr ),
|
m_view( nullptr ), m_controls( nullptr ),
|
||||||
m_board( nullptr ), m_frame( nullptr ), m_mode( MODE::NONE ),
|
m_board( nullptr ), m_frame( nullptr ), m_mode( MODE::NONE ),
|
||||||
m_lineWidth( 1 ),
|
m_lineWidth( 1 )
|
||||||
m_menu( *this )
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,14 +180,15 @@ bool DRAWING_TOOL::Init()
|
||||||
|
|
||||||
auto& ctxMenu = m_menu.GetMenu();
|
auto& ctxMenu = m_menu.GetMenu();
|
||||||
|
|
||||||
// cancel current toool goes in main context menu at the top if present
|
// cancel current tool goes in main context menu at the top if present
|
||||||
ctxMenu.AddItem( ACTIONS::cancelInteractive, activeToolFunctor, 1000 );
|
ctxMenu.AddItem( ACTIONS::cancelInteractive, activeToolFunctor, 1 );
|
||||||
|
ctxMenu.AddSeparator( activeToolFunctor, 1 );
|
||||||
|
|
||||||
// tool-specific actions
|
// tool-specific actions
|
||||||
ctxMenu.AddItem( closeZoneOutline, zoneActiveFunctor, 1000 );
|
ctxMenu.AddItem( closeZoneOutline, zoneActiveFunctor, 200 );
|
||||||
ctxMenu.AddItem( deleteLastPoint, canUndoPoint, 1000 );
|
ctxMenu.AddItem( deleteLastPoint, canUndoPoint, 200 );
|
||||||
|
|
||||||
ctxMenu.AddSeparator( activeToolFunctor, 1000 );
|
ctxMenu.AddSeparator( canUndoPoint, 500 );
|
||||||
|
|
||||||
// Type-specific sub-menus will be added for us by other tools
|
// Type-specific sub-menus will be added for us by other tools
|
||||||
// For example, zone fill/unfill is provided by the PCB control tool
|
// For example, zone fill/unfill is provided by the PCB control tool
|
||||||
|
@ -1688,6 +1688,8 @@ int DRAWING_TOOL::DrawVia( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
VIA_PLACER placer( frame() );
|
VIA_PLACER placer( frame() );
|
||||||
|
|
||||||
|
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::VIA );
|
||||||
|
|
||||||
frame()->SetToolID( ID_PCB_DRAW_VIA_BUTT, wxCURSOR_PENCIL, _( "Add vias" ) );
|
frame()->SetToolID( ID_PCB_DRAW_VIA_BUTT, wxCURSOR_PENCIL, _( "Add vias" ) );
|
||||||
|
|
||||||
doInteractiveItemPlacement( &placer, _( "Place via" ),
|
doInteractiveItemPlacement( &placer, _( "Place via" ),
|
||||||
|
|
|
@ -77,7 +77,8 @@ public:
|
||||||
DIMENSION,
|
DIMENSION,
|
||||||
KEEPOUT,
|
KEEPOUT,
|
||||||
ZONE,
|
ZONE,
|
||||||
GRAPHIC_POLYGON
|
GRAPHIC_POLYGON,
|
||||||
|
VIA
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -280,9 +281,6 @@ private:
|
||||||
/// Stores the current line width for multisegment drawing.
|
/// Stores the current line width for multisegment drawing.
|
||||||
unsigned int m_lineWidth;
|
unsigned int m_lineWidth;
|
||||||
|
|
||||||
/// Menu model displayed by the tool.
|
|
||||||
TOOL_MENU m_menu;
|
|
||||||
|
|
||||||
// How does line width change after one -/+ key press.
|
// How does line width change after one -/+ key press.
|
||||||
static const unsigned int WIDTH_STEP;
|
static const unsigned int WIDTH_STEP;
|
||||||
|
|
||||||
|
|
|
@ -237,8 +237,7 @@ void EnsureEditableFilter( const VECTOR2I&, GENERAL_COLLECTOR& aCollector )
|
||||||
|
|
||||||
EDIT_TOOL::EDIT_TOOL() :
|
EDIT_TOOL::EDIT_TOOL() :
|
||||||
PCB_TOOL( "pcbnew.InteractiveEdit" ), m_selectionTool( NULL ),
|
PCB_TOOL( "pcbnew.InteractiveEdit" ), m_selectionTool( NULL ),
|
||||||
m_dragging( false ),
|
m_dragging( false )
|
||||||
m_measureMenu( *this )
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -319,16 +318,6 @@ bool EDIT_TOOL::Init()
|
||||||
menu.AddItem( PCB_ACTIONS::updateFootprints, singleModuleCondition );
|
menu.AddItem( PCB_ACTIONS::updateFootprints, singleModuleCondition );
|
||||||
menu.AddItem( PCB_ACTIONS::exchangeFootprints, singleModuleCondition );
|
menu.AddItem( PCB_ACTIONS::exchangeFootprints, singleModuleCondition );
|
||||||
|
|
||||||
// Initialize menu for Measurement Tool
|
|
||||||
auto& ctxMenu = m_measureMenu.GetMenu();
|
|
||||||
|
|
||||||
// cancel current toool goes in main context menu at the top if present
|
|
||||||
ctxMenu.AddItem( ACTIONS::cancelInteractive, SELECTION_CONDITIONS::ShowAlways, 1000 );
|
|
||||||
ctxMenu.AddSeparator( SELECTION_CONDITIONS::ShowAlways, 1000 );
|
|
||||||
|
|
||||||
// Finally, add the standard zoom/grid items
|
|
||||||
m_measureMenu.AddStandardSubMenus( *getEditFrame<PCB_BASE_FRAME>() );
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1304,7 +1293,7 @@ int EDIT_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
else if( evt->IsClick( BUT_RIGHT ) )
|
else if( evt->IsClick( BUT_RIGHT ) )
|
||||||
{
|
{
|
||||||
m_measureMenu.ShowContextMenu();
|
m_menu.ShowContextMenu();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -194,9 +194,6 @@ private:
|
||||||
///> of edit reference point).
|
///> of edit reference point).
|
||||||
VECTOR2I m_cursor;
|
VECTOR2I m_cursor;
|
||||||
|
|
||||||
///> A context menu for the Measurement Tool
|
|
||||||
TOOL_MENU m_measureMenu;
|
|
||||||
|
|
||||||
///> Returns the right modification point (e.g. for rotation), depending on the number of
|
///> Returns the right modification point (e.g. for rotation), depending on the number of
|
||||||
///> selected items.
|
///> selected items.
|
||||||
bool updateModificationPoint( SELECTION& aSelection );
|
bool updateModificationPoint( SELECTION& aSelection );
|
||||||
|
|
|
@ -91,8 +91,7 @@ TOOL_ACTION PCB_ACTIONS::microwaveCreateLine(
|
||||||
|
|
||||||
|
|
||||||
MICROWAVE_TOOL::MICROWAVE_TOOL() :
|
MICROWAVE_TOOL::MICROWAVE_TOOL() :
|
||||||
PCB_TOOL( "pcbnew.MicrowaveTool" ),
|
PCB_TOOL( "pcbnew.MicrowaveTool" )
|
||||||
m_menu( *this )
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,24 +105,6 @@ void MICROWAVE_TOOL::Reset( RESET_REASON aReason )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool MICROWAVE_TOOL::Init()
|
|
||||||
{
|
|
||||||
auto activeToolFunctor = [] ( const SELECTION& aSel ) {
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
auto& ctxMenu = m_menu.GetMenu();
|
|
||||||
|
|
||||||
// cancel current goes in main context menu at the top if present
|
|
||||||
ctxMenu.AddItem( ACTIONS::cancelInteractive, activeToolFunctor, 1000 );
|
|
||||||
ctxMenu.AddSeparator( activeToolFunctor, 1000 );
|
|
||||||
|
|
||||||
m_menu.AddStandardSubMenus( *getEditFrame<PCB_BASE_FRAME>() );
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
struct MICROWAVE_TOOL_INFO
|
struct MICROWAVE_TOOL_INFO
|
||||||
{
|
{
|
||||||
using MOD_CREATOR = std::function<std::unique_ptr<MODULE>()>;
|
using MOD_CREATOR = std::function<std::unique_ptr<MODULE>()>;
|
||||||
|
@ -226,7 +207,8 @@ int MICROWAVE_TOOL::addMicrowaveFootprint( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
MICROWAVE_PLACER placer ( info );
|
MICROWAVE_PLACER placer ( info );
|
||||||
|
|
||||||
doInteractiveItemPlacement( &placer, _( "Place microwave feature" ) );
|
doInteractiveItemPlacement( &placer, _( "Place microwave feature" ),
|
||||||
|
IPO_REPEAT | IPO_SINGLE_CLICK | IPO_ROTATE | IPO_FLIP | IPO_PROPERTIES );
|
||||||
|
|
||||||
frame.SetNoToolSelected();
|
frame.SetNoToolSelected();
|
||||||
|
|
||||||
|
|
|
@ -43,9 +43,6 @@ public:
|
||||||
///> React to model/view changes
|
///> React to model/view changes
|
||||||
void Reset( RESET_REASON aReason ) override;
|
void Reset( RESET_REASON aReason ) override;
|
||||||
|
|
||||||
///> Basic initalization
|
|
||||||
bool Init() override;
|
|
||||||
|
|
||||||
///> Bind handlers to corresponding TOOL_ACTIONs
|
///> Bind handlers to corresponding TOOL_ACTIONs
|
||||||
void setTransitions() override;
|
void setTransitions() override;
|
||||||
|
|
||||||
|
@ -59,9 +56,6 @@ private:
|
||||||
|
|
||||||
///> Draw a microwave inductor interactively
|
///> Draw a microwave inductor interactively
|
||||||
int drawMicrowaveInductor( const TOOL_EVENT& aEvent );
|
int drawMicrowaveInductor( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
/// Menu model displayed by the tool.
|
|
||||||
TOOL_MENU m_menu;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -308,10 +308,10 @@ bool PCB_EDITOR_CONTROL::Init()
|
||||||
toolMenu.AddSubMenu( lockMenu );
|
toolMenu.AddSubMenu( lockMenu );
|
||||||
|
|
||||||
menu.AddMenu( zoneMenu.get(), false,
|
menu.AddMenu( zoneMenu.get(), false,
|
||||||
SELECTION_CONDITIONS::OnlyType( PCB_ZONE_AREA_T ) );
|
SELECTION_CONDITIONS::OnlyType( PCB_ZONE_AREA_T ), 200 );
|
||||||
|
|
||||||
menu.AddMenu( lockMenu.get(), false,
|
menu.AddMenu( lockMenu.get(), false,
|
||||||
SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::LockableItems ) );
|
SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::LockableItems ), 200 );
|
||||||
}
|
}
|
||||||
|
|
||||||
DRAWING_TOOL* drawingTool = m_toolMgr->GetTool<DRAWING_TOOL>();
|
DRAWING_TOOL* drawingTool = m_toolMgr->GetTool<DRAWING_TOOL>();
|
||||||
|
@ -333,7 +333,7 @@ bool PCB_EDITOR_CONTROL::Init()
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
menu.AddMenu( zoneMenu.get(), false, toolActiveFunctor( DRAWING_TOOL::MODE::ZONE ) );
|
menu.AddMenu( zoneMenu.get(), false, toolActiveFunctor( DRAWING_TOOL::MODE::ZONE ), 200 );
|
||||||
}
|
}
|
||||||
|
|
||||||
m_ratsnestTimer.SetOwner( this );
|
m_ratsnestTimer.SetOwner( this );
|
||||||
|
|
|
@ -61,7 +61,7 @@ void PCB_TOOL::doInteractiveItemPlacement( INTERACTIVE_PLACER_BASE* aPlacer,
|
||||||
aPlacer->m_frame = frame();
|
aPlacer->m_frame = frame();
|
||||||
aPlacer->m_modifiers = 0;
|
aPlacer->m_modifiers = 0;
|
||||||
|
|
||||||
if( aOptions & IPO_SINGLE_CLICK )
|
if( aOptions & IPO_SINGLE_CLICK && !( aOptions & IPO_PROPERTIES ) )
|
||||||
{
|
{
|
||||||
VECTOR2I cursorPos = controls()->GetCursorPosition();
|
VECTOR2I cursorPos = controls()->GetCursorPosition();
|
||||||
|
|
||||||
|
@ -101,7 +101,6 @@ void PCB_TOOL::doInteractiveItemPlacement( INTERACTIVE_PLACER_BASE* aPlacer,
|
||||||
if( evt->IsActivate() ) // now finish unconditionally
|
if( evt->IsActivate() ) // now finish unconditionally
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if( evt->IsClick( BUT_LEFT ) )
|
else if( evt->IsClick( BUT_LEFT ) )
|
||||||
{
|
{
|
||||||
if( !newItem )
|
if( !newItem )
|
||||||
|
@ -151,7 +150,7 @@ void PCB_TOOL::doInteractiveItemPlacement( INTERACTIVE_PLACER_BASE* aPlacer,
|
||||||
if( !( aOptions & IPO_REPEAT ) )
|
if( !( aOptions & IPO_REPEAT ) )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if( aOptions & IPO_SINGLE_CLICK )
|
if( aOptions & IPO_SINGLE_CLICK && !( aOptions & IPO_PROPERTIES ) )
|
||||||
{
|
{
|
||||||
VECTOR2I pos = controls()->GetCursorPosition();
|
VECTOR2I pos = controls()->GetCursorPosition();
|
||||||
|
|
||||||
|
@ -162,7 +161,10 @@ void PCB_TOOL::doInteractiveItemPlacement( INTERACTIVE_PLACER_BASE* aPlacer,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if( evt->IsClick( BUT_RIGHT ) )
|
||||||
|
{
|
||||||
|
m_menu.ShowContextMenu();
|
||||||
|
}
|
||||||
else if( newItem && evt->Category() == TC_COMMAND )
|
else if( newItem && evt->Category() == TC_COMMAND )
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
@ -198,6 +200,23 @@ void PCB_TOOL::doInteractiveItemPlacement( INTERACTIVE_PLACER_BASE* aPlacer,
|
||||||
view()->Remove( &preview );
|
view()->Remove( &preview );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PCB_TOOL::Init()
|
||||||
|
{
|
||||||
|
// A basic context manu. Many (but not all) tools will choose to override this.
|
||||||
|
|
||||||
|
auto& ctxMenu = m_menu.GetMenu();
|
||||||
|
|
||||||
|
// cancel current tool goes in main context menu at the top if present
|
||||||
|
ctxMenu.AddItem( ACTIONS::cancelInteractive, SELECTION_CONDITIONS::ShowAlways, 1 );
|
||||||
|
ctxMenu.AddSeparator( SELECTION_CONDITIONS::ShowAlways, 1 );
|
||||||
|
|
||||||
|
// Finally, add the standard zoom/grid items
|
||||||
|
m_menu.AddStandardSubMenus( *getEditFrame<PCB_BASE_FRAME>() );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void PCB_TOOL::Reset( RESET_REASON aReason )
|
void PCB_TOOL::Reset( RESET_REASON aReason )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
#include <pcb_view.h>
|
#include <pcb_view.h>
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <tool/tool_menu.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class PCB_TOOL
|
* Class PCB_TOOL
|
||||||
|
@ -70,6 +70,7 @@ public:
|
||||||
* Creates a tool with given id & name. The name must be unique. */
|
* Creates a tool with given id & name. The name must be unique. */
|
||||||
PCB_TOOL( TOOL_ID aId, const std::string& aName ) :
|
PCB_TOOL( TOOL_ID aId, const std::string& aName ) :
|
||||||
TOOL_INTERACTIVE ( aId, aName ),
|
TOOL_INTERACTIVE ( aId, aName ),
|
||||||
|
m_menu( *this ),
|
||||||
m_editModules( false ) {};
|
m_editModules( false ) {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -78,10 +79,12 @@ public:
|
||||||
* Creates a tool with given name. The name must be unique. */
|
* Creates a tool with given name. The name must be unique. */
|
||||||
PCB_TOOL( const std::string& aName ) :
|
PCB_TOOL( const std::string& aName ) :
|
||||||
TOOL_INTERACTIVE ( aName ),
|
TOOL_INTERACTIVE ( aName ),
|
||||||
|
m_menu( *this ),
|
||||||
m_editModules( false ) {};
|
m_editModules( false ) {};
|
||||||
|
|
||||||
virtual ~PCB_TOOL() {};
|
virtual ~PCB_TOOL() {};
|
||||||
|
|
||||||
|
virtual bool Init() override;
|
||||||
virtual void Reset( RESET_REASON aReason ) override;
|
virtual void Reset( RESET_REASON aReason ) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -141,6 +144,9 @@ protected:
|
||||||
const SELECTION& selection() const;
|
const SELECTION& selection() const;
|
||||||
SELECTION& selection();
|
SELECTION& selection();
|
||||||
|
|
||||||
|
/// Menu model displayed by the tool.
|
||||||
|
TOOL_MENU m_menu;
|
||||||
|
|
||||||
bool m_editModules;
|
bool m_editModules;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue