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)
 
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
 
KIGFX::WS_PROXY_VIEW_ITEMm_ws
 
std::vector< EDA_ITEM * > m_previewItems
 
KIGFX::GAL_DISPLAY_OPTIONS m_galDisplayOptions
 

Detailed Description

Definition at line 41 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_ws( 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  createThemeList( app_settings->m_ColorTheme );
70 
71  m_optOverrideColors->SetValue( current->GetOverrideSchItemColors() );
72 
73  m_currentSettings = new COLOR_SETTINGS( *current );
74 
75  for( int id = SCH_LAYER_ID_START; id < SCH_LAYER_ID_END; id++ )
76  m_validLayers.push_back( id );
77 
79 
81 
82  m_galDisplayOptions.ReadConfig( *common_settings, app_settings->m_Window, this );
84 
85  auto type = static_cast<EDA_DRAW_PANEL_GAL::GAL_TYPE>( app_settings->m_Graphics.canvas_type );
86 
87  m_preview = new SCH_PREVIEW_PANEL( this, wxID_ANY, wxDefaultPosition, wxSize( -1, -1 ),
88  m_galDisplayOptions, type );
89  m_preview->SetStealsFocus( false );
90  m_preview->ShowScrollbars( wxSHOW_SB_NEVER, wxSHOW_SB_NEVER );
91  m_preview->GetGAL()->SetAxesEnabled( false );
92 
93  m_colorsMainSizer->Add( 10, 0, 0, wxEXPAND, 5 );
94  m_colorsMainSizer->Add( m_preview, 1, wxALL | wxEXPAND, 5 );
95  m_colorsMainSizer->Add( 10, 0, 0, wxEXPAND, 5 );
96 
98  updatePreview();
100 }
bool m_forceDisplayCursor
Force cursor display
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:102
std::string m_colorNamespace
A namespace that will be passed to SETTINGS_MANAGER::SaveColorSettings.
void createThemeList(const wxString &aCurrent)
COLOR_SETTINGS * m_currentSettings
void SetStealsFocus(bool aStealsFocus)
Set whether focus is taken on certain events (mouseover, keys, etc).
KIGFX::GAL * GetGAL() const
Function GetGAL() Returns 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)
Enables 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:173
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:176

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 103 of file panel_eeschema_color_settings.cpp.

104 {
105  delete m_page;
106  delete m_titleBlock;
107  delete m_ws;
108  delete m_currentSettings;
109 
110  for( EDA_ITEM* item : m_previewItems )
111  delete item;
112 }
COLOR_SETTINGS * m_currentSettings
EDA_ITEM is a base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:148

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

Member Function Documentation

◆ createPreviewItems()

void PANEL_EESCHEMA_COLOR_SETTINGS::createPreviewItems ( )
private

Definition at line 221 of file panel_eeschema_color_settings.cpp.

222 {
223  KIGFX::VIEW* view = m_preview->GetView();
224 
227  m_titleBlock->SetTitle( _( "Color Preview" ) );
228  m_titleBlock->SetDate( wxDateTime::Now().FormatDate() );
229 
230  m_page->SetHeightMils( 5000 );
231  m_page->SetWidthMils( 6000 );
232 
235  view->Add( m_ws );
236 
237  // NOTE: It would be nice to parse a schematic file here.
238  // This is created from the color_settings.sch file in demos folder
239 
240  auto addItem = [&]( EDA_ITEM* aItem )
241  {
242  view->Add( aItem );
243  m_previewItems.push_back( aItem );
244  };
245 
246  std::vector<std::pair<SCH_LAYER_ID, std::pair<wxPoint, wxPoint>>> lines = {
247  { LAYER_WIRE, { { 1950, 1500 }, { 2325, 1500 } } },
248  { LAYER_WIRE, { { 1950, 2600 }, { 2350, 2600 } } },
249  { LAYER_WIRE, { { 2150, 1700 }, { 2325, 1700 } } },
250  { LAYER_WIRE, { { 2150, 2000 }, { 2150, 1700 } } },
251  { LAYER_WIRE, { { 2925, 1600 }, { 3075, 1600 } } },
252  { LAYER_WIRE, { { 3075, 1600 }, { 3075, 2000 } } },
253  { LAYER_WIRE, { { 3075, 1600 }, { 3250, 1600 } } },
254  { LAYER_WIRE, { { 3075, 2000 }, { 2150, 2000 } } },
255  { LAYER_BUS, { { 1750, 1400 }, { 1850, 1400 } } },
256  { LAYER_BUS, { { 1850, 2500 }, { 1850, 1400 } } },
257  { LAYER_NOTES, { { 2350, 2125 }, { 2350, 2300 } } },
258  { LAYER_NOTES, { { 2350, 2125 }, { 2950, 2125 } } },
259  { LAYER_NOTES, { { 2950, 2125 }, { 2950, 2300 } } },
260  { LAYER_NOTES, { { 2950, 2300 }, { 2350, 2300 } } }
261  };
262 
263  for( const auto& line : lines )
264  {
265  SCH_LINE* wire = new SCH_LINE;
266  wire->SetLayer( line.first );
267  wire->SetStartPoint( wxPoint( Mils2iu( line.second.first.x ),
268  Mils2iu( line.second.first.y ) ) );
269  wire->SetEndPoint( wxPoint( Mils2iu( line.second.second.x ),
270  Mils2iu( line.second.second.y ) ) );
271  addItem( wire );
272  }
273 
274  auto nc = new SCH_NO_CONNECT;
275  nc->SetPosition( wxPoint( Mils2iu( 2525 ), Mils2iu( 1300 ) ) );
276  addItem( nc );
277 
278  auto e1 = new SCH_BUS_WIRE_ENTRY;
279  e1->SetPosition( wxPoint( Mils2iu( 1850 ), Mils2iu( 1400 ) ) );
280  addItem( e1 );
281 
282  auto e2 = new SCH_BUS_WIRE_ENTRY;
283  e2->SetPosition( wxPoint( Mils2iu( 1850 ), Mils2iu( 2500 ) ) );
284  addItem( e2 );
285 
286  auto t1 = new SCH_TEXT( wxPoint( Mils2iu( 2850 ), Mils2iu( 2250 ) ), wxT( "PLAIN TEXT" ) );
287  t1->SetLabelSpinStyle( LABEL_SPIN_STYLE::SPIN::LEFT );
288  addItem( t1 );
289 
290  auto t2 = new SCH_LABEL( wxPoint( Mils2iu( 1975 ), Mils2iu( 1500 ) ), wxT( "LABEL_{0}" ) );
291  t2->SetLabelSpinStyle( LABEL_SPIN_STYLE::SPIN::RIGHT );
292  t2->SetIsDangling( false );
293  addItem( t2 );
294 
295  auto t3 = new SCH_LABEL( wxPoint( Mils2iu( 1975 ), Mils2iu( 2600 ) ), wxT( "LABEL_{1}" ) );
296  t3->SetLabelSpinStyle( LABEL_SPIN_STYLE::SPIN::RIGHT );
297  t3->SetIsDangling( false );
298  addItem( t3 );
299 
300  auto t4 = new SCH_GLOBALLABEL( wxPoint( Mils2iu( 1750 ), Mils2iu( 1400 ) ), wxT( "GLOBAL[3..0]" ) );
301  t4->SetLabelSpinStyle( LABEL_SPIN_STYLE::SPIN::LEFT );
302  t4->SetIsDangling( false );
303  addItem( t4 );
304 
305  auto t5 = new SCH_HIERLABEL( wxPoint( Mils2iu( 3250 ), Mils2iu( 1600 ) ), wxT( "HIER_LABEL" ) );
306  t5->SetLabelSpinStyle( LABEL_SPIN_STYLE::SPIN::RIGHT );
307  t5->SetIsDangling( false );
308  addItem( t5 );
309 
310  auto j = new SCH_JUNCTION( wxPoint( Mils2iu( 3075 ), Mils2iu( 1600 ) ) );
311  addItem( j );
312 
313  e2->SetBrightened();
314  t2->SetSelected();
315 
316  {
317  LIB_PART* part = new LIB_PART( wxEmptyString );
318  wxPoint p( 2625, -1600 );
319 
320  LIB_FIELD& ref = part->GetReferenceField();
321 
322  ref.SetText( wxT( "U1" ) );
323  ref.SetPosition( wxPoint( Mils2iu( p.x + 30 ), Mils2iu( p.y + 260 ) ) );
325 
326  LIB_FIELD& value = part->GetValueField();
327 
328  value.SetText( wxT( "OPA604" ) );
329  value.SetPosition( wxPoint( Mils2iu( p.x + 30 ), Mils2iu( p.y + 180 ) ) );
331 
332  part->SetShowPinNames( true );
333  part->SetShowPinNumbers( true );
334  part->SetPinNameOffset( 0 );
335 
336  addItem( part );
337 
338  LIB_POLYLINE* comp_body = new LIB_POLYLINE( part );
339 
340  comp_body->SetUnit( 0 );
341  comp_body->SetConvert( 0 );
342  comp_body->SetWidth( Mils2iu( 10 ) );
344  comp_body->AddPoint( wxPoint( Mils2iu( p.x - 200 ), Mils2iu( p.y + 200 ) ) );
345  comp_body->AddPoint( wxPoint( Mils2iu( p.x + 200 ), Mils2iu( p.y ) ) );
346  comp_body->AddPoint( wxPoint( Mils2iu( p.x - 200 ), Mils2iu( p.y - 200 ) ) );
347  comp_body->AddPoint( wxPoint( Mils2iu( p.x - 200 ), Mils2iu( p.y + 200 ) ) );
348 
349  addItem( comp_body );
350 
351  LIB_PIN* pin = new LIB_PIN( part );
352 
353  pin->SetPosition( wxPoint( Mils2iu( p.x - 200 ), Mils2iu( p.y + 100 ) ) );
354  pin->SetLength( Mils2iu( 100 ) );
355  pin->SetOrientation( PIN_LEFT );
357  pin->SetNumber( wxT( "1" ) );
358  pin->SetName( wxT( "-" ) );
359 
360  part->AddDrawItem( pin );
361 
362  pin = new LIB_PIN( part );
363 
364  pin->SetPosition( wxPoint( Mils2iu( p.x - 200 ), Mils2iu( p.y - 100 ) ) );
365  pin->SetLength( Mils2iu( 100 ) );
366  pin->SetOrientation( PIN_LEFT );
368  pin->SetNumber( wxT( "2" ) );
369  pin->SetName( wxT( "+" ) );
370 
371  part->AddDrawItem( pin );
372 
373  pin = new LIB_PIN( part );
374 
375  pin->SetPosition( wxPoint( Mils2iu( p.x + 200 ), Mils2iu( p.y ) ) );
376  pin->SetLength( Mils2iu( 100 ) );
377  pin->SetOrientation( PIN_RIGHT );
379  pin->SetNumber( wxT( "3" ) );
380  pin->SetName( wxT( "OUT" ) );
381 
382  part->AddDrawItem( pin );
383  }
384 
385  auto s = new SCH_SHEET( nullptr, wxPoint( Mils2iu( 4000 ), Mils2iu( 1300 ) ) );
386  s->SetSize( wxSize( Mils2iu( 800 ), Mils2iu( 1300 ) ) );
387  s->GetFields().at( SHEETNAME ).SetText( wxT( "SHEET" ) );
388  s->GetFields().at( SHEETFILENAME ).SetText( _( "/path/to/sheet" ) );
389  s->AutoplaceFields( nullptr, false );
390  addItem( s );
391 
392  auto sp = new SCH_SHEET_PIN( s, wxPoint( Mils2iu( 4500 ), Mils2iu( 1500 ) ), wxT( "SHEET PIN" ) );
393  addItem( sp );
394 
395  zoomFitPreview();
396 }
void SetOrientation(int aOrientation)
Definition: lib_pin.h:126
Field object used in symbol libraries.
Definition: lib_field.h:59
void SetFillMode(FILL_TYPE aFillMode)
Definition: lib_item.h:301
void SetPosition(const wxPoint &aPosition) override
LIB_FIELD & GetValueField()
Return reference to the value field.
void SetDate(const wxString &aDate)
Function SetDate sets the date field, and defaults to the current time and date.
Definition: title_block.h:74
void SetLength(int aLength)
Definition: lib_pin.h:132
static const wxChar Custom[]
"User" defined page type
Definition: page_info.h:79
void SetPosition(const wxPoint &aPos) override
Definition: lib_pin.h:259
void SetColorLayer(int aLayerId)
Can be used to override which layer ID is used for worksheet item colors.
void SetWidth(int aWidth) override
Definition: lib_polyline.h:103
TITLE_BLOCK holds the information shown in the lower right corner of a plot, printout,...
Definition: title_block.h:40
void SetEndPoint(const wxPoint &aPosition)
Definition: sch_line.h:98
void AddDrawItem(LIB_ITEM *aItem)
Add a new draw aItem to the draw object list.
void SetNumber(const wxString &aNumber)
Definition: lib_pin.h:166
void SetType(ELECTRICAL_PINTYPE aType)
Definition: lib_pin.h:135
LIB_FIELD & GetReferenceField()
Return reference to the reference designator field.
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:121
void SetPosition(const wxPoint &aPosition) override
PAGE_INFO describes the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:54
void SetStartPoint(const wxPoint &aPosition)
Definition: sch_line.h:95
void SetLayer(SCH_LAYER_ID aLayer)
Set the layer this item is on.
Definition: sch_item.h:292
Define a library symbol object.
virtual KIGFX::VIEW * GetView() const
Function GetView() Returns 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.h:85
void AddPoint(const wxPoint &aPoint)
void SetTitle(const wxString &aTitle)
Definition: title_block.h:60
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:219
void SetConvert(int aConvert)
Definition: lib_item.h:298
void SetUnit(int aUnit)
Definition: lib_item.h:295
void SetName(const wxString &aName)
Definition: lib_pin.h:157
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.
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
EDA_ITEM is a base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:148
Class for a wire to bus entry.
void SetPosition(const wxPoint &aPosition) override
Definition: lib_item.h:249
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:327
VIEW.
Definition: view.h:63
void SetShowPinNames(bool aShow)
Set or clear the pin name visibility flag.
void SetPinNameOffset(int aOffset)
Set the offset in mils of the pin name text from the pin symbol.

References _, KIGFX::VIEW::Add(), LIB_PART::AddDrawItem(), LIB_POLYLINE::AddPoint(), PAGE_INFO::Custom, FILLED_WITH_BG_BODYCOLOR, LIB_PART::GetReferenceField(), LIB_PART::GetValueField(), EDA_DRAW_PANEL_GAL::GetView(), GR_TEXT_HJUSTIFY_LEFT, IU_PER_MILS, LAYER_BUS, LAYER_NOTES, LAYER_SCHEMATIC_WORKSHEET, LAYER_WIRE, m_page, m_preview, m_previewItems, m_titleBlock, m_ws, PIN_LEFT, PIN_RIGHT, PT_INPUT, PT_OUTPUT, KIGFX::WS_PROXY_VIEW_ITEM::SetColorLayer(), LIB_ITEM::SetConvert(), TITLE_BLOCK::SetDate(), SCH_LINE::SetEndPoint(), LIB_ITEM::SetFillMode(), PAGE_INFO::SetHeightMils(), EDA_TEXT::SetHorizJustify(), SCH_ITEM::SetLayer(), LIB_PIN::SetLength(), LIB_PIN::SetName(), LIB_PIN::SetNumber(), LIB_PIN::SetOrientation(), LIB_PART::SetPinNameOffset(), SCH_NO_CONNECT::SetPosition(), SCH_BUS_ENTRY_BASE::SetPosition(), LIB_ITEM::SetPosition(), LIB_PIN::SetPosition(), LIB_PART::SetShowPinNames(), LIB_PART::SetShowPinNumbers(), SCH_LINE::SetStartPoint(), EDA_TEXT::SetText(), TITLE_BLOCK::SetTitle(), LIB_PIN::SetType(), 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 231 of file panel_color_settings.cpp.

232 {
233  wxStaticText* label = new wxStaticText( m_colorsListWindow, wxID_ANY, aName );
234 
235  // The previously selected theme can be deleted and cannot be selected.
236  // so select the default theme (first theme of the list)
237  if( m_cbTheme->GetSelection() < 0 )
238  {
239  m_cbTheme->SetSelection( 0 );
241  }
242 
243  void* clientData = m_cbTheme->GetClientData( m_cbTheme->GetSelection() );
244  COLOR_SETTINGS* selected = static_cast<COLOR_SETTINGS*>( clientData );
245 
246  int id = FIRST_BUTTON_ID + aLayer;
247  COLOR4D defaultColor = selected->GetDefaultColor( aLayer );
249  COLOR4D backgroundColor = m_currentSettings->GetColor( m_backgroundLayer );
250 
251  COLOR_SWATCH* swatch = new COLOR_SWATCH( m_colorsListWindow, color, id, backgroundColor,
252  defaultColor, SWATCH_MEDIUM );
253  swatch->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) );
254 
255  m_colorsGridSizer->Add( label, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxLEFT, 5 );
256  m_colorsGridSizer->Add( swatch, 0, wxALIGN_CENTER_VERTICAL | wxALL, 3 );
257 
258  m_labels[aLayer] = label;
259  m_swatches[aLayer] = swatch;
260 
261  swatch->Bind( wxEVT_RIGHT_DOWN,
262  [&, aLayer]( wxMouseEvent& aEvent )
263  {
264  ShowColorContextMenu( aEvent, aLayer );
265  } );
266 
267  swatch->Bind( COLOR_SWATCH_CHANGED, &PANEL_COLOR_SETTINGS::OnColorChanged, this );
268 }
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)
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:100

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 184 of file panel_eeschema_color_settings.cpp.

