Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhanced Scrollable Area #3598

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions gns3/graphics_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ def setZoom(self, zoom):
factor = zoom / 100.
self.scale(factor, factor)

# Calculate the bounding rectangle of all items
bounding_rect = self.scene().itemsBoundingRect()

# Set the scene rectangle to the bounding rectangle
self.scene().setSceneRect(bounding_rect)

def setNodeGridSize(self, grid_size):
"""
Sets the grid size for nodes.
Expand Down
24 changes: 24 additions & 0 deletions gns3/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,14 @@ def _zoomInActionSlot(self):
self.uiGraphicsView.scaleView(factor_in)
self._updateZoomSettings()

scene = self.uiGraphicsView.scene()

# Calculate the bounding rectangle of all items
bounding_rect = scene.itemsBoundingRect()

# Set the scene rectangle to the bounding rectangle
scene.setSceneRect(bounding_rect)

def _zoomOutActionSlot(self):
"""
Slot called to scale out the view.
Expand All @@ -763,6 +771,14 @@ def _zoomOutActionSlot(self):
self.uiGraphicsView.scaleView(factor_out)
self._updateZoomSettings()

scene = self.uiGraphicsView.scene()

# Calculate the bounding rectangle of all items
bounding_rect = scene.itemsBoundingRect()

# Set the scene rectangle to the bounding rectangle
scene.setSceneRect(bounding_rect)

def _zoomResetActionSlot(self):
"""
Slot called to reset the zoom.
Expand All @@ -771,6 +787,14 @@ def _zoomResetActionSlot(self):
self.uiGraphicsView.resetTransform()
self._updateZoomSettings()

scene = self.uiGraphicsView.scene()

# Calculate the bounding rectangle of all items
bounding_rect = scene.itemsBoundingRect()

# Set the scene rectangle to the bounding rectangle
scene.setSceneRect(bounding_rect)

def _fitInViewActionSlot(self):
"""
Slot called to fit the topology in the view.
Expand Down
Loading