Skip to content

Commit

Permalink
Node and label distance correct with redraw
Browse files Browse the repository at this point in the history
Related to coreemu#673
  • Loading branch information
mateodurante authored Mar 22, 2022
1 parent d684b8e commit 53931eb
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions daemon/core/gui/graph/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def redraw(self) -> None:
self.canvas.itemconfig(self.id, image=self.image)
label = self.get_label()
self.canvas.itemconfig(self.text_id, text=label)
self.scale_text()
for edge in self.edges:
edge.redraw()

Expand All @@ -146,9 +147,10 @@ def _get_label_y(self) -> int:

def scale_text(self) -> None:
text_bound = self.canvas.bbox(self.text_id)
prev_y = (text_bound[3] + text_bound[1]) / 2
new_y = self._get_label_y()
self.canvas.move(self.text_id, 0, new_y - prev_y)
if text_bound:
prev_y = (text_bound[3] + text_bound[1]) / 2
new_y = self._get_label_y()
self.canvas.move(self.text_id, 0, new_y - prev_y)

def move(self, x: float, y: float) -> None:
x, y = self.canvas.get_scaled_coords(x, y)
Expand Down

0 comments on commit 53931eb

Please sign in to comment.