Skip to content

Commit b8a18bf

Browse files
committed
doc updates
1 parent c3ceb2d commit b8a18bf

File tree

20 files changed

+399
-377
lines changed

20 files changed

+399
-377
lines changed

NodeGraphQt/base/graph.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,7 @@ def create_node(self, node_type, name=None, selected=True, color=None,
885885
push_undo (bool): register the command to the undo stack. (default: True)
886886
887887
Returns:
888-
NodeObject: the created instance of the node.
888+
BaseNode: the created instance of the node.
889889
"""
890890
node = self._node_factory.create_node_instance(node_type)
891891
if node:
@@ -1894,6 +1894,8 @@ class SubGraph(NodeGraph):
18941894
18951895
.. image:: _images/sub_graph.png
18961896
:width: 70%
1897+
1898+
-
18971899
"""
18981900

18991901
def __init__(self, parent=None, node=None, node_factory=None):
@@ -2178,6 +2180,9 @@ def node(self):
21782180
"""
21792181
Returns the parent node to the sub graph.
21802182
2183+
.. image:: _images/group_node.png
2184+
:width: 250px
2185+
21812186
Returns:
21822187
NodeGraphQt.GroupNode: group node.
21832188
"""
@@ -2304,6 +2309,8 @@ def get_input_port_nodes(self):
23042309
.. image:: _images/port_in_node.png
23052310
:width: 150px
23062311
2312+
-
2313+
23072314
See Also:
23082315
:meth:`NodeGraph.get_nodes_by_type`,
23092316
:meth:`SubGraph.get_output_port_nodes`
@@ -2320,6 +2327,8 @@ def get_output_port_nodes(self):
23202327
.. image:: _images/port_out_node.png
23212328
:width: 150px
23222329
2330+
-
2331+
23232332
See Also:
23242333
:meth:`NodeGraph.get_nodes_by_type`,
23252334
:meth:`SubGraph.get_input_port_nodes`

NodeGraphQt/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252

5353
NODE_WIDTH = 160
5454
NODE_HEIGHT = 60
55-
NODE_ICON_SIZE = 24
55+
NODE_ICON_SIZE = 18
5656
NODE_SEL_COLOR = (255, 255, 255, 30)
5757
NODE_SEL_BORDER_COLOR = (254, 207, 42, 255)
5858

NodeGraphQt/custom_widgets/nodes_tree.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ def __init__(self, parent=None, node_graph=None):
5555
self._custom_labels = {}
5656
self._category_items = {}
5757

58+
self._build_tree()
59+
5860
def __repr__(self):
5961
return '<{} object at {}>'.format(
6062
self.__class__.__name__, hex(id(self))

NodeGraphQt/nodes/backdrop_node.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ class BackdropNode(NodeObject):
1515
1616
.. image:: ../_images/backdrop.png
1717
:width: 250px
18+
19+
-
1820
"""
1921

2022
NODE_NAME = 'Backdrop'

NodeGraphQt/nodes/base_node.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@ class BaseNode(NodeObject):
3737
3838
from NodeGraphQt import BaseNode
3939
40-
class FooNode(BaseNode):
40+
class ExampleNode(BaseNode):
4141
4242
# unique node identifier domain.
43-
__identifier__ = 'com.chantasticvfx'
43+
__identifier__ = 'io.jchanvfx.github'
4444
4545
# initial default node name.
46-
NODE_NAME = 'Foo Node'
46+
NODE_NAME = 'My Node'
4747
4848
def __init__(self):
49-
super(FooNode, self).__init__()
49+
super(ExampleNode, self).__init__()
5050
5151
# create an input port.
5252
self.add_input('in')

NodeGraphQt/nodes/group_node.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ class GroupNode(BaseNode):
1818
1919
.. image:: ../_images/group_node.png
2020
:width: 250px
21+
22+
-
2123
"""
2224

2325
NODE_NAME = 'Group'

NodeGraphQt/nodes/port_node.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class PortInputNode(BaseNode):
2121
.. image:: ../_images/port_in_node.png
2222
:width: 150px
2323
24+
-
2425
"""
2526

2627
NODE_NAME = 'InputPort'
@@ -81,6 +82,7 @@ class PortOutputNode(BaseNode):
8182
.. image:: ../_images/port_out_node.png
8283
:width: 150px
8384
85+
-
8486
"""
8587

8688
NODE_NAME = 'OutputPort'

NodeGraphQt/qgraphics/node_base.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ def __init__(self, name='node', parent=None):
2929
super(NodeItem, self).__init__(name, parent)
3030
pixmap = QtGui.QPixmap(ICON_NODE_BASE)
3131
if pixmap.size().height() > NODE_ICON_SIZE:
32-
pixmap = pixmap.scaledToHeight(NODE_ICON_SIZE,
33-
QtCore.Qt.SmoothTransformation)
32+
pixmap = pixmap.scaledToHeight(
33+
NODE_ICON_SIZE, QtCore.Qt.SmoothTransformation
34+
)
3435
self._properties['icon'] = ICON_NODE_BASE
3536
self._icon_item = QtWidgets.QGraphicsPixmapItem(pixmap, self)
3637
self._icon_item.setTransformationMode(QtCore.Qt.SmoothTransformation)
@@ -329,8 +330,10 @@ def align_icon(self, h_offset=0.0, v_offset=0.0):
329330
v_offset (float): additional vertical offset.
330331
h_offset (float): additional horizontal offset.
331332
"""
332-
top_left = self.boundingRect().topLeft()
333-
x, y = top_left.x(), top_left.y()
333+
icon_rect = self._icon_item.boundingRect()
334+
text_rect = self._text_item.boundingRect()
335+
x = self.boundingRect().left() + 2.0
336+
y = text_rect.center().y() - (icon_rect.height() / 2)
334337
self._icon_item.setPos(x + h_offset, y + v_offset)
335338

336339
def align_label(self, h_offset=0.0, v_offset=0.0):

NodeGraphQt/qgraphics/node_group.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def draw_node(self):
161161
height = self._text_item.boundingRect().height()
162162

163163
# setup initial base size.
164-
self._set_base_size(add_w=8.0, add_h=height)
164+
self._set_base_size(add_w=8.0, add_h=height + 10)
165165
# set text color when node is initialized.
166166
self._set_text_color(self.text_color)
167167
# set the tooltip

NodeGraphQt/widgets/actions.py

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,45 @@
11
#!/usr/bin/python
22
from Qt import QtCore, QtWidgets
33

4-
from NodeGraphQt.widgets.stylesheet import STYLE_QMENU
4+
from NodeGraphQt.constants import VIEWER_BG_COLOR
55

66

77
class BaseMenu(QtWidgets.QMenu):
88

99
def __init__(self, *args, **kwargs):
1010
super(BaseMenu, self).__init__(*args, **kwargs)
11-
self.setStyleSheet(STYLE_QMENU)
11+
text_color = self.palette().text().color().toTuple()
12+
selected_color = self.palette().highlight().color().toTuple()
13+
style_dict = {
14+
'QMenu': {
15+
'color': 'rgb({0},{1},{2})'.format(*text_color),
16+
'background-color': 'rgb({0},{1},{2})'.format(*VIEWER_BG_COLOR),
17+
'border': '1px solid rgba({0},{1},{2},30)'.format(*text_color),
18+
'border-radius': '3px',
19+
},
20+
'QMenu::item': {
21+
'padding': '5px 18px 2px',
22+
'background-color': 'transparent',
23+
},
24+
'QMenu::item:selected': {
25+
'color': 'rgb({0},{1},{2})'.format(*text_color),
26+
'background-color': 'rgba({0},{1},{2},200)'
27+
.format(*selected_color),
28+
},
29+
'QMenu::separator': {
30+
'height': '1px',
31+
'background': 'rgba({0},{1},{2}, 50)'.format(*text_color),
32+
'margin': '4px 8px',
33+
}
34+
}
35+
stylesheet = ''
36+
for css_class, css in style_dict.items():
37+
style = '{} {{\n'.format(css_class)
38+
for elm_name, elm_val in css.items():
39+
style += ' {}:{};\n'.format(elm_name, elm_val)
40+
style += '}\n'
41+
stylesheet += style
42+
self.setStyleSheet(stylesheet)
1243
self.node_class = None
1344
self.graph = None
1445

0 commit comments

Comments
 (0)