|
1 | 1 | 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() |
3 | 15 |
|
4 | 16 |
|
5 | 17 | class ColorWell(VanillaBaseObject):
|
@@ -38,17 +50,32 @@ def colorWellEdit(self, sender):
|
38 | 50 | **color** A `NSColor`_ object. If *None* is given, the color shown will
|
39 | 51 | be white.
|
40 | 52 |
|
| 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 | +
|
41 | 63 | .. _NSColor: https://developer.apple.com/documentation/appkit/nscolor?language=objc
|
42 | 64 | """
|
43 | 65 |
|
44 | 66 | nsColorWellClass = NSColorWell
|
45 | 67 |
|
46 |
| - def __init__(self, posSize, callback=None, color=None): |
| 68 | + def __init__(self, posSize, callback=None, color=None, colorWellStyle=None): |
47 | 69 | self._setupView(self.nsColorWellClass, posSize, callback=callback)
|
48 | 70 | if color is not None:
|
49 | 71 | self._nsObject.setColor_(color)
|
50 | 72 | colorPanel = NSColorPanel.sharedColorPanel()
|
51 | 73 | 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) |
52 | 79 |
|
53 | 80 | def getNSColorWell(self):
|
54 | 81 | """
|
|
0 commit comments