|
1 | 1 | #!/usr/bin/python |
2 | 2 | from Qt import QtGui, QtCore, QtWidgets |
3 | 3 |
|
4 | | -from NodeGraphQt.constants import (VIEWER_BG_COLOR, |
5 | | - VIEWER_GRID_SIZE, |
6 | | - VIEWER_GRID_COLOR, |
7 | | - VIEWER_GRID_DOTS, |
8 | | - VIEWER_GRID_LINES) |
| 4 | +from NodeGraphQt.constants import VIEWER_STYLING |
9 | 5 |
|
10 | 6 |
|
11 | 7 | class NodeScene(QtWidgets.QGraphicsScene): |
12 | 8 |
|
13 | 9 | def __init__(self, parent=None): |
14 | 10 | super(NodeScene, self).__init__(parent) |
15 | | - self._grid_mode = VIEWER_GRID_LINES |
16 | | - self._grid_color = VIEWER_GRID_COLOR |
17 | | - self._bg_color = VIEWER_BG_COLOR |
| 11 | + self._grid_mode = VIEWER_STYLING.GRID_DISPLAY_LINES.value |
| 12 | + self._grid_color = VIEWER_STYLING.GRID_COLOR.value |
| 13 | + self._bg_color = VIEWER_STYLING.BACKGROUND_COLOR.value |
18 | 14 | self.setBackgroundBrush(QtGui.QColor(*self._bg_color)) |
19 | 15 |
|
20 | 16 | def __repr__(self): |
@@ -98,21 +94,25 @@ def drawBackground(self, painter, rect): |
98 | 94 | painter.setRenderHint(QtGui.QPainter.Antialiasing, False) |
99 | 95 | painter.setBrush(self.backgroundBrush()) |
100 | 96 |
|
101 | | - if self._grid_mode is VIEWER_GRID_DOTS: |
| 97 | + if self._grid_mode is VIEWER_STYLING.GRID_DISPLAY_DOTS.value: |
102 | 98 | pen = QtGui.QPen(QtGui.QColor(*self.grid_color), 0.65) |
103 | | - self._draw_dots(painter, rect, pen, VIEWER_GRID_SIZE) |
| 99 | + self._draw_dots(painter, rect, pen, VIEWER_STYLING.GRID_SIZE.value) |
104 | 100 |
|
105 | | - elif self._grid_mode is VIEWER_GRID_LINES: |
| 101 | + elif self._grid_mode is VIEWER_STYLING.GRID_DISPLAY_LINES.value: |
106 | 102 | zoom = self.viewer().get_zoom() |
107 | 103 | if zoom > -0.5: |
108 | 104 | pen = QtGui.QPen(QtGui.QColor(*self.grid_color), 0.65) |
109 | | - self._draw_grid(painter, rect, pen, VIEWER_GRID_SIZE) |
| 105 | + self._draw_grid( |
| 106 | + painter, rect, pen, VIEWER_STYLING.GRID_SIZE.value |
| 107 | + ) |
110 | 108 |
|
111 | 109 | color = QtGui.QColor(*self._bg_color).darker(150) |
112 | 110 | if zoom < -0.0: |
113 | 111 | color = color.darker(100 - int(zoom * 110)) |
114 | 112 | pen = QtGui.QPen(color, 0.65) |
115 | | - self._draw_grid(painter, rect, pen, VIEWER_GRID_SIZE * 8) |
| 113 | + self._draw_grid( |
| 114 | + painter, rect, pen, VIEWER_STYLING.GRID_SIZE.value * 8 |
| 115 | + ) |
116 | 116 |
|
117 | 117 | painter.restore() |
118 | 118 |
|
@@ -148,7 +148,9 @@ def grid_mode(self): |
148 | 148 | return self._grid_mode |
149 | 149 |
|
150 | 150 | @grid_mode.setter |
151 | | - def grid_mode(self, mode=VIEWER_GRID_LINES): |
| 151 | + def grid_mode(self, mode=None): |
| 152 | + if mode is None: |
| 153 | + mode = VIEWER_STYLING.GRID_DISPLAY_LINES.value |
152 | 154 | self._grid_mode = mode |
153 | 155 |
|
154 | 156 | @property |
|
0 commit comments