Use the new color4Dpicker to choose a color in Eeschema.
However, the opacity is not modifiable because the wxDC used in Eeschema does not know the alpha channel.
This commit is contained in:
parent
2e96a5bc9f
commit
4e96f9990d
|
@ -7,9 +7,11 @@
|
|||
|
||||
#define ALPHA_MAX 100 // the max value returned by the alpha (opacity) slider
|
||||
|
||||
COLOR4D_PICKER_DLG::COLOR4D_PICKER_DLG( wxWindow* aParent, KIGFX::COLOR4D& aCurrentColor )
|
||||
COLOR4D_PICKER_DLG::COLOR4D_PICKER_DLG( wxWindow* aParent, KIGFX::COLOR4D& aCurrentColor,
|
||||
bool aAllowOpacityControl )
|
||||
: COLOR4D_PICKER_DLG_BASE( aParent )
|
||||
{
|
||||
m_allowOpacityCtrl = aAllowOpacityControl;
|
||||
m_previousColor4D = aCurrentColor;
|
||||
m_newColor4D = aCurrentColor;
|
||||
m_cursorsSize = 8; // Size of square cursors drawn on color bitmaps
|
||||
|
@ -17,6 +19,14 @@ COLOR4D_PICKER_DLG::COLOR4D_PICKER_DLG( wxWindow* aParent, KIGFX::COLOR4D& aCurr
|
|||
m_bitmapRGB = nullptr;
|
||||
m_bitmapHSV = nullptr;
|
||||
m_selectedCursor = nullptr;
|
||||
|
||||
if( !m_allowOpacityCtrl )
|
||||
{
|
||||
m_SizerTransparency->Show( false );
|
||||
m_previousColor4D.a = 1.0;
|
||||
m_newColor4D.a = 1.0;
|
||||
}
|
||||
|
||||
m_notebook->SetSelection( m_ActivePage );
|
||||
|
||||
// Build the defined colors panel:
|
||||
|
|
|
@ -23,7 +23,14 @@ enum CHANGED_COLOR
|
|||
class COLOR4D_PICKER_DLG : public COLOR4D_PICKER_DLG_BASE
|
||||
{
|
||||
public:
|
||||
COLOR4D_PICKER_DLG( wxWindow* aParent, KIGFX::COLOR4D& aCurrentColor );
|
||||
/**
|
||||
* Dialog constructor
|
||||
* @param aParent is the caller
|
||||
* @param aCurrentColor is the current color, used to show it in dialog
|
||||
* @param aAllowOpacityControl = true to allow opacity (alpha channel) setting
|
||||
* false to not show this setting (opacity = 1.0 always)
|
||||
*/
|
||||
COLOR4D_PICKER_DLG( wxWindow* aParent, KIGFX::COLOR4D& aCurrentColor, bool aAllowOpacityControl );
|
||||
~COLOR4D_PICKER_DLG();
|
||||
|
||||
KIGFX::COLOR4D GetColor() { return m_newColor4D; };
|
||||
|
@ -31,6 +38,8 @@ public:
|
|||
static int m_ActivePage; ///< the active notebook page, stored during a session
|
||||
|
||||
private:
|
||||
bool m_allowOpacityCtrl; ///< true to show the widget,
|
||||
///< false to keep alpha channel = 1.0
|
||||
KIGFX::COLOR4D m_previousColor4D; ///< the inital color4d
|
||||
KIGFX::COLOR4D m_newColor4D; ///< the current color4d
|
||||
int m_cursorsSize;
|
||||
|
|
|
@ -195,24 +195,23 @@ COLOR4D_PICKER_DLG_BASE::COLOR4D_PICKER_DLG_BASE( wxWindow* parent, wxWindowID i
|
|||
|
||||
bSizerUpperMain->Add( m_notebook, 1, wxEXPAND | wxALL, 5 );
|
||||
|
||||
wxBoxSizer* bSizerTransparency;
|
||||
bSizerTransparency = new wxBoxSizer( wxVERTICAL );
|
||||
m_SizerTransparency = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
|
||||
bSizerTransparency->Add( 0, 20, 0, 0, 5 );
|
||||
m_SizerTransparency->Add( 0, 20, 0, 0, 5 );
|
||||
|
||||
m_staticText9 = new wxStaticText( this, wxID_ANY, wxT("Opacity %"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticText9->Wrap( -1 );
|
||||
bSizerTransparency->Add( m_staticText9, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );
|
||||
m_SizerTransparency->Add( m_staticText9, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );
|
||||
|
||||
m_sliderTransparency = new wxSlider( this, wxID_ANY, 80, 20, 100, wxDefaultPosition, wxDefaultSize, wxSL_LABELS|wxSL_LEFT|wxSL_VERTICAL );
|
||||
bSizerTransparency->Add( m_sliderTransparency, 1, wxALL, 5 );
|
||||
m_SizerTransparency->Add( m_sliderTransparency, 1, wxALL, 5 );
|
||||
|
||||
|
||||
bSizerTransparency->Add( 0, 20, 0, 0, 5 );
|
||||
m_SizerTransparency->Add( 0, 20, 0, 0, 5 );
|
||||
|
||||
|
||||
bSizerUpperMain->Add( bSizerTransparency, 0, wxEXPAND, 5 );
|
||||
bSizerUpperMain->Add( m_SizerTransparency, 0, wxEXPAND, 5 );
|
||||
|
||||
wxBoxSizer* bSizerShowColors;
|
||||
bSizerShowColors = new wxBoxSizer( wxVERTICAL );
|
||||
|
|
|
@ -1779,9 +1779,9 @@
|
|||
<property name="proportion">0</property>
|
||||
<object class="wxBoxSizer" expanded="1">
|
||||
<property name="minimum_size"></property>
|
||||
<property name="name">bSizerTransparency</property>
|
||||
<property name="name">m_SizerTransparency</property>
|
||||
<property name="orient">wxVERTICAL</property>
|
||||
<property name="permission">none</property>
|
||||
<property name="permission">protected</property>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag"></property>
|
||||
|
|
|
@ -63,6 +63,7 @@ class COLOR4D_PICKER_DLG_BASE : public DIALOG_SHIM
|
|||
wxPanel* m_panelDefinedColors;
|
||||
wxBoxSizer* m_SizerDefinedColors;
|
||||
wxFlexGridSizer* m_fgridColor;
|
||||
wxBoxSizer* m_SizerTransparency;
|
||||
wxStaticText* m_staticText9;
|
||||
wxSlider* m_sliderTransparency;
|
||||
wxStaticText* m_staticTextOldColor;
|
||||
|
|
|
@ -23,9 +23,7 @@
|
|||
|
||||
#include <widgets/color_swatch.h>
|
||||
|
||||
//#include <wx/colour.h>
|
||||
//#include <wx/colordlg.h>
|
||||
#include <color4Dpickerdlg.h>
|
||||
#include "color4Dpickerdlg.h"
|
||||
#include <memory>
|
||||
|
||||
wxDEFINE_EVENT(COLOR_SWATCH_CHANGED, wxCommandEvent);
|
||||
|
@ -150,10 +148,10 @@ void COLOR_SWATCH::GetNewSwatchColor()
|
|||
|
||||
if( m_arbitraryColors )
|
||||
{
|
||||
COLOR4D_PICKER_DLG dialog( this, m_color );
|
||||
COLOR4D_PICKER_DLG dialog( this, m_color, true );
|
||||
|
||||
if( dialog.ShowModal() == wxID_OK )
|
||||
newColor = COLOR4D( dialog.GetColor() );
|
||||
newColor = dialog.GetColor();
|
||||
}
|
||||
else
|
||||
newColor = DisplayColorFrame( this, m_color );
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
|
||||
#include <wx/settings.h>
|
||||
|
||||
int DIALOG_EESCHEMA_OPTIONS::m_lastPageSelected = 0;
|
||||
|
||||
DIALOG_EESCHEMA_OPTIONS::DIALOG_EESCHEMA_OPTIONS( SCH_EDIT_FRAME* parent ) :
|
||||
DIALOG_EESCHEMA_OPTIONS_BASE( parent )
|
||||
|
@ -61,8 +62,8 @@ DIALOG_EESCHEMA_OPTIONS::DIALOG_EESCHEMA_OPTIONS( SCH_EDIT_FRAME* parent ) :
|
|||
m_colorConfigCtrl = new WIDGET_EESCHEMA_COLOR_CONFIG( m_panelColors, GetParent() );
|
||||
m_colorConfigCtrl->InstallOnPanel( m_panelColors );
|
||||
|
||||
// Make sure we select the first tab of the options tab page
|
||||
m_notebook->SetSelection( 0 );
|
||||
// Make sure we select the last used tab of the options tab page
|
||||
m_notebook->SetSelection( m_lastPageSelected );
|
||||
|
||||
// Lay out all child pages
|
||||
// No, I don't know why this->Layout() doesn't propagate through to these,
|
||||
|
@ -287,6 +288,8 @@ bool DIALOG_EESCHEMA_OPTIONS::TransferDataToWindow()
|
|||
|
||||
bool DIALOG_EESCHEMA_OPTIONS::TransferDataFromWindow()
|
||||
{
|
||||
m_lastPageSelected = m_notebook->GetSelection();
|
||||
|
||||
if( !wxDialog::TransferDataFromWindow() )
|
||||
return false;
|
||||
|
||||
|
|
|
@ -40,6 +40,9 @@ class SCH_EDIT_FRAME;
|
|||
|
||||
class DIALOG_EESCHEMA_OPTIONS : public DIALOG_EESCHEMA_OPTIONS_BASE
|
||||
{
|
||||
private:
|
||||
static int m_lastPageSelected; ///< the active notebook page when closing this dialog
|
||||
///< strored to keep selection during a session
|
||||
protected:
|
||||
WIDGET_HOTKEY_LIST* m_hotkeyListCtrl;
|
||||
WIDGET_EESCHEMA_COLOR_CONFIG* m_colorConfigCtrl;
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
/* Set up color Layers for Eeschema
|
||||
/* Set up colors to draw items in Eeschema
|
||||
*/
|
||||
|
||||
#include <fctsys.h>
|
||||
|
@ -32,6 +32,7 @@
|
|||
#include <general.h>
|
||||
|
||||
#include "widget_eeschema_color_config.h"
|
||||
#include <../common/widgets/color4Dpickerdlg.h>
|
||||
|
||||
// Specify the width and height of every (color-displaying / bitmap) button
|
||||
const int BUTT_SIZE_X = 16;
|
||||
|
@ -232,20 +233,16 @@ void WIDGET_EESCHEMA_COLOR_CONFIG::SetColor( wxCommandEvent& event )
|
|||
COLORBUTTON* colorButton = (COLORBUTTON*) button->GetClientData();
|
||||
|
||||
wxCHECK_RET( colorButton != NULL, wxT( "Client data not set for color button." ) );
|
||||
|
||||
wxColourData colourData;
|
||||
colourData.SetColour( currentColors[ SCH_LAYER_INDEX( colorButton->m_Layer ) ].ToColour() );
|
||||
wxColourDialog *dialog = new wxColourDialog( this, &colourData );
|
||||
|
||||
COLOR4D oldColor = currentColors[ SCH_LAYER_INDEX( colorButton->m_Layer ) ];
|
||||
COLOR4D newColor = COLOR4D::UNSPECIFIED;
|
||||
COLOR4D_PICKER_DLG dialog( this, oldColor, false );
|
||||
|
||||
if( dialog->ShowModal() == wxID_OK )
|
||||
if( dialog.ShowModal() == wxID_OK )
|
||||
{
|
||||
newColor = COLOR4D( dialog->GetColourData().GetColour() );
|
||||
newColor = dialog.GetColor();
|
||||
}
|
||||
|
||||
if( newColor == COLOR4D::UNSPECIFIED ||
|
||||
currentColors[ SCH_LAYER_INDEX( colorButton->m_Layer ) ] == newColor )
|
||||
if( newColor == COLOR4D::UNSPECIFIED || oldColor == newColor )
|
||||
return;
|
||||
|
||||
currentColors[ SCH_LAYER_INDEX( colorButton->m_Layer ) ] = newColor;
|
||||
|
|
Loading…
Reference in New Issue