Make color picker dialog usable on hidpi monitors.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17860
This commit is contained in:
Alex Shvartzkop 2024-05-25 04:13:10 +03:00
parent e9fde0051f
commit 894bf45480
5 changed files with 1832 additions and 1791 deletions

View File

@ -1,7 +1,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2018-2022 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2018-2024 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software: you can redistribute it and/or modify it * This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
@ -28,6 +28,7 @@
#include <wx/dcmemory.h> #include <wx/dcmemory.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
#define SLOPE_AXIS ( bmsize.y / 5.28 ) // was 50 at 264 size
using KIGFX::COLOR4D; using KIGFX::COLOR4D;
@ -52,13 +53,17 @@ DIALOG_COLOR_PICKER::DIALOG_COLOR_PICKER( wxWindow* aParent, const COLOR4D& aCur
m_allowOpacityCtrl = aAllowOpacityControl; m_allowOpacityCtrl = aAllowOpacityControl;
m_previousColor4D = aCurrentColor; m_previousColor4D = aCurrentColor;
m_newColor4D = 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_newColor4D.ToHSV( m_hue, m_sat, m_val, true );
m_bitmapRGB = nullptr; m_bitmapRGB = nullptr;
m_bitmapHSV = nullptr; m_bitmapHSV = nullptr;
m_selectedCursor = nullptr; m_selectedCursor = nullptr;
m_defaultColor = aDefaultColor; m_defaultColor = aDefaultColor;
updateHandleSize();
m_OldColorRect->SetMinSize( FromDIP( wxSize( 24, 24 ) ) );
m_NewColorRect->SetMinSize( FromDIP( wxSize( 24, 24 ) ) );
if( !m_allowOpacityCtrl ) if( !m_allowOpacityCtrl )
{ {
m_SizerTransparency->Show( false ); m_SizerTransparency->Show( false );
@ -121,16 +126,15 @@ void DIALOG_COLOR_PICKER::updatePreview( wxStaticBitmap* aStaticBitmap, COLOR4D&
wxBitmap newBm = COLOR_SWATCH::MakeBitmap( aColor4D, COLOR4D::WHITE, aStaticBitmap->GetSize(), wxBitmap newBm = COLOR_SWATCH::MakeBitmap( aColor4D, COLOR4D::WHITE, aStaticBitmap->GetSize(),
ConvertDialogToPixels( CHECKERBOARD_SIZE_DU ), ConvertDialogToPixels( CHECKERBOARD_SIZE_DU ),
aStaticBitmap->GetParent()->GetBackgroundColour() ); aStaticBitmap->GetParent()->GetBackgroundColour() );
newBm.SetScaleFactor( GetDPIScaleFactor() );
aStaticBitmap->SetBitmap( newBm ); aStaticBitmap->SetBitmap( newBm );
} }
bool DIALOG_COLOR_PICKER::TransferDataToWindow() bool DIALOG_COLOR_PICKER::TransferDataToWindow()
{ {
// Draw all bitmaps, with colors according to the color 4D
updatePreview( m_OldColorRect, m_previousColor4D );
SetEditVals( ALL_CHANGED, false ); SetEditVals( ALL_CHANGED, false );
drawAll();
// Configure the spin control sizes // Configure the spin control sizes
configureSpinCtrl( m_spinCtrlGreen ); configureSpinCtrl( m_spinCtrlGreen );
@ -144,6 +148,10 @@ bool DIALOG_COLOR_PICKER::TransferDataToWindow()
finishDialogSettings(); finishDialogSettings();
// Draw all bitmaps, with colors according to the color 4D
updatePreview( m_OldColorRect, m_previousColor4D );
drawAll();
return true; return true;
} }
@ -171,6 +179,8 @@ void DIALOG_COLOR_PICKER::initDefinedColors( CUSTOM_COLORS_LIST* aPredefinedColo
{ {
wxBitmap bm = COLOR_SWATCH::MakeBitmap( aColor, COLOR4D::WHITE, swatchSize, wxBitmap bm = COLOR_SWATCH::MakeBitmap( aColor, COLOR4D::WHITE, swatchSize,
checkerboardSize, checkboardBackground ); checkerboardSize, checkboardBackground );
bm.SetScaleFactor( GetDPIScaleFactor() );
wxStaticBitmap* swatch = new wxStaticBitmap( m_panelDefinedColors, aId, bm ); wxStaticBitmap* swatch = new wxStaticBitmap( m_panelDefinedColors, aId, bm );
m_fgridColor->Add( swatch, 0, wxALIGN_CENTER_VERTICAL, 5 ); m_fgridColor->Add( swatch, 0, wxALIGN_CENTER_VERTICAL, 5 );
@ -245,7 +255,6 @@ void DIALOG_COLOR_PICKER::createRGBBitmap()
// Red blue area in X Z 3d axis // Red blue area in X Z 3d axis
double inc = 255.0 / half_size; double inc = 255.0 / half_size;
#define SLOPE_AXIS 50.0
double slope = SLOPE_AXIS/half_size; double slope = SLOPE_AXIS/half_size;
color.g = 0.0; color.g = 0.0;
@ -315,6 +324,7 @@ void DIALOG_COLOR_PICKER::createRGBBitmap()
delete m_bitmapRGB; delete m_bitmapRGB;
m_bitmapRGB = new wxBitmap( img, 24 ); m_bitmapRGB = new wxBitmap( img, 24 );
m_bitmapRGB->SetScaleFactor( m_RgbBitmap->GetDPIScaleFactor() );
m_RgbBitmap->SetBitmap( *m_bitmapRGB ); m_RgbBitmap->SetBitmap( *m_bitmapRGB );
} }
@ -379,6 +389,7 @@ void DIALOG_COLOR_PICKER::createHSVBitmap()
delete m_bitmapHSV; delete m_bitmapHSV;
m_bitmapHSV = new wxBitmap( img, 24 ); m_bitmapHSV = new wxBitmap( img, 24 );
m_bitmapHSV->SetScaleFactor( m_HsvBitmap->GetDPIScaleFactor() );
m_HsvBitmap->SetBitmap( *m_bitmapHSV ); m_HsvBitmap->SetBitmap( *m_bitmapHSV );
} }
@ -413,8 +424,7 @@ void DIALOG_COLOR_PICKER::drawRGBPalette()
bitmapDC.SetBrush( brush ); bitmapDC.SetBrush( brush );
int half_csize = m_cursorsSize / 2; int half_csize = m_cursorsSize / 2;
#define SLOPE_AXIS 50.0 double slope = SLOPE_AXIS / ( half_size );
double slope = SLOPE_AXIS / half_size;
// Red axis cursor (Z 3Daxis): // Red axis cursor (Z 3Daxis):
m_cursorBitmapRed.x = 0; m_cursorBitmapRed.x = 0;
@ -539,8 +549,15 @@ void DIALOG_COLOR_PICKER::SetEditVals( CHANGED_COLOR aChanged, bool aCheckTransp
} }
void DIALOG_COLOR_PICKER::updateHandleSize()
{
m_cursorsSize = FromDIP( 8 ); // Size of square cursors drawn on color bitmaps
}
void DIALOG_COLOR_PICKER::drawAll() void DIALOG_COLOR_PICKER::drawAll()
{ {
updateHandleSize();
m_NewColorRect->Freeze(); // Avoid flicker m_NewColorRect->Freeze(); // Avoid flicker
m_HsvBitmap->Freeze(); m_HsvBitmap->Freeze();
m_RgbBitmap->Freeze(); m_RgbBitmap->Freeze();
@ -699,6 +716,14 @@ void DIALOG_COLOR_PICKER::onHSVMouseDrag( wxMouseEvent& event )
} }
void DIALOG_COLOR_PICKER::onSize( wxSizeEvent& event )
{
drawAll();
event.Skip();
}
void DIALOG_COLOR_PICKER::OnColorValueText( wxCommandEvent& event ) void DIALOG_COLOR_PICKER::OnColorValueText( wxCommandEvent& event )
{ {
if( m_newColor4D.SetFromHexString( m_colorValue->GetValue() ) ) if( m_newColor4D.SetFromHexString( m_colorValue->GetValue() ) )

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b) // C++ code generated with wxFormBuilder (version 4.1.0-0-g733bf3d)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO *NOT* EDIT THIS FILE! // PLEASE DO *NOT* EDIT THIS FILE!
@ -33,7 +33,10 @@ DIALOG_COLOR_PICKER_BASE::DIALOG_COLOR_PICKER_BASE( wxWindow* parent, wxWindowID
m_RgbBitmap = new wxStaticBitmap( sbSizerViewRGB->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 264,264 ), 0 ); m_RgbBitmap = new wxStaticBitmap( sbSizerViewRGB->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 264,264 ), 0 );
m_RgbBitmap->SetMinSize( wxSize( 264,264 ) ); m_RgbBitmap->SetMinSize( wxSize( 264,264 ) );
sbSizerViewRGB->Add( m_RgbBitmap, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 ); sbSizerViewRGB->Add( m_RgbBitmap, 0, wxALIGN_CENTER_HORIZONTAL|wxALL|wxEXPAND|wxSHAPED, 5 );
sbSizerViewRGB->Add( 0, 0, 1, wxEXPAND, 5 );
wxFlexGridSizer* fgSizerRGB; wxFlexGridSizer* fgSizerRGB;
fgSizerRGB = new wxFlexGridSizer( 0, 3, 0, 0 ); fgSizerRGB = new wxFlexGridSizer( 0, 3, 0, 0 );
@ -68,18 +71,18 @@ DIALOG_COLOR_PICKER_BASE::DIALOG_COLOR_PICKER_BASE( wxWindow* parent, wxWindowID
sbSizerViewRGB->Add( fgSizerRGB, 0, wxEXPAND, 5 ); sbSizerViewRGB->Add( fgSizerRGB, 0, wxEXPAND, 5 );
bSizerPanels->Add( sbSizerViewRGB, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); bSizerPanels->Add( sbSizerViewRGB, 1, wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT, 5 );
wxStaticBoxSizer* sbSizerViewHSV; wxStaticBoxSizer* sbSizerViewHSV;
sbSizerViewHSV = new wxStaticBoxSizer( new wxStaticBox( m_panelFreeColors, wxID_ANY, _("HSV") ), wxHORIZONTAL ); sbSizerViewHSV = new wxStaticBoxSizer( new wxStaticBox( m_panelFreeColors, wxID_ANY, _("HSV") ), wxVERTICAL );
wxBoxSizer* bSizer10;
bSizer10 = new wxBoxSizer( wxVERTICAL );
m_HsvBitmap = new wxStaticBitmap( sbSizerViewHSV->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 264,264 ), 0 ); m_HsvBitmap = new wxStaticBitmap( sbSizerViewHSV->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 264,264 ), 0 );
m_HsvBitmap->SetMinSize( wxSize( 264,264 ) ); m_HsvBitmap->SetMinSize( wxSize( 264,264 ) );
bSizer10->Add( m_HsvBitmap, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 ); sbSizerViewHSV->Add( m_HsvBitmap, 0, wxALIGN_CENTER_HORIZONTAL|wxALL|wxEXPAND|wxSHAPED, 5 );
sbSizerViewHSV->Add( 0, 0, 1, wxEXPAND, 5 );
wxFlexGridSizer* fgSizerHSV; wxFlexGridSizer* fgSizerHSV;
fgSizerHSV = new wxFlexGridSizer( 0, 2, 0, 0 ); fgSizerHSV = new wxFlexGridSizer( 0, 2, 0, 0 );
@ -103,26 +106,23 @@ DIALOG_COLOR_PICKER_BASE::DIALOG_COLOR_PICKER_BASE( wxWindow* parent, wxWindowID
fgSizerHSV->Add( m_spinCtrlSaturation, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); fgSizerHSV->Add( m_spinCtrlSaturation, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
bSizer10->Add( fgSizerHSV, 0, wxEXPAND, 5 ); sbSizerViewHSV->Add( fgSizerHSV, 0, wxEXPAND, 5 );
sbSizerViewHSV->Add( bSizer10, 0, wxEXPAND, 5 ); bSizerPanels->Add( sbSizerViewHSV, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
wxBoxSizer* bSizerBright; wxBoxSizer* bSizerBright;
bSizerBright = new wxBoxSizer( wxVERTICAL ); bSizerBright = new wxBoxSizer( wxVERTICAL );
m_staticTextBright = new wxStaticText( sbSizerViewHSV->GetStaticBox(), wxID_ANY, _("Value:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextBright = new wxStaticText( m_panelFreeColors, wxID_ANY, _("Value:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextBright->Wrap( -1 ); m_staticTextBright->Wrap( -1 );
bSizerBright->Add( m_staticTextBright, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 ); bSizerBright->Add( m_staticTextBright, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );
m_sliderBrightness = new wxSlider( sbSizerViewHSV->GetStaticBox(), wxID_ANY, 255, 0, 255, wxDefaultPosition, wxDefaultSize, wxSL_INVERSE|wxSL_LABELS|wxSL_LEFT|wxSL_VERTICAL ); m_sliderBrightness = new wxSlider( m_panelFreeColors, wxID_ANY, 255, 0, 255, wxDefaultPosition, wxDefaultSize, wxSL_INVERSE|wxSL_LABELS|wxSL_LEFT|wxSL_VERTICAL );
bSizerBright->Add( m_sliderBrightness, 1, wxALIGN_CENTER_HORIZONTAL|wxRIGHT|wxTOP, 5 ); bSizerBright->Add( m_sliderBrightness, 1, wxALIGN_CENTER_HORIZONTAL|wxRIGHT|wxTOP, 5 );
sbSizerViewHSV->Add( bSizerBright, 0, wxEXPAND, 5 ); bSizerPanels->Add( bSizerBright, 0, wxALL|wxEXPAND, 5 );
bSizerPanels->Add( sbSizerViewHSV, 0, wxEXPAND|wxBOTTOM|wxRIGHT, 5 );
bSizerUpperFreeColors->Add( bSizerPanels, 1, wxEXPAND, 5 ); bSizerUpperFreeColors->Add( bSizerPanels, 1, wxEXPAND, 5 );
@ -153,7 +153,7 @@ DIALOG_COLOR_PICKER_BASE::DIALOG_COLOR_PICKER_BASE( wxWindow* parent, wxWindowID
m_SizerDefinedColors->Fit( m_panelDefinedColors ); m_SizerDefinedColors->Fit( m_panelDefinedColors );
m_notebook->AddPage( m_panelDefinedColors, _("Defined Colors"), false ); m_notebook->AddPage( m_panelDefinedColors, _("Defined Colors"), false );
bSizerUpperMain->Add( m_notebook, 0, wxEXPAND | wxALL, 5 ); bSizerUpperMain->Add( m_notebook, 1, wxEXPAND | wxALL, 5 );
m_SizerTransparency = new wxBoxSizer( wxVERTICAL ); m_SizerTransparency = new wxBoxSizer( wxVERTICAL );
@ -171,35 +171,29 @@ DIALOG_COLOR_PICKER_BASE::DIALOG_COLOR_PICKER_BASE( wxWindow* parent, wxWindowID
bSizerUpperMain->Add( m_SizerTransparency, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); bSizerUpperMain->Add( m_SizerTransparency, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 );
bSizerUpperMain->Add( 0, 0, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 ); bSizerMain->Add( bSizerUpperMain, 1, wxEXPAND, 5 );
bSizerMain->Add( bSizerUpperMain, 0, wxEXPAND, 5 );
wxBoxSizer* bButtonsSizer; wxBoxSizer* bButtonsSizer;
bButtonsSizer = new wxBoxSizer( wxHORIZONTAL ); bButtonsSizer = new wxBoxSizer( wxHORIZONTAL );
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|wxRIGHT|wxLEFT, 5 ); bButtonsSizer->Add( m_staticTextOldColor, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 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( 24,24 ) ); m_OldColorRect->SetMinSize( wxSize( 24,24 ) );
bButtonsSizer->Add( m_OldColorRect, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); bButtonsSizer->Add( m_OldColorRect, 0, wxALIGN_CENTER_VERTICAL|wxSHAPED, 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( 24,24 ) ); m_NewColorRect->SetMinSize( wxSize( 24,24 ) );
bButtonsSizer->Add( m_NewColorRect, 0, wxALIGN_CENTER_VERTICAL, 5 ); bButtonsSizer->Add( m_NewColorRect, 0, wxALIGN_CENTER_VERTICAL|wxSHAPED, 5 );
bButtonsSizer->Add( 10, 0, 0, wxEXPAND, 5 );
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, 5 ); bButtonsSizer->Add( m_colorValue, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
bButtonsSizer->Add( 20, 0, 0, wxEXPAND, 5 ); bButtonsSizer->Add( 20, 0, 0, wxEXPAND, 5 );
@ -217,7 +211,7 @@ DIALOG_COLOR_PICKER_BASE::DIALOG_COLOR_PICKER_BASE( wxWindow* parent, wxWindowID
bButtonsSizer->Add( m_sdbSizer, 1, wxALL, 5 ); bButtonsSizer->Add( m_sdbSizer, 1, wxALL, 5 );
bSizerMain->Add( bButtonsSizer, 1, wxEXPAND|wxLEFT, 10 ); bSizerMain->Add( bButtonsSizer, 0, wxEXPAND|wxLEFT, 10 );
this->SetSizer( bSizerMain ); this->SetSizer( bSizerMain );
@ -234,6 +228,7 @@ DIALOG_COLOR_PICKER_BASE::DIALOG_COLOR_PICKER_BASE( wxWindow* parent, wxWindowID
m_spinCtrlBlue->Connect( wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler( DIALOG_COLOR_PICKER_BASE::OnChangeEditBlue ), NULL, this ); m_spinCtrlBlue->Connect( wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler( DIALOG_COLOR_PICKER_BASE::OnChangeEditBlue ), NULL, this );
m_HsvBitmap->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_COLOR_PICKER_BASE::onHSVMouseClick ), NULL, this ); m_HsvBitmap->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_COLOR_PICKER_BASE::onHSVMouseClick ), NULL, this );
m_HsvBitmap->Connect( wxEVT_MOTION, wxMouseEventHandler( DIALOG_COLOR_PICKER_BASE::onHSVMouseDrag ), NULL, this ); m_HsvBitmap->Connect( wxEVT_MOTION, wxMouseEventHandler( DIALOG_COLOR_PICKER_BASE::onHSVMouseDrag ), NULL, this );
m_HsvBitmap->Connect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_COLOR_PICKER_BASE::onSize ), NULL, this );
m_spinCtrlHue->Connect( wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler( DIALOG_COLOR_PICKER_BASE::OnChangeEditHue ), NULL, this ); m_spinCtrlHue->Connect( wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler( DIALOG_COLOR_PICKER_BASE::OnChangeEditHue ), NULL, this );
m_spinCtrlSaturation->Connect( wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler( DIALOG_COLOR_PICKER_BASE::OnChangeEditSat ), NULL, this ); m_spinCtrlSaturation->Connect( wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler( DIALOG_COLOR_PICKER_BASE::OnChangeEditSat ), NULL, this );
m_sliderBrightness->Connect( wxEVT_SCROLL_TOP, wxScrollEventHandler( DIALOG_COLOR_PICKER_BASE::OnChangeBrightness ), NULL, this ); m_sliderBrightness->Connect( wxEVT_SCROLL_TOP, wxScrollEventHandler( DIALOG_COLOR_PICKER_BASE::OnChangeBrightness ), NULL, this );
@ -268,6 +263,7 @@ DIALOG_COLOR_PICKER_BASE::~DIALOG_COLOR_PICKER_BASE()
m_spinCtrlBlue->Disconnect( wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler( DIALOG_COLOR_PICKER_BASE::OnChangeEditBlue ), NULL, this ); m_spinCtrlBlue->Disconnect( wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler( DIALOG_COLOR_PICKER_BASE::OnChangeEditBlue ), NULL, this );
m_HsvBitmap->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_COLOR_PICKER_BASE::onHSVMouseClick ), NULL, this ); m_HsvBitmap->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_COLOR_PICKER_BASE::onHSVMouseClick ), NULL, this );
m_HsvBitmap->Disconnect( wxEVT_MOTION, wxMouseEventHandler( DIALOG_COLOR_PICKER_BASE::onHSVMouseDrag ), NULL, this ); m_HsvBitmap->Disconnect( wxEVT_MOTION, wxMouseEventHandler( DIALOG_COLOR_PICKER_BASE::onHSVMouseDrag ), NULL, this );
m_HsvBitmap->Disconnect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_COLOR_PICKER_BASE::onSize ), NULL, this );
m_spinCtrlHue->Disconnect( wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler( DIALOG_COLOR_PICKER_BASE::OnChangeEditHue ), NULL, this ); m_spinCtrlHue->Disconnect( wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler( DIALOG_COLOR_PICKER_BASE::OnChangeEditHue ), NULL, this );
m_spinCtrlSaturation->Disconnect( wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler( DIALOG_COLOR_PICKER_BASE::OnChangeEditSat ), NULL, this ); m_spinCtrlSaturation->Disconnect( wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEventHandler( DIALOG_COLOR_PICKER_BASE::OnChangeEditSat ), NULL, this );
m_sliderBrightness->Disconnect( wxEVT_SCROLL_TOP, wxScrollEventHandler( DIALOG_COLOR_PICKER_BASE::OnChangeBrightness ), NULL, this ); m_sliderBrightness->Disconnect( wxEVT_SCROLL_TOP, wxScrollEventHandler( DIALOG_COLOR_PICKER_BASE::OnChangeBrightness ), NULL, this );

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b) // C++ code generated with wxFormBuilder (version 4.1.0-0-g733bf3d)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO *NOT* EDIT THIS FILE! // PLEASE DO *NOT* EDIT THIS FILE!
@ -81,6 +81,7 @@ class DIALOG_COLOR_PICKER_BASE : public DIALOG_SHIM
virtual void OnChangeEditBlue( wxSpinEvent& event ) { event.Skip(); } virtual void OnChangeEditBlue( wxSpinEvent& event ) { event.Skip(); }
virtual void onHSVMouseClick( wxMouseEvent& event ) { event.Skip(); } virtual void onHSVMouseClick( wxMouseEvent& event ) { event.Skip(); }
virtual void onHSVMouseDrag( wxMouseEvent& event ) { event.Skip(); } virtual void onHSVMouseDrag( wxMouseEvent& event ) { event.Skip(); }
virtual void onSize( wxSizeEvent& event ) { event.Skip(); }
virtual void OnChangeEditHue( wxSpinEvent& event ) { event.Skip(); } virtual void OnChangeEditHue( wxSpinEvent& event ) { event.Skip(); }
virtual void OnChangeEditSat( wxSpinEvent& event ) { event.Skip(); } virtual void OnChangeEditSat( wxSpinEvent& event ) { event.Skip(); }
virtual void OnChangeBrightness( wxScrollEvent& event ) { event.Skip(); } virtual void OnChangeBrightness( wxScrollEvent& event ) { event.Skip(); }

View File

@ -1,7 +1,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2018-2021 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2018-2024 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software: you can redistribute it and/or modify it * This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
@ -156,6 +156,8 @@ private:
void onHSVMouseClick( wxMouseEvent& event ) override; void onHSVMouseClick( wxMouseEvent& event ) override;
void onHSVMouseDrag( wxMouseEvent& event ) override; void onHSVMouseDrag( wxMouseEvent& event ) override;
void onSize( wxSizeEvent& event ) override;
void OnColorValueText( wxCommandEvent& event ) override; void OnColorValueText( wxCommandEvent& event ) override;
///< Event handler for the reset button press ///< Event handler for the reset button press
@ -187,6 +189,8 @@ private:
*/ */
void initDefinedColors( CUSTOM_COLORS_LIST* aPredefinedColors ); void initDefinedColors( CUSTOM_COLORS_LIST* aPredefinedColors );
void updateHandleSize();
// convert double value 0 ... 1 to int 0 ... aValMax // convert double value 0 ... 1 to int 0 ... aValMax
int normalizeToInt( double aValue, int aValMax = 255 ) int normalizeToInt( double aValue, int aValMax = 255 )
{ {