185 {
186  std::vector<SCH_LAYER_ID> layers;
187 
189  layers.push_back( i );
190 
191  std::sort( layers.begin(), layers.end(),
192  []( SCH_LAYER_ID a, SCH_LAYER_ID b )
193  {
194  return LayerName( a ) < LayerName( b );
195  } );
196 
197  for( int layer : layers )
198  {
199  wxString name = LayerName( layer );
200 
201  if( layer == LAYER_SCHEMATIC_GRID_AXES )
202  name += wxS( " " ) + _( "(symbol editor only)" );
203 
204  createSwatch( layer, name );
205  }
206 
207  // Give a minimal width to m_colorsListWindow, in order to always having
208  // a full row shown
209  int min_width = m_colorsGridSizer->GetMinSize().x;
210  const int margin = 20; // A margin around the sizer
211  m_colorsListWindow->SetMinSize( wxSize( min_width + margin, -1 ) );
212 }
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

Definition at line 198 of file panel_color_settings.cpp.

199 {
200  int width = 0;
201  int height = 0;
202 
203  m_cbTheme->GetTextExtent( _( "New Theme..." ), &width, &height );
204  int minwidth = width;
205 
206  m_cbTheme->Clear();
207 
208  for( COLOR_SETTINGS* settings : Pgm().GetSettingsManager().GetColorSettingsList() )
209  {
210  wxString name = settings->GetName();
211 
212  if( settings->IsReadOnly() )
213  name += wxS( " " ) + _( "(read-only)" );
214 
215  int pos = m_cbTheme->Append( name, static_cast<void*>( settings ) );
216 
217  if( settings->GetFilename() == aCurrent )
218  m_cbTheme->SetSelection( pos );
219 
220  m_cbTheme->GetTextExtent( name, &width, &height );
221  minwidth = std::max( minwidth, width );
222  }
223 
224  m_cbTheme->Append( wxT( "---" ) );
225  m_cbTheme->Append( _( "New Theme..." ) );
226 
227  m_cbTheme->SetMinSize( wxSize( minwidth + 50, -1 ) );
228 }
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:102
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 399 of file panel_eeschema_color_settings.cpp.

