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 (wxWindow *aParent)
 
 ~PANEL_EESCHEMA_COLOR_SETTINGS () override
 
void ResetPanel () override
 Reset the contents of this panel. More...
 
virtual wxString GetResetTooltip () const override
 Get the tooltip the reset button should display when showing this panel. More...
 
bool Show (bool show) override
 
wxString GetHelpTextAtPoint (const wxPoint &aPt, wxHelpEvent::Origin aOrigin) const override
 Overridden to supply the reset button tooltip when queried with { -INT_MAX, INT_MAX }. More...
 

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 createSwatches () 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
 
wxBoxSizer * m_previewPanelSizer
 

Private Member Functions

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

Private Attributes

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
 
EDA_DRAW_PANEL_GAL::GAL_TYPE m_galType
 

Detailed Description

Definition at line 35 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 ( wxWindow *  aParent)

Definition at line 57 of file panel_eeschema_color_settings.cpp.

57 :
58 PANEL_COLOR_SETTINGS( aParent ),
59 m_preview( nullptr ),
60 m_page( nullptr ),
61 m_titleBlock( nullptr ),
62 m_drawingSheet( nullptr ),
64{
65 m_colorNamespace = "schematic";
66
67 SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
68 COMMON_SETTINGS* common_settings = Pgm().GetCommonSettings();
70 COLOR_SETTINGS* current = mgr.GetColorSettings( app_settings->m_ColorTheme );
71
72 // Saved theme doesn't exist? Reset to default
73 if( current->GetFilename() != app_settings->m_ColorTheme )
74 app_settings->m_ColorTheme = current->GetFilename();
75
76 createThemeList( app_settings->m_ColorTheme );
77
78 m_optOverrideColors->SetValue( current->GetOverrideSchItemColors() );
79
80 m_currentSettings = new COLOR_SETTINGS( *current );
81
82 for( int id = SCH_LAYER_ID_START; id < SCH_LAYER_ID_END; id++ )
83 {
84 if( g_excludedLayers.count( id ) )
85 continue;
86
87 m_validLayers.push_back( id );
88 }
89
91
92 m_galDisplayOptions.ReadConfig( *common_settings, app_settings->m_Window, this );
94
95 m_galType = static_cast<EDA_DRAW_PANEL_GAL::GAL_TYPE>( app_settings->m_Graphics.canvas_type );
96}
WINDOW_SETTINGS m_Window
Definition: app_settings.h:181
wxString m_ColorTheme
Active color theme name.
Definition: app_settings.h:184
Color settings are a bit different than most of the settings objects in that there can be more than o...
void ReadConfig(COMMON_SETTINGS &aCommonConfig, WINDOW_SETTINGS &aWindowConfig, wxWindow *aWindow)
Read application and common configs.
bool m_forceDisplayCursor
The pixel scale factor (>1 for hi-DPI scaled displays)
void createThemeList(const wxString &aCurrent)
Builds the theme listbox and sets the selection to the current theme.
std::vector< int > m_validLayers
A list of layer IDs that are valid for the current color settings dialog.
std::string m_colorNamespace
A namespace that will be passed to SETTINGS_MANAGER::SaveColorSettings.
COLOR_SETTINGS * m_currentSettings
PANEL_COLOR_SETTINGS(wxWindow *aParent)
KIGFX::GAL_DISPLAY_OPTIONS m_galDisplayOptions
EDA_DRAW_PANEL_GAL::GAL_TYPE m_galType
T * GetAppSettings(bool aLoadNow=true)
Returns a handle to the a given settings by type If the settings have already been loaded,...
COLOR_SETTINGS * GetColorSettings(const wxString &aName="user")
Retrieves a color settings object that applications can read colors from.
@ SCH_LAYER_ID_END
Definition: layer_ids.h:387
@ SCH_LAYER_ID_START
Definition: layer_ids.h:342
@ LAYER_SCHEMATIC_BACKGROUND
Definition: layer_ids.h:376
std::set< int > g_excludedLayers
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:111

References APP_SETTINGS_BASE::GRAPHICS::canvas_type, PANEL_COLOR_SETTINGS::createThemeList(), g_excludedLayers, SETTINGS_MANAGER::GetAppSettings(), SETTINGS_MANAGER::GetColorSettings(), LAYER_SCHEMATIC_BACKGROUND, PANEL_COLOR_SETTINGS::m_backgroundLayer, PANEL_COLOR_SETTINGS::m_colorNamespace, APP_SETTINGS_BASE::m_ColorTheme, PANEL_COLOR_SETTINGS::m_currentSettings, KIGFX::GAL_DISPLAY_OPTIONS::m_forceDisplayCursor, m_galDisplayOptions, m_galType, APP_SETTINGS_BASE::m_Graphics, PANEL_COLOR_SETTINGS_BASE::m_optOverrideColors, PANEL_COLOR_SETTINGS::m_validLayers, APP_SETTINGS_BASE::m_Window, Pgm(), KIGFX::GAL_DISPLAY_OPTIONS::ReadConfig(), SCH_LAYER_ID_END, and SCH_LAYER_ID_START.

◆ ~PANEL_EESCHEMA_COLOR_SETTINGS()

PANEL_EESCHEMA_COLOR_SETTINGS::~PANEL_EESCHEMA_COLOR_SETTINGS ( )
override

Definition at line 99 of file panel_eeschema_color_settings.cpp.

