A better approach to clearing color overrides
This commit is contained in:
parent
9fda8d58d0
commit
b3b567e591
|
@ -64,9 +64,15 @@ DIALOG_COLOR_PICKER::DIALOG_COLOR_PICKER( wxWindow* aParent, KIGFX::COLOR4D& aCu
|
|||
// Build the defined colors panel:
|
||||
initDefinedColors( aUserColors );
|
||||
|
||||
// If there is no default color, don't give the option to reset to default
|
||||
/**
|
||||
* There are two types of color settings: theme colors and local overrides.
|
||||
* Theme colors have a default value, and the Reset to Default button reverts to it.
|
||||
* Local override colors have a default of UNSPECIFIED, which means "use the theme color".
|
||||
* The underlying action is the same, but we change the label here because the action from
|
||||
* the point of view of the user is slightly different.
|
||||
*/
|
||||
if( aDefaultColor == KIGFX::COLOR4D::UNSPECIFIED )
|
||||
m_resetToDefault->Hide();
|
||||
m_resetToDefault->SetLabel( _( "Clear Color" ) );
|
||||
|
||||
m_sdbSizerOK->SetDefault();
|
||||
}
|
||||
|
@ -851,5 +857,9 @@ void DIALOG_COLOR_PICKER::OnResetButton( wxCommandEvent& aEvent )
|
|||
m_newColor4D.ToHSV( m_hue, m_sat, m_val, true );
|
||||
SetEditVals( ALL_CHANGED, false );
|
||||
|
||||
drawAll();
|
||||
// When the default is UNSPECIFIED, this is the Clear Color button, which should accept
|
||||
if( m_defaultColor == KIGFX::COLOR4D::UNSPECIFIED )
|
||||
AcceptAndClose();
|
||||
else
|
||||
drawAll();
|
||||
}
|
||||
|
|
|
@ -56,6 +56,12 @@ wxBitmap COLOR_SWATCH::MakeBitmap( COLOR4D aColor, COLOR4D aBackground, wxSize a
|
|||
iconDC.SetBrush( brush );
|
||||
iconDC.DrawRectangle( 0, 0, aSize.x, aSize.y );
|
||||
|
||||
if( aColor == COLOR4D::UNSPECIFIED )
|
||||
{
|
||||
aColor = aBackground.Inverted();
|
||||
brush.SetStyle( wxBRUSHSTYLE_BDIAGONAL_HATCH );
|
||||
}
|
||||
|
||||
brush.SetColour( aColor.ToColour() );
|
||||
iconDC.SetBrush( brush );
|
||||
iconDC.DrawRectangle( 0, 0, aSize.x, aSize.y );
|
||||
|
@ -210,7 +216,7 @@ void COLOR_SWATCH::GetNewSwatchColor()
|
|||
if( dialog.ShowModal() == wxID_OK )
|
||||
newColor = dialog.GetColor();
|
||||
|
||||
if( newColor != COLOR4D::UNSPECIFIED )
|
||||
if( newColor != COLOR4D::UNSPECIFIED || m_default == COLOR4D::UNSPECIFIED )
|
||||
{
|
||||
m_color = newColor;
|
||||
|
||||
|
|
|
@ -133,7 +133,7 @@ void DIALOG_EDIT_LINE_STYLE::onColorButtonClicked( wxCommandEvent& event )
|
|||
if( dialog.ShowModal() == wxID_OK )
|
||||
newColor = dialog.GetColor();
|
||||
|
||||
if( newColor == COLOR4D::UNSPECIFIED || m_selectedColor == newColor )
|
||||
if( m_selectedColor == newColor )
|
||||
return;
|
||||
|
||||
setColor( newColor );
|
||||
|
|
|
@ -151,15 +151,11 @@ bool DIALOG_SCH_SHEET_PROPS::TransferDataToWindow()
|
|||
m_borderWidth.SetValue( m_sheet->GetBorderWidth() );
|
||||
|
||||
// set up color swatches
|
||||
COLOR_SETTINGS* colorSettings = m_frame->GetColorSettings();
|
||||
KIGFX::COLOR4D borderColor = m_sheet->GetBorderColor();
|
||||
KIGFX::COLOR4D backgroundColor = m_sheet->GetBackgroundColor();
|
||||
KIGFX::COLOR4D borderColor = m_sheet->GetBorderColor();
|
||||
KIGFX::COLOR4D backgroundColor = m_sheet->GetBackgroundColor();
|
||||
|
||||
if( borderColor == COLOR4D::UNSPECIFIED )
|
||||
borderColor = colorSettings->GetColor( LAYER_SHEET );
|
||||
|
||||
if( backgroundColor == COLOR4D::UNSPECIFIED )
|
||||
backgroundColor = colorSettings->GetColor( LAYER_SHEET_BACKGROUND );
|
||||
m_borderSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED );
|
||||
m_backgroundSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED );
|
||||
|
||||
m_borderSwatch->SetSwatchColor( borderColor, false );
|
||||
m_backgroundSwatch->SetSwatchColor( backgroundColor, false );
|
||||
|
@ -789,15 +785,3 @@ void DIALOG_SCH_SHEET_PROPS::OnInitDlg( wxInitDialogEvent& event )
|
|||
// Now all widgets have the size fixed, call FinishDialogSettings
|
||||
FinishDialogSettings();
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_SCH_SHEET_PROPS::OnRemoveColors( wxCommandEvent& event )
|
||||
{
|
||||
COLOR_SETTINGS* colorSettings = m_frame->GetColorSettings();
|
||||
|
||||
m_borderSwatch->SetDefaultColor( colorSettings->GetColor( LAYER_SHEET ) );
|
||||
m_backgroundSwatch->SetDefaultColor( colorSettings->GetColor( LAYER_SHEET_BACKGROUND ) );
|
||||
|
||||
m_borderSwatch->SetSwatchColor( COLOR4D::UNSPECIFIED, false );
|
||||
m_backgroundSwatch->SetSwatchColor( COLOR4D::UNSPECIFIED, false );
|
||||
}
|
||||
|
|
|
@ -71,7 +71,6 @@ private:
|
|||
void OnGridCellChanging( wxGridEvent& event );
|
||||
void OnUpdateUI( wxUpdateUIEvent& event ) override;
|
||||
void OnInitDlg( wxInitDialogEvent& event ) override;
|
||||
void OnRemoveColors( wxCommandEvent& event ) override;
|
||||
|
||||
void AdjustGridColumns( int aWidth );
|
||||
};
|
||||
|
|
|
@ -151,14 +151,6 @@ DIALOG_SCH_SHEET_PROPS_BASE::DIALOG_SCH_SHEET_PROPS_BASE( wxWindow* parent, wxWi
|
|||
sbSizer2->Add( m_backgroundSwatch, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
||||
|
||||
|
||||
sbSizer2->Add( 0, 0, 1, wxEXPAND, 5 );
|
||||
|
||||
m_btnResetColors = new wxButton( sbSizer2->GetStaticBox(), wxID_ANY, _("Remove Colors"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_btnResetColors->SetToolTip( _("Remove the specified colors for this sheet (the current color theme will be used instead)") );
|
||||
|
||||
sbSizer2->Add( m_btnResetColors, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
||||
|
||||
|
||||
bSizer5->Add( sbSizer2, 1, wxEXPAND|wxBOTTOM, 5 );
|
||||
|
||||
|
||||
|
@ -226,7 +218,6 @@ DIALOG_SCH_SHEET_PROPS_BASE::DIALOG_SCH_SHEET_PROPS_BASE( wxWindow* parent, wxWi
|
|||
m_bpMoveUp->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SCH_SHEET_PROPS_BASE::OnMoveUp ), NULL, this );
|
||||
m_bpMoveDown->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SCH_SHEET_PROPS_BASE::OnMoveDown ), NULL, this );
|
||||
m_bpDelete->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SCH_SHEET_PROPS_BASE::OnDeleteField ), NULL, this );
|
||||
m_btnResetColors->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SCH_SHEET_PROPS_BASE::OnRemoveColors ), NULL, this );
|
||||
}
|
||||
|
||||
DIALOG_SCH_SHEET_PROPS_BASE::~DIALOG_SCH_SHEET_PROPS_BASE()
|
||||
|
@ -239,6 +230,5 @@ DIALOG_SCH_SHEET_PROPS_BASE::~DIALOG_SCH_SHEET_PROPS_BASE()
|
|||
m_bpMoveUp->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SCH_SHEET_PROPS_BASE::OnMoveUp ), NULL, this );
|
||||
m_bpMoveDown->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SCH_SHEET_PROPS_BASE::OnMoveDown ), NULL, this );
|
||||
m_bpDelete->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SCH_SHEET_PROPS_BASE::OnDeleteField ), NULL, this );
|
||||
m_btnResetColors->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SCH_SHEET_PROPS_BASE::OnRemoveColors ), NULL, this );
|
||||
|
||||
}
|
||||
|
|
|
@ -968,89 +968,6 @@
|
|||
<property name="window_style"></property>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND</property>
|
||||
<property name="proportion">1</property>
|
||||
<object class="spacer" expanded="1">
|
||||
<property name="height">0</property>
|
||||
<property name="permission">protected</property>
|
||||
<property name="width">0</property>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALL</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxButton" expanded="1">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
<property name="TopDockable">1</property>
|
||||
<property name="aui_layer"></property>
|
||||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="bitmap"></property>
|
||||
<property name="caption"></property>
|
||||
<property name="caption_visible">1</property>
|
||||
<property name="center_pane">0</property>
|
||||
<property name="close_button">1</property>
|
||||
<property name="context_help"></property>
|
||||
<property name="context_menu">1</property>
|
||||
<property name="current"></property>
|
||||
<property name="default">0</property>
|
||||
<property name="default_pane">0</property>
|
||||
<property name="disabled"></property>
|
||||
<property name="dock">Dock</property>
|
||||
<property name="dock_fixed">0</property>
|
||||
<property name="docking">Left</property>
|
||||
<property name="enabled">1</property>
|
||||
<property name="fg"></property>
|
||||
<property name="floatable">1</property>
|
||||
<property name="focus"></property>
|
||||
<property name="font"></property>
|
||||
<property name="gripper">0</property>
|
||||
<property name="hidden">0</property>
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="label">Remove Colors</property>
|
||||
<property name="margins"></property>
|
||||
<property name="markup">0</property>
|
||||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
<property name="maximum_size"></property>
|
||||
<property name="min_size"></property>
|
||||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="moveable">1</property>
|
||||
<property name="name">m_btnResetColors</property>
|
||||
<property name="pane_border">1</property>
|
||||
<property name="pane_position"></property>
|
||||
<property name="pane_size"></property>
|
||||
<property name="permission">protected</property>
|
||||
<property name="pin_button">1</property>
|
||||
<property name="pos"></property>
|
||||
<property name="position"></property>
|
||||
<property name="pressed"></property>
|
||||
<property name="resize">Resizable</property>
|
||||
<property name="show">1</property>
|
||||
<property name="size"></property>
|
||||
<property name="style"></property>
|
||||
<property name="subclass">; ; forward_declare</property>
|
||||
<property name="toolbar_pane">0</property>
|
||||
<property name="tooltip">Remove the specified colors for this sheet (the current color theme will be used instead)</property>
|
||||
<property name="validator_data_type"></property>
|
||||
<property name="validator_style">wxFILTER_NONE</property>
|
||||
<property name="validator_type">wxDefaultValidator</property>
|
||||
<property name="validator_variable"></property>
|
||||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
<event name="OnButtonClick">OnRemoveColors</event>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
|
|
|
@ -56,7 +56,6 @@ class DIALOG_SCH_SHEET_PROPS_BASE : public DIALOG_SHIM
|
|||
COLOR_SWATCH* m_borderSwatch;
|
||||
wxStaticText* m_backgroundColorLabel;
|
||||
COLOR_SWATCH* m_backgroundSwatch;
|
||||
wxButton* m_btnResetColors;
|
||||
wxStaticText* m_hiearchicalPathLabel;
|
||||
wxTextCtrl* m_heirarchyPath;
|
||||
wxStaticText* m_timestampLabel;
|
||||
|
@ -74,7 +73,6 @@ class DIALOG_SCH_SHEET_PROPS_BASE : public DIALOG_SHIM
|
|||
virtual void OnMoveUp( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnMoveDown( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnDeleteField( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnRemoveColors( wxCommandEvent& event ) { event.Skip(); }
|
||||
|
||||
|
||||
public:
|
||||
|
|
|
@ -412,6 +412,9 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::ResetPanel()
|
|||
|
||||
void PANEL_EESCHEMA_COLOR_SETTINGS::updatePreview()
|
||||
{
|
||||
if( !m_preview )
|
||||
return;
|
||||
|
||||
KIGFX::VIEW* view = m_preview->GetView();
|
||||
auto settings = static_cast<KIGFX::SCH_RENDER_SETTINGS*>( view->GetPainter()->GetSettings() );
|
||||
settings->LoadColors( m_currentSettings );
|
||||
|
|
Loading…
Reference in New Issue