Allow turning on/off opacity selector in wxColourDialog (wxOSX)

This feature to show/hide alpha values and opacity selector (slider) is
already implemented under wxGTK and for generic wxColourDialog.
For the sake of backward compatibility, this feature is enabled here by
default (through the corresponding property of wxColourData).
This commit is contained in:
Artur Wieczorek
2017-07-03 21:13:49 +02:00
parent 294436c8bb
commit a29815e19a
4 changed files with 29 additions and 1 deletions

View File

@@ -213,6 +213,7 @@ wxOSX:
- Add a native implementation for clearing bitmap/window wxGraphicsContexts
- wxiOS now needs a minimum of iOS 9 for deployment
- Fix handling CTM in wxGraphicsContext::SeTransform and GetTransform().
- Allow turning on/off opacity selector in wxColourDialog.
Unix:

View File

@@ -46,6 +46,16 @@ public:
*/
bool GetChooseFull() const;
/**
Indicates whether the colour dialog will display alpha values
and an opacity selector. It is meaningful under wxGTK, wxOSX
and with regards to generic colour dialog.
The default value is @false, except wxOSX where it is @true (for
the sake of backward compatibility).
*/
bool GetChooseAlpha() const;
/**
Gets the current colour associated with the colour dialog.
@@ -72,6 +82,16 @@ public:
*/
void SetChooseFull(bool flag);
/**
Tells the colour dialog to show alpha values and an opacity selector
(slider). Currently it has effect under wxGTK, wxOSX and for generic
colour dialog.
The default value is @false, except wxOSX where it is @true for
backward compatibility.
*/
void SetChooseAlpha(bool flag);
/**
Sets the default colour for the colour dialog.

View File

@@ -25,7 +25,14 @@ wxIMPLEMENT_DYNAMIC_CLASS(wxColourData, wxObject);
wxColourData::wxColourData()
{
m_chooseFull = false;
#ifdef __WXOSX__
// Under OSX, legacy wxColourDialog had opacity selector
// (slider) always enabled, so for backward compatibilty
// we should tell the dialog to enable it by default.
m_chooseAlpha = true;
#else
m_chooseAlpha = false;
#endif // __WXOSX__ / !__WXOSX__
m_dataColour.Set(0,0,0);
// m_custColours are wxNullColours initially
}

View File

@@ -106,7 +106,7 @@ bool wxColourDialog::Create(wxWindow *parent, wxColourData *data)
NSAutoreleasePool *thePool;
thePool = [[NSAutoreleasePool alloc] init];
[[NSColorPanel sharedColorPanel] setShowsAlpha:YES];
[[NSColorPanel sharedColorPanel] setShowsAlpha:m_colourData.GetChooseAlpha() ? YES : NO];
if(m_colourData.GetColour().IsOk())
[[NSColorPanel sharedColorPanel] setColor:m_colourData.GetColour().OSXGetNSColor()];
else