diff --git a/NodeGraphQt/constants.py b/NodeGraphQt/constants.py index 21fbe648..4d73ed80 100644 --- a/NodeGraphQt/constants.py +++ b/NodeGraphQt/constants.py @@ -228,23 +228,23 @@ class NodePropWidgetEnum(Enum): QDOUBLESPIN_BOX = 8 #: Node property represented with a ColorPicker widget. COLOR_PICKER = 9 + #: Node property represented with a ColorPicker (RGBA) widget. + COLOR4_PICKER = 10 #: Node property represented with a Slider widget. - SLIDER = 10 + SLIDER = 11 #: Node property represented with a file selector widget. - FILE_OPEN = 11 + FILE_OPEN = 12 #: Node property represented with a file save widget. - FILE_SAVE = 12 + FILE_SAVE = 13 #: Node property represented with a vector2 widget. - VECTOR2 = 13 + VECTOR2 = 14 #: Node property represented with vector3 widget. - VECTOR3 = 14 + VECTOR3 = 15 #: Node property represented with vector4 widget. - VECTOR4 = 15 + VECTOR4 = 16 #: Node property represented with float line edit widget. - FLOAT = 16 + FLOAT = 17 #: Node property represented with int line edit widget. - INT = 17 + INT = 18 #: Node property represented with button widget. - BUTTON = 18 - #: Node property represented with a ColorPickerRGBA widget. - COLOR4_PICKER = 19 + BUTTON = 19 diff --git a/NodeGraphQt/custom_widgets/properties_bin/custom_widget_color_picker.py b/NodeGraphQt/custom_widgets/properties_bin/custom_widget_color_picker.py index 35c4a51e..79d0813b 100644 --- a/NodeGraphQt/custom_widgets/properties_bin/custom_widget_color_picker.py +++ b/NodeGraphQt/custom_widgets/properties_bin/custom_widget_color_picker.py @@ -64,13 +64,13 @@ def set_value(self, value): self.value_changed.emit(self.toolTip(), value) -class PropColorPickerRGBA(BaseProperty): +class PropColorPickerRGBA(PropColorPickerRGB): """ Color4 (rgba) picker widget for a node property. """ def __init__(self, parent=None): - super(PropColorPickerRGBA, self).__init__(parent) + BaseProperty.__init__(self, parent) self._color = (0, 0, 0, 255) self._button = QtWidgets.QPushButton() self._vector = PropVector4() @@ -85,22 +85,6 @@ def __init__(self, parent=None): layout.addWidget(self._button, 0, QtCore.Qt.AlignLeft) layout.addWidget(self._vector, 1, QtCore.Qt.AlignLeft) - def _on_vector_changed(self, _, value): - self._color = tuple(value) - self._update_color() - self.value_changed.emit(self.toolTip(), value) - - def _on_select_color(self): - current_color = QtGui.QColor(*self.get_value()) - alpha_option = QtWidgets.QColorDialog.ShowAlphaChannel - color = QtWidgets.QColorDialog.getColor( - current_color, self, options=alpha_option) - if color.isValid(): - self.set_value(color.getRgb()) - - def _update_vector(self): - self._vector.set_value(self._color) - def _update_color(self): c = [int(max(min(i, 255), 0)) for i in self._color] hex_color = '#{0:02x}{1:02x}{2:02x}{3:03x}'.format(*c) @@ -116,10 +100,3 @@ def _update_color(self): def get_value(self): return self._color[:4] - - def set_value(self, value): - if value != self.get_value(): - self._color = value - self._update_color() - self._update_vector() - self.value_changed.emit(self.toolTip(), value)