Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions NodeGraphQt/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand All @@ -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)