33
44from Qt import QtGui , QtCore , QtWidgets
55
6- from NodeGraphQt .constants import (PORT_TYPE , PORT_STYLING ,
7- NODE_WIDTH , NODE_HEIGHT ,
8- NODE_ICON_SIZE , ICON_NODE_BASE ,
9- NODE_SEL_COLOR , NODE_SEL_BORDER_COLOR ,
10- Z_VAL_NODE ,
11- ITEM_CACHE_MODE )
6+ from NodeGraphQt .constants import (
7+ ITEM_CACHE_MODE ,
8+ ICON_NODE_BASE ,
9+ NODE_STYLING ,
10+ PORT_STYLING ,
11+ PORT_TYPE ,
12+ Z_VAL_NODE
13+ )
1214from NodeGraphQt .errors import NodeWidgetError
1315from NodeGraphQt .qgraphics .node_abstract import AbstractNodeItem
1416from NodeGraphQt .qgraphics .node_overlay_disabled import XDisabledItem
@@ -28,9 +30,10 @@ class NodeItem(AbstractNodeItem):
2830 def __init__ (self , name = 'node' , parent = None ):
2931 super (NodeItem , self ).__init__ (name , parent )
3032 pixmap = QtGui .QPixmap (ICON_NODE_BASE )
31- if pixmap .size ().height () > NODE_ICON_SIZE :
33+ if pixmap .size ().height () > NODE_STYLING . ICON_SIZE . value :
3234 pixmap = pixmap .scaledToHeight (
33- NODE_ICON_SIZE , QtCore .Qt .SmoothTransformation
35+ NODE_STYLING .ICON_SIZE .value ,
36+ QtCore .Qt .SmoothTransformation
3437 )
3538 self ._properties ['icon' ] = ICON_NODE_BASE
3639 self ._icon_item = QtWidgets .QGraphicsPixmapItem (pixmap , self )
@@ -73,7 +76,7 @@ def paint(self, painter, option, widget):
7376
7477 # light overlay on background when selected.
7578 if self .selected :
76- painter .setBrush (QtGui .QColor (* NODE_SEL_COLOR ))
79+ painter .setBrush (QtGui .QColor (* NODE_STYLING . SELECTED_COLOR . value ))
7780 painter .drawRoundedRect (rect , radius , radius )
7881
7982 # node name background.
@@ -84,15 +87,17 @@ def paint(self, painter, option, widget):
8487 rect .width () - padding [0 ] - margin ,
8588 text_rect .height () - (padding [1 ] * 2 ))
8689 if self .selected :
87- painter .setBrush (QtGui .QColor (* NODE_SEL_COLOR ))
90+ painter .setBrush (QtGui .QColor (* NODE_STYLING . SELECTED_COLOR . value ))
8891 else :
8992 painter .setBrush (QtGui .QColor (0 , 0 , 0 , 80 ))
9093 painter .drawRoundedRect (text_rect , 3.0 , 3.0 )
9194
9295 # node border
9396 if self .selected :
9497 border_width = 1.2
95- border_color = QtGui .QColor (* NODE_SEL_BORDER_COLOR )
98+ border_color = QtGui .QColor (
99+ * NODE_STYLING .SELECTED_BORDER_COLOR .value
100+ )
96101 else :
97102 border_width = 0.8
98103 border_color = QtGui .QColor (* self .border_color )
@@ -202,10 +207,10 @@ def _set_base_size(self, add_w=0.0, add_h=0.0):
202207 add_h (float): add additional height.
203208 """
204209 self ._width , self ._height = self .calc_size (add_w , add_h )
205- if self ._width < NODE_WIDTH :
206- self ._width = NODE_WIDTH
207- if self ._height < NODE_HEIGHT :
208- self ._height = NODE_HEIGHT
210+ if self ._width < NODE_STYLING . WIDTH . value :
211+ self ._width = NODE_STYLING . WIDTH . value
212+ if self ._height < NODE_STYLING . HEIGHT . value :
213+ self ._height = NODE_STYLING . HEIGHT . value
209214
210215 def _set_text_color (self , color ):
211216 """
@@ -524,9 +529,11 @@ def icon(self, path=None):
524529 self ._properties ['icon' ] = path
525530 path = path or ICON_NODE_BASE
526531 pixmap = QtGui .QPixmap (path )
527- if pixmap .size ().height () > NODE_ICON_SIZE :
528- pixmap = pixmap .scaledToHeight (NODE_ICON_SIZE ,
529- QtCore .Qt .SmoothTransformation )
532+ if pixmap .size ().height () > NODE_STYLING .ICON_SIZE .value :
533+ pixmap = pixmap .scaledToHeight (
534+ NODE_STYLING .ICON_SIZE .value ,
535+ QtCore .Qt .SmoothTransformation
536+ )
530537 self ._icon_item .setPixmap (pixmap )
531538 if self .scene ():
532539 self .post_init ()
@@ -808,14 +815,16 @@ def paint(self, painter, option, widget):
808815
809816 # light overlay on background when selected.
810817 if self .selected :
811- painter .setBrush (QtGui .QColor (* NODE_SEL_COLOR ))
818+ painter .setBrush (
819+ QtGui .QColor (* NODE_STYLING .SELECTED_COLOR .value )
820+ )
812821 painter .drawRoundedRect (rect , radius , radius )
813822
814823 # top & bottom edge background.
815824 padding = 2.0
816825 height = 10
817826 if self .selected :
818- painter .setBrush (QtGui .QColor (* NODE_SEL_COLOR ))
827+ painter .setBrush (QtGui .QColor (* NODE_STYLING . SELECTED_COLOR . value ))
819828 else :
820829 painter .setBrush (QtGui .QColor (0 , 0 , 0 , 80 ))
821830 for y in [rect .y () + padding , rect .height () - height - 1 ]:
@@ -828,7 +837,9 @@ def paint(self, painter, option, widget):
828837 border_color = QtGui .QColor (* self .border_color )
829838 if self .selected :
830839 border_width = 1.2
831- border_color = QtGui .QColor (* NODE_SEL_BORDER_COLOR )
840+ border_color = QtGui .QColor (
841+ * NODE_STYLING .SELECTED_BORDER_COLOR .value
842+ )
832843 border_rect = QtCore .QRectF (rect .left (), rect .top (),
833844 rect .width (), rect .height ())
834845
0 commit comments