Activate context menu in LIB_VIEW_FRAME canvas.
This commit is contained in:
parent
0979aadae8
commit
b8e2054b23
|
@ -29,6 +29,7 @@
|
|||
#include <sch_base_frame.h>
|
||||
#include <sch_edit_frame.h>
|
||||
#include <lib_edit_frame.h>
|
||||
#include <viewlib_frame.h>
|
||||
#include <sch_component.h>
|
||||
#include <sch_sheet.h>
|
||||
#include <sch_field.h>
|
||||
|
@ -161,6 +162,7 @@ EE_SELECTION_TOOL::EE_SELECTION_TOOL() :
|
|||
m_multiple( false ),
|
||||
m_skip_heuristics( false ),
|
||||
m_isLibEdit( false ),
|
||||
m_isLibView( false ),
|
||||
m_unit( 0 ),
|
||||
m_convert( 0 ),
|
||||
m_menu( *this )
|
||||
|
@ -179,6 +181,7 @@ bool EE_SELECTION_TOOL::Init()
|
|||
{
|
||||
m_frame = getEditFrame<SCH_BASE_FRAME>();
|
||||
|
||||
LIB_VIEW_FRAME* libViewFrame = dynamic_cast<LIB_VIEW_FRAME*>( m_frame );
|
||||
LIB_EDIT_FRAME* libEditFrame = dynamic_cast<LIB_EDIT_FRAME*>( m_frame );
|
||||
|
||||
if( libEditFrame )
|
||||
|
@ -187,6 +190,9 @@ bool EE_SELECTION_TOOL::Init()
|
|||
m_unit = libEditFrame->GetUnit();
|
||||
m_convert = libEditFrame->GetConvert();
|
||||
}
|
||||
else
|
||||
m_isLibView = libViewFrame != nullptr;
|
||||
|
||||
|
||||
static KICAD_T wireOrBusTypes[] = { SCH_LINE_LOCATE_WIRE_T, SCH_LINE_LOCATE_BUS_T, EOT };
|
||||
|
||||
|
@ -195,10 +201,10 @@ bool EE_SELECTION_TOOL::Init()
|
|||
auto wireOrBusSelection = E_C::MoreThan( 0 ) && E_C::OnlyTypes( wireOrBusTypes );
|
||||
auto sheetSelection = E_C::Count( 1 ) && E_C::OnlyType( SCH_SHEET_T );
|
||||
auto schEditCondition = [this] ( const SELECTION& aSel ) {
|
||||
return !m_isLibEdit;
|
||||
return !m_isLibEdit && !m_isLibView;
|
||||
};
|
||||
auto belowRootSheetCondition = [this] ( const SELECTION& aSel ) {
|
||||
return !m_isLibEdit && g_CurrentSheet->Last() != g_RootSheet;
|
||||
return !m_isLibEdit && !m_isLibView && g_CurrentSheet->Last() != g_RootSheet;
|
||||
};
|
||||
auto havePartCondition = [ this ] ( const SELECTION& sel ) {
|
||||
return m_isLibEdit && ( (LIB_EDIT_FRAME*) m_frame )->GetCurPart();
|
||||
|
@ -254,6 +260,7 @@ void EE_SELECTION_TOOL::Reset( RESET_REASON aReason )
|
|||
getView()->GetPainter()->GetSettings()->SetHighlight( false );
|
||||
|
||||
LIB_EDIT_FRAME* libEditFrame = dynamic_cast<LIB_EDIT_FRAME*>( m_frame );
|
||||
LIB_VIEW_FRAME* libViewFrame = dynamic_cast<LIB_VIEW_FRAME*>( m_frame );
|
||||
|
||||
if( libEditFrame )
|
||||
{
|
||||
|
@ -261,6 +268,8 @@ void EE_SELECTION_TOOL::Reset( RESET_REASON aReason )
|
|||
m_unit = libEditFrame->GetUnit();
|
||||
m_convert = libEditFrame->GetConvert();
|
||||
}
|
||||
else
|
||||
m_isLibView = libViewFrame != nullptr;
|
||||
}
|
||||
else
|
||||
// Restore previous properties of selected items and remove them from containers
|
||||
|
|
|
@ -242,7 +242,8 @@ private:
|
|||
bool m_multiple; // Multiple selection mode is active
|
||||
bool m_skip_heuristics; // Heuristics are not allowed when choosing item under cursor
|
||||
|
||||
bool m_isLibEdit;
|
||||
bool m_isLibEdit; // True when libedit is the parent frame
|
||||
bool m_isLibView; // True when libview is the parent frame
|
||||
int m_unit; // Fixed unit filter (for symbol editor)
|
||||
int m_convert; // Fixed DeMorgan filter (for symbol editor)
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
#include <tool/common_tools.h>
|
||||
#include <tool/zoom_tool.h>
|
||||
#include <tools/lib_control.h>
|
||||
#include <tools/lib_move_tool.h>
|
||||
|
||||
// Save previous component library viewer state.
|
||||
wxString LIB_VIEW_FRAME::m_libraryName;
|
||||
|
@ -137,11 +138,12 @@ LIB_VIEW_FRAME::LIB_VIEW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame
|
|||
|
||||
// Synchronize some draw options
|
||||
SetShowElectricalType( true );
|
||||
GetRenderSettings()->m_ShowPinsElectricalType = GetShowElectricalType();
|
||||
|
||||
// Ensure axis are always drawn (initial default display was not drawn)
|
||||
KIGFX::GAL_DISPLAY_OPTIONS& gal_opts = GetGalDisplayOptions();
|
||||
gal_opts.m_axesEnabled = true;
|
||||
GetGalCanvas()->GetGAL()->SetAxesEnabled( true );
|
||||
GetRenderSettings()->m_ShowPinsElectricalType = GetShowElectricalType();
|
||||
GetGalCanvas()->GetGAL()->SetGridVisibility( IsGridVisible() );
|
||||
|
||||
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
|
||||
|
||||
|
@ -201,8 +203,6 @@ LIB_VIEW_FRAME::LIB_VIEW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame
|
|||
|
||||
SyncView();
|
||||
GetGalCanvas()->GetViewControls()->SetSnapping( true );
|
||||
GetGalCanvas()->GetGAL()->SetAxesEnabled( true );
|
||||
GetGalCanvas()->GetGAL()->SetGridVisibility( IsGridVisible() );
|
||||
|
||||
// Set the working/draw area size to display a symbol to a reasonable value:
|
||||
// A 450mm x 450mm with a origin at the area center looks like a large working area
|
||||
|
@ -234,11 +234,16 @@ void LIB_VIEW_FRAME::setupTools()
|
|||
// Register tools
|
||||
m_toolManager->RegisterTool( new COMMON_TOOLS );
|
||||
m_toolManager->RegisterTool( new ZOOM_TOOL );
|
||||
m_toolManager->RegisterTool( new EE_SELECTION_TOOL );
|
||||
m_toolManager->RegisterTool( new LIB_CONTROL );
|
||||
m_toolManager->RegisterTool( new EE_SELECTION_TOOL ); // manage context menu
|
||||
m_toolManager->RegisterTool( new LIB_CONTROL ); // manage show electrical type option
|
||||
m_toolManager->RegisterTool( new LIB_MOVE_TOOL );
|
||||
|
||||
m_toolManager->InitTools();
|
||||
|
||||
// Run the selection tool, it is supposed to be always active
|
||||
// It also manages the mouse right click to show the context menu
|
||||
m_toolManager->InvokeTool( "eeschema.InteractiveSelection" );
|
||||
|
||||
GetCanvas()->SetEventDispatcher( m_toolDispatcher );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue