Cleaner look for colour swatches and the undefined colour.
This commit is contained in:
parent
5c3a1d059e
commit
aceed2b0a4
|
@ -21,9 +21,14 @@
|
||||||
#include "dialog_color_picker.h"
|
#include "dialog_color_picker.h"
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <kiface_i.h>
|
||||||
|
#include <settings/app_settings.h>
|
||||||
|
#include <widgets/color_swatch.h>
|
||||||
|
|
||||||
#define ALPHA_MAX 100 // the max value returned by the alpha (opacity) slider
|
#define ALPHA_MAX 100 // the max value returned by the alpha (opacity) slider
|
||||||
|
|
||||||
|
using KIGFX::COLOR4D;
|
||||||
|
|
||||||
// Configure the spin controls contained inside the dialog
|
// Configure the spin controls contained inside the dialog
|
||||||
void configureSpinCtrl( wxSpinCtrl* aCtrl )
|
void configureSpinCtrl( wxSpinCtrl* aCtrl )
|
||||||
{
|
{
|
||||||
|
@ -35,10 +40,11 @@ void configureSpinCtrl( wxSpinCtrl* aCtrl )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DIALOG_COLOR_PICKER::DIALOG_COLOR_PICKER( wxWindow* aParent, KIGFX::COLOR4D& aCurrentColor,
|
DIALOG_COLOR_PICKER::DIALOG_COLOR_PICKER( wxWindow* aParent, COLOR4D& aCurrentColor,
|
||||||
bool aAllowOpacityControl, CUSTOM_COLORS_LIST* aUserColors,
|
bool aAllowOpacityControl,
|
||||||
const KIGFX::COLOR4D& aDefaultColor )
|
CUSTOM_COLORS_LIST* aUserColors,
|
||||||
: DIALOG_COLOR_PICKER_BASE( aParent )
|
const COLOR4D& aDefaultColor ) :
|
||||||
|
DIALOG_COLOR_PICKER_BASE( aParent )
|
||||||
{
|
{
|
||||||
m_allowMouseEvents = false;
|
m_allowMouseEvents = false;
|
||||||
m_allowOpacityCtrl = aAllowOpacityControl;
|
m_allowOpacityCtrl = aAllowOpacityControl;
|
||||||
|
@ -58,8 +64,10 @@ DIALOG_COLOR_PICKER::DIALOG_COLOR_PICKER( wxWindow* aParent, KIGFX::COLOR4D& aCu
|
||||||
m_newColor4D.a = 1.0;
|
m_newColor4D.a = 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( m_ActivePage >= 0 )
|
APP_SETTINGS_BASE* cfg = Kiface().KifaceSettings();
|
||||||
m_notebook->SetSelection( (unsigned) m_ActivePage );
|
wxASSERT( cfg );
|
||||||
|
|
||||||
|
m_notebook->SetSelection( cfg->m_ColorPicker.default_tab );
|
||||||
|
|
||||||
// Build the defined colors panel:
|
// Build the defined colors panel:
|
||||||
initDefinedColors( aUserColors );
|
initDefinedColors( aUserColors );
|
||||||
|
@ -71,87 +79,44 @@ DIALOG_COLOR_PICKER::DIALOG_COLOR_PICKER( wxWindow* aParent, KIGFX::COLOR4D& aCu
|
||||||
* The underlying action is the same, but we change the label here because the action from
|
* 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.
|
* the point of view of the user is slightly different.
|
||||||
*/
|
*/
|
||||||
if( aDefaultColor == KIGFX::COLOR4D::UNSPECIFIED )
|
if( aDefaultColor == COLOR4D::UNSPECIFIED )
|
||||||
m_resetToDefault->SetLabel( _( "Clear Color" ) );
|
m_resetToDefault->SetLabel( _( "Clear Color" ) );
|
||||||
|
|
||||||
m_sdbSizerOK->SetDefault();
|
m_sdbSizerOK->SetDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
int DIALOG_COLOR_PICKER::m_ActivePage = 0; // the active notebook page, stored during a session
|
|
||||||
|
|
||||||
|
|
||||||
DIALOG_COLOR_PICKER::~DIALOG_COLOR_PICKER()
|
DIALOG_COLOR_PICKER::~DIALOG_COLOR_PICKER()
|
||||||
{
|
{
|
||||||
|
APP_SETTINGS_BASE* cfg = Kiface().KifaceSettings();
|
||||||
|
wxASSERT( cfg );
|
||||||
|
|
||||||
|
cfg->m_ColorPicker.default_tab = m_notebook->GetSelection();
|
||||||
|
|
||||||
delete m_bitmapRGB;
|
delete m_bitmapRGB;
|
||||||
delete m_bitmapHSV;
|
delete m_bitmapHSV;
|
||||||
|
|
||||||
m_ActivePage = m_notebook->GetSelection();
|
for( wxStaticBitmap* swatch : m_colorSwatches )
|
||||||
|
|
||||||
for( auto button : m_buttonsColor )
|
|
||||||
button->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED,
|
|
||||||
wxCommandEventHandler( DIALOG_COLOR_PICKER::buttColorClick ), NULL, this );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void DIALOG_COLOR_PICKER::setIconColor( wxStaticBitmap* aStaticBitmap, KIGFX::COLOR4D& aColor4D )
|
|
||||||
{
|
{
|
||||||
// Draw the icon that shows the aColor4D,
|
swatch->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED,
|
||||||
// with colors according to the color 4D rgb and alpha
|
wxMouseEventHandler( DIALOG_COLOR_PICKER::buttColorClick ),
|
||||||
// for alpha = 1 (no tranparency, the icon is a full rgb color rect
|
NULL, this );
|
||||||
// for alpha = 0 (100% tranparency, the icon is a grid of rgb color
|
|
||||||
// and background color small sub rect
|
|
||||||
wxMemoryDC bitmapDC;
|
|
||||||
wxSize size = aStaticBitmap->GetSize();
|
|
||||||
wxBitmap newBm( size );
|
|
||||||
bitmapDC.SelectObject( newBm );
|
|
||||||
wxPen pen( aColor4D.ToColour() );
|
|
||||||
wxBrush brush( aColor4D.ToColour() );
|
|
||||||
|
|
||||||
// clear background (set bg color to aColor4D )
|
|
||||||
bitmapDC.SetBackground( brush );
|
|
||||||
bitmapDC.Clear();
|
|
||||||
|
|
||||||
|
|
||||||
// Draw the alpha subrect
|
|
||||||
int stepx = size.x/8;
|
|
||||||
int stepy = size.y/8;
|
|
||||||
|
|
||||||
// build the alpha color for icon:
|
|
||||||
// the alpha color is the initial color modified to be
|
|
||||||
// the initial color for transparency = 0 ( alpha = 1 )
|
|
||||||
// and white color for transparency = 1( alpha = 0 )
|
|
||||||
KIGFX::COLOR4D bgcolor( GetBackgroundColour() );
|
|
||||||
KIGFX::COLOR4D alphacolor = aColor4D;
|
|
||||||
alphacolor.r = ( alphacolor.r * aColor4D.a ) + ( bgcolor.r * (1-aColor4D.a) );
|
|
||||||
alphacolor.g = ( alphacolor.g * aColor4D.a ) + ( bgcolor.g * (1-aColor4D.a) );
|
|
||||||
alphacolor.b = ( alphacolor.b * aColor4D.a ) + ( bgcolor.b * (1-aColor4D.a) );
|
|
||||||
|
|
||||||
pen.SetColour( alphacolor.ToColour() );
|
|
||||||
brush.SetColour( alphacolor.ToColour() );
|
|
||||||
bitmapDC.SetPen( pen );
|
|
||||||
bitmapDC.SetBrush( brush );
|
|
||||||
|
|
||||||
for( int ii = 0; ii < size.x/stepx; ii+=2 )
|
|
||||||
{
|
|
||||||
for( int jj = 0; jj < size.y/stepy; jj+= 2 )
|
|
||||||
{
|
|
||||||
wxPoint pos( stepx*ii + stepx/2, stepy*jj + stepy/2 );
|
|
||||||
bitmapDC.DrawRectangle( pos, wxSize( stepx, stepy ) );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DIALOG_COLOR_PICKER::updatePreview( wxStaticBitmap* aStaticBitmap, COLOR4D& aColor4D )
|
||||||
|
{
|
||||||
|
wxBitmap newBm = COLOR_SWATCH::MakeBitmap( aColor4D, COLOR4D::WHITE, aStaticBitmap->GetSize(),
|
||||||
|
ConvertDialogToPixels( CHECKERBOARD_SIZE_DU ) );
|
||||||
aStaticBitmap->SetBitmap( newBm );
|
aStaticBitmap->SetBitmap( newBm );
|
||||||
|
|
||||||
// Deselect the Tool Bitmap from DC, in order to delete the MemoryDC
|
|
||||||
// safely without deleting the bitmap
|
|
||||||
bitmapDC.SelectObject( wxNullBitmap );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool DIALOG_COLOR_PICKER::TransferDataToWindow()
|
bool DIALOG_COLOR_PICKER::TransferDataToWindow()
|
||||||
{
|
{
|
||||||
// Draw all bitmaps, with colors according to the color 4D
|
// Draw all bitmaps, with colors according to the color 4D
|
||||||
setIconColor( m_OldColorRect, m_previousColor4D );
|
updatePreview( m_OldColorRect, m_previousColor4D );
|
||||||
SetEditVals( ALL_CHANGED, false );
|
SetEditVals( ALL_CHANGED, false );
|
||||||
drawAll();
|
drawAll();
|
||||||
|
|
||||||
|
@ -175,9 +140,6 @@ void DIALOG_COLOR_PICKER::initDefinedColors( CUSTOM_COLORS_LIST* aPredefinedColo
|
||||||
{
|
{
|
||||||
#define ID_COLOR_BLACK 2000 // colors_id = ID_COLOR_BLACK a ID_COLOR_BLACK + NBCOLORS-1
|
#define ID_COLOR_BLACK 2000 // colors_id = ID_COLOR_BLACK a ID_COLOR_BLACK + NBCOLORS-1
|
||||||
|
|
||||||
// Size of color swatches
|
|
||||||
const int w = 32, h = 32;
|
|
||||||
|
|
||||||
// Colors are built from the colorRefs() table (size NBCOLORS).
|
// Colors are built from the colorRefs() table (size NBCOLORS).
|
||||||
// The look is better when colorRefs() order is displayed in a grid matrix
|
// The look is better when colorRefs() order is displayed in a grid matrix
|
||||||
// of 6 row and 5 columns, first filling a row, and after the next column.
|
// of 6 row and 5 columns, first filling a row, and after the next column.
|
||||||
|
@ -188,6 +150,29 @@ void DIALOG_COLOR_PICKER::initDefinedColors( CUSTOM_COLORS_LIST* aPredefinedColo
|
||||||
int grid_row = 0;
|
int grid_row = 0;
|
||||||
int table_row_count = 6;
|
int table_row_count = 6;
|
||||||
|
|
||||||
|
wxSize swatchSize = ConvertDialogToPixels( SWATCH_SIZE_LARGE_DU );
|
||||||
|
wxSize checkerboardSize = ConvertDialogToPixels( CHECKERBOARD_SIZE_DU );
|
||||||
|
|
||||||
|
auto addSwatch =
|
||||||
|
[&]( int aId, COLOR4D aColor, const wxString& aColorName )
|
||||||
|
{
|
||||||
|
wxBitmap bitmap = COLOR_SWATCH::MakeBitmap( aColor, COLOR4D::WHITE, swatchSize,
|
||||||
|
checkerboardSize );
|
||||||
|
wxStaticBitmap* swatch = new wxStaticBitmap( m_panelDefinedColors, aId, bitmap );
|
||||||
|
|
||||||
|
m_fgridColor->Add( swatch, 0, wxALIGN_CENTER_VERTICAL, 5 );
|
||||||
|
|
||||||
|
wxStaticText* label = new wxStaticText( m_panelDefinedColors, wxID_ANY, aColorName,
|
||||||
|
wxDefaultPosition, wxDefaultSize, 0 );
|
||||||
|
m_fgridColor->Add( label, 1, wxALIGN_CENTER_VERTICAL | wxRIGHT, 15 );
|
||||||
|
|
||||||
|
m_colorSwatches.push_back( swatch );
|
||||||
|
|
||||||
|
swatch->Connect( wxEVT_LEFT_DOWN,
|
||||||
|
wxMouseEventHandler( DIALOG_COLOR_PICKER::buttColorClick ),
|
||||||
|
NULL, this );
|
||||||
|
};
|
||||||
|
|
||||||
// If no predefined list is given, build the default predefined colors:
|
// If no predefined list is given, build the default predefined colors:
|
||||||
if( aPredefinedColors )
|
if( aPredefinedColors )
|
||||||
{
|
{
|
||||||
|
@ -195,46 +180,14 @@ void DIALOG_COLOR_PICKER::initDefinedColors( CUSTOM_COLORS_LIST* aPredefinedColo
|
||||||
{
|
{
|
||||||
CUSTOM_COLOR_ITEM* item = & *aPredefinedColors->begin() + jj;
|
CUSTOM_COLOR_ITEM* item = & *aPredefinedColors->begin() + jj;
|
||||||
int butt_ID = ID_COLOR_BLACK + jj;
|
int butt_ID = ID_COLOR_BLACK + jj;
|
||||||
wxMemoryDC iconDC;
|
|
||||||
wxBitmap ButtBitmap( w, h );
|
|
||||||
wxBrush brush;
|
|
||||||
|
|
||||||
iconDC.SelectObject( ButtBitmap );
|
addSwatch( butt_ID, item->m_Color, item->m_ColorName );
|
||||||
|
m_Color4DList.push_back( item->m_Color );
|
||||||
KIGFX::COLOR4D buttcolor = item->m_Color;
|
|
||||||
|
|
||||||
iconDC.SetPen( *wxBLACK_PEN );
|
|
||||||
brush.SetColour( buttcolor.ToColour() );
|
|
||||||
brush.SetStyle( wxBRUSHSTYLE_SOLID );
|
|
||||||
|
|
||||||
iconDC.SetBrush( brush );
|
|
||||||
iconDC.SetBackground( *wxGREY_BRUSH );
|
|
||||||
iconDC.Clear();
|
|
||||||
iconDC.DrawRoundedRectangle( 0, 0, w, h, (double) h / 3 );
|
|
||||||
|
|
||||||
wxBitmapButton* bitmapButton = new wxBitmapButton( m_panelDefinedColors, butt_ID, ButtBitmap,
|
|
||||||
wxDefaultPosition, wxSize( w+8, h+6 ) );
|
|
||||||
m_fgridColor->Add( bitmapButton, 0,
|
|
||||||
wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |
|
|
||||||
wxLEFT | wxBOTTOM, 5 );
|
|
||||||
|
|
||||||
wxStaticText* label = new wxStaticText( m_panelDefinedColors, -1,
|
|
||||||
item->m_ColorName,
|
|
||||||
wxDefaultPosition, wxDefaultSize, 0 );
|
|
||||||
m_fgridColor->Add( label, 1,
|
|
||||||
wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |
|
|
||||||
wxLEFT | wxRIGHT | wxBOTTOM, 5 );
|
|
||||||
m_buttonsColor.push_back( bitmapButton );
|
|
||||||
|
|
||||||
m_Color4DList.push_back( buttcolor );
|
|
||||||
|
|
||||||
bitmapButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED,
|
|
||||||
wxCommandEventHandler( DIALOG_COLOR_PICKER::buttColorClick ), NULL, this );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_Color4DList.assign( NBCOLORS, KIGFX::COLOR4D( 0.0, 0.0, 0.0, 1.0 ) );
|
m_Color4DList.assign( NBCOLORS, COLOR4D( 0.0, 0.0, 0.0, 1.0 ) );
|
||||||
|
|
||||||
for( int jj = 0; jj < NBCOLORS; ++jj, grid_col++ )
|
for( int jj = 0; jj < NBCOLORS; ++jj, grid_col++ )
|
||||||
{
|
{
|
||||||
|
@ -245,41 +198,11 @@ void DIALOG_COLOR_PICKER::initDefinedColors( CUSTOM_COLORS_LIST* aPredefinedColo
|
||||||
}
|
}
|
||||||
|
|
||||||
int ii = grid_row + (grid_col*table_row_count); // The index in colorRefs()
|
int ii = grid_row + (grid_col*table_row_count); // The index in colorRefs()
|
||||||
|
|
||||||
int butt_ID = ID_COLOR_BLACK + ii;
|
int butt_ID = ID_COLOR_BLACK + ii;
|
||||||
wxMemoryDC iconDC;
|
COLOR4D buttcolor = COLOR4D( colorRefs()[ii].m_Numcolor );
|
||||||
wxBitmap ButtBitmap( w, h );
|
|
||||||
wxBrush brush;
|
|
||||||
|
|
||||||
iconDC.SelectObject( ButtBitmap );
|
addSwatch( butt_ID, buttcolor, wxGetTranslation( colorRefs()[ii].m_ColorName ) );
|
||||||
|
|
||||||
KIGFX::COLOR4D buttcolor = KIGFX::COLOR4D( colorRefs()[ii].m_Numcolor );
|
|
||||||
m_Color4DList[ butt_ID - ID_COLOR_BLACK ] = buttcolor;
|
m_Color4DList[ butt_ID - ID_COLOR_BLACK ] = buttcolor;
|
||||||
|
|
||||||
iconDC.SetPen( *wxBLACK_PEN );
|
|
||||||
brush.SetColour( buttcolor.ToColour() );
|
|
||||||
brush.SetStyle( wxBRUSHSTYLE_SOLID );
|
|
||||||
|
|
||||||
iconDC.SetBrush( brush );
|
|
||||||
iconDC.SetBackground( *wxGREY_BRUSH );
|
|
||||||
iconDC.Clear();
|
|
||||||
iconDC.DrawRoundedRectangle( 0, 0, w, h, (double) h / 3 );
|
|
||||||
|
|
||||||
wxBitmapButton* bitmapButton = new wxBitmapButton( m_panelDefinedColors, butt_ID, ButtBitmap,
|
|
||||||
wxDefaultPosition, wxSize( w+8, h+6 ) );
|
|
||||||
m_fgridColor->Add( bitmapButton, 0,
|
|
||||||
wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |
|
|
||||||
wxLEFT | wxBOTTOM, 5 );
|
|
||||||
|
|
||||||
wxStaticText* label = new wxStaticText( m_panelDefinedColors, -1,
|
|
||||||
wxGetTranslation( colorRefs()[ii].m_ColorName ),
|
|
||||||
wxDefaultPosition, wxDefaultSize, 0 );
|
|
||||||
m_fgridColor->Add( label, 1,
|
|
||||||
wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |
|
|
||||||
wxLEFT | wxRIGHT | wxBOTTOM, 5 );
|
|
||||||
m_buttonsColor.push_back( bitmapButton );
|
|
||||||
bitmapButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED,
|
|
||||||
wxCommandEventHandler( DIALOG_COLOR_PICKER::buttColorClick ), NULL, this );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -306,7 +229,7 @@ void DIALOG_COLOR_PICKER::createRGBBitmap()
|
||||||
// Reserve room to draw cursors inside the bitmap
|
// Reserve room to draw cursors inside the bitmap
|
||||||
half_size -= m_cursorsSize/2;
|
half_size -= m_cursorsSize/2;
|
||||||
|
|
||||||
KIGFX::COLOR4D color;
|
COLOR4D color;
|
||||||
|
|
||||||
// Red blue area in X Z 3d axis
|
// Red blue area in X Z 3d axis
|
||||||
double inc = 1.0 / half_size;
|
double inc = 1.0 / half_size;
|
||||||
|
@ -392,7 +315,7 @@ void DIALOG_COLOR_PICKER::createHSVBitmap()
|
||||||
half_size -= m_cursorsSize/2;
|
half_size -= m_cursorsSize/2;
|
||||||
|
|
||||||
double hue, sat;
|
double hue, sat;
|
||||||
KIGFX::COLOR4D color;
|
COLOR4D color;
|
||||||
int sq_radius = half_size*half_size;
|
int sq_radius = half_size*half_size;
|
||||||
|
|
||||||
for( int xx = -half_size; xx < half_size; xx++ )
|
for( int xx = -half_size; xx < half_size; xx++ )
|
||||||
|
@ -575,7 +498,7 @@ void DIALOG_COLOR_PICKER::drawAll()
|
||||||
m_NewColorRect->Freeze(); // Avoid flicker
|
m_NewColorRect->Freeze(); // Avoid flicker
|
||||||
m_HsvBitmap->Freeze();
|
m_HsvBitmap->Freeze();
|
||||||
m_RgbBitmap->Freeze();
|
m_RgbBitmap->Freeze();
|
||||||
setIconColor( m_NewColorRect, m_newColor4D );
|
updatePreview( m_NewColorRect, m_newColor4D );
|
||||||
drawHSVPalette();
|
drawHSVPalette();
|
||||||
drawRGBPalette();
|
drawRGBPalette();
|
||||||
m_NewColorRect->Thaw();
|
m_NewColorRect->Thaw();
|
||||||
|
@ -587,10 +510,10 @@ void DIALOG_COLOR_PICKER::drawAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DIALOG_COLOR_PICKER::buttColorClick( wxCommandEvent& event )
|
void DIALOG_COLOR_PICKER::buttColorClick( wxMouseEvent& event )
|
||||||
{
|
{
|
||||||
int id = event.GetId();
|
int id = event.GetId();
|
||||||
KIGFX::COLOR4D color( m_Color4DList[id - ID_COLOR_BLACK] );//EDA_COLOR_T( id - ID_COLOR_BLACK ) );
|
COLOR4D color( m_Color4DList[id - ID_COLOR_BLACK] );
|
||||||
m_newColor4D.r = color.r;
|
m_newColor4D.r = color.r;
|
||||||
m_newColor4D.g = color.g;
|
m_newColor4D.g = color.g;
|
||||||
m_newColor4D.b = color.b;
|
m_newColor4D.b = color.b;
|
||||||
|
@ -775,7 +698,7 @@ void DIALOG_COLOR_PICKER::OnChangeAlpha( wxScrollEvent& event )
|
||||||
double alpha = (double)event.GetPosition() / ALPHA_MAX;
|
double alpha = (double)event.GetPosition() / ALPHA_MAX;
|
||||||
m_newColor4D.a = alpha;
|
m_newColor4D.a = alpha;
|
||||||
m_NewColorRect->Freeze(); // Avoid flicker
|
m_NewColorRect->Freeze(); // Avoid flicker
|
||||||
setIconColor( m_NewColorRect, m_newColor4D );
|
updatePreview( m_NewColorRect, m_newColor4D );
|
||||||
m_NewColorRect->Thaw();
|
m_NewColorRect->Thaw();
|
||||||
m_NewColorRect->Refresh();
|
m_NewColorRect->Refresh();
|
||||||
}
|
}
|
||||||
|
@ -857,9 +780,5 @@ void DIALOG_COLOR_PICKER::OnResetButton( wxCommandEvent& aEvent )
|
||||||
m_newColor4D.ToHSV( m_hue, m_sat, m_val, true );
|
m_newColor4D.ToHSV( m_hue, m_sat, m_val, true );
|
||||||
SetEditVals( ALL_CHANGED, false );
|
SetEditVals( ALL_CHANGED, false );
|
||||||
|
|
||||||
// When the default is UNSPECIFIED, this is the Clear Color button, which should accept
|
|
||||||
if( m_defaultColor == KIGFX::COLOR4D::UNSPECIFIED )
|
|
||||||
AcceptAndClose();
|
|
||||||
else
|
|
||||||
drawAll();
|
drawAll();
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,9 @@
|
||||||
#include <gal/color4d.h>
|
#include <gal/color4d.h>
|
||||||
#include "dialog_color_picker_base.h"
|
#include "dialog_color_picker_base.h"
|
||||||
|
|
||||||
|
class COLOR_SWATCH;
|
||||||
|
|
||||||
|
|
||||||
/** a class to handle a custom color (predefined color) for
|
/** a class to handle a custom color (predefined color) for
|
||||||
* the color picker dialog
|
* the color picker dialog
|
||||||
*/
|
*/
|
||||||
|
@ -83,8 +86,6 @@ public:
|
||||||
|
|
||||||
KIGFX::COLOR4D GetColor() { return m_newColor4D; };
|
KIGFX::COLOR4D GetColor() { return m_newColor4D; };
|
||||||
|
|
||||||
static int m_ActivePage; ///< the active notebook page, stored during a session
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/* When the dialog is created, the mouse cursor can be on the RGB or HSV palette selector
|
/* When the dialog is created, the mouse cursor can be on the RGB or HSV palette selector
|
||||||
* Because this dialog is created by clicking double clicking on a widget, the left mouse
|
* Because this dialog is created by clicking double clicking on a widget, the left mouse
|
||||||
|
@ -116,7 +117,7 @@ private:
|
||||||
wxBitmap* m_bitmapRGB; ///< the basic RGB palette
|
wxBitmap* m_bitmapRGB; ///< the basic RGB palette
|
||||||
wxBitmap* m_bitmapHSV; ///< the basic HUV palette
|
wxBitmap* m_bitmapHSV; ///< the basic HUV palette
|
||||||
|
|
||||||
std::vector<wxBitmapButton*> m_buttonsColor; ///< list of defined colors buttons
|
std::vector<wxStaticBitmap*> m_colorSwatches; ///< list of defined colors buttons
|
||||||
|
|
||||||
void SetEditVals( CHANGED_COLOR aChanged, bool aCheckTransparency );
|
void SetEditVals( CHANGED_COLOR aChanged, bool aCheckTransparency );
|
||||||
void drawAll();
|
void drawAll();
|
||||||
|
@ -125,10 +126,9 @@ private:
|
||||||
void drawHSVPalette(); ///< draws the HSV color circle
|
void drawHSVPalette(); ///< draws the HSV color circle
|
||||||
void createRGBBitmap(); ///< generate the bitmap that shows the RVB color space
|
void createRGBBitmap(); ///< generate the bitmap that shows the RVB color space
|
||||||
void drawRGBPalette(); ///< draws the RVB color space
|
void drawRGBPalette(); ///< draws the RVB color space
|
||||||
void drawRGBCursors();
|
|
||||||
|
|
||||||
///> repaint a static bitmap with the aColor4D color
|
///> repaint a static bitmap with the aColor4D color
|
||||||
void setIconColor( wxStaticBitmap* aStaticBitmap, KIGFX::COLOR4D& aColor4D );
|
void updatePreview( wxStaticBitmap* aStaticBitmap, KIGFX::COLOR4D& aColor4D );
|
||||||
|
|
||||||
///< Event handler from wxSlider: brightness (value) control
|
///< Event handler from wxSlider: brightness (value) control
|
||||||
void OnChangeBrightness( wxScrollEvent& event ) override;
|
void OnChangeBrightness( wxScrollEvent& event ) override;
|
||||||
|
@ -164,7 +164,7 @@ private:
|
||||||
bool setHSvaluesFromCursor( wxPoint aMouseCursor );
|
bool setHSvaluesFromCursor( wxPoint aMouseCursor );
|
||||||
|
|
||||||
///> Event handler for defined color buttons
|
///> Event handler for defined color buttons
|
||||||
void buttColorClick( wxCommandEvent& event );
|
void buttColorClick( wxMouseEvent& event );
|
||||||
|
|
||||||
///> called when creating the dialog
|
///> called when creating the dialog
|
||||||
bool TransferDataToWindow() override;
|
bool TransferDataToWindow() override;
|
||||||
|
|
|
@ -135,7 +135,7 @@ DIALOG_COLOR_PICKER_BASE::DIALOG_COLOR_PICKER_BASE( wxWindow* parent, wxWindowID
|
||||||
m_panelDefinedColors = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
|
m_panelDefinedColors = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
|
||||||
m_SizerDefinedColors = new wxBoxSizer( wxVERTICAL );
|
m_SizerDefinedColors = new wxBoxSizer( wxVERTICAL );
|
||||||
|
|
||||||
m_fgridColor = new wxFlexGridSizer( 0, 10, 0, 0 );
|
m_fgridColor = new wxFlexGridSizer( 0, 10, 25, 5 );
|
||||||
m_fgridColor->AddGrowableCol( 1 );
|
m_fgridColor->AddGrowableCol( 1 );
|
||||||
m_fgridColor->AddGrowableCol( 3 );
|
m_fgridColor->AddGrowableCol( 3 );
|
||||||
m_fgridColor->AddGrowableCol( 5 );
|
m_fgridColor->AddGrowableCol( 5 );
|
||||||
|
@ -145,7 +145,7 @@ DIALOG_COLOR_PICKER_BASE::DIALOG_COLOR_PICKER_BASE( wxWindow* parent, wxWindowID
|
||||||
m_fgridColor->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
|
m_fgridColor->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
|
||||||
|
|
||||||
|
|
||||||
m_SizerDefinedColors->Add( m_fgridColor, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL|wxTOP|wxBOTTOM, 5 );
|
m_SizerDefinedColors->Add( m_fgridColor, 1, wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL|wxALL|wxEXPAND, 10 );
|
||||||
|
|
||||||
|
|
||||||
m_panelDefinedColors->SetSizer( m_SizerDefinedColors );
|
m_panelDefinedColors->SetSizer( m_SizerDefinedColors );
|
||||||
|
@ -184,15 +184,15 @@ DIALOG_COLOR_PICKER_BASE::DIALOG_COLOR_PICKER_BASE( wxWindow* parent, wxWindowID
|
||||||
|
|
||||||
m_staticTextOldColor = new wxStaticText( this, wxID_ANY, _("Preview (old/new):"), wxDefaultPosition, wxDefaultSize, 0 );
|
m_staticTextOldColor = new wxStaticText( this, wxID_ANY, _("Preview (old/new):"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||||
m_staticTextOldColor->Wrap( -1 );
|
m_staticTextOldColor->Wrap( -1 );
|
||||||
bButtonsSizer->Add( m_staticTextOldColor, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
|
bButtonsSizer->Add( m_staticTextOldColor, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
|
||||||
|
|
||||||
m_OldColorRect = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( -1,-1 ), 0 );
|
m_OldColorRect = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( -1,-1 ), 0 );
|
||||||
m_OldColorRect->SetMinSize( wxSize( 30,22 ) );
|
m_OldColorRect->SetMinSize( wxSize( 24,24 ) );
|
||||||
|
|
||||||
bButtonsSizer->Add( m_OldColorRect, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
|
bButtonsSizer->Add( m_OldColorRect, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
|
||||||
|
|
||||||
m_NewColorRect = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( -1,-1 ), 0 );
|
m_NewColorRect = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( -1,-1 ), 0 );
|
||||||
m_NewColorRect->SetMinSize( wxSize( 30,22 ) );
|
m_NewColorRect->SetMinSize( wxSize( 24,24 ) );
|
||||||
|
|
||||||
bButtonsSizer->Add( m_NewColorRect, 0, wxALIGN_CENTER_VERTICAL, 5 );
|
bButtonsSizer->Add( m_NewColorRect, 0, wxALIGN_CENTER_VERTICAL, 5 );
|
||||||
|
|
||||||
|
@ -202,7 +202,7 @@ DIALOG_COLOR_PICKER_BASE::DIALOG_COLOR_PICKER_BASE( wxWindow* parent, wxWindowID
|
||||||
m_colorValue = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
m_colorValue = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
||||||
m_colorValue->SetMinSize( wxSize( 176,-1 ) );
|
m_colorValue->SetMinSize( wxSize( 176,-1 ) );
|
||||||
|
|
||||||
bButtonsSizer->Add( m_colorValue, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
|
bButtonsSizer->Add( m_colorValue, 0, wxALIGN_CENTER_VERTICAL, 5 );
|
||||||
|
|
||||||
|
|
||||||
bButtonsSizer->Add( 20, 0, 0, wxEXPAND, 5 );
|
bButtonsSizer->Add( 20, 0, 0, wxEXPAND, 5 );
|
||||||
|
|
|
@ -1212,21 +1212,21 @@
|
||||||
<property name="orient">wxVERTICAL</property>
|
<property name="orient">wxVERTICAL</property>
|
||||||
<property name="permission">protected</property>
|
<property name="permission">protected</property>
|
||||||
<object class="sizeritem" expanded="1">
|
<object class="sizeritem" expanded="1">
|
||||||
<property name="border">5</property>
|
<property name="border">10</property>
|
||||||
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL|wxTOP|wxBOTTOM</property>
|
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL|wxALL|wxEXPAND</property>
|
||||||
<property name="proportion">0</property>
|
<property name="proportion">1</property>
|
||||||
<object class="wxFlexGridSizer" expanded="1">
|
<object class="wxFlexGridSizer" expanded="1">
|
||||||
<property name="cols">10</property>
|
<property name="cols">10</property>
|
||||||
<property name="flexible_direction">wxBOTH</property>
|
<property name="flexible_direction">wxBOTH</property>
|
||||||
<property name="growablecols">1,3,5,7,9</property>
|
<property name="growablecols">1,3,5,7,9</property>
|
||||||
<property name="growablerows"></property>
|
<property name="growablerows"></property>
|
||||||
<property name="hgap">0</property>
|
<property name="hgap">5</property>
|
||||||
<property name="minimum_size"></property>
|
<property name="minimum_size"></property>
|
||||||
<property name="name">m_fgridColor</property>
|
<property name="name">m_fgridColor</property>
|
||||||
<property name="non_flexible_grow_mode">wxFLEX_GROWMODE_SPECIFIED</property>
|
<property name="non_flexible_grow_mode">wxFLEX_GROWMODE_SPECIFIED</property>
|
||||||
<property name="permission">protected</property>
|
<property name="permission">protected</property>
|
||||||
<property name="rows">0</property>
|
<property name="rows">0</property>
|
||||||
<property name="vgap">0</property>
|
<property name="vgap">25</property>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
|
@ -1463,7 +1463,7 @@
|
||||||
<property name="permission">none</property>
|
<property name="permission">none</property>
|
||||||
<object class="sizeritem" expanded="1">
|
<object class="sizeritem" expanded="1">
|
||||||
<property name="border">5</property>
|
<property name="border">5</property>
|
||||||
<property name="flag">wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT</property>
|
<property name="flag">wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT</property>
|
||||||
<property name="proportion">0</property>
|
<property name="proportion">0</property>
|
||||||
<object class="wxStaticText" expanded="1">
|
<object class="wxStaticText" expanded="1">
|
||||||
<property name="BottomDockable">1</property>
|
<property name="BottomDockable">1</property>
|
||||||
|
@ -1560,7 +1560,7 @@
|
||||||
<property name="maximum_size"></property>
|
<property name="maximum_size"></property>
|
||||||
<property name="min_size"></property>
|
<property name="min_size"></property>
|
||||||
<property name="minimize_button">0</property>
|
<property name="minimize_button">0</property>
|
||||||
<property name="minimum_size">30,22</property>
|
<property name="minimum_size">24,24</property>
|
||||||
<property name="moveable">1</property>
|
<property name="moveable">1</property>
|
||||||
<property name="name">m_OldColorRect</property>
|
<property name="name">m_OldColorRect</property>
|
||||||
<property name="pane_border">1</property>
|
<property name="pane_border">1</property>
|
||||||
|
@ -1618,7 +1618,7 @@
|
||||||
<property name="maximum_size"></property>
|
<property name="maximum_size"></property>
|
||||||
<property name="min_size"></property>
|
<property name="min_size"></property>
|
||||||
<property name="minimize_button">0</property>
|
<property name="minimize_button">0</property>
|
||||||
<property name="minimum_size">30,22</property>
|
<property name="minimum_size">24,24</property>
|
||||||
<property name="moveable">1</property>
|
<property name="moveable">1</property>
|
||||||
<property name="name">m_NewColorRect</property>
|
<property name="name">m_NewColorRect</property>
|
||||||
<property name="pane_border">1</property>
|
<property name="pane_border">1</property>
|
||||||
|
@ -1650,7 +1650,7 @@
|
||||||
</object>
|
</object>
|
||||||
<object class="sizeritem" expanded="1">
|
<object class="sizeritem" expanded="1">
|
||||||
<property name="border">5</property>
|
<property name="border">5</property>
|
||||||
<property name="flag">wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT</property>
|
<property name="flag">wxALIGN_CENTER_VERTICAL</property>
|
||||||
<property name="proportion">0</property>
|
<property name="proportion">0</property>
|
||||||
<object class="wxTextCtrl" expanded="1">
|
<object class="wxTextCtrl" expanded="1">
|
||||||
<property name="BottomDockable">1</property>
|
<property name="BottomDockable">1</property>
|
||||||
|
|
|
@ -215,7 +215,7 @@ void PANEL_COLOR_SETTINGS::createSwatch( int aLayer, const wxString& aName )
|
||||||
COLOR4D backgroundColor = m_currentSettings->GetColor( m_backgroundLayer );
|
COLOR4D backgroundColor = m_currentSettings->GetColor( m_backgroundLayer );
|
||||||
|
|
||||||
COLOR_SWATCH* swatch = new COLOR_SWATCH( m_colorsListWindow, color, id, backgroundColor,
|
COLOR_SWATCH* swatch = new COLOR_SWATCH( m_colorsListWindow, color, id, backgroundColor,
|
||||||
defaultColor, true );
|
defaultColor, SWATCH_MEDIUM );
|
||||||
swatch->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) );
|
swatch->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) );
|
||||||
|
|
||||||
m_colorsGridSizer->Add( label, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxLEFT, 5 );
|
m_colorsGridSizer->Add( label, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxLEFT, 5 );
|
||||||
|
|
|
@ -36,6 +36,7 @@ APP_SETTINGS_BASE::APP_SETTINGS_BASE( const std::string& aFilename, int aSchemaV
|
||||||
m_CrossProbing(),
|
m_CrossProbing(),
|
||||||
m_FindReplace(),
|
m_FindReplace(),
|
||||||
m_Graphics(),
|
m_Graphics(),
|
||||||
|
m_ColorPicker(),
|
||||||
m_LibTree(),
|
m_LibTree(),
|
||||||
m_Printing(),
|
m_Printing(),
|
||||||
m_System(),
|
m_System(),
|
||||||
|
@ -63,58 +64,66 @@ APP_SETTINGS_BASE::APP_SETTINGS_BASE( const std::string& aFilename, int aSchemaV
|
||||||
|
|
||||||
#ifdef __WXMAC__
|
#ifdef __WXMAC__
|
||||||
// Cairo renderer doesn't handle Retina displays so default to OpenGL
|
// Cairo renderer doesn't handle Retina displays so default to OpenGL
|
||||||
m_params.emplace_back( new PARAM<int>( "graphics.canvas_type", &m_Graphics.canvas_type,
|
m_params.emplace_back( new PARAM<int>( "graphics.canvas_type",
|
||||||
EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL ) );
|
&m_Graphics.canvas_type, EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL ) );
|
||||||
#else
|
#else
|
||||||
m_params.emplace_back( new PARAM<int>( "graphics.canvas_type", &m_Graphics.canvas_type,
|
m_params.emplace_back( new PARAM<int>( "graphics.canvas_type",
|
||||||
EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO ) );
|
&m_Graphics.canvas_type, EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO ) );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_params.emplace_back(
|
m_params.emplace_back( new PARAM<int>( "color_picker.default_tab",
|
||||||
new PARAM<int>( "lib_tree.column_width", &m_LibTree.column_width, 360 ) );
|
&m_ColorPicker.default_tab, 0 ) );
|
||||||
|
|
||||||
m_params.emplace_back(
|
m_params.emplace_back( new PARAM<int>( "lib_tree.column_width",
|
||||||
new PARAM<bool>( "printing.background", &m_Printing.background, false ) );
|
&m_LibTree.column_width, 360 ) );
|
||||||
|
|
||||||
m_params.emplace_back( new PARAM<bool>( "printing.monochrome", &m_Printing.monochrome, true ) );
|
m_params.emplace_back( new PARAM<bool>( "printing.background",
|
||||||
|
&m_Printing.background, false ) );
|
||||||
|
|
||||||
m_params.emplace_back( new PARAM<double>( "printing.scale", &m_Printing.scale, 1.0 ) );
|
m_params.emplace_back( new PARAM<bool>( "printing.monochrome",
|
||||||
|
&m_Printing.monochrome, true ) );
|
||||||
|
|
||||||
m_params.emplace_back(
|
m_params.emplace_back( new PARAM<double>( "printing.scale",
|
||||||
new PARAM<bool>( "printing.use_theme", &m_Printing.use_theme, false ) );
|
&m_Printing.scale, 1.0 ) );
|
||||||
|
|
||||||
m_params.emplace_back(
|
m_params.emplace_back( new PARAM<bool>( "printing.use_theme",
|
||||||
new PARAM<wxString>( "printing.color_theme", &m_Printing.color_theme, "" ) );
|
&m_Printing.use_theme, false ) );
|
||||||
|
|
||||||
|
m_params.emplace_back( new PARAM<wxString>( "printing.color_theme",
|
||||||
|
&m_Printing.color_theme, "" ) );
|
||||||
|
|
||||||
m_params.emplace_back( new PARAM<bool>( "printing.title_block",
|
m_params.emplace_back( new PARAM<bool>( "printing.title_block",
|
||||||
&m_Printing.title_block, false ) );
|
&m_Printing.title_block, false ) );
|
||||||
|
|
||||||
m_params.emplace_back( new PARAM_LIST<int>( "printing.layers", &m_Printing.layers, {} ) );
|
m_params.emplace_back( new PARAM_LIST<int>( "printing.layers",
|
||||||
|
&m_Printing.layers, {} ) );
|
||||||
|
|
||||||
m_params.emplace_back( new PARAM<bool>( "system.first_run_shown",
|
m_params.emplace_back( new PARAM<bool>( "system.first_run_shown",
|
||||||
&m_System.first_run_shown, false ) );
|
&m_System.first_run_shown, false ) );
|
||||||
|
|
||||||
m_params.emplace_back( new PARAM<int>( "system.max_undo_items", &m_System.max_undo_items, 0 ) );
|
m_params.emplace_back( new PARAM<int>( "system.max_undo_items",
|
||||||
|
&m_System.max_undo_items, 0 ) );
|
||||||
|
|
||||||
|
|
||||||
m_params.emplace_back( new PARAM_LIST<wxString>( "system.file_history",
|
m_params.emplace_back( new PARAM_LIST<wxString>( "system.file_history",
|
||||||
&m_System.file_history, {} ) );
|
&m_System.file_history, {} ) );
|
||||||
|
|
||||||
m_params.emplace_back( new PARAM<int>( "system.units", &m_System.units,
|
m_params.emplace_back( new PARAM<int>( "system.units",
|
||||||
static_cast<int>( EDA_UNITS::MILLIMETRES ) ) );
|
&m_System.units, static_cast<int>( EDA_UNITS::MILLIMETRES ) ) );
|
||||||
|
|
||||||
m_params.emplace_back( new PARAM<wxString>( "appearance.color_theme", &m_ColorTheme, "user" ) );
|
m_params.emplace_back( new PARAM<wxString>( "appearance.color_theme",
|
||||||
|
&m_ColorTheme, "user" ) );
|
||||||
|
|
||||||
addParamsForWindow( &m_Window, "window" );
|
addParamsForWindow( &m_Window, "window" );
|
||||||
|
|
||||||
m_params.emplace_back( new PARAM<bool>(
|
m_params.emplace_back( new PARAM<bool>( "cross_probing.center_on_items",
|
||||||
"cross_probing.center_on_items", &m_CrossProbing.center_on_items, true ) );
|
&m_CrossProbing.center_on_items, true ) );
|
||||||
|
|
||||||
m_params.emplace_back(
|
m_params.emplace_back( new PARAM<bool>( "cross_probing.zoom_to_fit",
|
||||||
new PARAM<bool>( "cross_probing.zoom_to_fit", &m_CrossProbing.zoom_to_fit, true ) );
|
&m_CrossProbing.zoom_to_fit, true ) );
|
||||||
|
|
||||||
m_params.emplace_back( new PARAM<bool>(
|
m_params.emplace_back( new PARAM<bool>( "cross_probing.auto_highlight",
|
||||||
"cross_probing.auto_highlight", &m_CrossProbing.auto_highlight, true ) );
|
&m_CrossProbing.auto_highlight, true ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -31,9 +31,6 @@ wxDEFINE_EVENT(COLOR_SWATCH_CHANGED, wxCommandEvent);
|
||||||
using KIGFX::COLOR4D;
|
using KIGFX::COLOR4D;
|
||||||
|
|
||||||
|
|
||||||
const static wxSize PALETTE_SWATCH_SIZE_DU( 8, 6 );
|
|
||||||
const static wxSize DIALOG_SWATCH_SIZE_DU( 24, 10 );
|
|
||||||
|
|
||||||
// See selcolor.cpp:
|
// See selcolor.cpp:
|
||||||
extern COLOR4D DisplayColorFrame( wxWindow* aParent, COLOR4D aOldColor );
|
extern COLOR4D DisplayColorFrame( wxWindow* aParent, COLOR4D aOldColor );
|
||||||
|
|
||||||
|
@ -43,49 +40,83 @@ extern COLOR4D DisplayColorFrame( wxWindow* aParent, COLOR4D aOldColor );
|
||||||
*
|
*
|
||||||
* @param aWindow - window used as context for device-independent size
|
* @param aWindow - window used as context for device-independent size
|
||||||
*/
|
*/
|
||||||
wxBitmap COLOR_SWATCH::MakeBitmap( COLOR4D aColor, COLOR4D aBackground, wxSize aSize )
|
wxBitmap COLOR_SWATCH::MakeBitmap( COLOR4D aColor, COLOR4D aBackground, wxSize aSize,
|
||||||
|
wxSize aCheckerboardSize )
|
||||||
{
|
{
|
||||||
wxBitmap bitmap( aSize );
|
wxBitmap bitmap( aSize );
|
||||||
wxBrush brush;
|
wxBrush brush;
|
||||||
|
wxPen pen;
|
||||||
wxMemoryDC iconDC;
|
wxMemoryDC iconDC;
|
||||||
|
|
||||||
iconDC.SelectObject( bitmap );
|
iconDC.SelectObject( bitmap );
|
||||||
|
|
||||||
brush.SetStyle( wxBRUSHSTYLE_SOLID );
|
brush.SetStyle( wxBRUSHSTYLE_SOLID );
|
||||||
brush.SetColour( aBackground.WithAlpha(1.0).ToColour() );
|
|
||||||
iconDC.SetBrush( brush );
|
|
||||||
iconDC.DrawRectangle( 0, 0, aSize.x, aSize.y );
|
|
||||||
|
|
||||||
if( aColor == COLOR4D::UNSPECIFIED )
|
if( aColor == COLOR4D::UNSPECIFIED )
|
||||||
{
|
{
|
||||||
aColor = aBackground.Inverted();
|
bool rowCycle = true;
|
||||||
brush.SetStyle( wxBRUSHSTYLE_BDIAGONAL_HATCH );
|
|
||||||
|
for( int x = 0; x < aSize.x; x += aCheckerboardSize.x )
|
||||||
|
{
|
||||||
|
bool colCycle = rowCycle;
|
||||||
|
|
||||||
|
for( int y = 0; y < aSize.y; y += aCheckerboardSize.y )
|
||||||
|
{
|
||||||
|
COLOR4D color = colCycle ? COLOR4D( LIGHTGRAY ) : COLOR4D( WHITE );
|
||||||
|
brush.SetColour( color.ToColour() );
|
||||||
|
pen.SetColour( color.ToColour() );
|
||||||
|
|
||||||
|
iconDC.SetBrush( brush );
|
||||||
|
iconDC.SetPen( pen );
|
||||||
|
iconDC.DrawRectangle( x, y, x + aCheckerboardSize.x, y + aCheckerboardSize.y );
|
||||||
|
|
||||||
|
colCycle = !colCycle;
|
||||||
}
|
}
|
||||||
|
|
||||||
brush.SetColour( aColor.ToColour() );
|
rowCycle = !rowCycle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
brush.SetColour( aBackground.WithAlpha(1.0).ToColour() );
|
||||||
|
pen.SetColour( aBackground.WithAlpha(1.0).ToColour() );
|
||||||
|
|
||||||
iconDC.SetBrush( brush );
|
iconDC.SetBrush( brush );
|
||||||
|
iconDC.SetPen( pen );
|
||||||
iconDC.DrawRectangle( 0, 0, aSize.x, aSize.y );
|
iconDC.DrawRectangle( 0, 0, aSize.x, aSize.y );
|
||||||
|
|
||||||
|
brush.SetColour( aColor.ToColour() );
|
||||||
|
pen.SetColour( aColor.ToColour() );
|
||||||
|
|
||||||
|
iconDC.SetBrush( brush );
|
||||||
|
iconDC.SetPen( pen );
|
||||||
|
iconDC.DrawRectangle( 0, 0, aSize.x, aSize.y );
|
||||||
|
}
|
||||||
|
|
||||||
return bitmap;
|
return bitmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
COLOR_SWATCH::COLOR_SWATCH( wxWindow* aParent, COLOR4D aColor, int aID, COLOR4D aBackground,
|
COLOR_SWATCH::COLOR_SWATCH( wxWindow* aParent, COLOR4D aColor, int aID, COLOR4D aBackground,
|
||||||
const COLOR4D aDefault, bool aForDialog ) :
|
const COLOR4D aDefault, SWATCH_SIZE aSwatchSize ) :
|
||||||
wxPanel( aParent, aID ),
|
wxPanel( aParent, aID ),
|
||||||
m_color( aColor ),
|
m_color( aColor ),
|
||||||
m_background( aBackground ),
|
m_background( aBackground ),
|
||||||
m_default( aDefault )
|
m_default( aDefault )
|
||||||
{
|
{
|
||||||
if( aForDialog )
|
switch( aSwatchSize )
|
||||||
m_size = ConvertDialogToPixels( DIALOG_SWATCH_SIZE_DU );
|
{
|
||||||
else
|
case SWATCH_MEDIUM: m_size = ConvertDialogToPixels( SWATCH_SIZE_MEDIUM_DU ); break;
|
||||||
m_size = ConvertDialogToPixels( PALETTE_SWATCH_SIZE_DU );
|
case SWATCH_SMALL: m_size = ConvertDialogToPixels( SWATCH_SIZE_SMALL_DU ); break;
|
||||||
|
case SWATCH_LARGE: m_size = ConvertDialogToPixels( SWATCH_SIZE_LARGE_DU ); break;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_checkerboardSize = ConvertDialogToPixels( CHECKERBOARD_SIZE_DU );
|
||||||
|
|
||||||
auto sizer = new wxBoxSizer( wxHORIZONTAL );
|
auto sizer = new wxBoxSizer( wxHORIZONTAL );
|
||||||
SetSizer( sizer );
|
SetSizer( sizer );
|
||||||
|
|
||||||
wxBitmap bitmap = COLOR_SWATCH::MakeBitmap( aColor, aBackground, m_size );
|
wxBitmap bitmap = COLOR_SWATCH::MakeBitmap( aColor, aBackground, m_size,
|
||||||
|
m_checkerboardSize );
|
||||||
m_swatch = new wxStaticBitmap( this, aID, bitmap );
|
m_swatch = new wxStaticBitmap( this, aID, bitmap );
|
||||||
|
|
||||||
sizer->Add( m_swatch, 0, 0 );
|
sizer->Add( m_swatch, 0, 0 );
|
||||||
|
@ -99,17 +130,19 @@ COLOR_SWATCH::COLOR_SWATCH( wxWindow *aParent, wxWindowID aID, const wxPoint &aP
|
||||||
wxPanel( aParent, aID, aPos, aSize, aStyle )
|
wxPanel( aParent, aID, aPos, aSize, aStyle )
|
||||||
{
|
{
|
||||||
if( aSize == wxDefaultSize )
|
if( aSize == wxDefaultSize )
|
||||||
m_size = ConvertDialogToPixels( DIALOG_SWATCH_SIZE_DU );
|
m_size = ConvertDialogToPixels( SWATCH_SIZE_MEDIUM_DU );
|
||||||
else
|
else
|
||||||
m_size = aSize;
|
m_size = aSize;
|
||||||
|
|
||||||
|
m_checkerboardSize = ConvertDialogToPixels( CHECKERBOARD_SIZE_DU );
|
||||||
|
|
||||||
SetSize( m_size );
|
SetSize( m_size );
|
||||||
|
|
||||||
auto sizer = new wxBoxSizer( wxHORIZONTAL );
|
auto sizer = new wxBoxSizer( wxHORIZONTAL );
|
||||||
SetSizer( sizer );
|
SetSizer( sizer );
|
||||||
|
|
||||||
wxBitmap bitmap = COLOR_SWATCH::MakeBitmap( KIGFX::COLOR4D::UNSPECIFIED,
|
wxBitmap bitmap = COLOR_SWATCH::MakeBitmap( COLOR4D::UNSPECIFIED, COLOR4D::UNSPECIFIED,
|
||||||
KIGFX::COLOR4D::UNSPECIFIED, m_size );
|
m_size, m_checkerboardSize );
|
||||||
m_swatch = new wxStaticBitmap( this, aID, bitmap );
|
m_swatch = new wxStaticBitmap( this, aID, bitmap );
|
||||||
|
|
||||||
sizer->Add( m_swatch, 0, 0 );
|
sizer->Add( m_swatch, 0, 0 );
|
||||||
|
@ -178,8 +211,7 @@ void COLOR_SWATCH::SetSwatchColor( COLOR4D aColor, bool sendEvent )
|
||||||
{
|
{
|
||||||
m_color = aColor;
|
m_color = aColor;
|
||||||
|
|
||||||
wxBitmap bm = MakeBitmap( m_color == COLOR4D::UNSPECIFIED ? m_default : m_color,
|
wxBitmap bm = MakeBitmap( m_color, m_background, m_size, m_checkerboardSize );
|
||||||
m_background, m_size );
|
|
||||||
m_swatch->SetBitmap( bm );
|
m_swatch->SetBitmap( bm );
|
||||||
|
|
||||||
if( sendEvent )
|
if( sendEvent )
|
||||||
|
@ -196,7 +228,7 @@ void COLOR_SWATCH::SetDefaultColor( COLOR4D aColor )
|
||||||
void COLOR_SWATCH::SetSwatchBackground( COLOR4D aBackground )
|
void COLOR_SWATCH::SetSwatchBackground( COLOR4D aBackground )
|
||||||
{
|
{
|
||||||
m_background = aBackground;
|
m_background = aBackground;
|
||||||
wxBitmap bm = MakeBitmap( m_color, m_background, m_size );
|
wxBitmap bm = MakeBitmap( m_color, m_background, m_size, m_checkerboardSize );
|
||||||
m_swatch->SetBitmap( bm );
|
m_swatch->SetBitmap( bm );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,7 +253,7 @@ void COLOR_SWATCH::GetNewSwatchColor()
|
||||||
{
|
{
|
||||||
m_color = newColor;
|
m_color = newColor;
|
||||||
|
|
||||||
wxBitmap bm = MakeBitmap( newColor, m_background, m_size );
|
wxBitmap bm = MakeBitmap( newColor, m_background, m_size, m_checkerboardSize );
|
||||||
m_swatch->SetBitmap( bm );
|
m_swatch->SetBitmap( bm );
|
||||||
|
|
||||||
sendSwatchChangeEvent( *this );
|
sendSwatchChangeEvent( *this );
|
||||||
|
|
|
@ -108,6 +108,11 @@ public:
|
||||||
int canvas_type;
|
int canvas_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct COLOR_PICKER
|
||||||
|
{
|
||||||
|
int default_tab;
|
||||||
|
};
|
||||||
|
|
||||||
struct LIB_TREE
|
struct LIB_TREE
|
||||||
{
|
{
|
||||||
int column_width;
|
int column_width;
|
||||||
|
@ -145,6 +150,8 @@ public:
|
||||||
|
|
||||||
GRAPHICS m_Graphics;
|
GRAPHICS m_Graphics;
|
||||||
|
|
||||||
|
COLOR_PICKER m_ColorPicker;
|
||||||
|
|
||||||
LIB_TREE m_LibTree;
|
LIB_TREE m_LibTree;
|
||||||
|
|
||||||
PRINTING m_Printing;
|
PRINTING m_Printing;
|
||||||
|
|
|
@ -31,6 +31,20 @@
|
||||||
#include <gal/color4d.h>
|
#include <gal/color4d.h>
|
||||||
|
|
||||||
|
|
||||||
|
enum SWATCH_SIZE
|
||||||
|
{
|
||||||
|
SWATCH_SMALL,
|
||||||
|
SWATCH_MEDIUM,
|
||||||
|
SWATCH_LARGE
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const static wxSize SWATCH_SIZE_SMALL_DU( 8, 6 );
|
||||||
|
const static wxSize SWATCH_SIZE_MEDIUM_DU( 24, 10 );
|
||||||
|
const static wxSize SWATCH_SIZE_LARGE_DU( 24, 16 );
|
||||||
|
const static wxSize CHECKERBOARD_SIZE_DU( 3, 3 );
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class representing a simple color swatch, of the kind used to
|
* Class representing a simple color swatch, of the kind used to
|
||||||
* set layer colors
|
* set layer colors
|
||||||
|
@ -47,7 +61,7 @@ public:
|
||||||
* @param aID id to use when sending swatch events
|
* @param aID id to use when sending swatch events
|
||||||
*/
|
*/
|
||||||
COLOR_SWATCH( wxWindow* aParent, KIGFX::COLOR4D aColor, int aID, KIGFX::COLOR4D aBackground,
|
COLOR_SWATCH( wxWindow* aParent, KIGFX::COLOR4D aColor, int aID, KIGFX::COLOR4D aBackground,
|
||||||
const KIGFX::COLOR4D aDefault, bool aForDialog );
|
const KIGFX::COLOR4D aDefault, SWATCH_SIZE aSwatchType );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* constructor for wxFormBuilder
|
* constructor for wxFormBuilder
|
||||||
|
@ -82,7 +96,8 @@ public:
|
||||||
*/
|
*/
|
||||||
void GetNewSwatchColor();
|
void GetNewSwatchColor();
|
||||||
|
|
||||||
static wxBitmap MakeBitmap( KIGFX::COLOR4D aColor, KIGFX::COLOR4D aBackground, wxSize aSize );
|
static wxBitmap MakeBitmap( KIGFX::COLOR4D aColor, KIGFX::COLOR4D aBackground, wxSize aSize,
|
||||||
|
wxSize aCheckerboardSize );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupEvents();
|
void setupEvents();
|
||||||
|
@ -92,19 +107,14 @@ private:
|
||||||
*/
|
*/
|
||||||
void rePostEvent( wxEvent& aEvt );
|
void rePostEvent( wxEvent& aEvt );
|
||||||
|
|
||||||
///> The current colour of the swatch
|
|
||||||
KIGFX::COLOR4D m_color;
|
KIGFX::COLOR4D m_color;
|
||||||
|
|
||||||
///> The background colour to show the swatch over
|
|
||||||
KIGFX::COLOR4D m_background;
|
KIGFX::COLOR4D m_background;
|
||||||
|
|
||||||
///> The default color for the swatch
|
|
||||||
KIGFX::COLOR4D m_default;
|
KIGFX::COLOR4D m_default;
|
||||||
|
|
||||||
///> Handle of the actual swatch shown
|
|
||||||
wxStaticBitmap* m_swatch;
|
wxStaticBitmap* m_swatch;
|
||||||
|
|
||||||
wxSize m_size;
|
wxSize m_size;
|
||||||
|
wxSize m_checkerboardSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -331,7 +331,7 @@ void LAYER_WIDGET::insertLayerRow( int aRow, const ROW& aSpec )
|
||||||
col = COLUMN_COLORBM;
|
col = COLUMN_COLORBM;
|
||||||
|
|
||||||
auto bmb = new COLOR_SWATCH( m_LayerScrolledWindow, aSpec.color, encodeId( col, aSpec.id ),
|
auto bmb = new COLOR_SWATCH( m_LayerScrolledWindow, aSpec.color, encodeId( col, aSpec.id ),
|
||||||
getBackgroundLayerColor(), aSpec.defaultColor, false );
|
getBackgroundLayerColor(), aSpec.defaultColor, SWATCH_SMALL );
|
||||||
bmb->Bind( wxEVT_LEFT_DOWN, &LAYER_WIDGET::OnLeftDownLayers, this );
|
bmb->Bind( wxEVT_LEFT_DOWN, &LAYER_WIDGET::OnLeftDownLayers, this );
|
||||||
bmb->Bind( COLOR_SWATCH_CHANGED, &LAYER_WIDGET::OnLayerSwatchChanged, this );
|
bmb->Bind( COLOR_SWATCH_CHANGED, &LAYER_WIDGET::OnLayerSwatchChanged, this );
|
||||||
bmb->SetToolTip( _("Left double click or middle click for color change, right click for menu" ) );
|
bmb->SetToolTip( _("Left double click or middle click for color change, right click for menu" ) );
|
||||||
|
@ -431,7 +431,7 @@ void LAYER_WIDGET::insertRenderRow( int aRow, const ROW& aSpec )
|
||||||
if( aSpec.color != COLOR4D::UNSPECIFIED )
|
if( aSpec.color != COLOR4D::UNSPECIFIED )
|
||||||
{
|
{
|
||||||
auto bmb = new COLOR_SWATCH( m_RenderScrolledWindow, aSpec.color, encodeId( col, aSpec.id ),
|
auto bmb = new COLOR_SWATCH( m_RenderScrolledWindow, aSpec.color, encodeId( col, aSpec.id ),
|
||||||
getBackgroundLayerColor(), aSpec.defaultColor, false );
|
getBackgroundLayerColor(), aSpec.defaultColor, SWATCH_SMALL );
|
||||||
bmb->Bind( COLOR_SWATCH_CHANGED, &LAYER_WIDGET::OnRenderSwatchChanged, this );
|
bmb->Bind( COLOR_SWATCH_CHANGED, &LAYER_WIDGET::OnRenderSwatchChanged, this );
|
||||||
bmb->SetToolTip( _( "Left double click or middle click for color change" ) );
|
bmb->SetToolTip( _( "Left double click or middle click for color change" ) );
|
||||||
m_RenderFlexGridSizer->wxSizer::Insert( index+col, bmb, 0, flags );
|
m_RenderFlexGridSizer->wxSizer::Insert( index+col, bmb, 0, flags );
|
||||||
|
|
|
@ -530,7 +530,8 @@ void APPEARANCE_CONTROLS::rebuildLayers()
|
||||||
ROW_ICON_PROVIDER::STATE::OFF, layer );
|
ROW_ICON_PROVIDER::STATE::OFF, layer );
|
||||||
|
|
||||||
COLOR_SWATCH* swatch = new COLOR_SWATCH( panel, COLOR4D::UNSPECIFIED, layer,
|
COLOR_SWATCH* swatch = new COLOR_SWATCH( panel, COLOR4D::UNSPECIFIED, layer,
|
||||||
bgColor, theme->GetColor( layer ), false );
|
bgColor, theme->GetColor( layer ),
|
||||||
|
SWATCH_SMALL );
|
||||||
swatch->SetToolTip( _( "Left double click or middle click for color change, "
|
swatch->SetToolTip( _( "Left double click or middle click for color change, "
|
||||||
"right click for menu" ) );
|
"right click for menu" ) );
|
||||||
|
|
||||||
|
@ -989,7 +990,7 @@ void APPEARANCE_CONTROLS::rebuildObjects()
|
||||||
if( color != COLOR4D::UNSPECIFIED )
|
if( color != COLOR4D::UNSPECIFIED )
|
||||||
{
|
{
|
||||||
COLOR_SWATCH* swatch = new COLOR_SWATCH( m_windowObjects, color, layer,
|
COLOR_SWATCH* swatch = new COLOR_SWATCH( m_windowObjects, color, layer,
|
||||||
bgColor, defColor, false );
|
bgColor, defColor, SWATCH_SMALL );
|
||||||
swatch->SetToolTip( _( "Left double click or middle click for color change, "
|
swatch->SetToolTip( _( "Left double click or middle click for color change, "
|
||||||
"right click for menu" ) );
|
"right click for menu" ) );
|
||||||
|
|
||||||
|
@ -1195,13 +1196,10 @@ void APPEARANCE_CONTROLS::rebuildNets()
|
||||||
COLOR4D::UNSPECIFIED;
|
COLOR4D::UNSPECIFIED;
|
||||||
|
|
||||||
setting->ctl_color = new COLOR_SWATCH( setting->ctl_panel, color, id, bgColor,
|
setting->ctl_color = new COLOR_SWATCH( setting->ctl_panel, color, id, bgColor,
|
||||||
COLOR4D::UNSPECIFIED, false );
|
COLOR4D::UNSPECIFIED, SWATCH_SMALL );
|
||||||
setting->ctl_color->SetToolTip( _( "Left double click or middle click for color "
|
setting->ctl_color->SetToolTip( _( "Left double click or middle click for color "
|
||||||
"change, right click for menu" ) );
|
"change, right click for menu" ) );
|
||||||
|
|
||||||
if( color == COLOR4D::UNSPECIFIED )
|
|
||||||
setting->ctl_color->Hide();
|
|
||||||
|
|
||||||
setting->ctl_color->Bind( COLOR_SWATCH_CHANGED,
|
setting->ctl_color->Bind( COLOR_SWATCH_CHANGED,
|
||||||
[&]( wxCommandEvent& aEvent )
|
[&]( wxCommandEvent& aEvent )
|
||||||
{
|
{
|
||||||
|
@ -1211,9 +1209,6 @@ void APPEARANCE_CONTROLS::rebuildNets()
|
||||||
|
|
||||||
netColors[net] = s->GetSwatchColor();
|
netColors[net] = s->GetSwatchColor();
|
||||||
|
|
||||||
if( s->GetSwatchColor() == COLOR4D::UNSPECIFIED )
|
|
||||||
s->Hide();
|
|
||||||
|
|
||||||
m_frame->GetCanvas()->GetView()->UpdateAllLayersColor();
|
m_frame->GetCanvas()->GetView()->UpdateAllLayersColor();
|
||||||
|
|
||||||
m_frame->GetCanvas()->RedrawRatsnest();
|
m_frame->GetCanvas()->RedrawRatsnest();
|
||||||
|
@ -1234,13 +1229,14 @@ void APPEARANCE_CONTROLS::rebuildNets()
|
||||||
aNet->GetShortNetname() );
|
aNet->GetShortNetname() );
|
||||||
setting->ctl_text->Wrap( -1 );
|
setting->ctl_text->Wrap( -1 );
|
||||||
|
|
||||||
int flags = wxALIGN_CENTER_VERTICAL | wxRIGHT;
|
sizer->Add( setting->ctl_color, 0, wxALIGN_CENTER_VERTICAL, 5 );
|
||||||
|
sizer->AddSpacer( 7 );
|
||||||
|
sizer->Add( setting->ctl_visibility, 0, wxALIGN_CENTER_VERTICAL, 5 );
|
||||||
|
sizer->AddSpacer( 3 );
|
||||||
|
sizer->Add( setting->ctl_text, 1, wxALIGN_CENTER_VERTICAL, 5 );
|
||||||
|
|
||||||
sizer->Add( setting->ctl_color, 0, flags | wxRESERVE_SPACE_EVEN_IF_HIDDEN, 5 );
|
m_netsOuterSizer->Add( setting->ctl_panel, 0, wxEXPAND, 5 );
|
||||||
sizer->Add( setting->ctl_visibility, 0, flags, 5 );
|
m_netsOuterSizer->AddSpacer( 1 );
|
||||||
sizer->Add( setting->ctl_text, 1, flags, 5 );
|
|
||||||
|
|
||||||
m_netsOuterSizer->Add( setting->ctl_panel, 0, wxEXPAND, 0 );
|
|
||||||
|
|
||||||
setting->ctl_visibility->Bind( TOGGLE_CHANGED,
|
setting->ctl_visibility->Bind( TOGGLE_CHANGED,
|
||||||
[&]( wxCommandEvent& aEvent )
|
[&]( wxCommandEvent& aEvent )
|
||||||
|
@ -1292,7 +1288,7 @@ void APPEARANCE_CONTROLS::rebuildNets()
|
||||||
};
|
};
|
||||||
|
|
||||||
auto appendNetclass =
|
auto appendNetclass =
|
||||||
[&]( int aId, const NETCLASSPTR& aClass, bool isDefault = false )
|
[&]( int aId, const NETCLASSPTR& aClass )
|
||||||
{
|
{
|
||||||
wxString name = aClass->GetName();
|
wxString name = aClass->GetName();
|
||||||
|
|
||||||
|
@ -1307,14 +1303,10 @@ void APPEARANCE_CONTROLS::rebuildNets()
|
||||||
COLOR4D::UNSPECIFIED;
|
COLOR4D::UNSPECIFIED;
|
||||||
|
|
||||||
setting->ctl_color = new COLOR_SWATCH( setting->ctl_panel, color, aId, bgColor,
|
setting->ctl_color = new COLOR_SWATCH( setting->ctl_panel, color, aId, bgColor,
|
||||||
COLOR4D::UNSPECIFIED, false );
|
COLOR4D::UNSPECIFIED, SWATCH_SMALL );
|
||||||
setting->ctl_color->SetToolTip( _( "Left double click or middle click for color "
|
setting->ctl_color->SetToolTip( _( "Left double click or middle click for color "
|
||||||
"change, right click for menu" ) );
|
"change, right click for menu" ) );
|
||||||
|
|
||||||
if( !isDefault || color == COLOR4D::UNSPECIFIED )
|
|
||||||
setting->ctl_color->Hide();
|
|
||||||
|
|
||||||
if( !isDefault )
|
|
||||||
setting->ctl_color->Bind( COLOR_SWATCH_CHANGED,
|
setting->ctl_color->Bind( COLOR_SWATCH_CHANGED,
|
||||||
&APPEARANCE_CONTROLS::onNetclassColorChanged, this );
|
&APPEARANCE_CONTROLS::onNetclassColorChanged, this );
|
||||||
|
|
||||||
|
@ -1329,31 +1321,29 @@ void APPEARANCE_CONTROLS::rebuildNets()
|
||||||
setting->ctl_text = new wxStaticText( setting->ctl_panel, aId, name );
|
setting->ctl_text = new wxStaticText( setting->ctl_panel, aId, name );
|
||||||
setting->ctl_text->Wrap( -1 );
|
setting->ctl_text->Wrap( -1 );
|
||||||
|
|
||||||
int flags = wxALIGN_CENTER_VERTICAL | wxRIGHT;
|
sizer->Add( setting->ctl_color, 0, wxALIGN_CENTER_VERTICAL, 5 );
|
||||||
|
sizer->AddSpacer( 7 );
|
||||||
|
sizer->Add( setting->ctl_visibility, 0, wxALIGN_CENTER_VERTICAL, 5 );
|
||||||
|
sizer->AddSpacer( 3 );
|
||||||
|
sizer->Add( setting->ctl_text, 1, wxALIGN_CENTER_VERTICAL, 5 );
|
||||||
|
|
||||||
sizer->Add( setting->ctl_color, 0, flags | wxRESERVE_SPACE_EVEN_IF_HIDDEN, 5 );
|
m_netclassOuterSizer->Add( setting->ctl_panel, 0, wxEXPAND, 5 );
|
||||||
sizer->Add( setting->ctl_visibility, 0, flags, 5 );
|
m_netclassOuterSizer->AddSpacer( 1 );
|
||||||
sizer->Add( setting->ctl_text, 1, flags, 5 );
|
|
||||||
|
|
||||||
m_netclassOuterSizer->Add( setting->ctl_panel, 0, wxEXPAND, 0 );
|
|
||||||
|
|
||||||
setting->ctl_visibility->Bind( TOGGLE_CHANGED,
|
setting->ctl_visibility->Bind( TOGGLE_CHANGED,
|
||||||
&APPEARANCE_CONTROLS::onNetclassVisibilityChanged,
|
&APPEARANCE_CONTROLS::onNetclassVisibilityChanged,
|
||||||
this );
|
this );
|
||||||
|
|
||||||
auto menuHandler =
|
auto menuHandler =
|
||||||
[&, name, isDefault]( wxMouseEvent& aEvent )
|
[&, name]( wxMouseEvent& aEvent )
|
||||||
{
|
{
|
||||||
m_contextMenuNetclass = name;
|
m_contextMenuNetclass = name;
|
||||||
|
|
||||||
wxMenu menu;
|
wxMenu menu;
|
||||||
|
|
||||||
if( !isDefault )
|
|
||||||
{
|
|
||||||
menu.Append( new wxMenuItem( &menu, ID_SET_NET_COLOR,
|
menu.Append( new wxMenuItem( &menu, ID_SET_NET_COLOR,
|
||||||
_( "Set netclass color" ), wxEmptyString,
|
_( "Set netclass color" ), wxEmptyString,
|
||||||
wxITEM_NORMAL ) );
|
wxITEM_NORMAL ) );
|
||||||
}
|
|
||||||
|
|
||||||
menu.Append( new wxMenuItem( &menu, ID_HIGHLIGHT_NET,
|
menu.Append( new wxMenuItem( &menu, ID_HIGHLIGHT_NET,
|
||||||
wxString::Format( _( "Highlight nets in %s" ), name ),
|
wxString::Format( _( "Highlight nets in %s" ), name ),
|
||||||
|
@ -1378,10 +1368,7 @@ void APPEARANCE_CONTROLS::rebuildNets()
|
||||||
|
|
||||||
setting->ctl_panel->Bind( wxEVT_RIGHT_DOWN, menuHandler );
|
setting->ctl_panel->Bind( wxEVT_RIGHT_DOWN, menuHandler );
|
||||||
setting->ctl_visibility->Bind( wxEVT_RIGHT_DOWN, menuHandler );
|
setting->ctl_visibility->Bind( wxEVT_RIGHT_DOWN, menuHandler );
|
||||||
|
|
||||||
if( !isDefault )
|
|
||||||
setting->ctl_color->Bind( wxEVT_RIGHT_DOWN, menuHandler );
|
setting->ctl_color->Bind( wxEVT_RIGHT_DOWN, menuHandler );
|
||||||
|
|
||||||
setting->ctl_text->Bind( wxEVT_RIGHT_DOWN, menuHandler );
|
setting->ctl_text->Bind( wxEVT_RIGHT_DOWN, menuHandler );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1416,7 +1403,7 @@ void APPEARANCE_CONTROLS::rebuildNets()
|
||||||
NETCLASSPTR defaultClass = board->GetDesignSettings().GetNetClasses().GetDefault();
|
NETCLASSPTR defaultClass = board->GetDesignSettings().GetNetClasses().GetDefault();
|
||||||
|
|
||||||
m_netclassIdMap[idx] = defaultClass->GetName();
|
m_netclassIdMap[idx] = defaultClass->GetName();
|
||||||
appendNetclass( idx++, defaultClass, true );
|
appendNetclass( idx++, defaultClass );
|
||||||
|
|
||||||
for( const wxString& name : names )
|
for( const wxString& name : names )
|
||||||
{
|
{
|
||||||
|
|
|
@ -185,6 +185,8 @@ const static wxSize LAYER_BITMAP_SIZE( 28, 28 ); // wxCocoa impl unhappy if thi
|
||||||
const static wxSize LAYER_BITMAP_SIZE( 24, 16 );
|
const static wxSize LAYER_BITMAP_SIZE( 24, 16 );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
const static wxSize CHECKERBOARD_SIZE( 8, 8 );
|
||||||
|
|
||||||
|
|
||||||
// A helper for setting up a dialog list for specifying zone layers. Used by all three
|
// A helper for setting up a dialog list for specifying zone layers. Used by all three
|
||||||
// zone settings dialogs.
|
// zone settings dialogs.
|
||||||
|
@ -219,7 +221,8 @@ void ZONE_SETTINGS::SetupLayersList( wxDataViewListCtrl* aList, PCB_BASE_FRAME*
|
||||||
textWidth = std::max( textWidth, GetTextSize( layerName, aList ).x );
|
textWidth = std::max( textWidth, GetTextSize( layerName, aList ).x );
|
||||||
|
|
||||||
COLOR4D layerColor = aFrame->GetColorSettings()->GetColor( layerID );
|
COLOR4D layerColor = aFrame->GetColorSettings()->GetColor( layerID );
|
||||||
auto bitmap = COLOR_SWATCH::MakeBitmap( layerColor, backgroundColor, LAYER_BITMAP_SIZE );
|
auto bitmap = COLOR_SWATCH::MakeBitmap( layerColor, backgroundColor, LAYER_BITMAP_SIZE,
|
||||||
|
CHECKERBOARD_SIZE );
|
||||||
wxIcon icon;
|
wxIcon icon;
|
||||||
icon.CopyFromBitmap( bitmap );
|
icon.CopyFromBitmap( bitmap );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue