Eeschema: minor color selection dialog improvements.
* Move color conflict checking code into TranferDataFromWindow so that it can be used in both the OK and Apply button message handlers. * Change Erc to ERC in text labels. * Check for color conflicts and give the user the option to dismiss the changes before applying them. * Add color conflict checking when apply button is pressed. * Use default dialog size to allow sizers to set the initial size of the dialog.
This commit is contained in:
parent
72e50b496c
commit
9b0bd8ff42
|
@ -65,7 +65,7 @@ static COLORBUTTON generalColorButtons[] = {
|
||||||
{ _( "Global label" ), LAYER_GLOBLABEL },
|
{ _( "Global label" ), LAYER_GLOBLABEL },
|
||||||
{ _( "Net name" ), LAYER_NETNAM },
|
{ _( "Net name" ), LAYER_NETNAM },
|
||||||
{ _( "Notes" ), LAYER_NOTES },
|
{ _( "Notes" ), LAYER_NOTES },
|
||||||
{ _( "No Connect Symbol" ), LAYER_NOCONNECT },
|
{ _( "No connect symbol" ), LAYER_NOCONNECT },
|
||||||
{ wxT( "" ), -1 } // Sentinel marking end of list.
|
{ wxT( "" ), -1 } // Sentinel marking end of list.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -91,8 +91,8 @@ static COLORBUTTON sheetColorButtons[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static COLORBUTTON miscColorButtons[] = {
|
static COLORBUTTON miscColorButtons[] = {
|
||||||
{ _( "Erc warning" ), LAYER_ERC_WARN },
|
{ _( "ERC warning" ), LAYER_ERC_WARN },
|
||||||
{ _( "Erc error" ), LAYER_ERC_ERR },
|
{ _( "ERC error" ), LAYER_ERC_ERR },
|
||||||
{ _( "Grid" ), LAYER_GRID },
|
{ _( "Grid" ), LAYER_GRID },
|
||||||
{ wxT( "" ), -1 } // Sentinel marking end of list.
|
{ wxT( "" ), -1 } // Sentinel marking end of list.
|
||||||
};
|
};
|
||||||
|
@ -204,8 +204,6 @@ void DIALOG_COLOR_CONFIG::CreateControls()
|
||||||
|
|
||||||
currentColors[ LAYER_BACKGROUND ] = m_parent->GetDrawBgColor();
|
currentColors[ LAYER_BACKGROUND ] = m_parent->GetDrawBgColor();
|
||||||
|
|
||||||
// button->SetFocus();
|
|
||||||
|
|
||||||
// Dialog now needs to be resized, but the associated command is found elsewhere.
|
// Dialog now needs to be resized, but the associated command is found elsewhere.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,56 +246,51 @@ void DIALOG_COLOR_CONFIG::SetColor( wxCommandEvent& event )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool DIALOG_COLOR_CONFIG::UpdateColorsSettings()
|
bool DIALOG_COLOR_CONFIG::TransferDataFromWindow()
|
||||||
{
|
{
|
||||||
// Update color of background
|
bool warning = false;
|
||||||
|
|
||||||
|
// Check for color conflicts with background color to give user a chance to bail
|
||||||
|
// out before making changes.
|
||||||
|
|
||||||
EDA_COLOR_T bgcolor = WHITE;
|
EDA_COLOR_T bgcolor = WHITE;
|
||||||
|
|
||||||
if( m_SelBgColor->GetSelection() > 0 )
|
if( m_SelBgColor->GetSelection() > 0 )
|
||||||
bgcolor = BLACK;
|
bgcolor = BLACK;
|
||||||
|
|
||||||
m_parent->SetDrawBgColor( bgcolor );
|
|
||||||
currentColors[ LAYER_BACKGROUND ] = bgcolor;
|
|
||||||
|
|
||||||
bool warning = false;
|
|
||||||
|
|
||||||
for( LAYERSCH_ID clyr = LAYER_WIRE; clyr < LAYERSCH_ID_COUNT; ++clyr )
|
for( LAYERSCH_ID clyr = LAYER_WIRE; clyr < LAYERSCH_ID_COUNT; ++clyr )
|
||||||
{
|
{
|
||||||
SetLayerColor( currentColors[ clyr ], clyr );
|
if( bgcolor == currentColors[ clyr ] && clyr != LAYER_BACKGROUND )
|
||||||
|
{
|
||||||
if( bgcolor == GetLayerColor( clyr ) && clyr != LAYER_BACKGROUND )
|
|
||||||
warning = true;
|
warning = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_parent->SetGridColor( GetLayerColor( LAYER_GRID ) );
|
|
||||||
|
|
||||||
if( bgcolor == GetLayerColor( LAYER_GRID ) )
|
|
||||||
warning = true;
|
|
||||||
|
|
||||||
return warning;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void DIALOG_COLOR_CONFIG::OnOkClick( wxCommandEvent& event )
|
|
||||||
{
|
|
||||||
bool warning = UpdateColorsSettings();
|
|
||||||
|
|
||||||
// Prompt the user if an item has the same color as the background
|
// Prompt the user if an item has the same color as the background
|
||||||
// because this item cannot be seen:
|
// because this item cannot be seen:
|
||||||
if( warning )
|
if( warning )
|
||||||
wxMessageBox( _("Warning:\nSome items have the same color as the background\n"
|
{
|
||||||
"and they will not be seen on screen") );
|
if( wxMessageBox( _( "Some items have the same color as the background\n"
|
||||||
|
"and they will not be seen on the screen. Are you\n"
|
||||||
|
"sure you want to use these colors?" ),
|
||||||
|
_( "Warning" ),
|
||||||
|
wxYES_NO | wxICON_QUESTION, this ) == wxNO )
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update color of background
|
||||||
|
m_parent->SetDrawBgColor( bgcolor );
|
||||||
|
currentColors[ LAYER_BACKGROUND ] = bgcolor;
|
||||||
|
|
||||||
|
|
||||||
|
for( LAYERSCH_ID clyr = LAYER_WIRE; clyr < LAYERSCH_ID_COUNT; ++clyr )
|
||||||
|
{
|
||||||
|
SetLayerColor( currentColors[ clyr ], clyr );
|
||||||
|
}
|
||||||
|
|
||||||
|
m_parent->SetGridColor( GetLayerColor( LAYER_GRID ) );
|
||||||
m_parent->GetCanvas()->Refresh();
|
m_parent->GetCanvas()->Refresh();
|
||||||
|
|
||||||
event.Skip();
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void DIALOG_COLOR_CONFIG::OnApplyClick( wxCommandEvent& event )
|
|
||||||
{
|
|
||||||
UpdateColorsSettings();
|
|
||||||
m_parent->GetCanvas()->Refresh();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,14 +46,13 @@ private:
|
||||||
// Creates the controls and sizers
|
// Creates the controls and sizers
|
||||||
void CreateControls();
|
void CreateControls();
|
||||||
|
|
||||||
bool UpdateColorsSettings();
|
|
||||||
void SetColor( wxCommandEvent& aEvent );
|
void SetColor( wxCommandEvent& aEvent );
|
||||||
void OnOkClick( wxCommandEvent& aEvent );
|
|
||||||
void OnApplyClick( wxCommandEvent& aEvent );
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructors and destructor
|
// Constructors and destructor
|
||||||
DIALOG_COLOR_CONFIG( EDA_DRAW_FRAME* aParent );
|
DIALOG_COLOR_CONFIG( EDA_DRAW_FRAME* aParent );
|
||||||
|
|
||||||
|
bool TransferDataFromWindow();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DIALOG_COLOR_CONFIG_H_
|
#endif // DIALOG_COLOR_CONFIG_H_
|
||||||
|
|
|
@ -38,18 +38,11 @@ DIALOG_COLOR_CONFIG_BASE::DIALOG_COLOR_CONFIG_BASE( wxWindow* parent, wxWindowID
|
||||||
|
|
||||||
this->SetSizer( bmainSizer );
|
this->SetSizer( bmainSizer );
|
||||||
this->Layout();
|
this->Layout();
|
||||||
|
bmainSizer->Fit( this );
|
||||||
|
|
||||||
this->Centre( wxBOTH );
|
this->Centre( wxBOTH );
|
||||||
|
|
||||||
// Connect Events
|
|
||||||
m_sdbSizerApply->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_COLOR_CONFIG_BASE::OnApplyClick ), NULL, this );
|
|
||||||
m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_COLOR_CONFIG_BASE::OnOkClick ), NULL, this );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DIALOG_COLOR_CONFIG_BASE::~DIALOG_COLOR_CONFIG_BASE()
|
DIALOG_COLOR_CONFIG_BASE::~DIALOG_COLOR_CONFIG_BASE()
|
||||||
{
|
{
|
||||||
// Disconnect Events
|
|
||||||
m_sdbSizerApply->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_COLOR_CONFIG_BASE::OnApplyClick ), NULL, this );
|
|
||||||
m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_COLOR_CONFIG_BASE::OnOkClick ), NULL, this );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
<property name="minimum_size"></property>
|
<property name="minimum_size"></property>
|
||||||
<property name="name">DIALOG_COLOR_CONFIG_BASE</property>
|
<property name="name">DIALOG_COLOR_CONFIG_BASE</property>
|
||||||
<property name="pos"></property>
|
<property name="pos"></property>
|
||||||
<property name="size">446,344</property>
|
<property name="size">-1,-1</property>
|
||||||
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
|
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
|
||||||
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
|
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
|
||||||
<property name="title">EESchema Colors</property>
|
<property name="title">EESchema Colors</property>
|
||||||
|
@ -201,12 +201,12 @@
|
||||||
<property name="minimum_size"></property>
|
<property name="minimum_size"></property>
|
||||||
<property name="name">m_sdbSizer</property>
|
<property name="name">m_sdbSizer</property>
|
||||||
<property name="permission">protected</property>
|
<property name="permission">protected</property>
|
||||||
<event name="OnApplyButtonClick">OnApplyClick</event>
|
<event name="OnApplyButtonClick"></event>
|
||||||
<event name="OnCancelButtonClick"></event>
|
<event name="OnCancelButtonClick"></event>
|
||||||
<event name="OnContextHelpButtonClick"></event>
|
<event name="OnContextHelpButtonClick"></event>
|
||||||
<event name="OnHelpButtonClick"></event>
|
<event name="OnHelpButtonClick"></event>
|
||||||
<event name="OnNoButtonClick"></event>
|
<event name="OnNoButtonClick"></event>
|
||||||
<event name="OnOKButtonClick">OnOkClick</event>
|
<event name="OnOKButtonClick"></event>
|
||||||
<event name="OnSaveButtonClick"></event>
|
<event name="OnSaveButtonClick"></event>
|
||||||
<event name="OnYesButtonClick"></event>
|
<event name="OnYesButtonClick"></event>
|
||||||
</object>
|
</object>
|
||||||
|
|
|
@ -41,15 +41,10 @@ class DIALOG_COLOR_CONFIG_BASE : public DIALOG_SHIM
|
||||||
wxButton* m_sdbSizerOK;
|
wxButton* m_sdbSizerOK;
|
||||||
wxButton* m_sdbSizerApply;
|
wxButton* m_sdbSizerApply;
|
||||||
wxButton* m_sdbSizerCancel;
|
wxButton* m_sdbSizerCancel;
|
||||||
|
|
||||||
// Virtual event handlers, overide them in your derived class
|
|
||||||
virtual void OnApplyClick( wxCommandEvent& event ) { event.Skip(); }
|
|
||||||
virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); }
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DIALOG_COLOR_CONFIG_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("EESchema Colors"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 446,344 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
|
DIALOG_COLOR_CONFIG_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("EESchema Colors"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
|
||||||
~DIALOG_COLOR_CONFIG_BASE();
|
~DIALOG_COLOR_CONFIG_BASE();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue