Skip to content

Commit 99557f1

Browse files
authored
Merge pull request #297 from jchanvfx/color_picker_cleanup
minor clean up
2 parents a5669aa + 3ce5910 commit 99557f1

File tree

2 files changed

+13
-36
lines changed

2 files changed

+13
-36
lines changed

NodeGraphQt/constants.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -228,23 +228,23 @@ class NodePropWidgetEnum(Enum):
228228
QDOUBLESPIN_BOX = 8
229229
#: Node property represented with a ColorPicker widget.
230230
COLOR_PICKER = 9
231+
#: Node property represented with a ColorPicker (RGBA) widget.
232+
COLOR4_PICKER = 10
231233
#: Node property represented with a Slider widget.
232-
SLIDER = 10
234+
SLIDER = 11
233235
#: Node property represented with a file selector widget.
234-
FILE_OPEN = 11
236+
FILE_OPEN = 12
235237
#: Node property represented with a file save widget.
236-
FILE_SAVE = 12
238+
FILE_SAVE = 13
237239
#: Node property represented with a vector2 widget.
238-
VECTOR2 = 13
240+
VECTOR2 = 14
239241
#: Node property represented with vector3 widget.
240-
VECTOR3 = 14
242+
VECTOR3 = 15
241243
#: Node property represented with vector4 widget.
242-
VECTOR4 = 15
244+
VECTOR4 = 16
243245
#: Node property represented with float line edit widget.
244-
FLOAT = 16
246+
FLOAT = 17
245247
#: Node property represented with int line edit widget.
246-
INT = 17
248+
INT = 18
247249
#: Node property represented with button widget.
248-
BUTTON = 18
249-
#: Node property represented with a ColorPickerRGBA widget.
250-
COLOR4_PICKER = 19
250+
BUTTON = 19

NodeGraphQt/custom_widgets/properties_bin/custom_widget_color_picker.py

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ def set_value(self, value):
6464
self.value_changed.emit(self.toolTip(), value)
6565

6666

67-
class PropColorPickerRGBA(BaseProperty):
67+
class PropColorPickerRGBA(PropColorPickerRGB):
6868
"""
6969
Color4 (rgba) picker widget for a node property.
7070
"""
7171

7272
def __init__(self, parent=None):
73-
super(PropColorPickerRGBA, self).__init__(parent)
73+
BaseProperty.__init__(self, parent)
7474
self._color = (0, 0, 0, 255)
7575
self._button = QtWidgets.QPushButton()
7676
self._vector = PropVector4()
@@ -85,22 +85,6 @@ def __init__(self, parent=None):
8585
layout.addWidget(self._button, 0, QtCore.Qt.AlignLeft)
8686
layout.addWidget(self._vector, 1, QtCore.Qt.AlignLeft)
8787

88-
def _on_vector_changed(self, _, value):
89-
self._color = tuple(value)
90-
self._update_color()
91-
self.value_changed.emit(self.toolTip(), value)
92-
93-
def _on_select_color(self):
94-
current_color = QtGui.QColor(*self.get_value())
95-
alpha_option = QtWidgets.QColorDialog.ShowAlphaChannel
96-
color = QtWidgets.QColorDialog.getColor(
97-
current_color, self, options=alpha_option)
98-
if color.isValid():
99-
self.set_value(color.getRgb())
100-
101-
def _update_vector(self):
102-
self._vector.set_value(self._color)
103-
10488
def _update_color(self):
10589
c = [int(max(min(i, 255), 0)) for i in self._color]
10690
hex_color = '#{0:02x}{1:02x}{2:02x}{3:03x}'.format(*c)
@@ -116,10 +100,3 @@ def _update_color(self):
116100

117101
def get_value(self):
118102
return self._color[:4]
119-
120-
def set_value(self, value):
121-
if value != self.get_value():
122-
self._color = value
123-
self._update_color()
124-
self._update_vector()
125-
self.value_changed.emit(self.toolTip(), value)

0 commit comments

Comments
 (0)