100{
101 delete m_page;
102 delete m_titleBlock;
103 delete m_drawingSheet;
104 delete m_currentSettings;
105
106 for( EDA_ITEM* item : m_previewItems )
107 delete item;
108}
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100

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
240 std::vector<DANGLING_END_ITEM> endPoints;
241
244 m_titleBlock->SetTitle( _( "Color Preview" ) );
245 m_titleBlock->SetDate( wxDateTime::Now().FormatDate() );
246
247 m_page->SetHeightMils( 5000 );
248 m_page->SetWidthMils( 6000 );
249
253 view->Add( m_drawingSheet );
254
255 // TODO: It would be nice to parse a schematic file here.
256 // This is created from the color_settings.sch file in demos folder
257
258 auto addItem = [&]( EDA_ITEM* aItem )
259 {
260 view->Add( aItem );
261 m_previewItems.push_back( aItem );
262 };
263
264 std::vector<std::pair<SCH_LAYER_ID, std::pair<VECTOR2I, VECTOR2I>>> lines = {
265 { LAYER_WIRE, { { 1950, 1500 }, { 2325, 1500 } } },
266 { LAYER_WIRE, { { 1950, 2600 }, { 2350, 2600 } } },
267 { LAYER_WIRE, { { 2150, 1700 }, { 2325, 1700 } } },
268 { LAYER_WIRE, { { 2150, 2000 }, { 2150, 1700 } } },
269 { LAYER_WIRE, { { 2925, 1600 }, { 3075, 1600 } } },
270 { LAYER_WIRE, { { 3075, 1600 }, { 3075, 2000 } } },
271 { LAYER_WIRE, { { 3075, 1600 }, { 3250, 1600 } } },
272 { LAYER_WIRE, { { 3075, 2000 }, { 2150, 2000 } } },
273 { LAYER_BUS, { { 1750, 1400 }, { 1850, 1400 } } },
274 { LAYER_BUS, { { 1850, 2500 }, { 1850, 1400 } } },
275 { LAYER_NOTES, { { 2350, 2125 }, { 2350, 2300 } } },
276 { LAYER_NOTES, { { 2350, 2125 }, { 2950, 2125 } } },
277 { LAYER_NOTES, { { 2950, 2125 }, { 2950, 2300 } } },
278 { LAYER_NOTES, { { 2950, 2300 }, { 2350, 2300 } } }
279 };
280
281 for( const std::pair<SCH_LAYER_ID, std::pair<VECTOR2I, VECTOR2I>>& line : lines )
282 {
283 SCH_LINE* wire = new SCH_LINE;
284 wire->SetLayer( line.first );
285 STROKE_PARAMS stroke = wire->GetStroke();
286 stroke.SetWidth( Mils2iu( 6 ) );
287
288 if( line.first != LAYER_NOTES )
289 {
291
292 if( line.first == LAYER_BUS )
293 stroke.SetWidth( Mils2iu( 12 ) );
294
295 }
296
297 wire->SetStroke( stroke );
298
299 wire->SetStartPoint( VECTOR2I( Mils2iu( line.second.first.x ),
300 Mils2iu( line.second.first.y ) ) );
301 wire->SetEndPoint( VECTOR2I( Mils2iu( line.second.second.x ),
302 Mils2iu( line.second.second.y ) ) );
303 addItem( wire );
304 }
305
306#define MILS_POINT( x, y ) VECTOR2I( Mils2iu( x ), Mils2iu( y ) )
307
309 nc->SetPosition( MILS_POINT( 2525, 1300 ) );
310 addItem( nc );
311
313 e1->SetPosition( MILS_POINT( 1850, 1400 ) );
314 addItem( e1 );
315
317 e2->SetPosition( MILS_POINT( 1850, 2500 ) );
318 addItem( e2 );
319
320 SCH_TEXT* t1 = new SCH_TEXT( MILS_POINT( 2850, 2250 ), wxT( "PLAIN TEXT" ) );
321 t1->SetTextSpinStyle( TEXT_SPIN_STYLE::SPIN::LEFT );
322 addItem( t1 );
323
324 SCH_LABEL* t2 = new SCH_LABEL( MILS_POINT( 1975, 1500 ), wxT( "LABEL_{0}" ) );
325 t2->SetTextSpinStyle( TEXT_SPIN_STYLE::SPIN::RIGHT );
326 t2->SetIsDangling( false );
327 addItem( t2 );
328
329 SCH_LABEL* t3 = new SCH_LABEL( MILS_POINT( 1975, 2600 ), wxT( "LABEL_{1}" ) );
330 t3->SetTextSpinStyle( TEXT_SPIN_STYLE::SPIN::RIGHT );
331 t3->SetIsDangling( false );
332 addItem( t3 );
333
334 SCH_GLOBALLABEL* t4 = new SCH_GLOBALLABEL( MILS_POINT( 1750, 1400 ), wxT( "GLOBAL[0..3]" ) );
335 t4->SetTextSpinStyle( TEXT_SPIN_STYLE::SPIN::LEFT );
336 t4->SetIsDangling( false );
337 addItem( t4 );
338
339 SCH_HIERLABEL* t5 = new SCH_HIERLABEL( MILS_POINT( 3250, 1600 ), wxT( "HIER_LABEL" ) );
340 t5->SetTextSpinStyle( TEXT_SPIN_STYLE::SPIN::RIGHT );
341 t5->SetIsDangling( false );
342 addItem( t5 );
343
344 SCH_JUNCTION* j = new SCH_JUNCTION( MILS_POINT( 3075, 1600 ) );
345 addItem( j );
346
347 t2->SetSelected();
348
349 {
350 auto mapLibItemPosition =
351 []( const VECTOR2I& aLibPosition ) -> VECTOR2I
352 {
353 return VECTOR2I( aLibPosition.x, -aLibPosition.y );
354 };
355
356 LIB_SYMBOL* symbol = new LIB_SYMBOL( wxEmptyString );
357 VECTOR2I p( 2625, -1600 );
358
359 LIB_FIELD& ref = symbol->GetReferenceField();
360
361 ref.SetText( wxT( "U1" ) );
362 ref.SetPosition( MILS_POINT( p.x + 30, p.y + 260 ) );
364
365 LIB_FIELD& value = symbol->GetValueField();
366
367 value.SetText( wxT( "OPA604" ) );
368 value.SetPosition( MILS_POINT( p.x + 30, p.y + 180 ) );
370
371 symbol->SetShowPinNames( true );
372 symbol->SetShowPinNumbers( true );
373 symbol->SetPinNameOffset( 0 );
374
375 LIB_SHAPE* comp_body = new LIB_SHAPE( symbol, SHAPE_T::POLY );
376
377 comp_body->SetUnit( 0 );
378 comp_body->SetConvert( 0 );
379 comp_body->SetStroke( STROKE_PARAMS( Mils2iu( 10 ), PLOT_DASH_TYPE::SOLID ) );
381 comp_body->AddPoint( MILS_POINT( p.x - 200, p.y + 200 ) );
382 comp_body->AddPoint( MILS_POINT( p.x + 200, p.y ) );
383 comp_body->AddPoint( MILS_POINT( p.x - 200, p.y - 200 ) );
384 comp_body->AddPoint( MILS_POINT( p.x - 200, p.y + 200 ) );
385
386 addItem( comp_body );
387
388 LIB_PIN* pin = new LIB_PIN( symbol );
389
390 pin->SetPosition( MILS_POINT( p.x - 300, p.y + 100 ) );
391 pin->SetLength( Mils2iu( 100 ) );
392 pin->SetOrientation( PIN_RIGHT );
394 pin->SetNumber( wxT( "1" ) );
395 pin->SetName( wxT( "-" ) );
396
397 endPoints.emplace_back( PIN_END, pin, mapLibItemPosition( pin->GetPosition() ) );
398 symbol->AddDrawItem( pin );
399
400 pin = new LIB_PIN( symbol );
401
402 pin->SetPosition( MILS_POINT( p.x - 300, p.y - 100 ) );
403 pin->SetLength( Mils2iu( 100 ) );
404 pin->SetOrientation( PIN_RIGHT );
406 pin->SetNumber( wxT( "2" ) );
407 pin->SetName( wxT( "+" ) );
408
409 endPoints.emplace_back( PIN_END, pin, mapLibItemPosition( pin->GetPosition() ) );
410 symbol->AddDrawItem( pin );
411
412 pin = new LIB_PIN( symbol );
413
414 pin->SetPosition( MILS_POINT( p.x + 300, p.y ) );
415 pin->SetLength( Mils2iu( 100 ) );
416 pin->SetOrientation( PIN_LEFT );
418 pin->SetNumber( wxT( "3" ) );
419 pin->SetName( wxT( "OUT" ) );
420
421 endPoints.emplace_back( PIN_END, pin, mapLibItemPosition( pin->GetPosition() ) );
422 symbol->AddDrawItem( pin );
423
424 addItem( symbol );
425 }
426
427 SCH_SHEET* s = new SCH_SHEET(
428 /* aParent */ nullptr,
429 /* aPosition */ MILS_POINT( 4000, 1300 ),
430 /* aSize */ wxSize( Mils2iu( 800 ), Mils2iu( 1300 ) ) );
431 s->GetFields().at( SHEETNAME ).SetText( wxT( "SHEET" ) );
432 s->GetFields().at( SHEETFILENAME ).SetText( _( "/path/to/sheet" ) );
433 s->AutoplaceFields( nullptr, false );
434 addItem( s );
435
436 SCH_SHEET_PIN* sp = new SCH_SHEET_PIN( s, MILS_POINT( 4500, 1500 ), wxT( "SHEET PIN" ) );
437 addItem( sp );
438
439 for( EDA_ITEM* item : m_previewItems )
440 {
441 SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( item );
442
443 if( sch_item && sch_item->IsConnectable() )
444 {
445 sch_item->AutoplaceFields( nullptr, false );
446 sch_item->GetEndPoints( endPoints );
447 }
448 }
449
450 for( EDA_ITEM* item : m_previewItems )
451 {
452 SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( item );
453
454 if( sch_item && sch_item->IsConnectable() )
455 sch_item->UpdateDanglingState( endPoints, nullptr );
456 }
457
459}
void SetPageBorderColorLayer(int aLayerId)
Overrides the layer used to pick the color of the page border (normally LAYER_GRID)
void SetColorLayer(int aLayerId)
Can be used to override which layer ID is used for drawing sheet item colors.
virtual KIGFX::VIEW * GetView() const
Return a pointer to the #VIEW instance used in the panel.
void SetSelected()
Definition: eda_item.h:128
void SetFillMode(FILL_T aFill)
Definition: eda_shape.h:99
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:163
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition: eda_text.cpp:240
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:69
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition: view.cpp:316
Field object used in symbol libraries.
Definition: lib_field.h:60
void SetPosition(const VECTOR2I &aPosition) override
Definition: lib_item.h:234
void SetConvert(int aConvert)
Definition: lib_item.h:274
void SetUnit(int aUnit)
Definition: lib_item.h:271
void SetStroke(const STROKE_PARAMS &aStroke)
Definition: lib_shape.h:53
void AddPoint(const VECTOR2I &aPosition)
Definition: lib_shape.cpp:483
Define a library symbol object.
Definition: lib_symbol.h:99
void SetShowPinNames(bool aShow)
Set or clear the pin name visibility flag.
Definition: lib_symbol.h:597
LIB_FIELD & GetReferenceField()
Return reference to the reference designator field.
void SetPinNameOffset(int aOffset)
Set the offset in mils of the pin name text from the pin symbol.
Definition: lib_symbol.h:589
void SetShowPinNumbers(bool aShow)
Set or clear the pin number visibility flag.
Definition: lib_symbol.h:605
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:713
LIB_FIELD & GetValueField()
Return reference to the value field.
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:54
void SetWidthMils(int aWidthInMils)
Definition: page_info.cpp:243
static const wxChar Custom[]
"User" defined page type
Definition: page_info.h:77
void SetHeightMils(int aHeightInMils)
Definition: page_info.cpp:257
void SetPosition(const VECTOR2I &aPosition) override
Class for a wire to bus entry.
void SetTextSpinStyle(TEXT_SPIN_STYLE aSpinStyle) override
Set a spin or rotation angle, along with specific horizontal and vertical justification styles with e...
Definition: sch_label.cpp:1204
void SetTextSpinStyle(TEXT_SPIN_STYLE aSpinStyle) override
Set a spin or rotation angle, along with specific horizontal and vertical justification styles with e...
Definition: sch_label.cpp:1438
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:145
virtual bool IsConnectable() const
Definition: sch_item.h:338
virtual void GetEndPoints(std::vector< DANGLING_END_ITEM > &aItemList)
Add the schematic item end points to aItemList if the item has end points.
Definition: sch_item.h:307
void SetLayer(SCH_LAYER_ID aLayer)
Set the layer this item is on.
Definition: sch_item.h:251
virtual bool UpdateDanglingState(std::vector< DANGLING_END_ITEM > &aItemList, const SCH_SHEET_PATH *aPath=nullptr)
Test the schematic item to aItemList to check if it's dangling state has changed.
Definition: sch_item.h:325
virtual void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual)
Definition: sch_item.h:431
void SetIsDangling(bool aIsDangling)
Definition: sch_label.h:161
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:38
void SetStartPoint(const VECTOR2I &aPosition)
Definition: sch_line.h:131
virtual STROKE_PARAMS GetStroke() const override
Definition: sch_line.h:168
virtual void SetStroke(const STROKE_PARAMS &aStroke) override
Definition: sch_line.h:169
void SetEndPoint(const VECTOR2I &aPosition)
Definition: sch_line.h:136
void SetPosition(const VECTOR2I &aPosition) override
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet_pin.h:66
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:55
std::vector< SCH_FIELD > & GetFields()
Definition: sch_sheet.h:90
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual) override
Definition: sch_sheet.cpp:564
virtual void SetTextSpinStyle(TEXT_SPIN_STYLE aSpinStyle)
Set a spin or rotation angle, along with specific horizontal and vertical justification styles with e...
Definition: sch_text.cpp:186
Simple container to manage line stroke parameters.
Definition: stroke_params.h:87
void SetWidth(int aWidth)
Definition: stroke_params.h:98
void SetPlotStyle(PLOT_DASH_TYPE aPlotStyle)
Hold the information shown in the lower right corner of a plot, printout, or editing view.
Definition: title_block.h:41
void SetTitle(const wxString &aTitle)
Definition: title_block.h:58
void SetDate(const wxString &aDate)
Set the date field, and defaults to the current time and date.
Definition: title_block.h:71
#define _(s)
@ FILLED_WITH_BG_BODYCOLOR
SCH_LAYER_ID
Eeschema drawing layers.
Definition: layer_ids.h:341
@ LAYER_WIRE
Definition: layer_ids.h:344
@ LAYER_NOTES
Definition: layer_ids.h:358
@ LAYER_BUS
Definition: layer_ids.h:345
@ LAYER_SCHEMATIC_DRAWINGSHEET
Definition: layer_ids.h:381
@ LAYER_SCHEMATIC_PAGE_LIMITS
Definition: layer_ids.h:382
@ PIN_LEFT
Definition: lib_pin.h:47
@ PIN_RIGHT
Definition: lib_pin.h:46
#define MILS_POINT(x, y)
@ PT_INPUT
usual pin input: must be connected
@ PT_OUTPUT
usual output
#define IU_PER_MILS
Definition: plotter.cpp:129
@ PIN_END
Definition: sch_item.h:66
@ SHEETNAME
Definition: sch_sheet.h:43
@ SHEETFILENAME
Definition: sch_sheet.h:44
@ GR_TEXT_H_ALIGN_LEFT
VECTOR2< int > VECTOR2I
Definition: vector2d.h:607

References _, KIGFX::VIEW::Add(), LIB_SYMBOL::AddDrawItem(), LIB_SHAPE::AddPoint(), SCH_ITEM::AutoplaceFields(), SCH_SHEET::AutoplaceFields(), PAGE_INFO::Custom, FILLED_WITH_BG_BODYCOLOR, SCH_ITEM::GetEndPoints(), SCH_SHEET::GetFields(), LIB_SYMBOL::GetReferenceField(), SCH_LINE::GetStroke(), LIB_SYMBOL::GetValueField(), EDA_DRAW_PANEL_GAL::GetView(), GR_TEXT_H_ALIGN_LEFT, SCH_ITEM::IsConnectable(), IU_PER_MILS, LAYER_BUS, LAYER_NOTES, LAYER_SCHEMATIC_DRAWINGSHEET, LAYER_SCHEMATIC_PAGE_LIMITS, LAYER_WIRE, m_drawingSheet, m_page, m_preview, m_previewItems, m_titleBlock, MILS_POINT, pin, PIN_END, PIN_LEFT, PIN_RIGHT, POLY, PT_INPUT, PT_OUTPUT, DS_PROXY_VIEW_ITEM::SetColorLayer(), LIB_ITEM::SetConvert(), TITLE_BLOCK::SetDate(), SCH_LINE::SetEndPoint(), EDA_SHAPE::SetFillMode(), PAGE_INFO::SetHeightMils(), EDA_TEXT::SetHorizJustify(), SCH_LABEL_BASE::SetIsDangling(), SCH_ITEM::SetLayer(), DS_PROXY_VIEW_ITEM::SetPageBorderColorLayer(), LIB_SYMBOL::SetPinNameOffset(), STROKE_PARAMS::SetPlotStyle(), LIB_ITEM::SetPosition(), SCH_BUS_ENTRY_BASE::SetPosition(), SCH_NO_CONNECT::SetPosition(), EDA_ITEM::SetSelected(), LIB_SYMBOL::SetShowPinNames(), LIB_SYMBOL::SetShowPinNumbers(), SCH_LINE::SetStartPoint(), LIB_SHAPE::SetStroke(), SCH_LINE::SetStroke(), EDA_TEXT::SetText(), SCH_TEXT::SetTextSpinStyle(), SCH_GLOBALLABEL::SetTextSpinStyle(), SCH_HIERLABEL::SetTextSpinStyle(), TITLE_BLOCK::SetTitle(), LIB_ITEM::SetUnit(), STROKE_PARAMS::SetWidth(), PAGE_INFO::SetWidthMils(), SHEETFILENAME, SHEETNAME, SOLID, SCH_ITEM::UpdateDanglingState(), VECTOR2< T >::x, VECTOR2< T >::y, and zoomFitPreview().

