Refinements if new color 4D selector
This commit is contained in:
parent
8debf32079
commit
cb75b72978
|
@ -580,49 +580,37 @@ void COLOR4D_PICKER_DLG::onRGBMouseDrag( wxMouseEvent& event )
|
|||
|
||||
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;
|
||||
if( setHSvaluesFromCursor( event.GetPosition() ) )
|
||||
drawAll();
|
||||
}
|
||||
|
||||
|
||||
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();
|
||||
if( setHSvaluesFromCursor( event.GetPosition() ) )
|
||||
drawAll();
|
||||
}
|
||||
|
||||
|
||||
bool COLOR4D_PICKER_DLG::setHSvaluesFromCursor( wxPoint aMouseCursor )
|
||||
{
|
||||
wxPoint mousePos = aMouseCursor;
|
||||
wxSize bmsize = m_bitmapHSV->GetSize();
|
||||
int half_size = std::min( bmsize.x, bmsize.y )/2;
|
||||
// Make the cursor position relative to the m_bitmapHSV wxBitmap center
|
||||
mousePos.x -= half_size;
|
||||
mousePos.y -= half_size;
|
||||
mousePos.y = -mousePos.y; // Use the bottom to top vertical axis
|
||||
mousePos.y = -mousePos.y; // Use the bottom to top vertical axis
|
||||
|
||||
// The HSV cursor position is restricted to a circle of radius half_size
|
||||
// The HS 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;
|
||||
// Saturation cannot be calculated:
|
||||
return false;
|
||||
|
||||
m_cursorBitmapHSV = mousePos;
|
||||
|
||||
|
@ -641,7 +629,7 @@ void COLOR4D_PICKER_DLG::onHSVMouseDrag( wxMouseEvent& event )
|
|||
m_newColor4D.FromHSV( m_hue, m_sat, m_val );
|
||||
SetEditVals( ALL_CHANGED );
|
||||
|
||||
drawAll();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -81,6 +81,15 @@ private:
|
|||
void onHSVMouseClick( wxMouseEvent& event ) override;
|
||||
void onHSVMouseDrag( wxMouseEvent& event ) override;
|
||||
|
||||
/** manage the Hue and Saturation settings when the mouse cursor
|
||||
* is at aMouseCursor.
|
||||
* @param aMouseCursor is the mouse cursor position on the HSV bitmap
|
||||
* @return true if the Hue and Saturation can be set from aMouseCursor,
|
||||
* if Saturation value computed from aMouseCursor is <= 1.0,
|
||||
* and false if aMouseCursor is outside this area.
|
||||
*/
|
||||
bool setHSvaluesFromCursor( wxPoint aMouseCursor );
|
||||
|
||||
///> Event handler for defined color buttons
|
||||
void buttColorClick( wxCommandEvent& event );
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ COLOR4D_PICKER_DLG_BASE::COLOR4D_PICKER_DLG_BASE( wxWindow* parent, wxWindowID i
|
|||
bSizerPanels->Add( sbSizerViewRGB, 1, wxEXPAND|wxBOTTOM|wxRIGHT, 5 );
|
||||
|
||||
wxStaticBoxSizer* sbSizerViewHSV;
|
||||
sbSizerViewHSV = new wxStaticBoxSizer( new wxStaticBox( m_panelFreeColors, wxID_ANY, wxT("HSV") ), wxVERTICAL );
|
||||
sbSizerViewHSV = new wxStaticBoxSizer( new wxStaticBox( m_panelFreeColors, wxID_ANY, wxT("Hue and Saturation") ), wxVERTICAL );
|
||||
|
||||
|
||||
sbSizerViewHSV->Add( 0, 0, 1, wxEXPAND|wxALIGN_CENTER_HORIZONTAL, 5 );
|
||||
|
@ -125,36 +125,35 @@ COLOR4D_PICKER_DLG_BASE::COLOR4D_PICKER_DLG_BASE( wxWindow* parent, wxWindowID i
|
|||
bSizerLowerFreeColors->Add( sbSizerSetRGB, 1, wxEXPAND, 5 );
|
||||
|
||||
wxStaticBoxSizer* sbSizerSetHSV;
|
||||
sbSizerSetHSV = new wxStaticBoxSizer( new wxStaticBox( m_panelFreeColors, wxID_ANY, wxT("RGB Values") ), wxHORIZONTAL );
|
||||
sbSizerSetHSV = new wxStaticBoxSizer( new wxStaticBox( m_panelFreeColors, wxID_ANY, wxT("HS 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 );
|
||||
wxFlexGridSizer* fgSizerHSV;
|
||||
fgSizerHSV = new wxFlexGridSizer( 0, 2, 0, 0 );
|
||||
fgSizerHSV->AddGrowableCol( 0 );
|
||||
fgSizerHSV->AddGrowableCol( 1 );
|
||||
fgSizerHSV->SetFlexibleDirection( wxBOTH );
|
||||
fgSizerHSV->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 );
|
||||
fgSizerHSV->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 );
|
||||
fgSizerHSV->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 );
|
||||
fgSizerHSV->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 );
|
||||
fgSizerHSV->Add( m_spinCtrlSaturation, 0, wxALL|wxEXPAND, 5 );
|
||||
|
||||
|
||||
sbSizerSetHSV->Add( fgSizerHSB, 1, wxEXPAND, 5 );
|
||||
sbSizerSetHSV->Add( fgSizerHSV, 1, wxEXPAND, 5 );
|
||||
|
||||
|
||||
bSizerLowerFreeColors->Add( sbSizerSetHSV, 1, wxEXPAND, 5 );
|
||||
|
@ -166,7 +165,7 @@ COLOR4D_PICKER_DLG_BASE::COLOR4D_PICKER_DLG_BASE( wxWindow* parent, wxWindowID i
|
|||
m_panelFreeColors->SetSizer( bSizerUpperFreeColors );
|
||||
m_panelFreeColors->Layout();
|
||||
bSizerUpperFreeColors->Fit( m_panelFreeColors );
|
||||
m_notebook->AddPage( m_panelFreeColors, wxT("Color Picker"), false );
|
||||
m_notebook->AddPage( m_panelFreeColors, wxT("Color Picker"), true );
|
||||
m_panelDefinedColors = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
|
||||
m_SizerDefinedColors = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
|
@ -192,7 +191,7 @@ COLOR4D_PICKER_DLG_BASE::COLOR4D_PICKER_DLG_BASE( wxWindow* parent, wxWindowID i
|
|||
m_panelDefinedColors->SetSizer( m_SizerDefinedColors );
|
||||
m_panelDefinedColors->Layout();
|
||||
m_SizerDefinedColors->Fit( m_panelDefinedColors );
|
||||
m_notebook->AddPage( m_panelDefinedColors, wxT("Defined Colors"), true );
|
||||
m_notebook->AddPage( m_panelDefinedColors, wxT("Defined Colors"), false );
|
||||
|
||||
bSizerUpperMain->Add( m_notebook, 1, wxEXPAND | wxALL, 5 );
|
||||
|
||||
|
|
|
@ -187,7 +187,7 @@
|
|||
<object class="notebookpage" expanded="1">
|
||||
<property name="bitmap"></property>
|
||||
<property name="label">Color Picker</property>
|
||||
<property name="select">0</property>
|
||||
<property name="select">1</property>
|
||||
<object class="wxPanel" expanded="1">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
|
@ -398,7 +398,7 @@
|
|||
<property name="proportion">1</property>
|
||||
<object class="wxStaticBoxSizer" expanded="1">
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="label">HSV</property>
|
||||
<property name="label">Hue and Saturation</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="name">sbSizerViewHSV</property>
|
||||
<property name="orient">wxVERTICAL</property>
|
||||
|
@ -1273,7 +1273,7 @@
|
|||
<property name="proportion">1</property>
|
||||
<object class="wxStaticBoxSizer" expanded="1">
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="label">RGB Values</property>
|
||||
<property name="label">HS Values</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="name">sbSizerSetHSV</property>
|
||||
<property name="orient">wxHORIZONTAL</property>
|
||||
|
@ -1287,11 +1287,11 @@
|
|||
<object class="wxFlexGridSizer" expanded="1">
|
||||
<property name="cols">2</property>
|
||||
<property name="flexible_direction">wxBOTH</property>
|
||||
<property name="growablecols">0,1,2</property>
|
||||
<property name="growablecols">0,1</property>
|
||||
<property name="growablerows"></property>
|
||||
<property name="hgap">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="name">fgSizerHSB</property>
|
||||
<property name="name">fgSizerHSV</property>
|
||||
<property name="non_flexible_grow_mode">wxFLEX_GROWMODE_SPECIFIED</property>
|
||||
<property name="permission">none</property>
|
||||
<property name="rows">0</property>
|
||||
|
@ -1650,7 +1650,7 @@
|
|||
<object class="notebookpage" expanded="1">
|
||||
<property name="bitmap"></property>
|
||||
<property name="label">Defined Colors</property>
|
||||
<property name="select">1</property>
|
||||
<property name="select">0</property>
|
||||
<object class="wxPanel" expanded="1">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
|
|
Loading…
Reference in New Issue