Skip to content

Commit 25dc3ab

Browse files
committed
backdrop node text
1 parent b4085c4 commit 25dc3ab

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

NodeGraphQt/base/node.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def __repr__(self):
5757
def type_(cls):
5858
"""
5959
Node type identifier followed by the class name.
60-
eg. com.chantasticvfx.MyNode
60+
eg. nodeGraphQt.nodes.MyNode
6161
6262
Returns:
6363
str: node type.
@@ -574,7 +574,7 @@ def __init__(self):
574574
super(BackdropNode, self).__init__(BackdropNodeItem())
575575
# override base default color.
576576
self.model.color = (5, 129, 138, 255)
577-
self.create_property('bg_text', '')
577+
self.create_property('backdrop_text', '')
578578

579579
def auto_size(self):
580580
"""

NodeGraphQt/qgraphics/node_backdrop.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,24 @@ def paint(self, painter, option, widget):
163163
painter.setPen(QtCore.Qt.NoPen)
164164
painter.drawRect(top_rect)
165165

166+
if self.backdrop_text:
167+
painter.setPen(QtGui.QColor(*self.text_color))
168+
txt_rect = QtCore.QRectF(
169+
top_rect.x() + 5.0, top_rect.height() + 2.0,
170+
rect.width() - 5.0, rect.height())
171+
painter.setPen(QtGui.QColor(*self.text_color))
172+
painter.drawText(txt_rect,
173+
QtCore.Qt.AlignLeft | QtCore.Qt.TextWordWrap,
174+
self.backdrop_text)
175+
166176
if self.selected and NODE_SEL_COLOR:
167177
sel_color = [x for x in NODE_SEL_COLOR]
168178
sel_color[-1] = 10
169179
painter.setBrush(QtGui.QColor(*sel_color))
170180
painter.setPen(QtCore.Qt.NoPen)
171181
painter.drawRect(rect)
172182

173-
txt_rect = QtCore.QRectF(top_rect.x(), top_rect.y() + 1.5,
183+
txt_rect = QtCore.QRectF(top_rect.x(), top_rect.y() + 1.2,
174184
rect.width(), top_rect.height())
175185
painter.setPen(QtGui.QColor(*self.text_color))
176186
painter.drawText(txt_rect, QtCore.Qt.AlignCenter, self.name)
@@ -250,6 +260,7 @@ def backdrop_text(self):
250260
@backdrop_text.setter
251261
def backdrop_text(self, text):
252262
self._properties['backdrop_text'] = text
263+
self.update(self.boundingRect())
253264

254265
@AbstractNodeItem.width.setter
255266
def width(self, width=0.0):

NodeGraphQt/qgraphics/node_base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,10 @@ def itemChange(self, change, value):
225225
return super(NodeItem, self).itemChange(change, value)
226226

227227
def _tooltip_disable(self, state):
228-
tooltip = '<b>{}</b>'.format(self._properties['name'])
228+
tooltip = '<b>{}</b>'.format(self.name)
229229
if state:
230230
tooltip += ' <font color="red"><b>(DISABLED)</b></font>'
231-
tooltip += '<br/>{}<br/>'.format(self._properties['type_'])
231+
tooltip += '<br/>{}<br/>'.format(self.type_)
232232
self.setToolTip(tooltip)
233233

234234
def _set_base_size(self):

0 commit comments

Comments
 (0)