Referenced by createSwatches().

◆ createSwatch()

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

Definition at line 239 of file panel_color_settings.cpp.

240{
241 wxStaticText* label = new wxStaticText( m_colorsListWindow, wxID_ANY, aName );
242
243 // The previously selected theme can be deleted and cannot be selected.
244 // so select the default theme (first theme of the list)
245 if( m_cbTheme->GetSelection() < 0 )
246 {
247 m_cbTheme->SetSelection( 0 );
249 }
250
251 void* clientData = m_cbTheme->GetClientData( m_cbTheme->GetSelection() );
252 COLOR_SETTINGS* selected = static_cast<COLOR_SETTINGS*>( clientData );
253
254 int id = FIRST_BUTTON_ID + aLayer;
255 COLOR4D defaultColor = selected->GetDefaultColor( aLayer );
258
259 COLOR_SWATCH* swatch = new COLOR_SWATCH( m_colorsListWindow, color, id, backgroundColor,
260 defaultColor, SWATCH_MEDIUM );
261 swatch->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) );
262
263 m_colorsGridSizer->Add( label, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxLEFT, 5 );
264 m_colorsGridSizer->Add( swatch, 0, wxALIGN_CENTER_VERTICAL | wxALL, 3 );
265
266 m_labels[aLayer] = label;
267 m_swatches[aLayer] = swatch;
268
269 swatch->Bind( wxEVT_RIGHT_DOWN,
270 [&, aLayer]( wxMouseEvent& aEvent )
271 {
272 ShowColorContextMenu( aEvent, aLayer );
273 } );
274
275 swatch->Bind( COLOR_SWATCH_CHANGED, &PANEL_COLOR_SETTINGS::OnColorChanged, this );
276}
int color
Definition: DXF_plotter.cpp:57
COLOR4D GetColor(int aLayer) const
COLOR4D GetDefaultColor(int aLayer)
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:104
void OnColorChanged(wxCommandEvent &aEvent)
std::map< int, wxStaticText * > m_labels
virtual void onNewThemeSelected()
Event fired when a new theme is selected that can be overridden in children.
void ShowColorContextMenu(wxMouseEvent &aEvent, int aLayer)
std::map< int, COLOR_SWATCH * > m_swatches
@ SWATCH_MEDIUM
Definition: color_swatch.h:41
constexpr int FIRST_BUTTON_ID

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 createSwatches(), PANEL_FP_EDITOR_COLOR_SETTINGS::createSwatches(), and PANEL_PCBNEW_COLOR_SETTINGS::createSwatches().

◆ createSwatches()

void PANEL_EESCHEMA_COLOR_SETTINGS::createSwatches ( )
overrideprotectedvirtual

Implements PANEL_COLOR_SETTINGS.

Definition at line 178 of file panel_eeschema_color_settings.cpp.

179{
180 std::vector<SCH_LAYER_ID> layers;
181
183 {
184 if( g_excludedLayers.count( i ) )
185 continue;
186
187 layers.push_back( i );
188 }
189
190 std::sort( layers.begin(), layers.end(),
191 []( SCH_LAYER_ID a, SCH_LAYER_ID b )
192 {
193 return LayerName( a ) < LayerName( b );
194 } );
195
196 for( int layer : layers )
197 {
198 wxString name = LayerName( layer );
199
200 if( layer == LAYER_SCHEMATIC_GRID_AXES )
201 name += wxS( " " ) + _( "(symbol editor only)" );
202
203 createSwatch( layer, name );
204 }
205
206 // Give a minimal width to m_colorsListWindow, in order to always having
207 // a full row shown
208 int min_width = m_colorsGridSizer->GetMinSize().x;
209 const int margin = 20; // A margin around the sizer
210 m_colorsListWindow->SetMinSize( wxSize( min_width + margin, -1 ) );
211
212 m_preview = new SCH_PREVIEW_PANEL( this, wxID_ANY, wxDefaultPosition, wxSize( -1, -1 ),
214 m_preview->SetStealsFocus( false );
215 m_preview->ShowScrollbars( wxSHOW_SB_NEVER, wxSHOW_SB_NEVER );
216 m_preview->GetGAL()->SetAxesEnabled( false );
217
218 m_colorsMainSizer->Add( 10, 0, 0, wxEXPAND, 5 );
219 m_colorsMainSizer->Add( m_preview, 1, wxALL | wxEXPAND, 5 );
220 m_colorsMainSizer->Add( 10, 0, 0, wxEXPAND, 5 );
221
222 m_colorsMainSizer->Layout();
223
227}
const char * name
Definition: DXF_plotter.cpp:56
KIGFX::GAL * GetGAL() const
Return a pointer to the GAL instance used in the panel.
void SetStealsFocus(bool aStealsFocus)
Set whether focus is taken on certain events (mouseover, keys, etc).
void SetAxesEnabled(bool aAxesEnabled)
Enable drawing the axes.
void createSwatch(int aLayer, const wxString &aName)
wxString LayerName(int aLayer)
Returns the default display name for a given layer.
Definition: layer_id.cpp:30
@ LAYER_SCHEMATIC_GRID_AXES
Definition: layer_ids.h:375

References _, createPreviewItems(), PANEL_COLOR_SETTINGS::createSwatch(), g_excludedLayers, EDA_DRAW_PANEL_GAL::GetGAL(), LAYER_SCHEMATIC_GRID_AXES, LayerName(), PANEL_COLOR_SETTINGS_BASE::m_colorsGridSizer, PANEL_COLOR_SETTINGS_BASE::m_colorsListWindow, PANEL_COLOR_SETTINGS_BASE::m_colorsMainSizer, m_galDisplayOptions, m_galType, m_preview, name, SCH_LAYER_ID_END, SCH_LAYER_ID_START, KIGFX::GAL::SetAxesEnabled(), EDA_DRAW_PANEL_GAL::SetStealsFocus(), updatePreview(), and zoomFitPreview().

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

207{
208 int width = 0;
209 int height = 0;
210
211 m_cbTheme->GetTextExtent( _( "New Theme..." ), &width, &height );
212 int minwidth = width;
213
214 m_cbTheme->Clear();
215
216 for( COLOR_SETTINGS* settings : Pgm().GetSettingsManager().GetColorSettingsList() )
217 {
218 wxString name = settings->GetName();
219
220 if( settings->IsReadOnly() )
221 name += wxS( " " ) + _( "(read-only)" );
222
223 int pos = m_cbTheme->Append( name, static_cast<void*>( settings ) );
224
225 if( settings->GetFilename() == aCurrent )
226 m_cbTheme->SetSelection( pos );
227
228 m_cbTheme->GetTextExtent( name, &width, &height );
229 minwidth = std::max( minwidth, width );
230 }
231
232 m_cbTheme->Append( wxT( "---" ) );
233 m_cbTheme->Append( _( "New Theme..." ) );
234
235 m_cbTheme->SetMinSize( wxSize( minwidth + 50, -1 ) );
236}
SETTINGS_MANAGER * GetSettingsManager()

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().

◆ GetHelpTextAtPoint()

wxString RESETTABLE_PANEL::GetHelpTextAtPoint ( const wxPoint &  aPt,
wxHelpEvent::Origin  aOrigin 
) const
inlineoverrideinherited

Overridden to supply the reset button tooltip when queried with { -INT_MAX, INT_MAX }.

Definition at line 72 of file resettable_panel.h.

73 {
74 if( aPt == wxPoint( -INT_MAX, INT_MAX ) )
75 return GetResetTooltip();
76 else
77 return wxPanel::GetHelpTextAtPoint( aPt, aOrigin );
78 }
virtual wxString GetResetTooltip() const
Get the tooltip the reset button should display when showing this panel.

References RESETTABLE_PANEL::GetResetTooltip().

◆ GetResetTooltip()

virtual wxString PANEL_COLOR_SETTINGS::GetResetTooltip ( ) const
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 }

