Add a new color selector, to adjust color selection for GAL mode, with support of opacity (alpha channel)
Pcbnew: save opacity value in color config, and keep it when switching between legacy and gal mode.
This commit is contained in:
parent
f509ccc7cf
commit
5f4599fb56
|
@ -166,6 +166,8 @@ set( COMMON_DLG_SRCS
|
||||||
|
|
||||||
set( COMMON_WIDGET_SRCS
|
set( COMMON_WIDGET_SRCS
|
||||||
widgets/color_swatch.cpp
|
widgets/color_swatch.cpp
|
||||||
|
widgets/color4Dpickerdlg_base.cpp
|
||||||
|
widgets/color4Dpickerdlg.cpp
|
||||||
widgets/gal_options_panel.cpp
|
widgets/gal_options_panel.cpp
|
||||||
widgets/mathplot.cpp
|
widgets/mathplot.cpp
|
||||||
widgets/widget_hotkey_list.cpp
|
widgets/widget_hotkey_list.cpp
|
||||||
|
|
|
@ -87,7 +87,10 @@ COLOR4D::COLOR4D( EDA_COLOR_T aColor )
|
||||||
candidate.r = ( (unsigned)( 255.0 * r ) | (unsigned)( 255.0 * aColor.r ) ) / 255.0,
|
candidate.r = ( (unsigned)( 255.0 * r ) | (unsigned)( 255.0 * aColor.r ) ) / 255.0,
|
||||||
candidate.g = ( (unsigned)( 255.0 * g ) | (unsigned)( 255.0 * aColor.g ) ) / 255.0,
|
candidate.g = ( (unsigned)( 255.0 * g ) | (unsigned)( 255.0 * aColor.g ) ) / 255.0,
|
||||||
candidate.b = ( (unsigned)( 255.0 * b ) | (unsigned)( 255.0 * aColor.b ) ) / 255.0,
|
candidate.b = ( (unsigned)( 255.0 * b ) | (unsigned)( 255.0 * aColor.b ) ) / 255.0,
|
||||||
candidate.a = 1.0;
|
|
||||||
|
// the alpha channel can be reinitialized
|
||||||
|
// but what is the best value?
|
||||||
|
candidate.a = ( aColor.a + a ) / 2;
|
||||||
|
|
||||||
return candidate;
|
return candidate;
|
||||||
}
|
}
|
||||||
|
@ -98,10 +101,12 @@ COLOR4D::COLOR4D( EDA_COLOR_T aColor )
|
||||||
EDA_COLOR_T legacyColor = GetNearestLegacyColor( *this );
|
EDA_COLOR_T legacyColor = GetNearestLegacyColor( *this );
|
||||||
EDA_COLOR_T highlightColor = g_ColorRefs[legacyColor].m_LightColor;
|
EDA_COLOR_T highlightColor = g_ColorRefs[legacyColor].m_LightColor;
|
||||||
|
|
||||||
|
// The alpha channel is not modified. Only R, G, B values are set,
|
||||||
|
// because legacy color does not know the alpha chanel.
|
||||||
|
|
||||||
r = g_ColorRefs[highlightColor].m_Red / 255.0;
|
r = g_ColorRefs[highlightColor].m_Red / 255.0;
|
||||||
g = g_ColorRefs[highlightColor].m_Green / 255.0;
|
g = g_ColorRefs[highlightColor].m_Green / 255.0;
|
||||||
b = g_ColorRefs[highlightColor].m_Blue / 255.0;
|
b = g_ColorRefs[highlightColor].m_Blue / 255.0;
|
||||||
a = 1.0;
|
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -111,10 +116,12 @@ COLOR4D::COLOR4D( EDA_COLOR_T aColor )
|
||||||
{
|
{
|
||||||
EDA_COLOR_T legacyColor = GetNearestLegacyColor( *this );
|
EDA_COLOR_T legacyColor = GetNearestLegacyColor( *this );
|
||||||
|
|
||||||
|
// The alpha channel is not modified. Only R, G, B values are set,
|
||||||
|
// because legacy color does not know the alpha chanel.
|
||||||
|
|
||||||
r = g_ColorRefs[legacyColor].m_Red / 255.0;
|
r = g_ColorRefs[legacyColor].m_Red / 255.0;
|
||||||
g = g_ColorRefs[legacyColor].m_Green / 255.0;
|
g = g_ColorRefs[legacyColor].m_Green / 255.0;
|
||||||
b = g_ColorRefs[legacyColor].m_Blue / 255.0;
|
b = g_ColorRefs[legacyColor].m_Blue / 255.0;
|
||||||
a = 1.0;
|
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,722 @@
|
||||||
|
/**
|
||||||
|
* @file color4Dpickerdlg.cpp :
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "math.h"
|
||||||
|
#include "color4Dpickerdlg.h"
|
||||||
|
|
||||||
|
#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_BASE( aParent )
|
||||||
|
{
|
||||||
|
m_previousColor4D = aCurrentColor;
|
||||||
|
m_newColor4D = aCurrentColor;
|
||||||
|
m_cursorsSize = 8; // Size of square cursors drawn on color bitmaps
|
||||||
|
m_newColor4D.ToHSV( m_hue, m_sat, m_val, true );
|
||||||
|
m_bitmapRGB = nullptr;
|
||||||
|
m_bitmapHSV = nullptr;
|
||||||
|
m_selectedCursor = nullptr;
|
||||||
|
m_notebook->SetSelection( m_ActivePage );
|
||||||
|
|
||||||
|
// Build the defined colors panel:
|
||||||
|
initDefinedColors();
|
||||||
|
|
||||||
|
m_sdbSizerOK->SetDefault();
|
||||||
|
|
||||||
|
FinishDialogSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
int COLOR4D_PICKER_DLG::m_ActivePage = 0; // the active notebook page, stored during a session
|
||||||
|
|
||||||
|
|
||||||
|
COLOR4D_PICKER_DLG::~COLOR4D_PICKER_DLG()
|
||||||
|
{
|
||||||
|
delete m_bitmapRGB;
|
||||||
|
delete m_bitmapHSV;
|
||||||
|
|
||||||
|
m_ActivePage = m_notebook->GetSelection();
|
||||||
|
|
||||||
|
for( auto button : m_buttonsColor )
|
||||||
|
button->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( COLOR4D_PICKER_DLG::buttColorClick ), NULL, this );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void COLOR4D_PICKER_DLG::setIconColor( wxStaticBitmap* aStaticBitmap, KIGFX::COLOR4D& aColor4D )
|
||||||
|
{
|
||||||
|
// Draw the icon that shows the aColor4D,
|
||||||
|
// with colors according to the color 4D rgb and alpha
|
||||||
|
// for alpha = 1 (no tranparency, the icon is a full rgb color rect
|
||||||
|
// 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 ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
aStaticBitmap->SetBitmap( newBm );
|
||||||
|
|
||||||
|
// Deselect the Tool Bitmap from DC, in order to delete the MemoryDC
|
||||||
|
// safely without deleting the bitmap
|
||||||
|
bitmapDC.SelectObject( wxNullBitmap );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool COLOR4D_PICKER_DLG::TransferDataToWindow()
|
||||||
|
{
|
||||||
|
// Draw all bitmaps, with colors according to the color 4D
|
||||||
|
setIconColor( m_OldColorRect, m_previousColor4D );
|
||||||
|
SetEditVals( ALL_CHANGED );
|
||||||
|
drawAll();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void COLOR4D_PICKER_DLG::initDefinedColors()
|
||||||
|
{
|
||||||
|
#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 g_ColorRefs table (size NBCOLORS).
|
||||||
|
// The look is better when g_ColorRefs order is displayed in a grid matrix
|
||||||
|
// of 6 row and 5 columns, first filling a row, and after the next column.
|
||||||
|
// But the wxFlexGrid used here must be filled by columns, then next row
|
||||||
|
// the best interval g_ColorRefs from a matrix row to the next row is 6
|
||||||
|
// So when have to reorder the index used to explore g_ColorRefs
|
||||||
|
int grid_col = 0;
|
||||||
|
int grid_row = 0;
|
||||||
|
int table_row_count = 6;
|
||||||
|
|
||||||
|
for( int jj = 0; jj < NBCOLORS; ++jj, grid_col++ )
|
||||||
|
{
|
||||||
|
if( grid_col*table_row_count >= NBCOLORS )
|
||||||
|
{ // the current grid row is filled, and we must fill the next grid row
|
||||||
|
grid_col = 0;
|
||||||
|
grid_row++;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ii = grid_row + (grid_col*table_row_count); // The index in g_ColorRefs
|
||||||
|
|
||||||
|
int butt_ID = ID_COLOR_BLACK + ii;
|
||||||
|
wxMemoryDC iconDC;
|
||||||
|
wxBitmap ButtBitmap( w, h );
|
||||||
|
wxBrush brush;
|
||||||
|
|
||||||
|
iconDC.SelectObject( ButtBitmap );
|
||||||
|
|
||||||
|
KIGFX::COLOR4D buttcolor = KIGFX::COLOR4D( g_ColorRefs[ii].m_Numcolor );
|
||||||
|
|
||||||
|
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( g_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( COLOR4D_PICKER_DLG::buttColorClick ), NULL, this );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void COLOR4D_PICKER_DLG::createRGBBitmap()
|
||||||
|
{
|
||||||
|
wxMemoryDC bitmapDC;
|
||||||
|
wxSize bmsize = m_RgbBitmap->GetSize();
|
||||||
|
int half_size = std::min( bmsize.x, bmsize.y )/2;
|
||||||
|
m_bitmapRGB = new wxBitmap( bmsize );
|
||||||
|
bitmapDC.SelectObject( *m_bitmapRGB );
|
||||||
|
wxPen pen;
|
||||||
|
|
||||||
|
// clear background (set the window bg color)
|
||||||
|
wxBrush bgbrush( GetBackgroundColour() );
|
||||||
|
bitmapDC.SetBackground( bgbrush );
|
||||||
|
bitmapDC.Clear();
|
||||||
|
|
||||||
|
// Use Y axis from bottom to top and origin to center
|
||||||
|
bitmapDC.SetAxisOrientation( true, true );
|
||||||
|
bitmapDC.SetDeviceOrigin( half_size, half_size );
|
||||||
|
|
||||||
|
// Reserve room to draw cursors inside the bitmap
|
||||||
|
half_size -= m_cursorsSize/2;
|
||||||
|
|
||||||
|
KIGFX::COLOR4D color;
|
||||||
|
|
||||||
|
// Red blue area in X Z 3d axis
|
||||||
|
double inc = 1.0 / half_size;
|
||||||
|
#define SLOPE_AXIS 50.0
|
||||||
|
double slope = SLOPE_AXIS/half_size;
|
||||||
|
color.g = 0;
|
||||||
|
|
||||||
|
for( int xx = 0; xx < half_size; xx++ ) // blue axis
|
||||||
|
{
|
||||||
|
color.b = inc * xx;
|
||||||
|
|
||||||
|
for( int yy = 0; yy < half_size; yy++ ) // Red axis
|
||||||
|
{
|
||||||
|
color.r = inc * yy;
|
||||||
|
|
||||||
|
pen.SetColour( color.ToColour() );
|
||||||
|
bitmapDC.SetPen( pen );
|
||||||
|
bitmapDC.DrawPoint( xx, yy - (slope*xx) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Red green area in y Z 3d axis
|
||||||
|
color.b = 0;
|
||||||
|
for( int xx = 0; xx < half_size; xx++ ) // green axis
|
||||||
|
{
|
||||||
|
color.g = inc * xx;
|
||||||
|
|
||||||
|
for( int yy = 0; yy < half_size; yy++ ) // Red axis
|
||||||
|
{
|
||||||
|
color.r = inc * yy;
|
||||||
|
|
||||||
|
pen.SetColour( color.ToColour() );
|
||||||
|
bitmapDC.SetPen( pen );
|
||||||
|
bitmapDC.DrawPoint( -xx, yy - (slope*xx) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Blue green area in x y 3d axis
|
||||||
|
color.r = 0;
|
||||||
|
for( int xx = 0; xx < half_size; xx++ ) // green axis
|
||||||
|
{
|
||||||
|
color.g = inc * xx;
|
||||||
|
|
||||||
|
for( int yy = 0; yy < half_size; yy++ ) // blue axis
|
||||||
|
{
|
||||||
|
color.b = inc * yy;
|
||||||
|
|
||||||
|
pen.SetColour( color.ToColour() );
|
||||||
|
bitmapDC.SetPen( pen );
|
||||||
|
|
||||||
|
// Mapping the xx, yy color axis to draw coordinates is more tricky than previously
|
||||||
|
// in DC coordinates:
|
||||||
|
// the blue axis is the (0, 0) to half_size, (-yy - SLOPE_AXIS)
|
||||||
|
// the green axis is the (0, 0) to - half_size, (-yy - SLOPE_AXIS)
|
||||||
|
int drawX = -xx + yy;
|
||||||
|
int drawY = - std::min( xx,yy ) * 0.9;
|
||||||
|
bitmapDC.DrawPoint( drawX, drawY - std::abs( slope*drawX ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void COLOR4D_PICKER_DLG::createHSVBitmap()
|
||||||
|
{
|
||||||
|
wxMemoryDC bitmapDC;
|
||||||
|
wxSize bmsize = m_HsvBitmap->GetSize();
|
||||||
|
int half_size = std::min( bmsize.x, bmsize.y )/2;
|
||||||
|
delete m_bitmapHSV;
|
||||||
|
m_bitmapHSV = new wxBitmap( bmsize );
|
||||||
|
bitmapDC.SelectObject( *m_bitmapHSV );
|
||||||
|
wxPen pen;
|
||||||
|
|
||||||
|
// clear background (set the window bd color)
|
||||||
|
wxBrush bgbrush( GetBackgroundColour() );
|
||||||
|
bitmapDC.SetBackground( bgbrush );
|
||||||
|
bitmapDC.Clear();
|
||||||
|
|
||||||
|
// Use Y axis from bottom to top and origin to center
|
||||||
|
bitmapDC.SetAxisOrientation( true, true );
|
||||||
|
bitmapDC.SetDeviceOrigin( half_size, half_size );
|
||||||
|
|
||||||
|
// Reserve room to draw cursors inside the bitmap
|
||||||
|
half_size -= m_cursorsSize/2;
|
||||||
|
|
||||||
|
double hue, sat;
|
||||||
|
KIGFX::COLOR4D color;
|
||||||
|
int sq_radius = half_size*half_size;
|
||||||
|
|
||||||
|
for( int xx = -half_size; xx < half_size; xx++ )
|
||||||
|
{
|
||||||
|
for( int yy = -half_size; yy < half_size; yy++ )
|
||||||
|
{
|
||||||
|
sat = double(xx*xx + yy*yy) / sq_radius;
|
||||||
|
|
||||||
|
// sat is <= 1.0
|
||||||
|
// any value > 1.0 is not a valid HSB color:
|
||||||
|
if( sat > 1.0 )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// sat is the distance from center
|
||||||
|
sat = sqrt( sat );
|
||||||
|
hue = atan2( (double)yy, (double)xx ) * 180 / M_PI;
|
||||||
|
|
||||||
|
if( hue < 0.0 )
|
||||||
|
hue += 360.0;
|
||||||
|
|
||||||
|
color.FromHSV( hue, sat, 1.0 );
|
||||||
|
|
||||||
|
pen.SetColour( color.ToColour() );
|
||||||
|
bitmapDC.SetPen( pen );
|
||||||
|
bitmapDC.DrawPoint( xx, yy );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Deselect the Tool Bitmap from DC,
|
||||||
|
* in order to delete the MemoryDC safely without deleting the bitmap
|
||||||
|
*/
|
||||||
|
bitmapDC.SelectObject( wxNullBitmap );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void COLOR4D_PICKER_DLG::drawRGBPalette()
|
||||||
|
{
|
||||||
|
if( !m_bitmapRGB || m_bitmapRGB->GetSize() != m_RgbBitmap->GetSize() )
|
||||||
|
createRGBBitmap();
|
||||||
|
|
||||||
|
wxMemoryDC bitmapDC;
|
||||||
|
wxSize bmsize = m_bitmapRGB->GetSize();
|
||||||
|
int half_size = std::min( bmsize.x, bmsize.y )/2;
|
||||||
|
wxBitmap newBm( *m_bitmapRGB );
|
||||||
|
bitmapDC.SelectObject( newBm );
|
||||||
|
|
||||||
|
// Use Y axis from bottom to top and origin to center
|
||||||
|
bitmapDC.SetAxisOrientation( true, true );
|
||||||
|
bitmapDC.SetDeviceOrigin( half_size, half_size );
|
||||||
|
|
||||||
|
// Reserve room to draw cursors inside the bitmap
|
||||||
|
half_size -= m_cursorsSize/2;
|
||||||
|
|
||||||
|
// Draw the 3 RGB cursors, usiing white color to make them always visible:
|
||||||
|
wxPen pen( wxColor( 255, 255, 255 ) );
|
||||||
|
wxBrush brush( wxColor( 0, 0, 0 ), wxBRUSHSTYLE_TRANSPARENT );
|
||||||
|
bitmapDC.SetPen( pen );
|
||||||
|
bitmapDC.SetBrush( brush );
|
||||||
|
int half_csize = m_cursorsSize/2;
|
||||||
|
|
||||||
|
#define SLOPE_AXIS 50.0
|
||||||
|
double slope = SLOPE_AXIS/half_size;
|
||||||
|
|
||||||
|
// Red axis cursor (Z 3Daxis):
|
||||||
|
m_cursorBitmapRed.x = 0;
|
||||||
|
m_cursorBitmapRed.y = m_newColor4D.r * half_size;
|
||||||
|
bitmapDC.DrawRectangle( m_cursorBitmapRed.x - half_csize,
|
||||||
|
m_cursorBitmapRed.y - half_csize,
|
||||||
|
m_cursorsSize, m_cursorsSize );
|
||||||
|
|
||||||
|
// Blue axis cursor (X 3Daxis):
|
||||||
|
m_cursorBitmapBlue.x = m_newColor4D.b * half_size;
|
||||||
|
m_cursorBitmapBlue.y = - slope*m_cursorBitmapBlue.x;
|
||||||
|
bitmapDC.DrawRectangle( m_cursorBitmapBlue.x - half_csize,
|
||||||
|
m_cursorBitmapBlue.y - half_csize,
|
||||||
|
m_cursorsSize, m_cursorsSize );
|
||||||
|
|
||||||
|
// Green axis cursor (Y 3Daxis):
|
||||||
|
m_cursorBitmapGreen.x = m_newColor4D.g * half_size;
|
||||||
|
m_cursorBitmapGreen.y = - slope * m_cursorBitmapGreen.x;
|
||||||
|
m_cursorBitmapGreen.x = -m_cursorBitmapGreen.x;
|
||||||
|
|
||||||
|
bitmapDC.DrawRectangle( m_cursorBitmapGreen.x - half_csize,
|
||||||
|
m_cursorBitmapGreen.y - half_csize,
|
||||||
|
m_cursorsSize, m_cursorsSize );
|
||||||
|
|
||||||
|
// Draw the 3 RGB axis:
|
||||||
|
half_size += half_size/5;
|
||||||
|
bitmapDC.DrawLine( 0, 0, 0, half_size ); // Red axis (Z 3D axis)
|
||||||
|
bitmapDC.DrawLine( 0, 0, half_size, - half_size*slope ); // Blue axis (X 3D axis)
|
||||||
|
bitmapDC.DrawLine( 0, 0, -half_size, - half_size*slope ); // green axis (Y 3D axis)
|
||||||
|
|
||||||
|
m_RgbBitmap->SetBitmap( newBm );
|
||||||
|
/* Deselect the Tool Bitmap from DC,
|
||||||
|
* in order to delete the MemoryDC safely without deleting the bitmap */
|
||||||
|
bitmapDC.SelectObject( wxNullBitmap );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void COLOR4D_PICKER_DLG::drawHSVPalette()
|
||||||
|
{
|
||||||
|
if( !m_bitmapHSV || m_bitmapHSV->GetSize() != m_HsvBitmap->GetSize() )
|
||||||
|
createHSVBitmap();
|
||||||
|
|
||||||
|
wxMemoryDC bitmapDC;
|
||||||
|
wxSize bmsize = m_bitmapHSV->GetSize();
|
||||||
|
int half_size = std::min( bmsize.x, bmsize.y )/2;
|
||||||
|
wxBitmap newBm( *m_bitmapHSV );
|
||||||
|
bitmapDC.SelectObject( newBm );
|
||||||
|
|
||||||
|
// Use Y axis from bottom to top and origin to center
|
||||||
|
bitmapDC.SetAxisOrientation( true, true );
|
||||||
|
bitmapDC.SetDeviceOrigin( half_size, half_size );
|
||||||
|
|
||||||
|
// Reserve room to draw cursors inside the bitmap
|
||||||
|
half_size -= m_cursorsSize/2;
|
||||||
|
|
||||||
|
// Draw the HSB cursor:
|
||||||
|
m_cursorBitmapHSV.x = cos( m_hue * M_PI / 180.0 ) * half_size * m_sat;
|
||||||
|
m_cursorBitmapHSV.y = sin( m_hue * M_PI / 180.0 ) * half_size * m_sat;
|
||||||
|
|
||||||
|
wxPen pen( wxColor( 0, 0, 0 ) );
|
||||||
|
wxBrush brush( wxColor( 0, 0, 0 ), wxBRUSHSTYLE_TRANSPARENT );
|
||||||
|
bitmapDC.SetPen( pen );
|
||||||
|
bitmapDC.SetBrush( brush );
|
||||||
|
|
||||||
|
int half_csize = m_cursorsSize/2;
|
||||||
|
bitmapDC.DrawRectangle( m_cursorBitmapHSV.x- half_csize,
|
||||||
|
m_cursorBitmapHSV.y-half_csize,
|
||||||
|
m_cursorsSize, m_cursorsSize );
|
||||||
|
|
||||||
|
m_HsvBitmap->SetBitmap( newBm );
|
||||||
|
/* Deselect the Tool Bitmap from DC,
|
||||||
|
* in order to delete the MemoryDC safely without deleting the bitmap
|
||||||
|
*/
|
||||||
|
bitmapDC.SelectObject( wxNullBitmap );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void COLOR4D_PICKER_DLG::SetEditVals( CHANGED_COLOR aChanged )
|
||||||
|
{
|
||||||
|
m_sliderTransparency->SetValue( normalizeToInt( m_newColor4D.a, ALPHA_MAX ) );
|
||||||
|
|
||||||
|
if( aChanged == RED_CHANGED || aChanged == GREEN_CHANGED || aChanged == BLUE_CHANGED )
|
||||||
|
m_newColor4D.ToHSV( m_hue, m_sat, m_val, true );
|
||||||
|
|
||||||
|
if( aChanged != RED_CHANGED )
|
||||||
|
m_spinCtrlRed->SetValue( normalizeToInt( m_newColor4D.r ) );
|
||||||
|
|
||||||
|
if( aChanged != GREEN_CHANGED )
|
||||||
|
m_spinCtrlGreen->SetValue( normalizeToInt( m_newColor4D.g ) );
|
||||||
|
|
||||||
|
if( aChanged != BLUE_CHANGED )
|
||||||
|
m_spinCtrlBlue->SetValue( normalizeToInt( m_newColor4D.b ) );
|
||||||
|
|
||||||
|
if( aChanged != HUE_CHANGED )
|
||||||
|
m_spinCtrlHue->SetValue( (int)m_hue );
|
||||||
|
|
||||||
|
if( aChanged != SAT_CHANGED )
|
||||||
|
m_spinCtrlSaturation->SetValue( m_sat * 255 );
|
||||||
|
|
||||||
|
if( aChanged != VAL_CHANGED )
|
||||||
|
{
|
||||||
|
m_sliderBrightness->SetValue(normalizeToInt( m_val ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void COLOR4D_PICKER_DLG::drawAll()
|
||||||
|
{
|
||||||
|
m_NewColorRect->Freeze(); // Avoid flicker
|
||||||
|
m_HsvBitmap->Freeze();
|
||||||
|
m_RgbBitmap->Freeze();
|
||||||
|
setIconColor( m_NewColorRect, m_newColor4D );
|
||||||
|
drawHSVPalette();
|
||||||
|
drawRGBPalette();
|
||||||
|
m_NewColorRect->Thaw();
|
||||||
|
m_HsvBitmap->Thaw();
|
||||||
|
m_RgbBitmap->Thaw();
|
||||||
|
m_NewColorRect->Refresh();
|
||||||
|
m_HsvBitmap->Refresh();
|
||||||
|
m_RgbBitmap->Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void COLOR4D_PICKER_DLG::buttColorClick( wxCommandEvent& event )
|
||||||
|
{
|
||||||
|
int id = event.GetId();
|
||||||
|
KIGFX::COLOR4D color( EDA_COLOR_T( id - ID_COLOR_BLACK ) );
|
||||||
|
m_newColor4D.r = color.r;
|
||||||
|
m_newColor4D.g = color.g;
|
||||||
|
m_newColor4D.b = color.b;
|
||||||
|
|
||||||
|
m_newColor4D.ToHSV( m_hue, m_sat, m_val, true );
|
||||||
|
SetEditVals( ALL_CHANGED );
|
||||||
|
|
||||||
|
drawAll();
|
||||||
|
|
||||||
|
event.Skip();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void COLOR4D_PICKER_DLG::onRGBMouseClick( wxMouseEvent& event )
|
||||||
|
{
|
||||||
|
wxPoint mousePos = event.GetPosition();
|
||||||
|
|
||||||
|
// The cursor position is relative to the m_bitmapHSV wxBitmap center
|
||||||
|
wxSize bmsize = m_bitmapRGB->GetSize();
|
||||||
|
int half_size = std::min( bmsize.x, bmsize.y )/2;
|
||||||
|
mousePos.x -= half_size;
|
||||||
|
mousePos.y -= half_size;
|
||||||
|
mousePos.y = -mousePos.y; // Use the bottom to top vertical axis
|
||||||
|
|
||||||
|
wxPoint dist = m_cursorBitmapRed - mousePos;
|
||||||
|
|
||||||
|
if( std::abs( dist.x ) <= m_cursorsSize/2 && std::abs( dist.y ) <= m_cursorsSize/2 )
|
||||||
|
{
|
||||||
|
m_selectedCursor = &m_cursorBitmapRed;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dist = m_cursorBitmapGreen - mousePos;
|
||||||
|
|
||||||
|
if( std::abs( dist.x ) <= m_cursorsSize/2 && std::abs( dist.y ) <= m_cursorsSize/2 )
|
||||||
|
{
|
||||||
|
m_selectedCursor = &m_cursorBitmapGreen;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dist = m_cursorBitmapBlue - mousePos;
|
||||||
|
|
||||||
|
if( std::abs( dist.x ) <= m_cursorsSize/2 && std::abs( dist.y ) <= m_cursorsSize/2 )
|
||||||
|
{
|
||||||
|
m_selectedCursor = &m_cursorBitmapBlue;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_selectedCursor = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void COLOR4D_PICKER_DLG::onRGBMouseDrag( wxMouseEvent& event )
|
||||||
|
{
|
||||||
|
if( !event.Dragging() )
|
||||||
|
{
|
||||||
|
m_selectedCursor = nullptr;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( m_selectedCursor != &m_cursorBitmapRed &&
|
||||||
|
m_selectedCursor != &m_cursorBitmapGreen &&
|
||||||
|
m_selectedCursor != &m_cursorBitmapBlue )
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Adjust the HSV cursor position to follow the mouse cursor
|
||||||
|
// The cursor position is relative to the m_bitmapHSV wxBitmap center
|
||||||
|
wxPoint mousePos = event.GetPosition();
|
||||||
|
wxSize bmsize = m_bitmapRGB->GetSize();
|
||||||
|
int half_size = std::min( bmsize.x, bmsize.y )/2;
|
||||||
|
mousePos.x -= half_size;
|
||||||
|
mousePos.y -= half_size;
|
||||||
|
mousePos.y = -mousePos.y; // Use the bottom to top vertical axis
|
||||||
|
|
||||||
|
half_size -= m_cursorsSize/2; // the actual half_size of the palette area
|
||||||
|
|
||||||
|
// Change colors according to the selected cursor:
|
||||||
|
if( m_selectedCursor == &m_cursorBitmapRed )
|
||||||
|
{
|
||||||
|
if( mousePos.y >= 0 && mousePos.y <= half_size )
|
||||||
|
m_newColor4D.r = (double)mousePos.y / half_size;
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( m_selectedCursor == &m_cursorBitmapGreen )
|
||||||
|
{
|
||||||
|
mousePos.x = -mousePos.x;
|
||||||
|
|
||||||
|
if( mousePos.x >= 0 && mousePos.x <= half_size )
|
||||||
|
m_newColor4D.g = (double)mousePos.x / half_size;
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( m_selectedCursor == &m_cursorBitmapBlue )
|
||||||
|
{
|
||||||
|
if( mousePos.x >= 0 && mousePos.x <= half_size )
|
||||||
|
m_newColor4D.b = (double)mousePos.x / half_size;
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_newColor4D.ToHSV( m_hue, m_sat, m_val, true );
|
||||||
|
SetEditVals( ALL_CHANGED );
|
||||||
|
|
||||||
|
drawAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void COLOR4D_PICKER_DLG::onHSVMouseClick( wxMouseEvent& event )
|
||||||
|
{
|
||||||
|
wxPoint mousePos = event.GetPosition();
|
||||||
|
|
||||||
|
// The cursor position is relative to the m_bitmapHSV wxBitmap center
|
||||||
|
wxSize bmsize = m_bitmapHSV->GetSize();
|
||||||
|
int half_size = std::min( bmsize.x, bmsize.y )/2;
|
||||||
|
mousePos.x -= half_size;
|
||||||
|
mousePos.y -= half_size;
|
||||||
|
mousePos.y = -mousePos.y; // Use the bottom to top vertical axis
|
||||||
|
|
||||||
|
wxPoint dist = m_cursorBitmapHSV - mousePos;
|
||||||
|
|
||||||
|
if( std::abs( dist.x ) <= m_cursorsSize/2 && std::abs( dist.y ) <= m_cursorsSize/2 )
|
||||||
|
m_selectedCursor = &m_cursorBitmapHSV;
|
||||||
|
else
|
||||||
|
m_selectedCursor = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void COLOR4D_PICKER_DLG::onHSVMouseDrag( wxMouseEvent& event )
|
||||||
|
{
|
||||||
|
if( !event.Dragging() )
|
||||||
|
{
|
||||||
|
m_selectedCursor = nullptr;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( m_selectedCursor != &m_cursorBitmapHSV )
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Adjust the HSV cursor position to follow the mouse cursor
|
||||||
|
// The cursor position is relative to the m_bitmapHSV wxBitmap center
|
||||||
|
wxPoint mousePos = event.GetPosition();
|
||||||
|
wxSize bmsize = m_bitmapHSV->GetSize();
|
||||||
|
int half_size = std::min( bmsize.x, bmsize.y )/2;
|
||||||
|
mousePos.x -= half_size;
|
||||||
|
mousePos.y -= half_size;
|
||||||
|
mousePos.y = -mousePos.y; // Use the bottom to top vertical axis
|
||||||
|
|
||||||
|
// The HSV cursor position is restricted to a circle of radius half_size
|
||||||
|
double dist_from_centre = hypot( (double)mousePos.x, (double)mousePos.y );
|
||||||
|
|
||||||
|
if( dist_from_centre > half_size )
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_cursorBitmapHSV = mousePos;
|
||||||
|
|
||||||
|
// Set saturation and hue from new cursor position:
|
||||||
|
half_size -= m_cursorsSize/2; // the actual half_size of the palette area
|
||||||
|
m_sat = dist_from_centre / half_size;
|
||||||
|
|
||||||
|
if( m_sat > 1.0 )
|
||||||
|
m_sat = 1.0;
|
||||||
|
|
||||||
|
m_hue = atan2( mousePos.y, mousePos.x ) / M_PI * 180.0;
|
||||||
|
|
||||||
|
if( m_hue < 0 )
|
||||||
|
m_hue += 360.0;
|
||||||
|
|
||||||
|
m_newColor4D.FromHSV( m_hue, m_sat, m_val );
|
||||||
|
SetEditVals( ALL_CHANGED );
|
||||||
|
|
||||||
|
drawAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void COLOR4D_PICKER_DLG::OnChangeAlpha( wxScrollEvent& event )
|
||||||
|
{
|
||||||
|
double alpha = (double)event.GetPosition() / ALPHA_MAX;
|
||||||
|
m_newColor4D.a = alpha;
|
||||||
|
m_NewColorRect->Freeze(); // Avoid flicker
|
||||||
|
setIconColor( m_NewColorRect, m_newColor4D );
|
||||||
|
m_NewColorRect->Thaw();
|
||||||
|
m_NewColorRect->Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void COLOR4D_PICKER_DLG::OnChangeEditRed( wxSpinEvent& event )
|
||||||
|
{
|
||||||
|
double val = (double)event.GetPosition() / 255.0;
|
||||||
|
m_newColor4D.r = val;
|
||||||
|
SetEditVals( RED_CHANGED );
|
||||||
|
|
||||||
|
drawAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void COLOR4D_PICKER_DLG::OnChangeEditGreen( wxSpinEvent& event )
|
||||||
|
{
|
||||||
|
double val = (double)event.GetPosition() / 255.0;
|
||||||
|
m_newColor4D.g = val;
|
||||||
|
SetEditVals( GREEN_CHANGED );
|
||||||
|
|
||||||
|
drawAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void COLOR4D_PICKER_DLG::OnChangeEditBlue( wxSpinEvent& event )
|
||||||
|
{
|
||||||
|
double val = (double)event.GetPosition() / 255.0;
|
||||||
|
m_newColor4D.b = val;
|
||||||
|
SetEditVals( BLUE_CHANGED );
|
||||||
|
|
||||||
|
drawAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void COLOR4D_PICKER_DLG::OnChangeEditHue( wxSpinEvent& event )
|
||||||
|
{
|
||||||
|
m_hue = (double)event.GetPosition();
|
||||||
|
|
||||||
|
m_newColor4D.FromHSV( m_hue, m_sat, m_val );
|
||||||
|
|
||||||
|
SetEditVals( HUE_CHANGED );
|
||||||
|
|
||||||
|
drawAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void COLOR4D_PICKER_DLG::OnChangeEditSat( wxSpinEvent& event )
|
||||||
|
{
|
||||||
|
m_sat = (double)event.GetPosition() / 255.0;
|
||||||
|
|
||||||
|
m_newColor4D.FromHSV( m_hue, m_sat, m_val );
|
||||||
|
|
||||||
|
SetEditVals( SAT_CHANGED );
|
||||||
|
|
||||||
|
drawAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void COLOR4D_PICKER_DLG::OnChangeBrightness( wxScrollEvent& event )
|
||||||
|
{
|
||||||
|
m_val = (double)event.GetPosition() / 255.0;
|
||||||
|
|
||||||
|
m_newColor4D.FromHSV( m_hue, m_sat, m_val );
|
||||||
|
|
||||||
|
SetEditVals( VAL_CHANGED );
|
||||||
|
|
||||||
|
drawAll();
|
||||||
|
}
|
|
@ -0,0 +1,101 @@
|
||||||
|
/**
|
||||||
|
* @file color4Dpickerdlg.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef COLOR4DPICKERDLG_H
|
||||||
|
#define COLOR4DPICKERDLG_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <gal/color4d.h>
|
||||||
|
#include "color4Dpickerdlg_base.h"
|
||||||
|
|
||||||
|
enum CHANGED_COLOR
|
||||||
|
{
|
||||||
|
ALL_CHANGED,
|
||||||
|
RED_CHANGED,
|
||||||
|
BLUE_CHANGED,
|
||||||
|
GREEN_CHANGED,
|
||||||
|
HUE_CHANGED,
|
||||||
|
SAT_CHANGED,
|
||||||
|
VAL_CHANGED,
|
||||||
|
};
|
||||||
|
|
||||||
|
class COLOR4D_PICKER_DLG : public COLOR4D_PICKER_DLG_BASE
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
COLOR4D_PICKER_DLG( wxWindow* aParent, KIGFX::COLOR4D& aCurrentColor );
|
||||||
|
~COLOR4D_PICKER_DLG();
|
||||||
|
|
||||||
|
KIGFX::COLOR4D GetColor() { return m_newColor4D; };
|
||||||
|
|
||||||
|
static int m_ActivePage; ///< the active notebook page, stored during a session
|
||||||
|
|
||||||
|
private:
|
||||||
|
KIGFX::COLOR4D m_previousColor4D; ///< the inital color4d
|
||||||
|
KIGFX::COLOR4D m_newColor4D; ///< the current color4d
|
||||||
|
int m_cursorsSize;
|
||||||
|
|
||||||
|
wxPoint m_cursorBitmapRed; ///< the red cursor on the RGB bitmap palette.
|
||||||
|
wxPoint m_cursorBitmapGreen; ///< the green cursor on the RGB bitmap palette.
|
||||||
|
wxPoint m_cursorBitmapBlue; ///< the blue cursor on the RGB bitmap palette.
|
||||||
|
wxPoint m_cursorBitmapHSV; ///< the cursor on the HSV bitmap palette.
|
||||||
|
wxPoint* m_selectedCursor; ///< the ref cursor to the selected curor, if any, or null.
|
||||||
|
|
||||||
|
double m_hue; ///< the current hue, in degrees (0 ... 360)
|
||||||
|
double m_sat; ///< the current saturation (0 ... 1.0)
|
||||||
|
double m_val; ///< the current value (0 ... 1.0)
|
||||||
|
|
||||||
|
wxBitmap* m_bitmapRGB; ///< the basic RGB palette
|
||||||
|
wxBitmap* m_bitmapHSV; ///< the basic HUV palette
|
||||||
|
|
||||||
|
std::vector<wxBitmapButton*> m_buttonsColor; ///< list of defined colors buttons
|
||||||
|
|
||||||
|
void SetEditVals( CHANGED_COLOR aChanged );
|
||||||
|
void drawAll();
|
||||||
|
|
||||||
|
void createHSVBitmap(); ///< generate the bitmap that shows the HSV color circle
|
||||||
|
void drawHSVPalette(); ///< draws the HSV color circle
|
||||||
|
void createRGBBitmap(); ///< generate the bitmap that shows the RVB color space
|
||||||
|
void drawRGBPalette(); ///< draws the RVB color space
|
||||||
|
void drawRGBCursors();
|
||||||
|
|
||||||
|
///> repaint a static bitmap with the aColor4D color
|
||||||
|
void setIconColor( wxStaticBitmap* aStaticBitmap, KIGFX::COLOR4D& aColor4D );
|
||||||
|
|
||||||
|
///< Event handler from wxSlider: brightness (value) control
|
||||||
|
void OnChangeBrightness( wxScrollEvent& event ) override;
|
||||||
|
|
||||||
|
///< Event handler from wxSlider: alpha (transparency) control
|
||||||
|
void OnChangeAlpha( wxScrollEvent& event ) override;
|
||||||
|
|
||||||
|
///< Event handlers from wxSpinControl
|
||||||
|
void OnChangeEditRed( wxSpinEvent& event ) override;
|
||||||
|
void OnChangeEditGreen( wxSpinEvent& event ) override;
|
||||||
|
void OnChangeEditBlue( wxSpinEvent& event ) override;
|
||||||
|
void OnChangeEditHue( wxSpinEvent& event ) override;
|
||||||
|
void OnChangeEditSat( wxSpinEvent& event ) override;
|
||||||
|
|
||||||
|
///> mouse handlers, when clicking on a palette bitmap
|
||||||
|
void onRGBMouseClick( wxMouseEvent& event ) override;
|
||||||
|
void onRGBMouseDrag( wxMouseEvent& event ) override;
|
||||||
|
void onHSVMouseClick( wxMouseEvent& event ) override;
|
||||||
|
void onHSVMouseDrag( wxMouseEvent& event ) override;
|
||||||
|
|
||||||
|
///> Event handler for defined color buttons
|
||||||
|
void buttColorClick( wxCommandEvent& event );
|
||||||
|
|
||||||
|
///> called when creating the dialog
|
||||||
|
bool TransferDataToWindow() override;
|
||||||
|
|
||||||
|
///> creates the bitmap buttons for each defined colors
|
||||||
|
void initDefinedColors();
|
||||||
|
|
||||||
|
// convert double value 0 ... 1 to int 0 ... aValMax
|
||||||
|
int normalizeToInt( double aValue, int aValMax = 255 )
|
||||||
|
{
|
||||||
|
return ( aValue * aValMax ) + 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // #define COLOR4DPICKERDLG_H
|
|
@ -0,0 +1,320 @@
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// C++ code generated with wxFormBuilder (version Jul 2 2017)
|
||||||
|
// http://www.wxformbuilder.org/
|
||||||
|
//
|
||||||
|
// PLEASE DO "NOT" EDIT THIS FILE!
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "color4Dpickerdlg_base.h"
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
COLOR4D_PICKER_DLG_BASE::COLOR4D_PICKER_DLG_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
|
||||||
|
{
|
||||||
|
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
|
||||||
|
|
||||||
|
wxBoxSizer* bSizerMain;
|
||||||
|
bSizerMain = new wxBoxSizer( wxVERTICAL );
|
||||||
|
|
||||||
|
wxBoxSizer* bSizerUpperMain;
|
||||||
|
bSizerUpperMain = new wxBoxSizer( wxHORIZONTAL );
|
||||||
|
|
||||||
|
m_notebook = new wxNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
|
||||||
|
m_panelFreeColors = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
|
||||||
|
wxBoxSizer* bSizerUpperFreeColors;
|
||||||
|
bSizerUpperFreeColors = new wxBoxSizer( wxVERTICAL );
|
||||||
|
|
||||||
|
wxBoxSizer* bSizerPanels;
|
||||||
|
bSizerPanels = new wxBoxSizer( wxHORIZONTAL );
|
||||||
|
|
||||||
|
wxStaticBoxSizer* sbSizerViewRGB;
|
||||||
|
sbSizerViewRGB = new wxStaticBoxSizer( new wxStaticBox( m_panelFreeColors, wxID_ANY, wxT("RGB") ), wxVERTICAL );
|
||||||
|
|
||||||
|
|
||||||
|
sbSizerViewRGB->Add( 0, 0, 1, wxEXPAND|wxALIGN_CENTER_HORIZONTAL, 5 );
|
||||||
|
|
||||||
|
m_RgbBitmap = new wxStaticBitmap( sbSizerViewRGB->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 264,264 ), 0 );
|
||||||
|
m_RgbBitmap->SetMinSize( wxSize( 264,264 ) );
|
||||||
|
|
||||||
|
sbSizerViewRGB->Add( m_RgbBitmap, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );
|
||||||
|
|
||||||
|
|
||||||
|
sbSizerViewRGB->Add( 0, 0, 1, wxEXPAND|wxALIGN_CENTER_HORIZONTAL, 5 );
|
||||||
|
|
||||||
|
|
||||||
|
bSizerPanels->Add( sbSizerViewRGB, 1, wxEXPAND|wxBOTTOM|wxRIGHT, 5 );
|
||||||
|
|
||||||
|
wxStaticBoxSizer* sbSizerViewHSV;
|
||||||
|
sbSizerViewHSV = new wxStaticBoxSizer( new wxStaticBox( m_panelFreeColors, wxID_ANY, wxT("HSV") ), wxVERTICAL );
|
||||||
|
|
||||||
|
|
||||||
|
sbSizerViewHSV->Add( 0, 0, 1, wxEXPAND|wxALIGN_CENTER_HORIZONTAL, 5 );
|
||||||
|
|
||||||
|
m_HsvBitmap = new wxStaticBitmap( sbSizerViewHSV->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 264,264 ), 0 );
|
||||||
|
m_HsvBitmap->SetMinSize( wxSize( 264,264 ) );
|
||||||
|
|
||||||
|
sbSizerViewHSV->Add( m_HsvBitmap, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );
|
||||||
|
|
||||||
|
|
||||||
|
sbSizerViewHSV->Add( 0, 0, 1, wxEXPAND|wxALIGN_CENTER_HORIZONTAL, 5 );
|
||||||
|
|
||||||
|
|
||||||
|
bSizerPanels->Add( sbSizerViewHSV, 1, wxEXPAND|wxBOTTOM, 5 );
|
||||||
|
|
||||||
|
wxBoxSizer* bSizerBright;
|
||||||
|
bSizerBright = new wxBoxSizer( wxVERTICAL );
|
||||||
|
|
||||||
|
m_staticTextBright = new wxStaticText( m_panelFreeColors, wxID_ANY, wxT("Value"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||||
|
m_staticTextBright->Wrap( -1 );
|
||||||
|
bSizerBright->Add( m_staticTextBright, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );
|
||||||
|
|
||||||
|
m_sliderBrightness = new wxSlider( m_panelFreeColors, wxID_ANY, 255, 0, 255, wxDefaultPosition, wxDefaultSize, wxSL_LABELS|wxSL_LEFT|wxSL_VERTICAL );
|
||||||
|
bSizerBright->Add( m_sliderBrightness, 1, wxALL, 5 );
|
||||||
|
|
||||||
|
|
||||||
|
bSizerPanels->Add( bSizerBright, 0, wxEXPAND, 5 );
|
||||||
|
|
||||||
|
|
||||||
|
bSizerUpperFreeColors->Add( bSizerPanels, 1, wxEXPAND, 5 );
|
||||||
|
|
||||||
|
wxBoxSizer* bSizerLowerFreeColors;
|
||||||
|
bSizerLowerFreeColors = new wxBoxSizer( wxHORIZONTAL );
|
||||||
|
|
||||||
|
wxStaticBoxSizer* sbSizerSetRGB;
|
||||||
|
sbSizerSetRGB = new wxStaticBoxSizer( new wxStaticBox( m_panelFreeColors, wxID_ANY, wxT("RGB Values") ), wxHORIZONTAL );
|
||||||
|
|
||||||
|
wxFlexGridSizer* fgSizerRGB;
|
||||||
|
fgSizerRGB = new wxFlexGridSizer( 0, 3, 0, 0 );
|
||||||
|
fgSizerRGB->AddGrowableCol( 0 );
|
||||||
|
fgSizerRGB->AddGrowableCol( 1 );
|
||||||
|
fgSizerRGB->AddGrowableCol( 2 );
|
||||||
|
fgSizerRGB->SetFlexibleDirection( wxBOTH );
|
||||||
|
fgSizerRGB->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
|
||||||
|
|
||||||
|
m_staticTextR = new wxStaticText( sbSizerSetRGB->GetStaticBox(), wxID_ANY, wxT("Red"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||||
|
m_staticTextR->Wrap( -1 );
|
||||||
|
fgSizerRGB->Add( m_staticTextR, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
|
||||||
|
|
||||||
|
m_staticTextG = new wxStaticText( sbSizerSetRGB->GetStaticBox(), wxID_ANY, wxT("Green"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||||
|
m_staticTextG->Wrap( -1 );
|
||||||
|
fgSizerRGB->Add( m_staticTextG, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
|
||||||
|
|
||||||
|
m_staticTextB = new wxStaticText( sbSizerSetRGB->GetStaticBox(), wxID_ANY, wxT("Blue"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||||
|
m_staticTextB->Wrap( -1 );
|
||||||
|
fgSizerRGB->Add( m_staticTextB, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
|
||||||
|
|
||||||
|
m_spinCtrlRed = new wxSpinCtrl( sbSizerSetRGB->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 255, 128 );
|
||||||
|
m_spinCtrlRed->SetMinSize( wxSize( 80,-1 ) );
|
||||||
|
|
||||||
|
fgSizerRGB->Add( m_spinCtrlRed, 0, wxALL|wxEXPAND, 5 );
|
||||||
|
|
||||||
|
m_spinCtrlGreen = new wxSpinCtrl( sbSizerSetRGB->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 255, 128 );
|
||||||
|
m_spinCtrlGreen->SetMinSize( wxSize( 80,-1 ) );
|
||||||
|
|
||||||
|
fgSizerRGB->Add( m_spinCtrlGreen, 0, wxALL|wxEXPAND, 5 );
|
||||||
|
|
||||||
|
m_spinCtrlBlue = new wxSpinCtrl( sbSizerSetRGB->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 255, 128 );
|
||||||
|
m_spinCtrlBlue->SetMinSize( wxSize( 80,-1 ) );
|
||||||
|
|
||||||
|
fgSizerRGB->Add( m_spinCtrlBlue, 0, wxALL|wxEXPAND, 5 );
|
||||||
|
|
||||||
|
|
||||||
|
sbSizerSetRGB->Add( fgSizerRGB, 1, wxEXPAND, 5 );
|
||||||
|
|
||||||
|
|
||||||
|
bSizerLowerFreeColors->Add( sbSizerSetRGB, 1, wxEXPAND, 5 );
|
||||||
|
|
||||||
|
wxStaticBoxSizer* sbSizerSetHSV;
|
||||||
|
sbSizerSetHSV = new wxStaticBoxSizer( new wxStaticBox( m_panelFreeColors, wxID_ANY, wxT("RGB Values") ), wxHORIZONTAL );
|
||||||
|
|
||||||
|
wxFlexGridSizer* fgSizerHSB;
|
||||||
|
fgSizerHSB = new wxFlexGridSizer( 0, 2, 0, 0 );
|
||||||
|
fgSizerHSB->AddGrowableCol( 0 );
|
||||||
|
fgSizerHSB->AddGrowableCol( 1 );
|
||||||
|
fgSizerHSB->AddGrowableCol( 2 );
|
||||||
|
fgSizerHSB->SetFlexibleDirection( wxBOTH );
|
||||||
|
fgSizerHSB->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
|
||||||
|
|
||||||
|
m_staticTextHue = new wxStaticText( sbSizerSetHSV->GetStaticBox(), wxID_ANY, wxT("Hue"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||||
|
m_staticTextHue->Wrap( -1 );
|
||||||
|
fgSizerHSB->Add( m_staticTextHue, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
|
||||||
|
|
||||||
|
m_staticTextSat = new wxStaticText( sbSizerSetHSV->GetStaticBox(), wxID_ANY, wxT("Saturation"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||||
|
m_staticTextSat->Wrap( -1 );
|
||||||
|
fgSizerHSB->Add( m_staticTextSat, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
|
||||||
|
|
||||||
|
m_spinCtrlHue = new wxSpinCtrl( sbSizerSetHSV->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS|wxSP_WRAP, 0, 359, 0 );
|
||||||
|
m_spinCtrlHue->SetMinSize( wxSize( 80,-1 ) );
|
||||||
|
|
||||||
|
fgSizerHSB->Add( m_spinCtrlHue, 0, wxALL|wxEXPAND, 5 );
|
||||||
|
|
||||||
|
m_spinCtrlSaturation = new wxSpinCtrl( sbSizerSetHSV->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 255, 128 );
|
||||||
|
m_spinCtrlSaturation->SetMinSize( wxSize( 80,-1 ) );
|
||||||
|
|
||||||
|
fgSizerHSB->Add( m_spinCtrlSaturation, 0, wxALL|wxEXPAND, 5 );
|
||||||
|
|
||||||
|
|
||||||
|
sbSizerSetHSV->Add( fgSizerHSB, 1, wxEXPAND, 5 );
|
||||||
|
|
||||||
|
|
||||||
|
bSizerLowerFreeColors->Add( sbSizerSetHSV, 1, wxEXPAND, 5 );
|
||||||
|
|
||||||
|
|
||||||
|
bSizerUpperFreeColors->Add( bSizerLowerFreeColors, 0, wxEXPAND, 5 );
|
||||||
|
|
||||||
|
|
||||||
|
m_panelFreeColors->SetSizer( bSizerUpperFreeColors );
|
||||||
|
m_panelFreeColors->Layout();
|
||||||
|
bSizerUpperFreeColors->Fit( m_panelFreeColors );
|
||||||
|
m_notebook->AddPage( m_panelFreeColors, wxT("Color Picker"), false );
|
||||||
|
m_panelDefinedColors = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
|
||||||
|
m_SizerDefinedColors = new wxBoxSizer( wxVERTICAL );
|
||||||
|
|
||||||
|
|
||||||
|
m_SizerDefinedColors->Add( 0, 0, 1, wxEXPAND, 5 );
|
||||||
|
|
||||||
|
m_fgridColor = new wxFlexGridSizer( 0, 10, 0, 0 );
|
||||||
|
m_fgridColor->AddGrowableCol( 1 );
|
||||||
|
m_fgridColor->AddGrowableCol( 3 );
|
||||||
|
m_fgridColor->AddGrowableCol( 5 );
|
||||||
|
m_fgridColor->AddGrowableCol( 7 );
|
||||||
|
m_fgridColor->AddGrowableCol( 9 );
|
||||||
|
m_fgridColor->SetFlexibleDirection( wxBOTH );
|
||||||
|
m_fgridColor->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
|
||||||
|
|
||||||
|
|
||||||
|
m_SizerDefinedColors->Add( m_fgridColor, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 );
|
||||||
|
|
||||||
|
|
||||||
|
m_SizerDefinedColors->Add( 0, 0, 1, wxEXPAND, 5 );
|
||||||
|
|
||||||
|
|
||||||
|
m_panelDefinedColors->SetSizer( m_SizerDefinedColors );
|
||||||
|
m_panelDefinedColors->Layout();
|
||||||
|
m_SizerDefinedColors->Fit( m_panelDefinedColors );
|
||||||
|
m_notebook->AddPage( m_panelDefinedColors, wxT("Defined Colors"), true );
|
||||||
|
|
||||||
|
bSizerUpperMain->Add( m_notebook, 1, wxEXPAND | wxALL, 5 );
|
||||||
|
|
||||||
|
wxBoxSizer* bSizerTransparency;
|
||||||
|
bSizerTransparency = new wxBoxSizer( wxVERTICAL );
|
||||||
|
|
||||||
|
|
||||||
|
bSizerTransparency->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_sliderTransparency = new wxSlider( this, wxID_ANY, 80, 20, 100, wxDefaultPosition, wxDefaultSize, wxSL_LABELS|wxSL_LEFT|wxSL_VERTICAL );
|
||||||
|
bSizerTransparency->Add( m_sliderTransparency, 1, wxALL, 5 );
|
||||||
|
|
||||||
|
|
||||||
|
bSizerTransparency->Add( 0, 20, 0, 0, 5 );
|
||||||
|
|
||||||
|
|
||||||
|
bSizerUpperMain->Add( bSizerTransparency, 0, wxEXPAND, 5 );
|
||||||
|
|
||||||
|
wxBoxSizer* bSizerShowColors;
|
||||||
|
bSizerShowColors = new wxBoxSizer( wxVERTICAL );
|
||||||
|
|
||||||
|
m_staticTextOldColor = new wxStaticText( this, wxID_ANY, wxT("Old Color"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||||
|
m_staticTextOldColor->Wrap( -1 );
|
||||||
|
bSizerShowColors->Add( m_staticTextOldColor, 0, wxALIGN_CENTER_HORIZONTAL|wxTOP|wxRIGHT|wxLEFT, 5 );
|
||||||
|
|
||||||
|
m_OldColorRect = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 64,64 ), 0 );
|
||||||
|
bSizerShowColors->Add( m_OldColorRect, 0, wxALL, 5 );
|
||||||
|
|
||||||
|
m_staticTextNewColor = new wxStaticText( this, wxID_ANY, wxT("New Color"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||||
|
m_staticTextNewColor->Wrap( -1 );
|
||||||
|
bSizerShowColors->Add( m_staticTextNewColor, 0, wxALIGN_CENTER_HORIZONTAL|wxTOP|wxRIGHT|wxLEFT, 5 );
|
||||||
|
|
||||||
|
m_NewColorRect = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 64,64 ), 0 );
|
||||||
|
bSizerShowColors->Add( m_NewColorRect, 0, wxALL, 5 );
|
||||||
|
|
||||||
|
|
||||||
|
bSizerUpperMain->Add( bSizerShowColors, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
|
||||||
|
|
||||||
|
|
||||||
|
bSizerMain->Add( bSizerUpperMain, 1, wxEXPAND, 5 );
|
||||||
|
|
||||||
|
m_staticline = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
|
||||||
|
bSizerMain->Add( m_staticline, 0, wxEXPAND | wxALL, 5 );
|
||||||
|
|
||||||
|
m_sdbSizer = new wxStdDialogButtonSizer();
|
||||||
|
m_sdbSizerOK = new wxButton( this, wxID_OK );
|
||||||
|
m_sdbSizer->AddButton( m_sdbSizerOK );
|
||||||
|
m_sdbSizerCancel = new wxButton( this, wxID_CANCEL );
|
||||||
|
m_sdbSizer->AddButton( m_sdbSizerCancel );
|
||||||
|
m_sdbSizer->Realize();
|
||||||
|
|
||||||
|
bSizerMain->Add( m_sdbSizer, 0, wxALIGN_RIGHT|wxALL, 5 );
|
||||||
|
|
||||||
|
|
||||||
|
this->SetSizer( bSizerMain );
|
||||||
|
this->Layout();
|
||||||
|
|
||||||
|
this->Centre( wxBOTH );
|
||||||
|
|
||||||
|
// Connect Events
|
||||||
|
m_RgbBitmap->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( COLOR4D_PICKER_DLG_BASE::onRGBMouseClick ), NULL, this );
|
||||||
|
m_RgbBitmap->Connect( wxEVT_MOTION, wxMouseEventHandler( COLOR4D_PICKER_DLG_BASE::onRGBMouseDrag ), NULL, this );
|
||||||
|
m_HsvBitmap->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( COLOR4D_PICKER_DLG_BASE::onHSVMouseClick ), NULL, this );
|
||||||
|
m_HsvBitmap->Connect( wxEVT_MOTION, wxMouseEventHandler( COLOR4D_PICKER_DLG_BASE::onHSVMouseDrag ), NULL, this );
|
||||||
|
m_sliderBrightness->Connect( wxEVT_SCROLL_TOP, wxScrollEventHandler( COLOR4D_PICKER_DLG_BASE::OnChangeBrightness ), NULL, this );
|
||||||
|
m_sliderBrightness->Connect( wxEVT_SCROLL_BOTTOM, wxScrollEventHandler( COLOR4D_PICKER_DLG_BASE::OnChangeBrightness ), NULL, this );
|
||||||
|
m_sliderBrightness->Connect( wxEVT_SCROLL_LINEUP, wxScrollEventHandler( COLOR4D_PICKER_DLG_BASE::OnChangeBrightness ), NULL, this );
|
||||||
|
m_sliderBrightness->Connect( wxEVT_SCROLL_LINEDOWN, wxScrollEventHandler( COLOR4D_PICKER_DLG_BASE::OnChangeBrightness ), NULL, this );
|
||||||
|
m_sliderBrightness->Connect( wxEVT_SCROLL_PAGEUP, wxScrollEventHandler( COLOR4D_PICKER_DLG_BASE::OnChangeBrightness ), NULL, this );
|
||||||
|
m_sliderBrightness->Connect( wxEVT_SCROLL_PAGEDOWN, wxScrollEventHandler( COLOR4D_PICKER_DLG_BASE::OnChangeBrightness ), NULL, this );
|
||||||
|
m_sliderBrightness->Connect( wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler( COLOR4D_PICKER_DLG_BASE::OnChangeBrightness ), NULL, this );
|
||||||
|
m_sliderBrightness->Connect( wxEVT_SCROLL_THUMBRELEASE, wxScrollEventHandler( COLOR4D_PICKER_DLG_BASE::OnChangeBrightness ), NULL, this );
|
||||||
|
m_sliderBrightness->Connect( wxEVT_SCROLL_CHANGED, wxScrollEventHandler( COLOR4D_PICKER_DLG_BASE::OnChangeBrightness ), NULL, this );
|
||||||
|
m_spinCtrlRed->Connect( wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler( COLOR4D_PICKER_DLG_BASE::OnChangeEditRed ), NULL, this );
|
||||||
|
m_spinCtrlGreen->Connect( wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler( COLOR4D_PICKER_DLG_BASE::OnChangeEditGreen ), NULL, this );
|
||||||
|
m_spinCtrlBlue->Connect( wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler( COLOR4D_PICKER_DLG_BASE::OnChangeEditBlue ), NULL, this );
|
||||||
|
m_spinCtrlHue->Connect( wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler( COLOR4D_PICKER_DLG_BASE::OnChangeEditHue ), NULL, this );
|
||||||
|
m_spinCtrlSaturation->Connect( wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler( COLOR4D_PICKER_DLG_BASE::OnChangeEditSat ), NULL, this );
|
||||||
|
m_sliderTransparency->Connect( wxEVT_SCROLL_TOP, wxScrollEventHandler( COLOR4D_PICKER_DLG_BASE::OnChangeAlpha ), NULL, this );
|
||||||
|
m_sliderTransparency->Connect( wxEVT_SCROLL_BOTTOM, wxScrollEventHandler( COLOR4D_PICKER_DLG_BASE::OnChangeAlpha ), NULL, this );
|
||||||
|
m_sliderTransparency->Connect( wxEVT_SCROLL_LINEUP, wxScrollEventHandler( COLOR4D_PICKER_DLG_BASE::OnChangeAlpha ), NULL, this );
|
||||||
|
m_sliderTransparency->Connect( wxEVT_SCROLL_LINEDOWN, wxScrollEventHandler( COLOR4D_PICKER_DLG_BASE::OnChangeAlpha ), NULL, this );
|
||||||
|
m_sliderTransparency->Connect( wxEVT_SCROLL_PAGEUP, wxScrollEventHandler( COLOR4D_PICKER_DLG_BASE::OnChangeAlpha ), NULL, this );
|
||||||
|
m_sliderTransparency->Connect( wxEVT_SCROLL_PAGEDOWN, wxScrollEventHandler( COLOR4D_PICKER_DLG_BASE::OnChangeAlpha ), NULL, this );
|
||||||
|
m_sliderTransparency->Connect( wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler( COLOR4D_PICKER_DLG_BASE::OnChangeAlpha ), NULL, this );
|
||||||
|
m_sliderTransparency->Connect( wxEVT_SCROLL_THUMBRELEASE, wxScrollEventHandler( COLOR4D_PICKER_DLG_BASE::OnChangeAlpha ), NULL, this );
|
||||||
|
m_sliderTransparency->Connect( wxEVT_SCROLL_CHANGED, wxScrollEventHandler( COLOR4D_PICKER_DLG_BASE::OnChangeAlpha ), NULL, this );
|
||||||
|
}
|
||||||
|
|
||||||
|
COLOR4D_PICKER_DLG_BASE::~COLOR4D_PICKER_DLG_BASE()
|
||||||
|
{
|
||||||
|
// Disconnect Events
|
||||||
|
m_RgbBitmap->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( COLOR4D_PICKER_DLG_BASE::onRGBMouseClick ), NULL, this );
|
||||||
|
m_RgbBitmap->Disconnect( wxEVT_MOTION, wxMouseEventHandler( COLOR4D_PICKER_DLG_BASE::onRGBMouseDrag ), NULL, this );
|
||||||
|
m_HsvBitmap->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( COLOR4D_PICKER_DLG_BASE::onHSVMouseClick ), NULL, this );
|
||||||
|
m_HsvBitmap->Disconnect( wxEVT_MOTION, wxMouseEventHandler( COLOR4D_PICKER_DLG_BASE::onHSVMouseDrag ), NULL, this );
|
||||||
|
m_sliderBrightness->Disconnect( wxEVT_SCROLL_TOP, wxScrollEventHandler( COLOR4D_PICKER_DLG_BASE::OnChangeBrightness ), NULL, this );
|
||||||
|
m_sliderBrightness->Disconnect( wxEVT_SCROLL_BOTTOM, wxScrollEventHandler( COLOR4D_PICKER_DLG_BASE::OnChangeBrightness ), NULL, this );
|
||||||
|
m_sliderBrightness->Disconnect( wxEVT_SCROLL_LINEUP, wxScrollEventHandler( COLOR4D_PICKER_DLG_BASE::OnChangeBrightness ), NULL, this );
|
||||||
|
m_sliderBrightness->Disconnect( wxEVT_SCROLL_LINEDOWN, wxScrollEventHandler( COLOR4D_PICKER_DLG_BASE::OnChangeBrightness ), NULL, this );
|
||||||
|
m_sliderBrightness->Disconnect( wxEVT_SCROLL_PAGEUP, wxScrollEventHandler( COLOR4D_PICKER_DLG_BASE::OnChangeBrightness ), NULL, this );
|
||||||
|
m_sliderBrightness->Disconnect( wxEVT_SCROLL_PAGEDOWN, wxScrollEventHandler( COLOR4D_PICKER_DLG_BASE::OnChangeBrightness ), NULL, this );
|
||||||
|
m_sliderBrightness->Disconnect( wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler( COLOR4D_PICKER_DLG_BASE::OnChangeBrightness ), NULL, this );
|
||||||
|
m_sliderBrightness->Disconnect( wxEVT_SCROLL_THUMBRELEASE, wxScrollEventHandler( COLOR4D_PICKER_DLG_BASE::OnChangeBrightness ), NULL, this );
|
||||||
|
m_sliderBrightness->Disconnect( wxEVT_SCROLL_CHANGED, wxScrollEventHandler( COLOR4D_PICKER_DLG_BASE::OnChangeBrightness ), NULL, this );
|
||||||
|
m_spinCtrlRed->Disconnect( wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler( COLOR4D_PICKER_DLG_BASE::OnChangeEditRed ), NULL, this );
|
||||||
|
m_spinCtrlGreen->Disconnect( wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler( COLOR4D_PICKER_DLG_BASE::OnChangeEditGreen ), NULL, this );
|
||||||
|
m_spinCtrlBlue->Disconnect( wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler( COLOR4D_PICKER_DLG_BASE::OnChangeEditBlue ), NULL, this );
|
||||||
|
m_spinCtrlHue->Disconnect( wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler( COLOR4D_PICKER_DLG_BASE::OnChangeEditHue ), NULL, this );
|
||||||
|
m_spinCtrlSaturation->Disconnect( wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler( COLOR4D_PICKER_DLG_BASE::OnChangeEditSat ), NULL, this );
|
||||||
|
m_sliderTransparency->Disconnect( wxEVT_SCROLL_TOP, wxScrollEventHandler( COLOR4D_PICKER_DLG_BASE::OnChangeAlpha ), NULL, this );
|
||||||
|
m_sliderTransparency->Disconnect( wxEVT_SCROLL_BOTTOM, wxScrollEventHandler( COLOR4D_PICKER_DLG_BASE::OnChangeAlpha ), NULL, this );
|
||||||
|
m_sliderTransparency->Disconnect( wxEVT_SCROLL_LINEUP, wxScrollEventHandler( COLOR4D_PICKER_DLG_BASE::OnChangeAlpha ), NULL, this );
|
||||||
|
m_sliderTransparency->Disconnect( wxEVT_SCROLL_LINEDOWN, wxScrollEventHandler( COLOR4D_PICKER_DLG_BASE::OnChangeAlpha ), NULL, this );
|
||||||
|
m_sliderTransparency->Disconnect( wxEVT_SCROLL_PAGEUP, wxScrollEventHandler( COLOR4D_PICKER_DLG_BASE::OnChangeAlpha ), NULL, this );
|
||||||
|
m_sliderTransparency->Disconnect( wxEVT_SCROLL_PAGEDOWN, wxScrollEventHandler( COLOR4D_PICKER_DLG_BASE::OnChangeAlpha ), NULL, this );
|
||||||
|
m_sliderTransparency->Disconnect( wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler( COLOR4D_PICKER_DLG_BASE::OnChangeAlpha ), NULL, this );
|
||||||
|
m_sliderTransparency->Disconnect( wxEVT_SCROLL_THUMBRELEASE, wxScrollEventHandler( COLOR4D_PICKER_DLG_BASE::OnChangeAlpha ), NULL, this );
|
||||||
|
m_sliderTransparency->Disconnect( wxEVT_SCROLL_CHANGED, wxScrollEventHandler( COLOR4D_PICKER_DLG_BASE::OnChangeAlpha ), NULL, this );
|
||||||
|
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,98 @@
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// C++ code generated with wxFormBuilder (version Jul 2 2017)
|
||||||
|
// http://www.wxformbuilder.org/
|
||||||
|
//
|
||||||
|
// PLEASE DO "NOT" EDIT THIS FILE!
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef __COLOR4DPICKERDLG_BASE_H__
|
||||||
|
#define __COLOR4DPICKERDLG_BASE_H__
|
||||||
|
|
||||||
|
#include <wx/artprov.h>
|
||||||
|
#include <wx/xrc/xmlres.h>
|
||||||
|
class DIALOG_SHIM;
|
||||||
|
|
||||||
|
#include "dialog_shim.h"
|
||||||
|
#include <wx/bitmap.h>
|
||||||
|
#include <wx/image.h>
|
||||||
|
#include <wx/icon.h>
|
||||||
|
#include <wx/statbmp.h>
|
||||||
|
#include <wx/gdicmn.h>
|
||||||
|
#include <wx/font.h>
|
||||||
|
#include <wx/colour.h>
|
||||||
|
#include <wx/settings.h>
|
||||||
|
#include <wx/string.h>
|
||||||
|
#include <wx/sizer.h>
|
||||||
|
#include <wx/statbox.h>
|
||||||
|
#include <wx/stattext.h>
|
||||||
|
#include <wx/slider.h>
|
||||||
|
#include <wx/spinctrl.h>
|
||||||
|
#include <wx/panel.h>
|
||||||
|
#include <wx/notebook.h>
|
||||||
|
#include <wx/statline.h>
|
||||||
|
#include <wx/button.h>
|
||||||
|
#include <wx/dialog.h>
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// Class COLOR4D_PICKER_DLG_BASE
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
class COLOR4D_PICKER_DLG_BASE : public DIALOG_SHIM
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
|
protected:
|
||||||
|
wxNotebook* m_notebook;
|
||||||
|
wxPanel* m_panelFreeColors;
|
||||||
|
wxStaticBitmap* m_RgbBitmap;
|
||||||
|
wxStaticBitmap* m_HsvBitmap;
|
||||||
|
wxStaticText* m_staticTextBright;
|
||||||
|
wxSlider* m_sliderBrightness;
|
||||||
|
wxStaticText* m_staticTextR;
|
||||||
|
wxStaticText* m_staticTextG;
|
||||||
|
wxStaticText* m_staticTextB;
|
||||||
|
wxSpinCtrl* m_spinCtrlRed;
|
||||||
|
wxSpinCtrl* m_spinCtrlGreen;
|
||||||
|
wxSpinCtrl* m_spinCtrlBlue;
|
||||||
|
wxStaticText* m_staticTextHue;
|
||||||
|
wxStaticText* m_staticTextSat;
|
||||||
|
wxSpinCtrl* m_spinCtrlHue;
|
||||||
|
wxSpinCtrl* m_spinCtrlSaturation;
|
||||||
|
wxPanel* m_panelDefinedColors;
|
||||||
|
wxBoxSizer* m_SizerDefinedColors;
|
||||||
|
wxFlexGridSizer* m_fgridColor;
|
||||||
|
wxStaticText* m_staticText9;
|
||||||
|
wxSlider* m_sliderTransparency;
|
||||||
|
wxStaticText* m_staticTextOldColor;
|
||||||
|
wxStaticBitmap* m_OldColorRect;
|
||||||
|
wxStaticText* m_staticTextNewColor;
|
||||||
|
wxStaticBitmap* m_NewColorRect;
|
||||||
|
wxStaticLine* m_staticline;
|
||||||
|
wxStdDialogButtonSizer* m_sdbSizer;
|
||||||
|
wxButton* m_sdbSizerOK;
|
||||||
|
wxButton* m_sdbSizerCancel;
|
||||||
|
|
||||||
|
// Virtual event handlers, overide them in your derived class
|
||||||
|
virtual void onRGBMouseClick( wxMouseEvent& event ) { event.Skip(); }
|
||||||
|
virtual void onRGBMouseDrag( wxMouseEvent& event ) { event.Skip(); }
|
||||||
|
virtual void onHSVMouseClick( wxMouseEvent& event ) { event.Skip(); }
|
||||||
|
virtual void onHSVMouseDrag( wxMouseEvent& event ) { event.Skip(); }
|
||||||
|
virtual void OnChangeBrightness( wxScrollEvent& event ) { event.Skip(); }
|
||||||
|
virtual void OnChangeEditRed( wxSpinEvent& event ) { event.Skip(); }
|
||||||
|
virtual void OnChangeEditGreen( wxSpinEvent& event ) { event.Skip(); }
|
||||||
|
virtual void OnChangeEditBlue( wxSpinEvent& event ) { event.Skip(); }
|
||||||
|
virtual void OnChangeEditHue( wxSpinEvent& event ) { event.Skip(); }
|
||||||
|
virtual void OnChangeEditSat( wxSpinEvent& event ) { event.Skip(); }
|
||||||
|
virtual void OnChangeAlpha( wxScrollEvent& event ) { event.Skip(); }
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
COLOR4D_PICKER_DLG_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Color Picker"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 707,406 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
|
||||||
|
~COLOR4D_PICKER_DLG_BASE();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //__COLOR4DPICKERDLG_BASE_H__
|
|
@ -23,9 +23,9 @@
|
||||||
|
|
||||||
#include <widgets/color_swatch.h>
|
#include <widgets/color_swatch.h>
|
||||||
|
|
||||||
#include <wx/colour.h>
|
//#include <wx/colour.h>
|
||||||
#include <wx/colordlg.h>
|
//#include <wx/colordlg.h>
|
||||||
|
#include <color4Dpickerdlg.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
wxDEFINE_EVENT(COLOR_SWATCH_CHANGED, wxCommandEvent);
|
wxDEFINE_EVENT(COLOR_SWATCH_CHANGED, wxCommandEvent);
|
||||||
|
@ -150,22 +150,13 @@ void COLOR_SWATCH::GetNewSwatchColor()
|
||||||
|
|
||||||
if( m_arbitraryColors )
|
if( m_arbitraryColors )
|
||||||
{
|
{
|
||||||
wxColourData colourData;
|
COLOR4D_PICKER_DLG dialog( this, m_color );
|
||||||
colourData.SetColour( m_color.ToColour() );
|
|
||||||
// Has effect only on Windows: shows the full color dialog
|
|
||||||
colourData.SetChooseFull(true);
|
|
||||||
|
|
||||||
wxColourDialog dialog( this, &colourData );
|
|
||||||
|
|
||||||
if( dialog.ShowModal() == wxID_OK )
|
if( dialog.ShowModal() == wxID_OK )
|
||||||
{
|
newColor = COLOR4D( dialog.GetColor() );
|
||||||
newColor = COLOR4D( dialog.GetColourData().GetColour() );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
newColor = DisplayColorFrame( this, m_color );
|
newColor = DisplayColorFrame( this, m_color );
|
||||||
}
|
|
||||||
|
|
||||||
if( newColor != COLOR4D::UNSPECIFIED )
|
if( newColor != COLOR4D::UNSPECIFIED )
|
||||||
{
|
{
|
||||||
|
|
|
@ -69,7 +69,11 @@ void PCB_RENDER_SETTINGS::ImportLegacyColors( const COLORS_DESIGN_SETTINGS* aSet
|
||||||
for( int i = 0; i < PCB_LAYER_ID_COUNT; i++ )
|
for( int i = 0; i < PCB_LAYER_ID_COUNT; i++ )
|
||||||
{
|
{
|
||||||
m_layerColors[i] = aSettings->GetLayerColor( i );
|
m_layerColors[i] = aSettings->GetLayerColor( i );
|
||||||
m_layerColors[i].a = 0.8; // slightly transparent
|
|
||||||
|
// Guard: if the alpah channel is too small, the layer is not visible.
|
||||||
|
// clamp it to 0.2
|
||||||
|
if( m_layerColors[i].a < 0.2 )
|
||||||
|
m_layerColors[i].a = 0.2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init specific graphic layers colors:
|
// Init specific graphic layers colors:
|
||||||
|
|
|
@ -737,7 +737,8 @@ void PCB_EDIT_FRAME::forceColorsToLegacy()
|
||||||
{
|
{
|
||||||
COLOR4D c = cds->GetLayerColor( i );
|
COLOR4D c = cds->GetLayerColor( i );
|
||||||
c.SetToNearestLegacyColor();
|
c.SetToNearestLegacyColor();
|
||||||
c.a = 0.8;
|
// Note the alpha chanel is not modified. Therefore the value
|
||||||
|
// is the previous value used in GAL canvas.
|
||||||
cds->SetLayerColor( i, c );
|
cds->SetLayerColor( i, c );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue