Add display options to Symbol Browser toolbar.

Particularly important on Mac where the menubar is disabled when the
frame is used in modal mode.

Also adds a display control to override the symbol's show pin numbers
setting.

Fixes https://gitlab.com/kicad/code/kicad/issues/7789
This commit is contained in:
Jeff Young 2022-09-06 17:28:44 +01:00
parent f4de7bfc48
commit b874aaac5e
12 changed files with 82 additions and 35 deletions

View File

@ -149,6 +149,7 @@ void SCH_EDIT_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
}
GetRenderSettings()->m_ShowPinsElectricalType = false;
GetRenderSettings()->m_ShowPinNumbers = false;
}

View File

@ -196,6 +196,7 @@ public:
int lib_list_width;
int cmp_list_width;
bool show_pin_electrical_type;
bool show_pin_numbers;
WINDOW_SETTINGS window;
};

View File

@ -95,6 +95,7 @@ SCH_RENDER_SETTINGS::SCH_RENDER_SETTINGS() :
m_ShowUnit( 0 ),
m_ShowConvert( 0 ),
m_ShowPinsElectricalType( true ),
m_ShowPinNumbers( false ),
m_ShowDisabled( false ),
m_ShowGraphicsDisabled( false ),
m_OverrideItemColors( false ),
@ -1323,6 +1324,8 @@ void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer )
int textOffset = libEntry->GetPinNameOffset();
float nameStrokeWidth = getLineWidth( aPin, drawingShadows );
float numStrokeWidth = getLineWidth( aPin, drawingShadows );
bool showPinNames = libEntry->ShowPinNames();
bool showPinNumbers = m_schSettings.m_ShowPinNumbers || libEntry->ShowPinNumbers();
nameStrokeWidth = Clamp_Text_PenSize( nameStrokeWidth, aPin->GetNameTextSize(), false );
numStrokeWidth = Clamp_Text_PenSize( numStrokeWidth, aPin->GetNumberTextSize(), false );
@ -1339,12 +1342,12 @@ void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer )
// TextOffset > 0 means pin NAMES on inside, pin NUMBERS above and nothing below
if( textOffset )
{
size [INSIDE] = libEntry->ShowPinNames() ? aPin->GetNameTextSize() : 0;
size [INSIDE] = showPinNames ? aPin->GetNameTextSize() : 0;
thickness[INSIDE] = nameStrokeWidth;
colour [INSIDE] = getRenderColor( aPin, LAYER_PINNAM, drawingShadows );
text [INSIDE] = aPin->GetShownName();
size [ABOVE] = libEntry->ShowPinNumbers() ? aPin->GetNumberTextSize() : 0;
size [ABOVE] = showPinNumbers ? aPin->GetNumberTextSize() : 0;
thickness[ABOVE] = numStrokeWidth;
colour [ABOVE] = getRenderColor( aPin, LAYER_PINNUM, drawingShadows );
text [ABOVE] = aPin->GetShownNumber();
@ -1352,12 +1355,12 @@ void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer )
// Otherwise pin NAMES go above and pin NUMBERS go below
else
{
size [ABOVE] = libEntry->ShowPinNames() ? aPin->GetNameTextSize() : 0;
size [ABOVE] = showPinNames ? aPin->GetNameTextSize() : 0;
thickness[ABOVE] = nameStrokeWidth;
colour [ABOVE] = getRenderColor( aPin, LAYER_PINNAM, drawingShadows );
text [ABOVE] = aPin->GetShownName();
size [BELOW] = libEntry->ShowPinNumbers() ? aPin->GetNumberTextSize() : 0;
size [BELOW] = showPinNumbers ? aPin->GetNumberTextSize() : 0;
thickness[BELOW] = numStrokeWidth;
colour [BELOW] = getRenderColor( aPin, LAYER_PINNUM, drawingShadows );
text [BELOW] = aPin->GetShownNumber();

View File

@ -110,10 +110,11 @@ public:
public:
bool m_IsSymbolEditor;
int m_ShowUnit; // Show all units if 0
int m_ShowConvert; // Show all conversions if 0
int m_ShowUnit; // Show all units if 0
int m_ShowConvert; // Show all conversions if 0
bool m_ShowPinsElectricalType;
bool m_ShowPinNumbers; // Force showing of pin numbers (normally symbol-specific)
bool m_ShowDisabled;
bool m_ShowGraphicsDisabled;

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2018-2019 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2018-2022 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -57,6 +57,7 @@ SCH_PREVIEW_PANEL::SCH_PREVIEW_PANEL( wxWindow* aParentWindow, wxWindowID aWindo
KIGFX::SCH_RENDER_SETTINGS* renderSettings = GetRenderSettings();
renderSettings->LoadColors( Pgm().GetSettingsManager().GetColorSettings() );
renderSettings->m_ShowPinsElectricalType = false;
renderSettings->m_ShowPinNumbers = false;
renderSettings->m_TextOffsetRatio = 0.35;
m_view->SetPainter( m_painter.get() );

View File

@ -314,9 +314,9 @@ void SYMBOL_VIEWER_FRAME::setupTools()
m_toolManager->RegisterTool( new COMMON_TOOLS );
m_toolManager->RegisterTool( new COMMON_CONTROL );
m_toolManager->RegisterTool( new ZOOM_TOOL );
m_toolManager->RegisterTool( new EE_INSPECTION_TOOL ); // manage show datasheet
m_toolManager->RegisterTool( new EE_SELECTION_TOOL ); // manage context menu
m_toolManager->RegisterTool( new SYMBOL_EDITOR_CONTROL );
m_toolManager->RegisterTool( new EE_INSPECTION_TOOL ); // manage show datasheet
m_toolManager->RegisterTool( new EE_SELECTION_TOOL ); // manage context menu
m_toolManager->RegisterTool( new SYMBOL_EDITOR_CONTROL ); // manage render settings
m_toolManager->InitTools();
@ -343,41 +343,48 @@ void SYMBOL_VIEWER_FRAME::setupUIConditions()
mgr->SetConditions( ACTIONS::toggleGrid, CHECK( cond.GridVisible() ) );
auto electricalTypesShownCondition =
[this] ( const SELECTION& aSel )
{
return GetRenderSettings()->m_ShowPinsElectricalType;
};
[this]( const SELECTION& aSel )
{
return GetRenderSettings()->m_ShowPinsElectricalType;
};
auto pinNumbersShownCondition =
[this]( const SELECTION& )
{
return GetRenderSettings()->m_ShowPinNumbers;
};
auto demorganCond =
[this] ( const SELECTION& )
{
LIB_SYMBOL* symbol = GetSelectedSymbol();
[this]( const SELECTION& )
{
LIB_SYMBOL* symbol = GetSelectedSymbol();
return symbol && symbol->HasConversion();
};
return symbol && symbol->HasConversion();
};
auto demorganStandardCond =
[] ( const SELECTION& )
{
return m_convert == LIB_ITEM::LIB_CONVERT::BASE;
};
[]( const SELECTION& )
{
return m_convert == LIB_ITEM::LIB_CONVERT::BASE;
};
auto demorganAlternateCond =
[] ( const SELECTION& )
{
return m_convert == LIB_ITEM::LIB_CONVERT::DEMORGAN;
};
[]( const SELECTION& )
{
return m_convert == LIB_ITEM::LIB_CONVERT::DEMORGAN;
};
auto haveDatasheetCond =
[this] ( const SELECTION& )
{
LIB_SYMBOL* symbol = GetSelectedSymbol();
[this]( const SELECTION& )
{
LIB_SYMBOL* symbol = GetSelectedSymbol();
return symbol && !symbol->GetDatasheetField().GetText().IsEmpty();
};
return symbol && !symbol->GetDatasheetField().GetText().IsEmpty();
};
mgr->SetConditions( EE_ACTIONS::showDatasheet, ENABLE( haveDatasheetCond ) );
mgr->SetConditions( EE_ACTIONS::showElectricalTypes, CHECK( electricalTypesShownCondition ) );
mgr->SetConditions( EE_ACTIONS::showPinNumbers, CHECK( pinNumbersShownCondition ) );
mgr->SetConditions( EE_ACTIONS::showDeMorganStandard,
ACTION_CONDITIONS().Enable( demorganCond ).Check( demorganStandardCond ) );
@ -833,6 +840,7 @@ void SYMBOL_VIEWER_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
m_symbolListWidth = cfg->m_LibViewPanel.cmp_list_width;
GetRenderSettings()->m_ShowPinsElectricalType = cfg->m_LibViewPanel.show_pin_electrical_type;
GetRenderSettings()->m_ShowPinNumbers = cfg->m_LibViewPanel.show_pin_numbers;
// Set parameters to a reasonable value.
int maxWidth = cfg->m_LibViewPanel.window.state.size_x - 80;
@ -859,8 +867,11 @@ void SYMBOL_VIEWER_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg)
cfg->m_LibViewPanel.lib_list_width = m_libListWidth;
cfg->m_LibViewPanel.cmp_list_width = m_symbolListWidth;
if( GetRenderSettings() )
cfg->m_LibViewPanel.show_pin_electrical_type = GetRenderSettings()->m_ShowPinsElectricalType;
if( KIGFX::SCH_RENDER_SETTINGS* renderSettings = GetRenderSettings() )
{
cfg->m_LibViewPanel.show_pin_electrical_type = renderSettings->m_ShowPinsElectricalType;
cfg->m_LibViewPanel.show_pin_numbers = renderSettings->m_ShowPinNumbers;
}
}

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2004-2022 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2019 CERN
*
* This program is free software: you can redistribute it and/or modify it
@ -64,6 +64,10 @@ void SYMBOL_VIEWER_FRAME::ReCreateHToolbar()
m_mainToolBar->Add( ACTIONS::zoomOutCenter );
m_mainToolBar->Add( ACTIONS::zoomFitScreen );
m_mainToolBar->AddScaledSeparator( this );
m_mainToolBar->Add( EE_ACTIONS::showElectricalTypes, ACTION_TOOLBAR::TOGGLE );
m_mainToolBar->Add( EE_ACTIONS::showPinNumbers, ACTION_TOOLBAR::TOGGLE );
m_mainToolBar->AddScaledSeparator( this );
m_mainToolBar->Add( EE_ACTIONS::showDeMorganStandard, ACTION_TOOLBAR::TOGGLE );
m_mainToolBar->Add( EE_ACTIONS::showDeMorganAlternate, ACTION_TOOLBAR::TOGGLE );
@ -123,6 +127,7 @@ void SYMBOL_VIEWER_FRAME::ReCreateMenuBar()
viewMenu->AppendSeparator();
viewMenu->Add( EE_ACTIONS::showElectricalTypes, ACTION_MENU::CHECK );
viewMenu->Add( EE_ACTIONS::showPinNumbers, ACTION_MENU::CHECK );
//-- Menubar -------------------------------------------------------------

View File

@ -192,6 +192,11 @@ TOOL_ACTION EE_ACTIONS::showElectricalTypes( "eeschema.SymbolLibraryControl.show
_( "Show Pin Electrical Types" ), _( "Annotate pins with their electrical types" ),
BITMAPS::pin_show_etype );
TOOL_ACTION EE_ACTIONS::showPinNumbers( "eeschema.SymbolLibraryControl.showPinNumbers",
AS_GLOBAL, 0, "",
_( "Show Pin Numbers" ), _( "Annotate pins with their numbers" ),
BITMAPS::pin );
TOOL_ACTION EE_ACTIONS::showSymbolTree( "eeschema.SymbolLibraryControl.showSymbolTree",
AS_GLOBAL, 0, "",
_( "Show Symbol Tree" ), "",

View File

@ -221,6 +221,7 @@ public:
static TOOL_ACTION pushPinNameSize;
static TOOL_ACTION pushPinNumSize;
static TOOL_ACTION showElectricalTypes;
static TOOL_ACTION showPinNumbers;
static TOOL_ACTION showSymbolTree;
static TOOL_ACTION hideSymbolTree;
static TOOL_ACTION drawSheetOnClipboard;

View File

@ -492,6 +492,19 @@ int SYMBOL_EDITOR_CONTROL::ShowElectricalTypes( const TOOL_EVENT& aEvent )
}
int SYMBOL_EDITOR_CONTROL::ShowPinNumbers( const TOOL_EVENT& aEvent )
{
KIGFX::SCH_RENDER_SETTINGS* renderSettings = m_frame->GetRenderSettings();
renderSettings->m_ShowPinNumbers = !renderSettings->m_ShowPinNumbers;
// Update canvas
m_frame->GetCanvas()->GetView()->UpdateAllItems( KIGFX::REPAINT );
m_frame->GetCanvas()->Refresh();
return 0;
}
int SYMBOL_EDITOR_CONTROL::ToggleSyncedPinsMode( const TOOL_EVENT& aEvent )
{
if( !m_isSymbolEditor )
@ -687,6 +700,7 @@ void SYMBOL_EDITOR_CONTROL::setTransitions()
Go( &SYMBOL_EDITOR_CONTROL::OnDeMorgan, EE_ACTIONS::showDeMorganAlternate.MakeEvent() );
Go( &SYMBOL_EDITOR_CONTROL::ShowElectricalTypes, EE_ACTIONS::showElectricalTypes.MakeEvent() );
Go( &SYMBOL_EDITOR_CONTROL::ShowPinNumbers, EE_ACTIONS::showPinNumbers.MakeEvent() );
Go( &SYMBOL_EDITOR_CONTROL::PinLibrary, ACTIONS::pinLibrary.MakeEvent() );
Go( &SYMBOL_EDITOR_CONTROL::UnpinLibrary, ACTIONS::unpinLibrary.MakeEvent() );
Go( &SYMBOL_EDITOR_CONTROL::ToggleSymbolTree, EE_ACTIONS::showSymbolTree.MakeEvent() );

View File

@ -64,6 +64,7 @@ public:
int OnDeMorgan( const TOOL_EVENT& aEvent );
int ShowElectricalTypes( const TOOL_EVENT& aEvent );
int ShowPinNumbers( const TOOL_EVENT& aEvent );
int PinLibrary( const TOOL_EVENT& aEvent );
int UnpinLibrary( const TOOL_EVENT& aEvent );
int ToggleSymbolTree( const TOOL_EVENT& aEvent );

View File

@ -77,6 +77,9 @@ SYMBOL_PREVIEW_WIDGET::SYMBOL_PREVIEW_WIDGET( wxWindow* aParent, KIWAY& aKiway,
m_preview->GetGAL()->SetClearColor( backgroundColor );
settings->m_ShowPinsElectricalType = app_settings->m_LibViewPanel.show_pin_electrical_type;
settings->m_ShowPinNumbers = app_settings->m_LibViewPanel.show_pin_numbers;
m_statusPanel = new wxPanel( this );
m_statusPanel->SetBackgroundColour( backgroundColor.ToColour() );
m_status = new wxStaticText( m_statusPanel, wxID_ANY, wxEmptyString );