References _.

◆ OnBtnOpenThemeFolderClicked()

void PANEL_COLOR_SETTINGS::OnBtnOpenThemeFolderClicked ( wxCommandEvent &  event)
overrideprotectedvirtualinherited

Reimplemented from PANEL_COLOR_SETTINGS_BASE.

Definition at line 59 of file panel_color_settings.cpp.

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

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

463{
465}

References updatePreview().

◆ OnColorChanged()

void PANEL_COLOR_SETTINGS::OnColorChanged ( wxCommandEvent &  aEvent)
protectedinherited

Definition at line 324 of file panel_color_settings.cpp.

325{
326 COLOR_SWATCH* swatch = static_cast<COLOR_SWATCH*>( aEvent.GetEventObject() );
327 COLOR4D newColor = swatch->GetSwatchColor();
328 int layer = static_cast<SCH_LAYER_ID>( swatch->GetId() - FIRST_BUTTON_ID );
329
330 updateColor( layer, newColor );
331}
KIGFX::COLOR4D GetSwatchColor() const
void updateColor(int aLayer, const KIGFX::COLOR4D &aColor)

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

104{
105 // Lazy rebuild of theme menu to catch any colour theme changes made in other panels
107
108 event.Skip();
109}
wxString GetFilename() const
Definition: json_settings.h:72

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

231{
233}

References updatePreview().

◆ OnOverrideItemColorsClicked()

void PANEL_EESCHEMA_COLOR_SETTINGS::OnOverrideItemColorsClicked ( wxCommandEvent &  aEvent)
overrideprotectedvirtual

Reimplemented from PANEL_COLOR_SETTINGS_BASE.

Definition at line 519 of file panel_eeschema_color_settings.cpp.

520{
522
523 // If the theme is not overriding individual item colors then don't show them so that
524 // the user doesn't get seduced into thinking they'll have some effect.
527
530
531 m_colorsGridSizer->Layout();
532 m_colorsListWindow->Layout();
533}
bool GetOverrideSchItemColors() const
void SetOverrideSchItemColors(bool aFlag)
@ LAYER_SHEET_BACKGROUND
Definition: layer_ids.h:373
@ LAYER_SHEET
Definition: layer_ids.h:362

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

513{
515 aEvent.Skip();
516}

References zoomFitPreview().

◆ OnThemeChanged()

void PANEL_COLOR_SETTINGS::OnThemeChanged ( wxCommandEvent &  aEvent)
overrideprotectedvirtualinherited

Reimplemented from PANEL_COLOR_SETTINGS_BASE.

Definition at line 112 of file panel_color_settings.cpp.

113{
114 int idx = m_cbTheme->GetSelection();
115
116 if( idx == static_cast<int>( m_cbTheme->GetCount() ) - 2 )
117 {
118 // separator; re-select active theme
119 m_cbTheme->SetStringSelection( m_currentSettings->GetName() );
120 return;
121 }
122
123 if( idx == (int)m_cbTheme->GetCount() - 1 )
124 {
125 // New Theme...
126
127 if( !saveCurrentTheme( false ) )
128 return;
129
130 FOOTPRINT_NAME_VALIDATOR themeNameValidator;
131 wxTextEntryDialog dlg( this, _( "New theme name:" ), _( "Add Color Theme" ) );
132 dlg.SetTextValidator( themeNameValidator );
133
134 if( dlg.ShowModal() != wxID_OK )
135 return;
136
137 wxString themeName = dlg.GetValue();
138 wxFileName fn( themeName + wxT( ".json" ) );
140
141 if( fn.Exists() )
142 {
143 wxMessageBox( _( "Theme already exists!" ) );
144 return;
145 }
146
147 SETTINGS_MANAGER& settingsMgr = Pgm().GetSettingsManager();
148 COLOR_SETTINGS* newSettings = settingsMgr.AddNewColorSettings( themeName );
149 newSettings->SetName( themeName );
150 newSettings->SetReadOnly( false );
151
152 for( int layer : m_validLayers )
153 newSettings->SetColor( layer, m_currentSettings->GetColor( layer ) );
154
155 newSettings->SaveToFile( settingsMgr.GetPathForSettingsFile( newSettings ) );
156
157 idx = m_cbTheme->Insert( themeName, idx - 1, static_cast<void*>( newSettings ) );
158 m_cbTheme->SetSelection( idx );
159
160 m_optOverrideColors->SetValue( newSettings->GetOverrideSchItemColors() );
161
162 *m_currentSettings = *newSettings;
165 }
166 else
167 {
168 COLOR_SETTINGS* selected = static_cast<COLOR_SETTINGS*>( m_cbTheme->GetClientData( idx ) );
169
170 if( selected->GetFilename() != m_currentSettings->GetFilename() )
171 {
172 if( !saveCurrentTheme( false ) )
173 return;
174
175 m_optOverrideColors->SetValue( selected->GetOverrideSchItemColors() );
176
177 *m_currentSettings = *selected;
180 }
181 }
182}
void SetName(const wxString &aName)
void SetColor(int aLayer, const COLOR4D &aColor)
const wxString & GetName() const
This class provides a custom wxValidator object for limiting the allowable characters when defining f...
Definition: validators.h:64
void SetReadOnly(bool aReadOnly)
Definition: json_settings.h:84
virtual bool SaveToFile(const wxString &aDirectory="", bool aForce=false)
virtual bool saveCurrentTheme(bool aValidate)
wxString GetPathForSettingsFile(JSON_SETTINGS *aSettings)
Returns the path a given settings file should be loaded from / stored to.
COLOR_SETTINGS * AddNewColorSettings(const wxString &aFilename)
Registers a new color settings object with the given filename.

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

469{
472}
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 157 of file panel_eeschema_color_settings.cpp.

158{
159 for( int layer : m_validLayers )
160 {
162
163 // Do not allow non-background layers to be completely white.
164 // This ensures the BW printing recognizes that the colors should be printed black.
166 && layer != LAYER_SHEET_BACKGROUND )
167 {
168 color.Darken( 0.01 );
169 }
170
172 }
173
174 return PANEL_COLOR_SETTINGS::saveCurrentTheme( aValidate );
175}
@ WHITE
Definition: color4d.h:48

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

85{
86 if( show )
87 {
88 // In case changes have been made to the current theme in another panel:
89 int idx = m_cbTheme->GetSelection();
90 COLOR_SETTINGS* settings = static_cast<COLOR_SETTINGS*>( m_cbTheme->GetClientData( idx ) );
91
92 if( settings )
93 *m_currentSettings = *settings;
94
97 }
98
99 return PANEL_COLOR_SETTINGS_BASE::Show( show );
100}

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

280{
281 auto selected =
282 static_cast<COLOR_SETTINGS*>( m_cbTheme->GetClientData( m_cbTheme->GetSelection() ) );
283
284 COLOR4D current = m_currentSettings->GetColor( aLayer );
285 COLOR4D saved = selected->GetColor( aLayer );
286 bool readOnly = m_currentSettings->IsReadOnly();
287
288 wxMenu menu;
289
290 AddMenuItem( &menu, ID_COPY, _( "Copy color" ), KiBitmap( BITMAPS::copy ) );
291
292 if( !readOnly && m_copied != COLOR4D::UNSPECIFIED )
293 AddMenuItem( &menu, ID_PASTE, _( "Paste color" ), KiBitmap( BITMAPS::paste ) );
294
295 if( !readOnly && current != saved )
296 AddMenuItem( &menu, ID_REVERT, _( "Revert to saved color" ), KiBitmap( BITMAPS::undo ) );
297
298 menu.Bind( wxEVT_COMMAND_MENU_SELECTED,
299 [&]( wxCommandEvent& aCmd )
300 {
301 switch( aCmd.GetId() )
302 {
303 case ID_COPY:
304 m_copied = current;
305 break;
306
307 case ID_PASTE:
308 updateColor( aLayer, m_copied );
309 break;
310
311 case ID_REVERT:
312 updateColor( aLayer, saved );
313 break;
314
315 default:
316 aCmd.Skip();
317 }
318 } );
319
320 PopupMenu( &menu );
321}
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:105
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:257
bool IsReadOnly() const
Definition: json_settings.h:83

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, and undo.

Referenced by PANEL_COLOR_SETTINGS::createSwatch().

◆ TransferDataFromWindow()

bool PANEL_EESCHEMA_COLOR_SETTINGS::TransferDataFromWindow ( )
overrideprotected

◆ TransferDataToWindow()

bool PANEL_EESCHEMA_COLOR_SETTINGS::TransferDataToWindow ( )
overrideprotected

Definition at line 126 of file panel_eeschema_color_settings.cpp.

127{
129 return true;
130}

References zoomFitPreview().

◆ updateColor()

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

Definition at line 334 of file panel_color_settings.cpp.

335{
337 m_currentSettings->SetColor( aLayer, aColor );
338
339 // Colors must be persisted when edited because multiple PANEL_COLOR_SETTINGS could be
340 // referring to the same theme.
341 saveCurrentTheme( false );
342
343 m_swatches[aLayer]->SetSwatchColor( aColor, false );
344
345 if( m_currentSettings && aLayer == m_backgroundLayer )
346 {
348
349 for( std::pair<int, COLOR_SWATCH*> pair : m_swatches )
350 pair.second->SetSwatchBackground( background );
351 }
352
354}
virtual void onColorChanged()
Event fired when the user changes any color.

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().

◆ updatePreview()

void PANEL_EESCHEMA_COLOR_SETTINGS::updatePreview ( )
private

Definition at line 475 of file panel_eeschema_color_settings.cpp.

476{
477 if( !m_preview )
478 return;
479
480 KIGFX::VIEW* view = m_preview->GetView();
481 auto settings = static_cast<KIGFX::SCH_RENDER_SETTINGS*>( view->GetPainter()->GetSettings() );
482 settings->LoadColors( m_currentSettings );
483
484 m_preview->GetGAL()->SetClearColor( settings->GetBackgroundColor() );
485
487 auto rect = m_preview->GetScreenRect();
488 m_preview->Refresh( true, &rect );
489}
void SetClearColor(const COLOR4D &aColor)
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
Store schematic specific render settings.
Definition: sch_painter.h:71
void LoadColors(const COLOR_SETTINGS *aSettings) override
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
Definition: view.cpp:1478
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:213
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...
@ COLOR
Color has changed.
Definition: view_item.h:48

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

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

◆ updateSwatches()

void PANEL_COLOR_SETTINGS::updateSwatches ( )
protectedinherited

Definition at line 185 of file panel_color_settings.cpp.

186{
187 if( m_swatches.empty() )
188 {
190 }
191 else
192 {
193 bool isReadOnly = m_currentSettings->IsReadOnly();
195
196 for( std::pair<int, COLOR_SWATCH*> pair : m_swatches )
197 {
198 pair.second->SetSwatchBackground( background );
199 pair.second->SetSwatchColor( m_currentSettings->GetColor( pair.first ), false );
200 pair.second->SetReadOnly( isReadOnly );
201 }
202 }
203}
virtual void createSwatches()=0

References PANEL_COLOR_SETTINGS::createSwatches(), 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 133 of file panel_eeschema_color_settings.cpp.

134{
136
137 for( SCH_LAYER_ID layer = SCH_LAYER_ID_START; layer < SCH_LAYER_ID_END; ++layer )
138 {
139 if( bgcolor == m_currentSettings->GetColor( layer )
140 && layer != LAYER_SCHEMATIC_BACKGROUND && layer != LAYER_SHEET_BACKGROUND )
141 {
142 wxString msg = _( "Some items have the same color as the background\n"
143 "and they will not be seen on the screen. Are you\n"
144 "sure you want to use these colors?" );
145
146 if( wxMessageBox( msg, _( "Warning" ), wxYES_NO | wxICON_QUESTION, this ) == wxNO )
147 return false;
148
149 break;
150 }
151 }
152
153 return true;
154}

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

493{
494 if( m_preview )
495 {
496 KIGFX::VIEW* view = m_preview->GetView();
497
498 view->SetScale( 1.0 );
499 VECTOR2D screenSize = view->ToWorld( m_preview->GetClientSize(), false );
500
501 VECTOR2I psize( m_page->GetWidthIU(), m_page->GetHeightIU() );
502 double scale = view->GetScale() / std::max( fabs( psize.x / screenSize.x ),
503 fabs( psize.y / screenSize.y ) );
504
505 view->SetScale( scale * m_galDisplayOptions.m_scaleFactor * 0.8 /* margin */ );
508 }
509}
Vec Centre() const
Definition: box2.h:63
const BOX2I ViewBBox() const override
void ForceRefresh()
Force a redraw.
double GetScale() const
Definition: view.h:269
virtual void SetScale(double aScale, VECTOR2D aAnchor={ 0, 0 })
Set the scaling factor, zooming around a given anchor point.
Definition: view.cpp:548
VECTOR2D ToWorld(const VECTOR2D &aCoord, bool aAbsolute=true) const
Converts a screen space point/vector to a point/vector in world space coordinates.
Definition: view.cpp:445
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
Definition: view.cpp:574
const int scale

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

Referenced by createPreviewItems(), createSwatches(), OnSize(), 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 123 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

wxScrolledWindow* PANEL_COLOR_SETTINGS_BASE::m_colorsListWindow
protectedinherited

◆ m_colorsMainSizer

wxBoxSizer* PANEL_COLOR_SETTINGS_BASE::m_colorsMainSizer
protectedinherited

◆ m_copied

KIGFX::COLOR4D PANEL_COLOR_SETTINGS::m_copied
protectedinherited

Definition at line 105 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_galDisplayOptions

KIGFX::GAL_DISPLAY_OPTIONS PANEL_EESCHEMA_COLOR_SETTINGS::m_galDisplayOptions
private

◆ m_galType

EDA_DRAW_PANEL_GAL::GAL_TYPE PANEL_EESCHEMA_COLOR_SETTINGS::m_galType
private

◆ 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_previewPanelSizer

wxBoxSizer* PANEL_COLOR_SETTINGS_BASE::m_previewPanelSizer
protectedinherited

◆ 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 115 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(), PANEL_COLOR_SETTINGS::saveCurrentTheme(), and saveCurrentTheme().


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