Properties: Use color picker dialog
This commit is contained in:
parent
a2ff3bce7d
commit
c7f6b20405
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include <macros.h>
|
||||
#include <validators.h>
|
||||
#include <dialogs/dialog_color_picker.h>
|
||||
#include <eda_draw_frame.h>
|
||||
#include <eda_units.h>
|
||||
#include <properties/color4d_variant.h>
|
||||
|
@ -407,7 +408,7 @@ const wxPGEditor* PGPROPERTY_BOOL::DoGetEditorClass() const
|
|||
|
||||
PGPROPERTY_COLOR4D::PGPROPERTY_COLOR4D( const wxString& aLabel, const wxString& aName,
|
||||
COLOR4D aValue ) :
|
||||
wxStringProperty( aLabel, aName, aValue.ToCSSString() )
|
||||
wxLongStringProperty( aLabel, aName, aValue.ToCSSString() )
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -427,7 +428,39 @@ wxString PGPROPERTY_COLOR4D::ValueToString( wxVariant& aValue, int aFlags ) cons
|
|||
if( aValue.IsType( wxS( "COLOR4D" ) ) )
|
||||
static_cast<COLOR4D_VARIANT_DATA*>( aValue.GetData() )->Write( ret );
|
||||
else
|
||||
return wxStringProperty::ValueToString( aValue, aFlags );
|
||||
return wxLongStringProperty::ValueToString( aValue, aFlags );
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
bool PGPROPERTY_COLOR4D::DisplayEditorDialog( wxPropertyGrid* aGrid, wxVariant& aValue )
|
||||
{
|
||||
KIGFX::COLOR4D color = KIGFX::COLOR4D::UNSPECIFIED;
|
||||
|
||||
COLOR4D_VARIANT_DATA* data = nullptr;
|
||||
|
||||
if( aValue.IsType( wxS( "COLOR4D" ) ) )
|
||||
{
|
||||
data = static_cast<COLOR4D_VARIANT_DATA*>( aValue.GetData() );
|
||||
color = data->Color();
|
||||
}
|
||||
|
||||
// TODO: Disable opacity where required
|
||||
DIALOG_COLOR_PICKER dialog( ::wxGetTopLevelParent( aGrid ), color, true,
|
||||
nullptr, KIGFX::COLOR4D::UNSPECIFIED );
|
||||
|
||||
int res = dialog.ShowModal();
|
||||
|
||||
if( res == wxID_OK )
|
||||
{
|
||||
if( !data )
|
||||
data = new COLOR4D_VARIANT_DATA();
|
||||
|
||||
data->SetColor( dialog.GetColor() );
|
||||
aValue.SetData( data );
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -190,7 +190,7 @@ public:
|
|||
};
|
||||
|
||||
|
||||
class PGPROPERTY_COLOR4D : public wxStringProperty
|
||||
class PGPROPERTY_COLOR4D : public wxLongStringProperty
|
||||
{
|
||||
public:
|
||||
PGPROPERTY_COLOR4D( const wxString& aLabel = wxPG_LABEL, const wxString& aName = wxPG_LABEL,
|
||||
|
@ -202,6 +202,8 @@ public:
|
|||
|
||||
bool StringToValue( wxVariant &aVariant, const wxString &aText,
|
||||
int aFlags = 0 ) const override;
|
||||
|
||||
bool DisplayEditorDialog( wxPropertyGrid* aGrid, wxVariant& aValue ) override;
|
||||
};
|
||||
|
||||
#endif /* PG_PROPERTIES_H */
|
||||
|
|
Loading…
Reference in New Issue