References updatePreview().

◆ OnColorChanged()

void PANEL_COLOR_SETTINGS::OnColorChanged ( wxCommandEvent &  aEvent)
protectedinherited

Definition at line 316 of file panel_color_settings.cpp.

317 {
318  COLOR_SWATCH* swatch = static_cast<COLOR_SWATCH*>( aEvent.GetEventObject() );
319  COLOR4D newColor = swatch->GetSwatchColor();
320  LAYER_NUM layer = static_cast<SCH_LAYER_ID>( swatch->GetId() - FIRST_BUTTON_ID );
321 
322  updateColor( layer, newColor );
323 }
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
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:100

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
104  wxString sel = m_cbTheme->GetStringSelection();
105  createThemeList( sel );
106 
107  event.Skip();
108 }
void createThemeList(const wxString &aCurrent)

References PANEL_COLOR_SETTINGS::createThemeList(), and PANEL_COLOR_SETTINGS_BASE::m_cbTheme.

◆ 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 215 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 453 of file panel_eeschema_color_settings.cpp.

454 {
456 
457  // If the theme is not overriding individual item colors then don't show them so that
458  // the user doesn't get seduced into thinking they'll have some effect.
461 
464 
465  m_colorsGridSizer->Layout();
466  m_colorsListWindow->Layout();
467 }
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 446 of file panel_eeschema_color_settings.cpp.

447 {
448  zoomFitPreview();
449  aEvent.Skip();
450 }

References zoomFitPreview().

◆ OnThemeChanged()

void PANEL_COLOR_SETTINGS::OnThemeChanged ( wxCommandEvent &  aEvent)
overrideprotectedvirtualinherited

Reimplemented from PANEL_COLOR_SETTINGS_BASE.

Definition at line 111 of file panel_color_settings.cpp.

