Skip to content

Commit

Permalink
Change use of sizing to use read-only methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
cmeyer committed Jul 21, 2023
1 parent 35534ca commit f7c5ed0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions nion/swift/ImageCanvasItem.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ def __update_sizing(self) -> None:
height = height + 4 + fm1.height + fm2.height
width = 20 + max(scale_marker_width, fm1.width, fm2.width)
new_sizing = self.copy_sizing()
new_sizing._set_fixed_width(width)
new_sizing._set_fixed_height(height)
new_sizing = new_sizing.with_fixed_width(width)
new_sizing = new_sizing.with_fixed_height(height)
self.update_sizing(new_sizing)
self.update()

Expand Down
24 changes: 12 additions & 12 deletions nion/swift/LineGraphCanvasItem.py
Original file line number Diff line number Diff line change
Expand Up @@ -950,13 +950,13 @@ def __init__(self) -> None:
def size_to_content(self) -> None:
""" Size the canvas item to the proper height. """
new_sizing = self.copy_sizing()
new_sizing._minimum_height = 0
new_sizing._maximum_height = 0
new_sizing = new_sizing.with_minimum_height(0)
new_sizing = new_sizing.with_maximum_height(0)
axes = self.__axes
if axes:
if axes.x_calibration and axes.x_calibration.units:
new_sizing._minimum_height = self.font_size + 4
new_sizing._maximum_height = self.font_size + 4
new_sizing = new_sizing.with_minimum_height(self.font_size + 4)
new_sizing = new_sizing.with_maximum_height(self.font_size + 4)
self.update_sizing(new_sizing)

def set_axes(self, axes: typing.Optional[LineGraphAxes]) -> None:
Expand Down Expand Up @@ -1084,8 +1084,8 @@ def size_to_content(self, ui_settings: UISettings.UISettings) -> None:
""" Size the canvas item to the proper width, the maximum of any label. """
new_sizing = self.copy_sizing()

new_sizing._minimum_width = 0
new_sizing._maximum_width = 0
new_sizing = new_sizing.with_minimum_width(0)
new_sizing = new_sizing.with_maximum_width(0)

axes = self.__axes
if axes:
Expand All @@ -1094,8 +1094,8 @@ def size_to_content(self, ui_settings: UISettings.UISettings) -> None:
y_range = axes.calibrated_value_max - axes.calibrated_value_min
max_width = max(max_width, calculate_scientific_notation_drawing_width(ui_settings, self.__fonts, axes.y_ticker.value_label(axes.calibrated_value_max + y_range * 5)))
max_width = max(max_width, calculate_scientific_notation_drawing_width(ui_settings, self.__fonts, axes.y_ticker.value_label(axes.calibrated_value_min - y_range * 5)))
new_sizing._minimum_width = max_width
new_sizing._maximum_width = max_width
new_sizing = new_sizing.with_minimum_width(max_width)
new_sizing = new_sizing.with_maximum_width(max_width)

self.update_sizing(new_sizing)

Expand Down Expand Up @@ -1159,13 +1159,13 @@ def __init__(self) -> None:
def size_to_content(self) -> None:
""" Size the canvas item to the proper width. """
new_sizing = self.copy_sizing()
new_sizing._minimum_width = 0
new_sizing._maximum_width = 0
new_sizing = new_sizing.with_minimum_width(0)
new_sizing = new_sizing.with_maximum_width(0)
axes = self.__axes
if axes:
if axes.y_calibration and axes.y_calibration.units:
new_sizing._minimum_width = self.font_size + 4
new_sizing._maximum_width = self.font_size + 4
new_sizing = new_sizing.with_minimum_width(self.font_size + 4)
new_sizing = new_sizing.with_maximum_width(self.font_size + 4)
self.update_sizing(new_sizing)

def set_axes(self, axes: typing.Optional[LineGraphAxes]) -> None:
Expand Down

0 comments on commit f7c5ed0

Please sign in to comment.