KiCad PCB EDA Suite
PANEL_EESCHEMA_COLOR_SETTINGS Class Reference

#include <panel_eeschema_color_settings.h>

Inheritance diagram for PANEL_EESCHEMA_COLOR_SETTINGS:
PANEL_COLOR_SETTINGS PANEL_COLOR_SETTINGS_BASE RESETTABLE_PANEL

Public Types

enum  COLOR_CONTEXT_ID { ID_COPY = wxID_HIGHEST + 1, ID_PASTE, ID_REVERT }
 

Public Member Functions

 PANEL_EESCHEMA_COLOR_SETTINGS (SCH_BASE_FRAME *aFrame, wxWindow *aParent)
 
 ~PANEL_EESCHEMA_COLOR_SETTINGS () override
 
void ResetPanel () override
 Reset the contents of this panel. More...
 
virtual wxString GetResetTooltip () override
 Get the tooltip the reset button should display when showing this panel. More...
 
bool Show (bool show) override
 

Public Attributes

wxCheckBox * m_optOverrideColors
 

Protected Member Functions

bool TransferDataFromWindow () override
 
bool TransferDataToWindow () override
 
void OnOverrideItemColorsClicked (wxCommandEvent &aEvent) override
 
void OnSize (wxSizeEvent &aEvent) override
 
void onNewThemeSelected () override
 Event fired when a new theme is selected that can be overridden in children. More...
 
void onColorChanged () override
 Event fired when the user changes any color. More...
 
bool validateSave (bool aQuiet=false) override
 Performs a pre-save validation of the current color theme. More...
 
bool saveCurrentTheme (bool aValidate) override
 
void OnBtnOpenThemeFolderClicked (wxCommandEvent &event) override
 
void OnLeftDownTheme (wxMouseEvent &event) override
 
void OnThemeChanged (wxCommandEvent &aEvent) override
 
void ShowColorContextMenu (wxMouseEvent &aEvent, int aLayer)
 
void OnColorChanged (wxCommandEvent &aEvent)
 
void updateSwatches ()
 
void createThemeList (const wxString &aCurrent)
 Builds the theme listbox and sets the selection to the current theme. More...
 
void createSwatch (int aLayer, const wxString &aName)
 
void updateColor (int aLayer, const KIGFX::COLOR4D &aColor)
 

Protected Attributes

COLOR_SETTINGSm_currentSettings
 
std::map< int, wxStaticText * > m_labels
 
std::map< int, COLOR_SWATCH * > m_swatches
 
KIGFX::COLOR4D m_copied
 
std::vector< int > m_validLayers
 A list of layer IDs that are valid for the current color settings dialog. More...
 
int m_backgroundLayer
 
std::string m_colorNamespace
 A namespace that will be passed to SETTINGS_MANAGER::SaveColorSettings. More...
 
wxBoxSizer * m_mainSizer
 
wxStaticText * m_staticText9
 
wxChoice * m_cbTheme
 
wxButton * m_btnOpenFolder
 
wxStaticLine * m_staticline2
 
wxBoxSizer * m_colorsMainSizer
 
wxScrolledWindow * m_colorsListWindow
 
wxFlexGridSizer * m_colorsGridSizer
 

Private Member Functions

void createPreviewItems ()
 
void createSwatches ()
 
void updatePreview ()
 
void zoomFitPreview ()
 

Private Attributes

SCH_BASE_FRAMEm_frame
 
SCH_PREVIEW_PANELm_preview
 
PAGE_INFOm_page
 
TITLE_BLOCKm_titleBlock
 
DS_PROXY_VIEW_ITEMm_drawingSheet
 
std::vector< EDA_ITEM * > m_previewItems
 
KIGFX::GAL_DISPLAY_OPTIONS m_galDisplayOptions
 

Detailed Description

Definition at line 39 of file panel_eeschema_color_settings.h.

Member Enumeration Documentation

◆ COLOR_CONTEXT_ID

Enumerator
ID_COPY 
ID_PASTE 
ID_REVERT 

Definition at line 39 of file panel_color_settings.h.

Constructor & Destructor Documentation

◆ PANEL_EESCHEMA_COLOR_SETTINGS()

PANEL_EESCHEMA_COLOR_SETTINGS::PANEL_EESCHEMA_COLOR_SETTINGS ( SCH_BASE_FRAME aFrame,
wxWindow *  aParent 
)

Definition at line 49 of file panel_eeschema_color_settings.cpp.

50  :
51  PANEL_COLOR_SETTINGS( aParent ),
52  m_frame( aFrame ),
53  m_preview( nullptr ),
54  m_page( nullptr ),
55  m_titleBlock( nullptr ),
56  m_drawingSheet( nullptr ),
58 {
59  m_colorNamespace = "schematic";
60 
61  SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
62 
63  mgr.ReloadColorSettings();
64 
65  COMMON_SETTINGS* common_settings = Pgm().GetCommonSettings();
66  EESCHEMA_SETTINGS* app_settings = mgr.GetAppSettings<EESCHEMA_SETTINGS>();
67  COLOR_SETTINGS* current = mgr.GetColorSettings( app_settings->m_ColorTheme );
68 
69  // Saved theme doesn't exist? Reset to default
70  if( current->GetFilename() != app_settings->m_ColorTheme )
71  app_settings->m_ColorTheme = current->GetFilename();
72 
73  createThemeList( app_settings->m_ColorTheme );
74 
75  m_optOverrideColors->SetValue( current->GetOverrideSchItemColors() );
76 
77  m_currentSettings = new COLOR_SETTINGS( *current );
78 
79  for( int id = SCH_LAYER_ID_START; id < SCH_LAYER_ID_END; id++ )
80  m_validLayers.push_back( id );
81 
83 
85 
86  m_galDisplayOptions.ReadConfig( *common_settings, app_settings->m_Window, this );
88 
89  auto type = static_cast<EDA_DRAW_PANEL_GAL::GAL_TYPE>( app_settings->m_Graphics.canvas_type );
90 
91  m_preview = new SCH_PREVIEW_PANEL( this, wxID_ANY, wxDefaultPosition, wxSize( -1, -1 ),
92  m_galDisplayOptions, type );
93  m_preview->SetStealsFocus( false );
94  m_preview->ShowScrollbars( wxSHOW_SB_NEVER, wxSHOW_SB_NEVER );
95  m_preview->GetGAL()->SetAxesEnabled( false );
96 
97  m_colorsMainSizer->Add( 10, 0, 0, wxEXPAND, 5 );
98  m_colorsMainSizer->Add( m_preview, 1, wxALL | wxEXPAND, 5 );
99  m_colorsMainSizer->Add( 10, 0, 0, wxEXPAND, 5 );
100 
102  updatePreview();
103  zoomFitPreview();
104 }
bool m_forceDisplayCursor
The pixel scale factor (>1 for hi-DPI scaled displays)
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:106
std::string m_colorNamespace
A namespace that will be passed to SETTINGS_MANAGER::SaveColorSettings.
void createThemeList(const wxString &aCurrent)
Builds the theme listbox and sets the selection to the current theme.
COLOR_SETTINGS * m_currentSettings
void SetStealsFocus(bool aStealsFocus)
Set whether focus is taken on certain events (mouseover, keys, etc).
KIGFX::GAL * GetGAL() const
Return a pointer to the GAL instance used in the panel.
AppSettings * GetAppSettings(bool aLoadNow=true)
Returns a handle to the a given settings by type If the settings have already been loaded,...
PANEL_COLOR_SETTINGS(wxWindow *aParent)
void SetAxesEnabled(bool aAxesEnabled)
Enable drawing the axes.
std::vector< int > m_validLayers
A list of layer IDs that are valid for the current color settings dialog.
COLOR_SETTINGS * GetColorSettings(const wxString &aName="user")
Retrieves a color settings object that applications can read colors from.
WINDOW_SETTINGS m_Window
Definition: app_settings.h:181
void ReloadColorSettings()
Re-scans the color themes directory, reloading any changes it finds.
void ReadConfig(COMMON_SETTINGS &aCommonConfig, WINDOW_SETTINGS &aWindowConfig, wxWindow *aWindow)
Read application and common configs.
Color settings are a bit different than most of the settings objects in that there can be more than o...
KIGFX::GAL_DISPLAY_OPTIONS m_galDisplayOptions
wxString m_ColorTheme
Active color theme name.
Definition: app_settings.h:184

References APP_SETTINGS_BASE::GRAPHICS::canvas_type, createPreviewItems(), createSwatches(), PANEL_COLOR_SETTINGS::createThemeList(), SETTINGS_MANAGER::GetAppSettings(), SETTINGS_MANAGER::GetColorSettings(), EDA_DRAW_PANEL_GAL::GetGAL(), LAYER_SCHEMATIC_BACKGROUND, PANEL_COLOR_SETTINGS::m_backgroundLayer, PANEL_COLOR_SETTINGS::m_colorNamespace, PANEL_COLOR_SETTINGS_BASE::m_colorsMainSizer, APP_SETTINGS_BASE::m_ColorTheme, PANEL_COLOR_SETTINGS::m_currentSettings, KIGFX::GAL_DISPLAY_OPTIONS::m_forceDisplayCursor, m_galDisplayOptions, APP_SETTINGS_BASE::m_Graphics, PANEL_COLOR_SETTINGS_BASE::m_optOverrideColors, m_preview, PANEL_COLOR_SETTINGS::m_validLayers, APP_SETTINGS_BASE::m_Window, Pgm(), KIGFX::GAL_DISPLAY_OPTIONS::ReadConfig(), SETTINGS_MANAGER::ReloadColorSettings(), SCH_LAYER_ID_END, SCH_LAYER_ID_START, KIGFX::GAL::SetAxesEnabled(), EDA_DRAW_PANEL_GAL::SetStealsFocus(), updatePreview(), and zoomFitPreview().

◆ ~PANEL_EESCHEMA_COLOR_SETTINGS()

PANEL_EESCHEMA_COLOR_SETTINGS::~PANEL_EESCHEMA_COLOR_SETTINGS ( )
override

Definition at line 107 of file panel_eeschema_color_settings.cpp.

108 {
109  delete m_page;
110  delete m_titleBlock;
111  delete m_drawingSheet;
112  delete m_currentSettings;
113 
114  for( EDA_ITEM* item : m_previewItems )
115  delete item;
116 }
COLOR_SETTINGS * m_currentSettings
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:150

References PANEL_COLOR_SETTINGS::m_currentSettings, m_drawingSheet, m_page, m_previewItems, and m_titleBlock.

Member Function Documentation

◆ createPreviewItems()

void PANEL_EESCHEMA_COLOR_SETTINGS::createPreviewItems ( )
private

Definition at line 236 of file panel_eeschema_color_settings.cpp.

237 {
238  KIGFX::VIEW* view = m_preview->GetView();
239 
242  m_titleBlock->SetTitle( _( "Color Preview" ) );
243  m_titleBlock->SetDate( wxDateTime::Now().FormatDate() );
244 
245  m_page->SetHeightMils( 5000 );
246  m_page->SetWidthMils( 6000 );
247 
250  view->Add( m_drawingSheet );
251 
252  // NOTE: It would be nice to parse a schematic file here.
253  // This is created from the color_settings.sch file in demos folder
254 
255  auto addItem = [&]( EDA_ITEM* aItem )
256  {
257  view->Add( aItem );
258  m_previewItems.push_back( aItem );
259  };
260 
261  std::vector<std::pair<SCH_LAYER_ID, std::pair<wxPoint, wxPoint>>> lines = {
262  { LAYER_WIRE, { { 1950, 1500 }, { 2325, 1500 } } },
263  { LAYER_WIRE, { { 1950, 2600 }, { 2350, 2600 } } },
264  { LAYER_WIRE, { { 2150, 1700 }, { 2325, 1700 } } },
265  { LAYER_WIRE, { { 2150, 2000 }, { 2150, 1700 } } },
266  { LAYER_WIRE, { { 2925, 1600 }, { 3075, 1600 } } },
267  { LAYER_WIRE, { { 3075, 1600 }, { 3075, 2000 } } },
268  { LAYER_WIRE, { { 3075, 1600 }, { 3250, 1600 } } },
269  { LAYER_WIRE, { { 3075, 2000 }, { 2150, 2000 } } },
270  { LAYER_BUS, { { 1750, 1400 }, { 1850, 1400 } } },
271  { LAYER_BUS, { { 1850, 2500 }, { 1850, 1400 } } },
272  { LAYER_NOTES, { { 2350, 2125 }, { 2350, 2300 } } },
273  { LAYER_NOTES, { { 2350, 2125 }, { 2950, 2125 } } },
274  { LAYER_NOTES, { { 2950, 2125 }, { 2950, 2300 } } },
275  { LAYER_NOTES, { { 2950, 2300 }, { 2350, 2300 } } }
276  };
277 
278  for( const auto& line : lines )
279  {
280  SCH_LINE* wire = new SCH_LINE;
281  wire->SetLayer( line.first );
282  wire->SetStartPoint( wxPoint( Mils2iu( line.second.first.x ),
283  Mils2iu( line.second.first.y ) ) );
284  wire->SetEndPoint( wxPoint( Mils2iu( line.second.second.x ),
285  Mils2iu( line.second.second.y ) ) );
286  addItem( wire );
287  }
288 
289 #define MILS_POINT( x, y ) wxPoint( Mils2iu( x ), Mils2iu( y ) )
290 
291  SCH_NO_CONNECT* nc = new SCH_NO_CONNECT;
292  nc->SetPosition( MILS_POINT( 2525, 1300 ) );
293  addItem( nc );
294 
296  e1->SetPosition( MILS_POINT( 1850, 1400 ) );
297  addItem( e1 );
298 
300  e2->SetPosition( MILS_POINT( 1850, 2500 ) );
301  addItem( e2 );
302 
303  SCH_TEXT* t1 = new SCH_TEXT( MILS_POINT( 2850, 2250 ), wxT( "PLAIN TEXT" ) );
304  t1->SetLabelSpinStyle( LABEL_SPIN_STYLE::SPIN::LEFT );
305  addItem( t1 );
306 
307  SCH_LABEL* t2 = new SCH_LABEL( MILS_POINT( 1975, 1500 ), wxT( "LABEL_{0}" ) );
308  t2->SetLabelSpinStyle( LABEL_SPIN_STYLE::SPIN::RIGHT );
309  t2->SetIsDangling( false );
310  addItem( t2 );
311 
312  SCH_LABEL* t3 = new SCH_LABEL( MILS_POINT( 1975, 2600 ), wxT( "LABEL_{1}" ) );
313  t3->SetLabelSpinStyle( LABEL_SPIN_STYLE::SPIN::RIGHT );
314  t3->SetIsDangling( false );
315  addItem( t3 );
316 
317  SCH_GLOBALLABEL* t4 = new SCH_GLOBALLABEL( MILS_POINT( 1750, 1400 ), wxT( "GLOBAL[3..0]" ) );
318  t4->SetLabelSpinStyle( LABEL_SPIN_STYLE::SPIN::LEFT );
319  t4->SetIsDangling( false );
320  addItem( t4 );
321 
322  SCH_HIERLABEL* t5 = new SCH_HIERLABEL( MILS_POINT( 3250, 1600 ), wxT( "HIER_LABEL" ) );
323  t5->SetLabelSpinStyle( LABEL_SPIN_STYLE::SPIN::RIGHT );
324  t5->SetIsDangling( false );
325  addItem( t5 );
326 
327  SCH_JUNCTION* j = new SCH_JUNCTION( MILS_POINT( 3075, 1600 ) );
328  addItem( j );
329 
330  t2->SetSelected();
331 
332  {
333  LIB_PART* part = new LIB_PART( wxEmptyString );
334  wxPoint p( 2625, -1600 );
335 
336  LIB_FIELD& ref = part->GetReferenceField();
337 
338  ref.SetText( wxT( "U1" ) );
339  ref.SetPosition( MILS_POINT( p.x + 30, p.y + 260 ) );
341 
342  LIB_FIELD& value = part->GetValueField();
343 
344  value.SetText( wxT( "OPA604" ) );
345  value.SetPosition( MILS_POINT( p.x + 30, p.y + 180 ) );
347 
348  part->SetShowPinNames( true );
349  part->SetShowPinNumbers( true );
350  part->SetPinNameOffset( 0 );
351 
352  LIB_POLYLINE* comp_body = new LIB_POLYLINE( part );
353 
354  comp_body->SetUnit( 0 );
355  comp_body->SetConvert( 0 );
356  comp_body->SetWidth( Mils2iu( 10 ) );
358  comp_body->AddPoint( MILS_POINT( p.x - 200, p.y + 200 ) );
359  comp_body->AddPoint( MILS_POINT( p.x + 200, p.y ) );
360  comp_body->AddPoint( MILS_POINT( p.x - 200, p.y - 200 ) );
361  comp_body->AddPoint( MILS_POINT( p.x - 200, p.y + 200 ) );
362 
363  addItem( comp_body );
364 
365  LIB_PIN* pin = new LIB_PIN( part );
366 
367  pin->SetPosition( MILS_POINT( p.x - 200, p.y + 100 ) );
368  pin->SetLength( Mils2iu( 100 ) );
369  pin->SetOrientation( PIN_LEFT );
370  pin->SetType( ELECTRICAL_PINTYPE::PT_INPUT );
371  pin->SetNumber( wxT( "1" ) );
372  pin->SetName( wxT( "-" ) );
373 
374  part->AddDrawItem( pin );
375 
376  pin = new LIB_PIN( part );
377 
378  pin->SetPosition( MILS_POINT( p.x - 200, p.y - 100 ) );
379  pin->SetLength( Mils2iu( 100 ) );
380  pin->SetOrientation( PIN_LEFT );
381  pin->SetType( ELECTRICAL_PINTYPE::PT_INPUT );
382  pin->SetNumber( wxT( "2" ) );
383  pin->SetName( wxT( "+" ) );
384 
385  part->AddDrawItem( pin );
386 
387  pin = new LIB_PIN( part );
388 
389  pin->SetPosition( MILS_POINT( p.x + 200, p.y ) );
390  pin->SetLength( Mils2iu( 100 ) );
391  pin->SetOrientation( PIN_RIGHT );
393  pin->SetNumber( wxT( "3" ) );
394  pin->SetName( wxT( "OUT" ) );
395 
396  part->AddDrawItem( pin );
397 
398  addItem( part );
399  }
400 
401  SCH_SHEET* s = new SCH_SHEET( nullptr, MILS_POINT( 4000, 1300 ) );
402  s->SetSize( wxSize( Mils2iu( 800 ), Mils2iu( 1300 ) ) );
403  s->GetFields().at( SHEETNAME ).SetText( wxT( "SHEET" ) );
404  s->GetFields().at( SHEETFILENAME ).SetText( _( "/path/to/sheet" ) );
405  s->AutoplaceFields( nullptr, false );
406  addItem( s );
407 
408  SCH_SHEET_PIN* sp = new SCH_SHEET_PIN( s, MILS_POINT( 4500, 1500 ), wxT( "SHEET PIN" ) );
409  addItem( sp );
410 
411  zoomFitPreview();
412 }
void SetColorLayer(int aLayerId)
Can be used to override which layer ID is used for worksheet item colors.
Field object used in symbol libraries.
Definition: lib_field.h:59
void SetFillMode(FILL_TYPE aFillMode)
Definition: lib_item.h:265
void SetPosition(const wxPoint &aPosition) override
LIB_FIELD & GetValueField()
Return reference to the value field.
Definition: lib_symbol.cpp:975
void SetDate(const wxString &aDate)
Set the date field, and defaults to the current time and date.
Definition: title_block.h:71
static const wxChar Custom[]
"User" defined page type
Definition: page_info.h:77
void SetIsDangling(bool aIsDangling)
Definition: sch_text.h:285
void SetWidth(int aWidth) override
Definition: lib_polyline.h:97
Hold the information shown in the lower right corner of a plot, printout, or editing view.
Definition: title_block.h:40
void SetEndPoint(const wxPoint &aPosition)
Definition: sch_line.h:94
std::vector< SCH_FIELD > & GetFields()
Definition: sch_sheet.h:88
#define MILS_POINT(x, y)
LIB_FIELD & GetReferenceField()
Return reference to the reference designator field.
Definition: lib_symbol.cpp:983
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:121
void SetSelected()
Definition: eda_item.h:179
void SetPosition(const wxPoint &aPosition) override
void AddDrawItem(LIB_ITEM *aItem, bool aSort=true)
Add a new draw aItem to the draw object list and sort according to aSort.
Definition: lib_symbol.cpp:655
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:53
void SetStartPoint(const wxPoint &aPosition)
Definition: sch_line.h:91
void SetLayer(SCH_LAYER_ID aLayer)
Set the layer this item is on.
Definition: sch_item.h:279
Define a library symbol object.
Definition: lib_symbol.h:93
void SetLabelSpinStyle(LABEL_SPIN_STYLE aSpinStyle) override
Set a spin or rotation angle, along with specific horizontal and vertical justification styles with e...
Definition: sch_text.cpp:1397
virtual KIGFX::VIEW * GetView() const
Return a pointer to the #VIEW instance used in the panel.
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet_pin.h:65
void AddPoint(const wxPoint &aPoint)
void SetTitle(const wxString &aTitle)
Definition: title_block.h:58
void SetHeightMils(int aHeightInMils)
Definition: page_info.cpp:257
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:54
void SetSize(const wxSize &aSize)
Definition: sch_sheet.h:106
void SetConvert(int aConvert)
Definition: lib_item.h:262
void SetUnit(int aUnit)
Definition: lib_item.h:259
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
void SetShowPinNumbers(bool aShow)
Set or clear the pin number visibility flag.
Definition: lib_symbol.h:572
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:208
#define _(s)
Definition: 3d_actions.cpp:33
usual pin input: must be connected
void SetWidthMils(int aWidthInMils)
Definition: page_info.cpp:243
#define IU_PER_MILS
Definition: plotter.cpp:137
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:150
Class for a wire to bus entry.
void SetPosition(const wxPoint &aPosition) override
Definition: lib_item.h:213
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition: view.cpp:322
void SetLabelSpinStyle(LABEL_SPIN_STYLE aSpinStyle) override
Set a spin or rotation angle, along with specific horizontal and vertical justification styles with e...
Definition: sch_text.cpp:948
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual) override
Definition: sch_sheet.cpp:515
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:67
virtual void SetLabelSpinStyle(LABEL_SPIN_STYLE aSpinStyle)
Set a spin or rotation angle, along with specific horizontal and vertical justification styles with e...
Definition: sch_text.cpp:248
void SetShowPinNames(bool aShow)
Set or clear the pin name visibility flag.
Definition: lib_symbol.h:564
void SetPinNameOffset(int aOffset)
Set the offset in mils of the pin name text from the pin symbol.
Definition: lib_symbol.h:556

References _, KIGFX::VIEW::Add(), LIB_PART::AddDrawItem(), LIB_POLYLINE::AddPoint(), SCH_SHEET::AutoplaceFields(), PAGE_INFO::Custom, FILLED_WITH_BG_BODYCOLOR, SCH_SHEET::GetFields(), LIB_PART::GetReferenceField(), LIB_PART::GetValueField(), EDA_DRAW_PANEL_GAL::GetView(), GR_TEXT_HJUSTIFY_LEFT, IU_PER_MILS, LAYER_BUS, LAYER_NOTES, LAYER_SCHEMATIC_DRAWINGSHEET, LAYER_WIRE, m_drawingSheet, m_page, m_preview, m_previewItems, m_titleBlock, MILS_POINT, pin, PIN_LEFT, PIN_RIGHT, PT_INPUT, PT_OUTPUT, DS_PROXY_VIEW_ITEM::SetColorLayer(), LIB_ITEM::SetConvert(), TITLE_BLOCK::SetDate(), SCH_LINE::SetEndPoint(), LIB_ITEM::SetFillMode(), PAGE_INFO::SetHeightMils(), EDA_TEXT::SetHorizJustify(), SCH_TEXT::SetIsDangling(), SCH_TEXT::SetLabelSpinStyle(), SCH_GLOBALLABEL::SetLabelSpinStyle(), SCH_HIERLABEL::SetLabelSpinStyle(), SCH_ITEM::SetLayer(), LIB_PART::SetPinNameOffset(), SCH_BUS_ENTRY_BASE::SetPosition(), SCH_NO_CONNECT::SetPosition(), LIB_ITEM::SetPosition(), EDA_ITEM::SetSelected(), LIB_PART::SetShowPinNames(), LIB_PART::SetShowPinNumbers(), SCH_SHEET::SetSize(), SCH_LINE::SetStartPoint(), EDA_TEXT::SetText(), TITLE_BLOCK::SetTitle(), LIB_ITEM::SetUnit(), LIB_POLYLINE::SetWidth(), PAGE_INFO::SetWidthMils(), SHEETFILENAME, SHEETNAME, and zoomFitPreview().

Referenced by PANEL_EESCHEMA_COLOR_SETTINGS().

◆ createSwatch()

void PANEL_COLOR_SETTINGS::createSwatch ( int  aLayer,
const wxString &  aName 
)
protectedinherited

Definition at line 230 of file panel_color_settings.cpp.

231 {
232  wxStaticText* label = new wxStaticText( m_colorsListWindow, wxID_ANY, aName );
233 
234  // The previously selected theme can be deleted and cannot be selected.
235  // so select the default theme (first theme of the list)
236  if( m_cbTheme->GetSelection() < 0 )
237  {
238  m_cbTheme->SetSelection( 0 );
240  }
241 
242  void* clientData = m_cbTheme->GetClientData( m_cbTheme->GetSelection() );
243  COLOR_SETTINGS* selected = static_cast<COLOR_SETTINGS*>( clientData );
244 
245  int id = FIRST_BUTTON_ID + aLayer;
246  COLOR4D defaultColor = selected->GetDefaultColor( aLayer );
248  COLOR4D backgroundColor = m_currentSettings->GetColor( m_backgroundLayer );
249 
250  COLOR_SWATCH* swatch = new COLOR_SWATCH( m_colorsListWindow, color, id, backgroundColor,
251  defaultColor, SWATCH_MEDIUM );
252  swatch->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) );
253 
254  m_colorsGridSizer->Add( label, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxLEFT, 5 );
255  m_colorsGridSizer->Add( swatch, 0, wxALIGN_CENTER_VERTICAL | wxALL, 3 );
256 
257  m_labels[aLayer] = label;
258  m_swatches[aLayer] = swatch;
259 
260  swatch->Bind( wxEVT_RIGHT_DOWN,
261  [&, aLayer]( wxMouseEvent& aEvent )
262  {
263  ShowColorContextMenu( aEvent, aLayer );
264  } );
265 
266  swatch->Bind( COLOR_SWATCH_CHANGED, &PANEL_COLOR_SETTINGS::OnColorChanged, this );
267 }
int color
Definition: DXF_plotter.cpp:60
std::map< int, wxStaticText * > m_labels
virtual void onNewThemeSelected()
Event fired when a new theme is selected that can be overridden in children.
std::map< int, COLOR_SWATCH * > m_swatches
void ShowColorContextMenu(wxMouseEvent &aEvent, int aLayer)
COLOR_SETTINGS * m_currentSettings
COLOR4D GetDefaultColor(int aLayer)
constexpr int FIRST_BUTTON_ID
COLOR4D GetColor(int aLayer) const
Class representing a simple color swatch, of the kind used to set layer colors.
Definition: color_swatch.h:57
Color settings are a bit different than most of the settings objects in that there can be more than o...
void OnColorChanged(wxCommandEvent &aEvent)
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:98

References color, FIRST_BUTTON_ID, COLOR_SETTINGS::GetColor(), COLOR_SETTINGS::GetDefaultColor(), PANEL_COLOR_SETTINGS::m_backgroundLayer, PANEL_COLOR_SETTINGS_BASE::m_cbTheme, PANEL_COLOR_SETTINGS_BASE::m_colorsGridSizer, PANEL_COLOR_SETTINGS_BASE::m_colorsListWindow, PANEL_COLOR_SETTINGS::m_currentSettings, PANEL_COLOR_SETTINGS::m_labels, PANEL_COLOR_SETTINGS::m_swatches, PANEL_COLOR_SETTINGS::OnColorChanged(), PANEL_COLOR_SETTINGS::onNewThemeSelected(), PANEL_COLOR_SETTINGS::ShowColorContextMenu(), and SWATCH_MEDIUM.

Referenced by PANEL_FP_EDITOR_COLOR_SETTINGS::createSwatches(), PANEL_PCBNEW_COLOR_SETTINGS::createSwatches(), and createSwatches().

◆ createSwatches()

void PANEL_EESCHEMA_COLOR_SETTINGS::createSwatches ( )
private

Definition at line 188 of file panel_eeschema_color_settings.cpp.

189 {
190  std::vector<SCH_LAYER_ID> layers;
191 
193  layers.push_back( i );
194 
195  std::sort( layers.begin(), layers.end(),
196  []( SCH_LAYER_ID a, SCH_LAYER_ID b )
197  {
198  return LayerName( a ) < LayerName( b );
199  } );
200 
201  for( int layer : layers )
202  {
203  wxString name = LayerName( layer );
204 
205  if( layer == LAYER_SCHEMATIC_GRID_AXES )
206  name += wxS( " " ) + _( "(symbol editor only)" );
207 
208  createSwatch( layer, name );
209  }
210 
211  // Give a minimal width to m_colorsListWindow, in order to always having
212  // a full row shown
213  int min_width = m_colorsGridSizer->GetMinSize().x;
214  const int margin = 20; // A margin around the sizer
215  m_colorsListWindow->SetMinSize( wxSize( min_width + margin, -1 ) );
216 }
wxString LayerName(int aLayer)
Returns the default display name for a given layer.
Definition: layer_id.cpp:27
SCH_LAYER_ID
Eeschema drawing layers.
const char * name
Definition: DXF_plotter.cpp:59
#define _(s)
Definition: 3d_actions.cpp:33
void createSwatch(int aLayer, const wxString &aName)

References _, PANEL_COLOR_SETTINGS::createSwatch(), LAYER_SCHEMATIC_GRID_AXES, LayerName(), PANEL_COLOR_SETTINGS_BASE::m_colorsGridSizer, PANEL_COLOR_SETTINGS_BASE::m_colorsListWindow, name, SCH_LAYER_ID_END, and SCH_LAYER_ID_START.

Referenced by PANEL_EESCHEMA_COLOR_SETTINGS().

◆ createThemeList()

void PANEL_COLOR_SETTINGS::createThemeList ( const wxString &  aCurrent)
protectedinherited

Builds the theme listbox and sets the selection to the current theme.

Parameters
aCurrentis the filename of the current color theme (no extension)

Definition at line 197 of file panel_color_settings.cpp.

198 {
199  int width = 0;
200  int height = 0;
201 
202  m_cbTheme->GetTextExtent( _( "New Theme..." ), &width, &height );
203  int minwidth = width;
204 
205  m_cbTheme->Clear();
206 
207  for( COLOR_SETTINGS* settings : Pgm().GetSettingsManager().GetColorSettingsList() )
208  {
209  wxString name = settings->GetName();
210 
211  if( settings->IsReadOnly() )
212  name += wxS( " " ) + _( "(read-only)" );
213 
214  int pos = m_cbTheme->Append( name, static_cast<void*>( settings ) );
215 
216  if( settings->GetFilename() == aCurrent )
217  m_cbTheme->SetSelection( pos );
218 
219  m_cbTheme->GetTextExtent( name, &width, &height );
220  minwidth = std::max( minwidth, width );
221  }
222 
223  m_cbTheme->Append( wxT( "---" ) );
224  m_cbTheme->Append( _( "New Theme..." ) );
225 
226  m_cbTheme->SetMinSize( wxSize( minwidth + 50, -1 ) );
227 }
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:106
SETTINGS_MANAGER * GetSettingsManager()
const char * name
Definition: DXF_plotter.cpp:59
#define _(s)
Definition: 3d_actions.cpp:33
Color settings are a bit different than most of the settings objects in that there can be more than o...

References _, GetSettingsManager(), PANEL_COLOR_SETTINGS_BASE::m_cbTheme, name, and Pgm().

Referenced by PANEL_COLOR_SETTINGS::OnLeftDownTheme(), PANEL_EESCHEMA_COLOR_SETTINGS(), PANEL_FP_EDITOR_COLOR_SETTINGS::PANEL_FP_EDITOR_COLOR_SETTINGS(), and PANEL_PCBNEW_COLOR_SETTINGS::PANEL_PCBNEW_COLOR_SETTINGS().

◆ GetResetTooltip()

virtual wxString PANEL_COLOR_SETTINGS::GetResetTooltip ( )
inlineoverridevirtualinherited

Get the tooltip the reset button should display when showing this panel.

Returns
the tooltip

Reimplemented from RESETTABLE_PANEL.

Definition at line 48 of file panel_color_settings.h.

49  {
50  return _( "Reset all colors in this theme to the KiCad defaults" );
51  }
#define _(s)
Definition: 3d_actions.cpp:33

References _.

◆ OnBtnOpenThemeFolderClicked()

void PANEL_COLOR_SETTINGS::OnBtnOpenThemeFolderClicked ( wxCommandEvent &  event)
overrideprotectedvirtualinherited

Reimplemented from PANEL_COLOR_SETTINGS_BASE.

Definition at line 57 of file panel_color_settings.cpp.

