Commit 2e58891a authored by Flavio TARSETTI's avatar Flavio TARSETTI

[widgets][toolchaineditor] patch pin text width/grid color/custom height

parent 24d6b5b0
......@@ -38,6 +38,7 @@ class DrawingSpace(QGraphicsScene):
super().__init__()
self.grid_size = configuration["grid_size"]
self.grid_color = configuration["grid_color"]
def drawBackground(self, painter, rect):
"""Background grid"""
......@@ -53,7 +54,7 @@ class DrawingSpace(QGraphicsScene):
lines.append(QLineF(rect.left(), i, rect.right(), i))
self.pen = QPen()
self.pen.setColor(QColor(50, 50, 50, 255))
self.pen.setColor(QColor(*self.grid_color))
self.pen.setWidth(0)
painter.setPen(self.pen)
painter.drawLines(lines)
......@@ -2,7 +2,8 @@
"drawing_space_config":{
"scene_width": 2000,
"scene_height": 2000,
"grid_size": 36
"grid_size": 36,
"grid_color": [232, 232, 232, 255]
},
"block_config":{
"width": 200,
......
......@@ -583,26 +583,28 @@ class Block(QGraphicsObject):
self.pin_font = QFont(config["pin_font"], config["pin_font_size"], QFont.Normal)
metrics = QFontMetrics(self.text_font)
text_width = metrics.boundingRect(self.name).width() + 14
text_width = metrics.boundingRect(self.name).width() + 24
if self.inputs is not None and len(self.inputs) > 0:
self.max_inputs_width = (
metrics.boundingRect(max(self.inputs, key=len)).width() + 14
metrics.boundingRect(max(self.inputs, key=len)).width() + 24
)
else:
self.max_inputs_width = 14
self.max_inputs_width = 24
if self.outputs is not None and len(self.outputs) > 0:
self.max_outputs_width = (
metrics.boundingRect(max(self.outputs, key=len)).width() + 14
metrics.boundingRect(max(self.outputs, key=len)).width() + 24
)
else:
self.max_outputs_width = 14
self.max_outputs_width = 24
self.custom_width = max(
self.max_outputs_width + self.max_inputs_width, text_width
)
self.custom_height = self.height
self.center = QPointF()
self.center.setX(self.custom_width / 2.0)
self.center.setY(self.height / 2.0)
......@@ -648,7 +650,7 @@ class Block(QGraphicsObject):
def boundingRect(self):
"""Bounding rect of the block object width by height"""
metrics = QFontMetrics(self.text_font)
text_height = metrics.boundingRect(self.name).height() + 14
text_height = metrics.boundingRect(self.name).height() + 24
if self.inputs is not None and self.outputs is not None:
max_pin_height = max(len(self.inputs), len(self.outputs))
......@@ -888,8 +890,8 @@ class Block(QGraphicsObject):
painter.setFont(self.text_font)
metrics = QFontMetrics(painter.font())
text_width = metrics.boundingRect(self.name).width() + 14
text_height = metrics.boundingRect(self.name).height() + 14
text_width = metrics.boundingRect(self.name).width() + 24
text_height = metrics.boundingRect(self.name).height() + 24
margin = (text_width - self.custom_width) * 0.5
text_rect = QRect(-margin, -text_height, text_width, text_height)
......@@ -996,7 +998,7 @@ class Toolchain(QWidget):
self.json_object = {}
with open("beat/editor/widgets/space_nodes_config.json") as json_file:
with open("beat/editor/widgets/toolchain_style_config.json") as json_file:
config_data = json.load(json_file)
self.scene_config = config_data["drawing_space_config"]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment