diff --git a/daemon/core/gui/dialogs/canvassizeandscale.py b/daemon/core/gui/dialogs/canvassizeandscale.py index 8155cb57..863d1174 100644 --- a/daemon/core/gui/dialogs/canvassizeandscale.py +++ b/daemon/core/gui/dialogs/canvassizeandscale.py @@ -24,7 +24,7 @@ class SizeAndScaleDialog(Dialog): super().__init__(app, "Canvas Size and Scale") self.manager: CanvasManager = self.app.manager self.section_font: font.Font = font.Font(weight=font.BOLD) - width, height = self.manager.current_dimensions + width, height = self.manager.current().current_dimensions self.pixel_width: tk.IntVar = tk.IntVar(value=width) self.pixel_height: tk.IntVar = tk.IntVar(value=height) location = self.app.core.session.location @@ -189,7 +189,7 @@ class SizeAndScaleDialog(Dialog): def click_apply(self) -> None: width, height = self.pixel_width.get(), self.pixel_height.get() - self.manager.redraw_canvases((width, height)) + self.manager.redraw_canvas((width, height)) location = self.app.core.session.location location.x = self.x.get() location.y = self.y.get() diff --git a/daemon/core/gui/graph/graph.py b/daemon/core/gui/graph/graph.py index 1362a2e0..e3225a4d 100644 --- a/daemon/core/gui/graph/graph.py +++ b/daemon/core/gui/graph/graph.py @@ -827,6 +827,7 @@ class CanvasGraph(tk.Canvas): wallpaper=wallpaper_path, wallpaper_style=self.scale_option.get(), fit_image=self.adjust_to_dim.get(), + dimensions=self.current_dimensions, ) def parse_metadata(self, config: Dict[str, Any]) -> None: @@ -834,6 +835,9 @@ class CanvasGraph(tk.Canvas): self.adjust_to_dim.set(fit_image) wallpaper_style = config.get("wallpaper_style", 1) self.scale_option.set(wallpaper_style) + dimensions = config.get("dimensions") + if dimensions: + self.redraw_canvas(dimensions) wallpaper = config.get("wallpaper") if wallpaper: wallpaper = Path(wallpaper) diff --git a/daemon/core/gui/graph/manager.py b/daemon/core/gui/graph/manager.py index 08352a25..8acce4c9 100644 --- a/daemon/core/gui/graph/manager.py +++ b/daemon/core/gui/graph/manager.py @@ -89,7 +89,6 @@ class CanvasManager: self.app.guiconfig.preferences.width, self.app.guiconfig.preferences.height, ) - self.current_dimensions: Tuple[int, int] = self.default_dimensions self.show_node_labels: ShowVar = ShowNodeLabels( self, tags.NODE_LABEL, value=True ) @@ -274,19 +273,15 @@ class CanvasManager: if not self.canvases: self.add_canvas() - def redraw_canvases(self, dimensions: Tuple[int, int]) -> None: - for canvas in self.canvases.values(): - canvas.redraw_canvas(dimensions) - if canvas.wallpaper: - canvas.redraw_wallpaper() + def redraw_canvas(self, dimensions: Tuple[int, int]) -> None: + canvas = self.current() + canvas.redraw_canvas(dimensions) + if canvas.wallpaper: + canvas.redraw_wallpaper() def get_metadata(self) -> Dict[str, Any]: canvases = [x.get_metadata() for x in self.all()] - return dict( - gridlines=self.app.manager.show_grid.get(), - dimensions=self.app.manager.current_dimensions, - canvases=canvases, - ) + return dict(gridlines=self.show_grid.get(), canvases=canvases) def parse_metadata_canvas(self, metadata: Dict[str, Any]) -> None: # canvas setting @@ -296,11 +291,8 @@ class CanvasManager: return canvas_config = json.loads(canvas_config) # get configured dimensions and gridlines option - dimensions = self.default_dimensions - dimensions = canvas_config.get("dimensions", dimensions) gridlines = canvas_config.get("gridlines", True) self.show_grid.set(gridlines) - self.redraw_canvases(dimensions) # get background configurations for canvas_config in canvas_config.get("canvases", []): diff --git a/daemon/core/gui/menubar.py b/daemon/core/gui/menubar.py index ff0c298a..e2df2f92 100644 --- a/daemon/core/gui/menubar.py +++ b/daemon/core/gui/menubar.py @@ -453,7 +453,7 @@ class Menubar(tk.Menu): dialog.show() def click_autogrid(self) -> None: - width, height = self.manager.current_dimensions + width, height = self.manager.current().current_dimensions padding = (images.NODE_SIZE / 2) + 10 layout_size = padding + images.NODE_SIZE col_count = width // layout_size