sacle toolbar button after choosing a node from node picker, scale canvas nodes and canvas node text
This commit is contained in:
parent
9cd756f2dc
commit
55b6cbbd90
5 changed files with 44 additions and 11 deletions
|
@ -12,7 +12,7 @@ from core.gui.graph.enums import GraphMode, ScaleOption
|
|||
from core.gui.graph.node import CanvasNode
|
||||
from core.gui.graph.shape import Shape
|
||||
from core.gui.graph.shapeutils import ShapeType, is_draw_shape, is_marker
|
||||
from core.gui.images import ImageEnum, Images
|
||||
from core.gui.images import ImageEnum, Images, TypeToImage
|
||||
from core.gui.nodeutils import EdgeUtils, NodeUtils
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
@ -914,3 +914,14 @@ class CanvasGraph(tk.Canvas):
|
|||
width=self.itemcget(edge.id, "width"),
|
||||
fill=self.itemcget(edge.id, "fill"),
|
||||
)
|
||||
|
||||
def scale_graph(self):
|
||||
for nid, canvas_node in self.nodes.items():
|
||||
image_enum = TypeToImage.get(
|
||||
canvas_node.core_node.type, canvas_node.core_node.model
|
||||
)
|
||||
img = Images.get(image_enum, int(ICON_SIZE * self.app_scale))
|
||||
self.itemconfig(nid, image=img)
|
||||
canvas_node.image = img
|
||||
|
||||
canvas_node.scale_text()
|
||||
|
|
|
@ -106,6 +106,12 @@ class CanvasNode:
|
|||
image_box = self.canvas.bbox(self.id)
|
||||
return image_box[3] + NODE_TEXT_OFFSET
|
||||
|
||||
def scale_text(self):
|
||||
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)
|
||||
|
||||
def move(self, x: int, y: int):
|
||||
x, y = self.canvas.get_scaled_coords(x, y)
|
||||
current_x, current_y = self.canvas.coords(self.id)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue