Skip to content

Commit 85024e4

Browse files
committed
Add support for colorWellStyle
1 parent 658445f commit 85024e4

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

Lib/vanilla/vanillaColorWell.py

+29-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
from AppKit import NSColorWell, NSColorPanel
2-
from vanilla.vanillaBase import VanillaBaseObject
2+
from vanilla.vanillaBase import VanillaBaseObject, osVersionCurrent, osVersion13_0
3+
4+
if osVersionCurrent >= osVersion13_0:
5+
from AppKit import NSColorWellStyleDefault, NSColorWellStyleMinimal, NSColorWellStyleExpanded
6+
7+
colorWellStyleMap = dict(
8+
default=NSColorWellStyleDefault,
9+
minimal=NSColorWellStyleMinimal,
10+
expanded=NSColorWellStyleExpanded
11+
)
12+
13+
else:
14+
colorWellStyleMap = dict()
315

416

517
class ColorWell(VanillaBaseObject):
@@ -38,17 +50,32 @@ def colorWellEdit(self, sender):
3850
**color** A `NSColor`_ object. If *None* is given, the color shown will
3951
be white.
4052
53+
**colorWellStyle** A string representing the desired color well style. The options are:
54+
55+
+------------+
56+
| "default" |
57+
+------------+
58+
| "minimal" |
59+
+------------+
60+
| "expanded" |
61+
+------------+
62+
4163
.. _NSColor: https://developer.apple.com/documentation/appkit/nscolor?language=objc
4264
"""
4365

4466
nsColorWellClass = NSColorWell
4567

46-
def __init__(self, posSize, callback=None, color=None):
68+
def __init__(self, posSize, callback=None, color=None, colorWellStyle=None):
4769
self._setupView(self.nsColorWellClass, posSize, callback=callback)
4870
if color is not None:
4971
self._nsObject.setColor_(color)
5072
colorPanel = NSColorPanel.sharedColorPanel()
5173
colorPanel.setShowsAlpha_(True)
74+
if osVersionCurrent >= osVersion13_0:
75+
# https://developer.apple.com/documentation/appkit/nscolorwell/3955203-colorwellstyle?language=objc
76+
nsColorWellStyle = colorWellStyleMap.get(colorWellStyle)
77+
if nsColorWellStyle is not None:
78+
colorPanel.setColorWellStyle_(nsColorWellStyle)
5279

5380
def getNSColorWell(self):
5481
"""

Lib/vanilla/vanillaList2.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -1299,11 +1299,15 @@ class ColorWellList2Cell(ColorWell):
12991299

13001300
def __init__(self,
13011301
editable=False,
1302-
callback=None
1302+
callback=None,
1303+
colorWellStyle=None
13031304
):
1305+
if colorWellStyle is None:
1306+
colorWellStyle = "minimal"
13041307
super().__init__(
13051308
"auto",
1306-
callback=callback
1309+
callback=callback,
1310+
colorWellStyle=colorWellStyle
13071311
)
13081312
colorWell = self.getNSColorWell()
13091313
self.enable(editable)

0 commit comments

Comments
 (0)