112 {
113  int idx = m_cbTheme->GetSelection();
114 
115  if( idx == static_cast<int>( m_cbTheme->GetCount() ) - 2 )
116  {
117  // separator; re-select active theme
118  m_cbTheme->SetStringSelection( m_currentSettings->GetName() );
119  return;
120  }
121 
122  if( idx == (int)m_cbTheme->GetCount() - 1 )
123  {
124  // New Theme...
125 
126  if( !saveCurrentTheme( false ) )
127  return;
128 
129  FOOTPRINT_NAME_VALIDATOR themeNameValidator;
130  wxTextEntryDialog dlg( this, _( "New theme name:" ), _( "Add Color Theme" ) );
131  dlg.SetTextValidator( themeNameValidator );
132 
133  if( dlg.ShowModal() != wxID_OK )
134  return;
135 
136  wxString themeName = dlg.GetValue();
137  wxFileName fn( themeName + wxT( ".json" ) );
139 
140  if( fn.Exists() )
141  {
142  wxMessageBox( _( "Theme already exists!" ) );
143  return;
144  }
145 
146  SETTINGS_MANAGER& settingsMgr = Pgm().GetSettingsManager();
147  COLOR_SETTINGS* newSettings = settingsMgr.AddNewColorSettings( themeName );
148  newSettings->SetName( themeName );
149  newSettings->SetReadOnly( false );
150 
151  for( auto layer : m_validLayers )
152  newSettings->SetColor( layer, m_currentSettings->GetColor( layer ) );
153 
154  newSettings->SaveToFile( settingsMgr.GetPathForSettingsFile( newSettings ) );
155 
156  idx = m_cbTheme->Insert( themeName, idx - 1, static_cast<void*>( newSettings ) );
157  m_cbTheme->SetSelection( idx );
158 
159  m_optOverrideColors->SetValue( newSettings->GetOverrideSchItemColors() );
160 
161  *m_currentSettings = *newSettings;
162  updateSwatches();
164  }
165  else
166  {
167  COLOR_SETTINGS* selected = static_cast<COLOR_SETTINGS*>( m_cbTheme->GetClientData( idx ) );
168 
169  if( selected->GetFilename() != m_currentSettings->GetFilename() )
170  {
171  if( !saveCurrentTheme( false ) )
172  return;
173 
174  m_optOverrideColors->SetValue( selected->GetOverrideSchItemColors() );
175 
176  *m_currentSettings = *selected;
178  updateSwatches();
179  }
180  }
181 }
virtual bool saveCurrentTheme(bool aValidate)
void SetReadOnly(bool aReadOnly)
Definition: json_settings.h:75
wxString GetFilename() const
Definition: json_settings.h:64
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:102
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 405 of file panel_eeschema_color_settings.cpp.

406 {
408  updatePreview();
409 }
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 163 of file panel_eeschema_color_settings.cpp.

164 {
165  for( auto layer : m_validLayers )
166  {
168 
169  // Do not allow non-background layers to be completely white.
170  // This ensures the BW printing recognizes that the colors should be printed black.
172  && layer != LAYER_SHEET_BACKGROUND )
173  {
174  color.Darken( 0.01 );
175  }
176 
177  m_currentSettings->SetColor( layer, color );
178  }
179 
180  return PANEL_COLOR_SETTINGS::saveCurrentTheme( aValidate );
181 }
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:49
COLOR4D GetColor(int aLayer) const
void SetColor(int aLayer, COLOR4D aColor)
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:100

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 271 of file panel_color_settings.cpp.

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

References _, AddMenuItem(), copy_xpm, 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_xpm, undo_xpm, and PANEL_COLOR_SETTINGS::updateColor().

Referenced by PANEL_COLOR_SETTINGS::createSwatch().

◆ TransferDataFromWindow()

bool PANEL_EESCHEMA_COLOR_SETTINGS::TransferDataFromWindow ( )
overrideprotected

Definition at line 115 of file panel_eeschema_color_settings.cpp.

116 {
118 
119  if( !saveCurrentTheme( true ) )
120  return false;
121 
123 
124  SETTINGS_MANAGER& settingsMgr = Pgm().GetSettingsManager();
125  EESCHEMA_SETTINGS* app_settings = settingsMgr.GetAppSettings<EESCHEMA_SETTINGS>();
126  app_settings->m_ColorTheme = m_currentSettings->GetFilename();
127 
128  return true;
129 }
KIGFX::SCH_VIEW * GetView() const override
Function GetView() Returns a pointer to the VIEW instance used in the panel.
wxString GetFilename() const
Definition: json_settings.h:64
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:102
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:201
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
Function GetAdapter Returns 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:176

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 132 of file panel_eeschema_color_settings.cpp.

133 {
134  zoomFitPreview();
135  return true;
136 }

References zoomFitPreview().

◆ updateColor()

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

Definition at line 326 of file panel_color_settings.cpp.