58 {
60  LaunchExternal( dir );
61 }
static wxString GetColorSettingsPath()
Returns the path where color scheme files are stored; creating it if missing (normally .
void LaunchExternal(const wxString &aPath)
Launches the given file or folder in the host OS.
Definition: launch_ext.cpp:26

References SETTINGS_MANAGER::GetColorSettingsPath(), and LaunchExternal().

◆ onColorChanged()

void PANEL_EESCHEMA_COLOR_SETTINGS::onColorChanged ( )
overrideprotectedvirtual

Event fired when the user changes any color.

Reimplemented from PANEL_COLOR_SETTINGS.

Definition at line 415 of file panel_eeschema_color_settings.cpp.

References updatePreview().

◆ OnColorChanged()

void PANEL_COLOR_SETTINGS::OnColorChanged ( wxCommandEvent &  aEvent)
protectedinherited

Definition at line 315 of file panel_color_settings.cpp.

316 {
317  COLOR_SWATCH* swatch = static_cast<COLOR_SWATCH*>( aEvent.GetEventObject() );
318  COLOR4D newColor = swatch->GetSwatchColor();
319  LAYER_NUM layer = static_cast<SCH_LAYER_ID>( swatch->GetId() - FIRST_BUTTON_ID );
320 
321  updateColor( layer, newColor );
322 }
KIGFX::COLOR4D GetSwatchColor() const
void updateColor(int aLayer, const KIGFX::COLOR4D &aColor)
constexpr int FIRST_BUTTON_ID
int LAYER_NUM
This can be replaced with int and removed.
Class representing a simple color swatch, of the kind used to set layer colors.
Definition: color_swatch.h:57
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:98

References FIRST_BUTTON_ID, COLOR_SWATCH::GetSwatchColor(), and PANEL_COLOR_SETTINGS::updateColor().

Referenced by PANEL_COLOR_SETTINGS::createSwatch().

◆ OnLeftDownTheme()

void PANEL_COLOR_SETTINGS::OnLeftDownTheme ( wxMouseEvent &  event)
overrideprotectedvirtualinherited

Reimplemented from PANEL_COLOR_SETTINGS_BASE.

Definition at line 101 of file panel_color_settings.cpp.

102 {
103  // Lazy rebuild of theme menu to catch any colour theme changes made in other panels
105 
106  event.Skip();
107 }
wxString GetFilename() const
Definition: json_settings.h:66
void createThemeList(const wxString &aCurrent)
Builds the theme listbox and sets the selection to the current theme.
COLOR_SETTINGS * m_currentSettings

References PANEL_COLOR_SETTINGS::createThemeList(), JSON_SETTINGS::GetFilename(), and PANEL_COLOR_SETTINGS::m_currentSettings.

◆ onNewThemeSelected()

void PANEL_EESCHEMA_COLOR_SETTINGS::onNewThemeSelected ( )
overrideprotectedvirtual

Event fired when a new theme is selected that can be overridden in children.

Reimplemented from PANEL_COLOR_SETTINGS.

Definition at line 219 of file panel_eeschema_color_settings.cpp.

References updatePreview().

◆ OnOverrideItemColorsClicked()

void PANEL_EESCHEMA_COLOR_SETTINGS::OnOverrideItemColorsClicked ( wxCommandEvent &  aEvent)
overrideprotectedvirtual

Reimplemented from PANEL_COLOR_SETTINGS_BASE.

Definition at line 469 of file panel_eeschema_color_settings.cpp.

470 {
472 
473  // If the theme is not overriding individual item colors then don't show them so that
474  // the user doesn't get seduced into thinking they'll have some effect.
477 
480 
481  m_colorsGridSizer->Layout();
482  m_colorsListWindow->Layout();
483 }
std::map< int, wxStaticText * > m_labels
std::map< int, COLOR_SWATCH * > m_swatches
COLOR_SETTINGS * m_currentSettings
void SetOverrideSchItemColors(bool aFlag)
bool GetOverrideSchItemColors() const

References COLOR_SETTINGS::GetOverrideSchItemColors(), LAYER_SHEET, LAYER_SHEET_BACKGROUND, PANEL_COLOR_SETTINGS_BASE::m_colorsGridSizer, PANEL_COLOR_SETTINGS_BASE::m_colorsListWindow, PANEL_COLOR_SETTINGS::m_currentSettings, PANEL_COLOR_SETTINGS::m_labels, PANEL_COLOR_SETTINGS_BASE::m_optOverrideColors, PANEL_COLOR_SETTINGS::m_swatches, and COLOR_SETTINGS::SetOverrideSchItemColors().

◆ OnSize()

void PANEL_EESCHEMA_COLOR_SETTINGS::OnSize ( wxSizeEvent &  aEvent)
overrideprotectedvirtual

Reimplemented from PANEL_COLOR_SETTINGS_BASE.

Definition at line 462 of file panel_eeschema_color_settings.cpp.

463 {
464  zoomFitPreview();
465  aEvent.Skip();
466 }

References zoomFitPreview().

◆ OnThemeChanged()

void PANEL_COLOR_SETTINGS::OnThemeChanged ( wxCommandEvent &  aEvent)
overrideprotectedvirtualinherited

Reimplemented from PANEL_COLOR_SETTINGS_BASE.

Definition at line 110 of file panel_color_settings.cpp.

111 {
112  int idx = m_cbTheme->GetSelection();
113 
114  if( idx == static_cast<int>( m_cbTheme->GetCount() ) - 2 )
115  {
116  // separator; re-select active theme
117  m_cbTheme->SetStringSelection( m_currentSettings->GetName() );
118  return;
119  }
120 
121  if( idx == (int)m_cbTheme->GetCount() - 1 )
122  {
123  // New Theme...
124 
125  if( !saveCurrentTheme( false ) )
126  return;
127 
128  FOOTPRINT_NAME_VALIDATOR themeNameValidator;
129  wxTextEntryDialog dlg( this, _( "New theme name:" ), _( "Add Color Theme" ) );
130  dlg.SetTextValidator( themeNameValidator );
131 
132  if( dlg.ShowModal() != wxID_OK )
133  return;
134 
135  wxString themeName = dlg.GetValue();
136  wxFileName fn( themeName + wxT( ".json" ) );
138 
139  if( fn.Exists() )
140  {
141  wxMessageBox( _( "Theme already exists!" ) );
142  return;
143  }
144 
145  SETTINGS_MANAGER& settingsMgr = Pgm().GetSettingsManager();
146  COLOR_SETTINGS* newSettings = settingsMgr.AddNewColorSettings( themeName );
147  newSettings->SetName( themeName );
148  newSettings->SetReadOnly( false );
149 
150  for( auto layer : m_validLayers )
151  newSettings->SetColor( layer, m_currentSettings->GetColor( layer ) );
152 
153  newSettings->SaveToFile( settingsMgr.GetPathForSettingsFile( newSettings ) );
154 
155  idx = m_cbTheme->Insert( themeName, idx - 1, static_cast<void*>( newSettings ) );
156  m_cbTheme->SetSelection( idx );
157 
158  m_optOverrideColors->SetValue( newSettings->GetOverrideSchItemColors() );
159 
160  *m_currentSettings = *newSettings;
161  updateSwatches();
163  }
164  else
165  {
166  COLOR_SETTINGS* selected = static_cast<COLOR_SETTINGS*>( m_cbTheme->GetClientData( idx ) );
167 
168  if( selected->GetFilename() != m_currentSettings->GetFilename() )
169  {
170  if( !saveCurrentTheme( false ) )
171  return;
172 
173  m_optOverrideColors->SetValue( selected->GetOverrideSchItemColors() );
174 
175  *m_currentSettings = *selected;
177  updateSwatches();
178  }
179  }
180 }
virtual bool saveCurrentTheme(bool aValidate)
void SetReadOnly(bool aReadOnly)
Definition: json_settings.h:77
wxString GetFilename() const
Definition: json_settings.h:66
virtual void onNewThemeSelected()
Event fired when a new theme is selected that can be overridden in children.
const wxString & GetName() const
COLOR_SETTINGS * AddNewColorSettings(const wxString &aFilename)
Registers a new color settings object with the given filename.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:106
This class provides a custom wxValidator object for limiting the allowable characters when defining f...
Definition: validators.h:63
virtual bool SaveToFile(const wxString &aDirectory="", bool aForce=false)
COLOR_SETTINGS * m_currentSettings
void SetName(const wxString &aName)
std::vector< int > m_validLayers
A list of layer IDs that are valid for the current color settings dialog.
static wxString GetColorSettingsPath()
Returns the path where color scheme files are stored; creating it if missing (normally .
COLOR4D GetColor(int aLayer) const
#define _(s)
Definition: 3d_actions.cpp:33
Color settings are a bit different than most of the settings objects in that there can be more than o...
bool GetOverrideSchItemColors() const
wxString GetPathForSettingsFile(JSON_SETTINGS *aSettings)
Returns the path a given settings file should be loaded from / stored to.
void SetColor(int aLayer, COLOR4D aColor)

References _, SETTINGS_MANAGER::AddNewColorSettings(), COLOR_SETTINGS::GetColor(), SETTINGS_MANAGER::GetColorSettingsPath(), JSON_SETTINGS::GetFilename(), COLOR_SETTINGS::GetName(), COLOR_SETTINGS::GetOverrideSchItemColors(), SETTINGS_MANAGER::GetPathForSettingsFile(), PANEL_COLOR_SETTINGS_BASE::m_cbTheme, PANEL_COLOR_SETTINGS::m_currentSettings, PANEL_COLOR_SETTINGS_BASE::m_optOverrideColors, PANEL_COLOR_SETTINGS::m_validLayers, PANEL_COLOR_SETTINGS::onNewThemeSelected(), Pgm(), PANEL_COLOR_SETTINGS::saveCurrentTheme(), JSON_SETTINGS::SaveToFile(), COLOR_SETTINGS::SetColor(), COLOR_SETTINGS::SetName(), JSON_SETTINGS::SetReadOnly(), and PANEL_COLOR_SETTINGS::updateSwatches().

◆ ResetPanel()

void PANEL_EESCHEMA_COLOR_SETTINGS::ResetPanel ( )
overridevirtual

Reset the contents of this panel.

Reimplemented from PANEL_COLOR_SETTINGS.

Definition at line 421 of file panel_eeschema_color_settings.cpp.

422 {
424  updatePreview();
425 }
virtual void ResetPanel() override
Reset the contents of this panel.

References PANEL_COLOR_SETTINGS::ResetPanel(), and updatePreview().

◆ saveCurrentTheme()

bool PANEL_EESCHEMA_COLOR_SETTINGS::saveCurrentTheme ( bool  aValidate)
overrideprotectedvirtual

Reimplemented from PANEL_COLOR_SETTINGS.

Definition at line 167 of file panel_eeschema_color_settings.cpp.

168 {
169  for( auto layer : m_validLayers )
170  {
172 
173  // Do not allow non-background layers to be completely white.
174  // This ensures the BW printing recognizes that the colors should be printed black.
176  && layer != LAYER_SHEET_BACKGROUND )
177  {
178  color.Darken( 0.01 );
179  }
180 
181  m_currentSettings->SetColor( layer, color );
182  }
183 
184  return PANEL_COLOR_SETTINGS::saveCurrentTheme( aValidate );
185 }
virtual bool saveCurrentTheme(bool aValidate)
int color
Definition: DXF_plotter.cpp:60
COLOR_SETTINGS * m_currentSettings
std::vector< int > m_validLayers
A list of layer IDs that are valid for the current color settings dialog.
Definition: color4d.h:48
COLOR4D GetColor(int aLayer) const
void SetColor(int aLayer, COLOR4D aColor)
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:98

References color, COLOR_SETTINGS::GetColor(), LAYER_SCHEMATIC_BACKGROUND, LAYER_SHEET_BACKGROUND, PANEL_COLOR_SETTINGS::m_currentSettings, PANEL_COLOR_SETTINGS::m_validLayers, PANEL_COLOR_SETTINGS::saveCurrentTheme(), COLOR_SETTINGS::SetColor(), and WHITE.

Referenced by TransferDataFromWindow().

◆ Show()

bool PANEL_COLOR_SETTINGS::Show ( bool  show)
overrideinherited

Definition at line 82 of file panel_color_settings.cpp.

83 {
84  if( show )
85  {
86  // In case changes have been made to the current theme in another panel:
87  int idx = m_cbTheme->GetSelection();
88  COLOR_SETTINGS* settings = static_cast<COLOR_SETTINGS*>( m_cbTheme->GetClientData( idx ) );
89 
90  if( settings )
91  *m_currentSettings = *settings;
92 
95  }
96 
97  return PANEL_COLOR_SETTINGS_BASE::Show( show );
98 }
virtual void onNewThemeSelected()
Event fired when a new theme is selected that can be overridden in children.
COLOR_SETTINGS * m_currentSettings
Color settings are a bit different than most of the settings objects in that there can be more than o...

References PANEL_COLOR_SETTINGS_BASE::m_cbTheme, PANEL_COLOR_SETTINGS::m_currentSettings, PANEL_COLOR_SETTINGS::onNewThemeSelected(), and PANEL_COLOR_SETTINGS::updateSwatches().

◆ ShowColorContextMenu()

void PANEL_COLOR_SETTINGS::ShowColorContextMenu ( wxMouseEvent &  aEvent,
int  aLayer 
)
protectedinherited

Definition at line 270 of file panel_color_settings.cpp.

271 {
272  auto selected =
273  static_cast<COLOR_SETTINGS*>( m_cbTheme->GetClientData( m_cbTheme->GetSelection() ) );
274 
275  COLOR4D current = m_currentSettings->GetColor( aLayer );
276  COLOR4D saved = selected->GetColor( aLayer );
277  bool readOnly = m_currentSettings->IsReadOnly();
278 
279  wxMenu menu;
280 
281  AddMenuItem( &menu, ID_COPY, _( "Copy color" ), KiBitmap( BITMAPS::copy ) );
282 
283  if( !readOnly && m_copied != COLOR4D::UNSPECIFIED )
284  AddMenuItem( &menu, ID_PASTE, _( "Paste color" ), KiBitmap( BITMAPS::paste ) );
285 
286  if( !readOnly && current != saved )
287  AddMenuItem( &menu, ID_REVERT, _( "Revert to saved color" ), KiBitmap( BITMAPS::undo ) );
288 
289  menu.Bind( wxEVT_COMMAND_MENU_SELECTED,
290  [&]( wxCommandEvent& aCmd )
291  {
292  switch( aCmd.GetId() )
293  {
294  case ID_COPY:
295  m_copied = current;
296  break;
297 
298  case ID_PASTE:
299  updateColor( aLayer, m_copied );
300  break;
301 
302  case ID_REVERT:
303  updateColor( aLayer, saved );
304  break;
305 
306  default:
307  aCmd.Skip();
308  }
309  } );
310 
311  PopupMenu( &menu );
312 }
wxMenuItem * AddMenuItem(wxMenu *aMenu, int aId, const wxString &aText, const wxBitmap &aImage, wxItemKind aType=wxITEM_NORMAL)
Create and insert a menu item with an icon into aMenu.
Definition: bitmap.cpp:245
void updateColor(int aLayer, const KIGFX::COLOR4D &aColor)
COLOR_SETTINGS * m_currentSettings
COLOR4D GetColor(int aLayer) const
#define _(s)
Definition: 3d_actions.cpp:33
bool IsReadOnly() const
Definition: json_settings.h:76
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:98
wxBitmap KiBitmap(BITMAPS aBitmap)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:104

References _, AddMenuItem(), copy, COLOR_SETTINGS::GetColor(), PANEL_COLOR_SETTINGS::ID_COPY, PANEL_COLOR_SETTINGS::ID_PASTE, PANEL_COLOR_SETTINGS::ID_REVERT, JSON_SETTINGS::IsReadOnly(), KiBitmap(), PANEL_COLOR_SETTINGS_BASE::m_cbTheme, PANEL_COLOR_SETTINGS::m_copied, PANEL_COLOR_SETTINGS::m_currentSettings, paste, undo, and PANEL_COLOR_SETTINGS::updateColor().

Referenced by PANEL_COLOR_SETTINGS::createSwatch().

◆ TransferDataFromWindow()

bool PANEL_EESCHEMA_COLOR_SETTINGS::TransferDataFromWindow ( )
overrideprotected

Definition at line 119 of file panel_eeschema_color_settings.cpp.

120 {
122 
123  if( !saveCurrentTheme( true ) )
124  return false;
125 
127 
128  SETTINGS_MANAGER& settingsMgr = Pgm().GetSettingsManager();
129  EESCHEMA_SETTINGS* app_settings = settingsMgr.GetAppSettings<EESCHEMA_SETTINGS>();
130  app_settings->m_ColorTheme = m_currentSettings->GetFilename();
131 
132  return true;
133 }
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
wxString GetFilename() const
Definition: json_settings.h:66
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:106
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:207
bool saveCurrentTheme(bool aValidate) override
COLOR_SETTINGS * m_currentSettings
void SetOverrideSchItemColors(bool aFlag)
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
AppSettings * GetAppSettings(bool aLoadNow=true)
Returns a handle to the a given settings by type If the settings have already been loaded,...
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
virtual void LoadColors(const COLOR_SETTINGS *aSettings)
wxString m_ColorTheme
Active color theme name.
Definition: app_settings.h:184

References SETTINGS_MANAGER::GetAppSettings(), SCH_BASE_FRAME::GetCanvas(), JSON_SETTINGS::GetFilename(), KIGFX::VIEW::GetPainter(), KIGFX::PAINTER::GetSettings(), SCH_DRAW_PANEL::GetView(), KIGFX::RENDER_SETTINGS::LoadColors(), APP_SETTINGS_BASE::m_ColorTheme, PANEL_COLOR_SETTINGS::m_currentSettings, m_frame, PANEL_COLOR_SETTINGS_BASE::m_optOverrideColors, Pgm(), saveCurrentTheme(), and COLOR_SETTINGS::SetOverrideSchItemColors().

◆ TransferDataToWindow()

bool PANEL_EESCHEMA_COLOR_SETTINGS::TransferDataToWindow ( )
overrideprotected

Definition at line 136 of file panel_eeschema_color_settings.cpp.

137 {
138  zoomFitPreview();
139  return true;
140 }

References zoomFitPreview().

◆ updateColor()

void PANEL_COLOR_SETTINGS::updateColor ( int  aLayer,
const KIGFX::COLOR4D aColor 
)
protectedinherited

Definition at line 325 of file panel_color_settings.cpp.

326 {
327  if( m_currentSettings )
328  m_currentSettings->SetColor( aLayer, aColor );
329 
330  // Colors must be persisted when edited because multiple PANEL_COLOR_SETTINGS could be
331  // referring to the same theme.
332  saveCurrentTheme( false );
333 
334  m_swatches[aLayer]->SetSwatchColor( aColor, false );
335 
336  if( m_currentSettings && aLayer == m_backgroundLayer )
337  {
339 
340  for( std::pair<int, COLOR_SWATCH*> pair : m_swatches )
341  pair.second->SetSwatchBackground( background );
342  }
343 
344  onColorChanged();
345 }
virtual bool saveCurrentTheme(bool aValidate)
std::map< int, COLOR_SWATCH * > m_swatches
COLOR_SETTINGS * m_currentSettings
virtual void onColorChanged()
Event fired when the user changes any color.
COLOR4D GetColor(int aLayer) const
void SetColor(int aLayer, COLOR4D aColor)
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:98

References COLOR_SETTINGS::GetColor(), PANEL_COLOR_SETTINGS::m_backgroundLayer, PANEL_COLOR_SETTINGS::m_currentSettings, PANEL_COLOR_SETTINGS::m_swatches, PANEL_COLOR_SETTINGS::onColorChanged(), PANEL_COLOR_SETTINGS::saveCurrentTheme(), and COLOR_SETTINGS::SetColor().

Referenced by PANEL_COLOR_SETTINGS::OnColorChanged(), and PANEL_COLOR_SETTINGS::ShowColorContextMenu().

◆ updatePreview()

void PANEL_EESCHEMA_COLOR_SETTINGS::updatePreview ( )
private

Definition at line 428 of file panel_eeschema_color_settings.cpp.

429 {
430  if( !m_preview )
431  return;
432 
433  KIGFX::VIEW* view = m_preview->GetView();
434  auto settings = static_cast<KIGFX::SCH_RENDER_SETTINGS*>( view->GetPainter()->GetSettings() );
435  settings->LoadColors( m_currentSettings );
436 
437  m_preview->GetGAL()->SetClearColor( settings->GetBackgroundColor() );
438 
439  view->UpdateAllItems( KIGFX::COLOR );
440  auto rect = m_preview->GetScreenRect();
441  m_preview->Refresh( true, &rect );
442 }
void SetClearColor(const COLOR4D &aColor)
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
Definition: view.cpp:1415
Color has changed.
Definition: view_item.h:53
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:207
COLOR_SETTINGS * m_currentSettings
KIGFX::GAL * GetGAL() const
Return a pointer to the GAL instance used in the panel.
virtual KIGFX::VIEW * GetView() const
Return a pointer to the #VIEW instance used in the panel.
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:67
void Refresh(bool aEraseBackground, const wxRect *aRect) override
Update the board display after modifying it by a python script (note: it is automatically called by a...

References KIGFX::COLOR, EDA_DRAW_PANEL_GAL::GetGAL(), KIGFX::VIEW::GetPainter(), KIGFX::PAINTER::GetSettings(), EDA_DRAW_PANEL_GAL::GetView(), PANEL_COLOR_SETTINGS::m_currentSettings, m_preview, SCH_PREVIEW_PANEL::Refresh(), KIGFX::GAL::SetClearColor(), and KIGFX::VIEW::UpdateAllItems().

Referenced by onColorChanged(), onNewThemeSelected(), PANEL_EESCHEMA_COLOR_SETTINGS(), and ResetPanel().

◆ updateSwatches()

void PANEL_COLOR_SETTINGS::updateSwatches ( )
protectedinherited

Definition at line 183 of file panel_color_settings.cpp.

184 {
185  bool isReadOnly = m_currentSettings->IsReadOnly();
187 
188  for( std::pair<int, COLOR_SWATCH*> pair : m_swatches )
189  {
190  pair.second->SetSwatchBackground( background );
191  pair.second->SetSwatchColor( m_currentSettings->GetColor( pair.first ), false );
192  pair.second->SetReadOnly( isReadOnly );
193  }
194 }
std::map< int, COLOR_SWATCH * > m_swatches
COLOR_SETTINGS * m_currentSettings
COLOR4D GetColor(int aLayer) const
bool IsReadOnly() const
Definition: json_settings.h:76
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:98

References COLOR_SETTINGS::GetColor(), JSON_SETTINGS::IsReadOnly(), PANEL_COLOR_SETTINGS::m_backgroundLayer, PANEL_COLOR_SETTINGS::m_currentSettings, and PANEL_COLOR_SETTINGS::m_swatches.

Referenced by PANEL_COLOR_SETTINGS::OnThemeChanged(), and PANEL_COLOR_SETTINGS::Show().

◆ validateSave()

bool PANEL_EESCHEMA_COLOR_SETTINGS::validateSave ( bool  aQuiet = false)
overrideprotectedvirtual

Performs a pre-save validation of the current color theme.

Parameters
aQuietwill suppress any warning output (prompt dialogs)
Returns
true if save is allowed

Reimplemented from PANEL_COLOR_SETTINGS.

Definition at line 143 of file panel_eeschema_color_settings.cpp.

144 {
146 
147  for( SCH_LAYER_ID layer = SCH_LAYER_ID_START; layer < SCH_LAYER_ID_END; ++layer )
148  {
149  if( bgcolor == m_currentSettings->GetColor( layer )
150  && layer != LAYER_SCHEMATIC_BACKGROUND && layer != LAYER_SHEET_BACKGROUND )
151  {
152  wxString msg = _( "Some items have the same color as the background\n"
153  "and they will not be seen on the screen. Are you\n"
154  "sure you want to use these colors?" );
155 
156  if( wxMessageBox( msg, _( "Warning" ), wxYES_NO | wxICON_QUESTION, this ) == wxNO )
157  return false;
158 
159  break;
160  }
161  }
162 
163  return true;
164 }
COLOR_SETTINGS * m_currentSettings
SCH_LAYER_ID
Eeschema drawing layers.
COLOR4D GetColor(int aLayer) const
#define _(s)
Definition: 3d_actions.cpp:33
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:98

References _, COLOR_SETTINGS::GetColor(), LAYER_SCHEMATIC_BACKGROUND, LAYER_SHEET_BACKGROUND, PANEL_COLOR_SETTINGS::m_currentSettings, SCH_LAYER_ID_END, and SCH_LAYER_ID_START.

◆ zoomFitPreview()

void PANEL_EESCHEMA_COLOR_SETTINGS::zoomFitPreview ( )
private

Definition at line 445 of file panel_eeschema_color_settings.cpp.

446 {
447  auto view = m_preview->GetView();
448 
449  view->SetScale( 1.0 );
450  VECTOR2D screenSize = view->ToWorld( m_preview->GetClientSize(), false );
451 
452  VECTOR2I psize( m_page->GetWidthIU(), m_page->GetHeightIU() );
453  double scale = view->GetScale() / std::max( fabs( psize.x / screenSize.x ),
454  fabs( psize.y / screenSize.y ) );
455 
456  view->SetScale( scale * 1.1 );
457  view->SetCenter( m_drawingSheet->ViewBBox().Centre() );
459 }
void ForceRefresh()
Force a redraw.
virtual KIGFX::VIEW * GetView() const
Return a pointer to the #VIEW instance used in the panel.
virtual void SetScale(double aScale, VECTOR2D aAnchor={ 0, 0 })
Set the scaling factor, zooming around a given anchor point.
Definition: view.cpp:554
const int scale
const BOX2I ViewBBox() const override
Vec Centre() const
Definition: box2.h:79

References BOX2< Vec >::Centre(), EDA_DRAW_PANEL_GAL::ForceRefresh(), EDA_DRAW_PANEL_GAL::GetView(), m_drawingSheet, m_page, m_preview, scale, KIGFX::VIEW::SetScale(), DS_PROXY_VIEW_ITEM::ViewBBox(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by createPreviewItems(), OnSize(), PANEL_EESCHEMA_COLOR_SETTINGS(), and TransferDataToWindow().

Member Data Documentation

◆ m_backgroundLayer

◆ m_btnOpenFolder

wxButton* PANEL_COLOR_SETTINGS_BASE::m_btnOpenFolder
protectedinherited

◆ m_cbTheme

◆ m_colorNamespace

std::string PANEL_COLOR_SETTINGS::m_colorNamespace
protectedinherited

A namespace that will be passed to SETTINGS_MANAGER::SaveColorSettings.

This should be set to the appropriate namespace in the application-specific constructor

Definition at line 122 of file panel_color_settings.h.

Referenced by PANEL_EESCHEMA_COLOR_SETTINGS(), PANEL_FP_EDITOR_COLOR_SETTINGS::PANEL_FP_EDITOR_COLOR_SETTINGS(), PANEL_PCBNEW_COLOR_SETTINGS::PANEL_PCBNEW_COLOR_SETTINGS(), and PANEL_COLOR_SETTINGS::saveCurrentTheme().

◆ m_colorsGridSizer

wxFlexGridSizer* PANEL_COLOR_SETTINGS_BASE::m_colorsGridSizer
protectedinherited

◆ m_colorsListWindow

◆ m_colorsMainSizer

◆ m_copied

KIGFX::COLOR4D PANEL_COLOR_SETTINGS::m_copied
protectedinherited

Definition at line 104 of file panel_color_settings.h.

Referenced by PANEL_COLOR_SETTINGS::ShowColorContextMenu().

◆ m_currentSettings

◆ m_drawingSheet

DS_PROXY_VIEW_ITEM* PANEL_EESCHEMA_COLOR_SETTINGS::m_drawingSheet
private

◆ m_frame

SCH_BASE_FRAME* PANEL_EESCHEMA_COLOR_SETTINGS::m_frame
private

Definition at line 63 of file panel_eeschema_color_settings.h.

Referenced by TransferDataFromWindow().

◆ m_galDisplayOptions

KIGFX::GAL_DISPLAY_OPTIONS PANEL_EESCHEMA_COLOR_SETTINGS::m_galDisplayOptions
private

Definition at line 71 of file panel_eeschema_color_settings.h.

Referenced by PANEL_EESCHEMA_COLOR_SETTINGS().

◆ m_labels

std::map<int, wxStaticText*> PANEL_COLOR_SETTINGS::m_labels
protectedinherited

◆ m_mainSizer

wxBoxSizer* PANEL_COLOR_SETTINGS_BASE::m_mainSizer
protectedinherited

◆ m_optOverrideColors

◆ m_page

PAGE_INFO* PANEL_EESCHEMA_COLOR_SETTINGS::m_page
private

◆ m_preview

SCH_PREVIEW_PANEL* PANEL_EESCHEMA_COLOR_SETTINGS::m_preview
private

◆ m_previewItems

std::vector<EDA_ITEM*> PANEL_EESCHEMA_COLOR_SETTINGS::m_previewItems
private

◆ m_staticline2

wxStaticLine* PANEL_COLOR_SETTINGS_BASE::m_staticline2
protectedinherited

◆ m_staticText9

wxStaticText* PANEL_COLOR_SETTINGS_BASE::m_staticText9
protectedinherited

◆ m_swatches

◆ m_titleBlock

TITLE_BLOCK* PANEL_EESCHEMA_COLOR_SETTINGS::m_titleBlock
private

◆ m_validLayers

std::vector<int> PANEL_COLOR_SETTINGS::m_validLayers
protectedinherited

A list of layer IDs that are valid for the current color settings dialog.

Valid colors will be shown for editing and are the set of colors that actions like resetting to defaults will apply to.

This list must be filled in the application-specific color settings panel constructors.

Definition at line 114 of file panel_color_settings.h.

Referenced by PANEL_FP_EDITOR_COLOR_SETTINGS::createSwatches(), PANEL_PCBNEW_COLOR_SETTINGS::createSwatches(), PANEL_COLOR_SETTINGS::OnThemeChanged(), PANEL_EESCHEMA_COLOR_SETTINGS(), PANEL_FP_EDITOR_COLOR_SETTINGS::PANEL_FP_EDITOR_COLOR_SETTINGS(), PANEL_PCBNEW_COLOR_SETTINGS::PANEL_PCBNEW_COLOR_SETTINGS(), saveCurrentTheme(), and PANEL_COLOR_SETTINGS::saveCurrentTheme().


The documentation for this class was generated from the following files: