Eeschema: Add option for selection highlight thickness

ADDED new option to set selection highlight thickness.
Also change selection shadow width constants to
make the selection thickness change less drastically
with the zoom level.
This commit is contained in:
Jonatan Liljedahl 2019-11-20 20:54:33 +01:00
parent 97b0b20a65
commit 681f6bc707
7 changed files with 191 additions and 2 deletions

View File

@ -81,6 +81,7 @@ bool PANEL_EESCHEMA_DISPLAY_OPTIONS::TransferDataToWindow()
m_checkSelTextBox->SetValue( GetSelectionTextAsBox() );
m_checkSelDrawChildItems->SetValue( GetSelectionDrawChildItems() );
m_checkSelFillShapes->SetValue( GetSelectionFillShapes() );
m_selWidthCtrl->SetValue( GetSelectionThickness() );
m_galOptsPanel->TransferDataToWindow();
@ -120,6 +121,7 @@ bool PANEL_EESCHEMA_DISPLAY_OPTIONS::TransferDataFromWindow()
SetSelectionTextAsBox( m_checkSelTextBox->GetValue() );
SetSelectionDrawChildItems( m_checkSelDrawChildItems->GetValue() );
SetSelectionFillShapes( m_checkSelFillShapes->GetValue() );
SetSelectionThickness( m_selWidthCtrl->GetValue() );
// Update canvas
m_frame->GetRenderSettings()->m_ShowHiddenPins = m_checkShowHiddenPins->GetValue();

View File

@ -117,6 +117,23 @@ PANEL_EESCHEMA_DISPLAY_OPTIONS_BASE::PANEL_EESCHEMA_DISPLAY_OPTIONS_BASE( wxWind
m_checkSelFillShapes = new wxCheckBox( sbSizer3->GetStaticBox(), wxID_ANY, _("Fill selected shapes"), wxDefaultPosition, wxDefaultSize, 0 );
sbSizer3->Add( m_checkSelFillShapes, 0, wxALL|wxEXPAND, 5 );
wxFlexGridSizer* fgSizer321;
fgSizer321 = new wxFlexGridSizer( 0, 2, 3, 0 );
fgSizer321->AddGrowableCol( 1 );
fgSizer321->SetFlexibleDirection( wxBOTH );
fgSizer321->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
m_selWidthLabel = new wxStaticText( sbSizer3->GetStaticBox(), wxID_ANY, _("&Highlight thickness:"), wxDefaultPosition, wxDefaultSize, 0 );
m_selWidthLabel->Wrap( -1 );
fgSizer321->Add( m_selWidthLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 );
m_selWidthCtrl = new wxSpinCtrlDouble( sbSizer3->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0.5, 50, 0, 0.5 );
m_selWidthCtrl->SetDigits( 1 );
fgSizer321->Add( m_selWidthCtrl, 0, wxEXPAND, 5 );
sbSizer3->Add( fgSizer321, 1, wxEXPAND|wxTOP, 5 );
bRightColumn->Add( sbSizer3, 1, wxEXPAND|wxTOP, 5 );

View File

@ -1220,6 +1220,149 @@
<property name="window_style"></property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxTOP</property>
<property name="proportion">1</property>
<object class="wxFlexGridSizer" expanded="1">
<property name="cols">2</property>
<property name="flexible_direction">wxBOTH</property>
<property name="growablecols">1</property>
<property name="growablerows"></property>
<property name="hgap">0</property>
<property name="minimum_size">-1,-1</property>
<property name="name">fgSizer321</property>
<property name="non_flexible_grow_mode">wxFLEX_GROWMODE_SPECIFIED</property>
<property name="permission">none</property>
<property name="rows">0</property>
<property name="vgap">3</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">&amp;Highlight thickness:</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_selWidthLabel</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxSpinCtrlDouble" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="digits">1</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="inc">0.5</property>
<property name="initial">0</property>
<property name="max">50</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min">0.5</property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_selWidthCtrl</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style">wxSP_ARROW_KEYS</property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="value"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
</object>
</object>
</object>
</object>
</object>

View File

@ -21,6 +21,7 @@
#include <wx/statbox.h>
#include <wx/choice.h>
#include <wx/checkbox.h>
#include <wx/spinctrl.h>
#include <wx/panel.h>
///////////////////////////////////////////////////////////////////////////
@ -51,6 +52,8 @@ class PANEL_EESCHEMA_DISPLAY_OPTIONS_BASE : public wxPanel
wxCheckBox* m_checkSelTextBox;
wxCheckBox* m_checkSelDrawChildItems;
wxCheckBox* m_checkSelFillShapes;
wxStaticText* m_selWidthLabel;
wxSpinCtrlDouble* m_selWidthCtrl;
public:

View File

@ -55,7 +55,7 @@ static int s_textMarkupFlags = 0;
static bool s_selectTextAsBox = false;
static bool s_selectDrawChildren = true;
static bool s_selectFillShapes = false;
static float s_selectThickness = DEFAULTSELECTIONTHICKNESS;
int GetDefaultBusThickness()
{
@ -153,6 +153,17 @@ void SetSelectionFillShapes( bool aBool )
}
float GetSelectionThickness()
{
return s_selectThickness;
}
void SetSelectionThickness( float aFloat )
{
s_selectThickness = aFloat;
}
// Color to draw selected items
COLOR4D GetItemSelectedColor()
{
@ -326,6 +337,7 @@ static const wxChar showPinElectricalType[] = wxT( "LibeditShowPinElectric
static const wxChar boxedSelectedText[] = wxT( "SelectionTextAsBox" );
static const wxChar drawSelectedChildren[] = wxT( "SelectionDrawChildItems" );
static const wxChar selectionFillShapes[] = wxT( "SelectionFillShapes" );
static const wxChar selectionThickness[] = wxT( "SelectionThickness" );
///@}
@ -388,6 +400,8 @@ void SCH_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg )
SetSelectionTextAsBox( aCfg->ReadBool( boxedSelectedText, false ) );
SetSelectionDrawChildItems( aCfg->ReadBool( drawSelectedChildren, true ) );
SetSelectionFillShapes( aCfg->ReadBool( selectionFillShapes, false ) );
SetSelectionThickness(
(float) aCfg->ReadDouble( selectionThickness, DEFAULTSELECTIONTHICKNESS ) );
SetTextMarkupFlags( (int) aCfg->Read( TextMarkupFlagsEntry, 0L ) );
@ -447,6 +461,7 @@ void SCH_EDIT_FRAME::SaveSettings( wxConfigBase* aCfg )
aCfg->Write( boxedSelectedText, GetSelectionTextAsBox() );
aCfg->Write( drawSelectedChildren, GetSelectionDrawChildItems() );
aCfg->Write( selectionFillShapes, GetSelectionFillShapes() );
aCfg->Write( selectionThickness, GetSelectionThickness() );
// Save template fieldnames
STRING_FORMATTER sf;

View File

@ -72,6 +72,9 @@ class SCH_SHEET_PATH;
///< The default library pane width
#define DEFAULTLIBWIDTH 250
///< The default selection highlight thickness
#define DEFAULTSELECTIONTHICKNESS 1.5
/* Rotation, mirror of graphic items in components bodies are handled by a
* transform matrix. The default matrix is useful to draw lib entries with
* using this default matrix ( no rotation, no mirror but Y axis is bottom to top, and
@ -138,6 +141,11 @@ void SetSelectionDrawChildItems( bool aBool );
bool GetSelectionFillShapes();
void SetSelectionFillShapes( bool aBool );
/**
* Selection highlight thickness
*/
float GetSelectionThickness();
void SetSelectionThickness( float aFloat );
int GetTextMarkupFlags();
void SetTextMarkupFlags( int aMarkupFlags );

View File

@ -232,7 +232,8 @@ float SCH_PAINTER::getShadowWidth()
// For best visuals the selection width must be a cross between the zoom level and the
// default line width.
return (float) ( ( fabs( matrix.GetScale().x * 5.5 ) + GetDefaultLineThickness() ) / 2.0 );
return (float) ( ( fabs( matrix.GetScale().x ) + GetDefaultLineThickness() )
* GetSelectionThickness() );
}