327 {
328  if( m_currentSettings )
329  m_currentSettings->SetColor( aLayer, aColor );
330 
331  // Colors must be persisted when edited because multiple PANEL_COLOR_SETTINGS could be
332  // referring to the same theme.
333  saveCurrentTheme( false );
334 
335  m_swatches[aLayer]->SetSwatchColor( aColor, false );
336 
337  if( m_currentSettings && aLayer == m_backgroundLayer )
338  {
340 
341  for( std::pair<int, COLOR_SWATCH*> pair : m_swatches )
342  pair.second->SetSwatchBackground( background );
343  }
344 
345  onColorChanged();
346 }
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)
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:100

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 412 of file panel_eeschema_color_settings.cpp.

413 {
414  if( !m_preview )
415  return;
416 
417  KIGFX::VIEW* view = m_preview->GetView();
418  auto settings = static_cast<KIGFX::SCH_RENDER_SETTINGS*>( view->GetPainter()->GetSettings() );
419  settings->LoadColors( m_currentSettings );
420 
421  m_preview->GetGAL()->SetClearColor( settings->GetBackgroundColor() );
422 
423  view->UpdateAllItems( KIGFX::COLOR );
424  auto rect = m_preview->GetScreenRect();
425  m_preview->Refresh( true, &rect );
426 }
void SetClearColor(const COLOR4D &aColor)
void UpdateAllItems(int aUpdateFlags)
Updates all items in the view according to the given flags.
Definition: view.cpp:1417
Visibility flag has changed.
Definition: view_item.h:58
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:201
COLOR_SETTINGS * m_currentSettings
KIGFX::GAL * GetGAL() const
Function GetGAL() Returns a pointer to the GAL instance used in the panel.
virtual KIGFX::VIEW * GetView() const
Function GetView() Returns a pointer to the VIEW instance used in the panel.
virtual RENDER_SETTINGS * GetSettings()=0
Function GetAdapter Returns pointer to current settings that are going to be used when drawing items.
VIEW.
Definition: view.h:63
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 184 of file panel_color_settings.cpp.

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

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 139 of file panel_eeschema_color_settings.cpp.

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

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 429 of file panel_eeschema_color_settings.cpp.

430 {
431  auto view = m_preview->GetView();
432 
433  view->SetScale( 1.0 );
434  VECTOR2D screenSize = view->ToWorld( m_preview->GetClientSize(), false );
435 
436  VECTOR2I psize( m_page->GetWidthIU(), m_page->GetHeightIU() );
437  double scale = view->GetScale() / std::max( fabs( psize.x / screenSize.x ),
438  fabs( psize.y / screenSize.y ) );
439 
440  view->SetScale( scale * 1.1 );
441  view->SetCenter( m_ws->ViewBBox().Centre() );
443 }
void ForceRefresh()
Function ForceRefresh() Forces a redraw.
const BOX2I ViewBBox() const override
Function ViewBBox() returns the bounding box of the item covering all its layers.
virtual KIGFX::VIEW * GetView() const
Function GetView() Returns a pointer to the VIEW instance used in the panel.
virtual void SetScale(double aScale, VECTOR2D aAnchor={ 0, 0 })
Function SetScale() Sets the scaling factor, zooming around a given anchor point.
Definition: view.cpp:559
const int scale
Vec Centre() const
Definition: box2.h:79

References BOX2< Vec >::Centre(), EDA_DRAW_PANEL_GAL::ForceRefresh(), EDA_DRAW_PANEL_GAL::GetView(), m_page, m_preview, m_ws, scale, KIGFX::VIEW::SetScale(), KIGFX::WS_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 118 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 100 of file panel_color_settings.h.

Referenced by PANEL_COLOR_SETTINGS::ShowColorContextMenu().

◆ m_currentSettings

◆ m_frame

SCH_BASE_FRAME* PANEL_EESCHEMA_COLOR_SETTINGS::m_frame
private

Definition at line 65 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 73 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 110 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().

◆ m_ws

KIGFX::WS_PROXY_VIEW_ITEM* PANEL_EESCHEMA_COLOR_SETTINGS::m_ws
private

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