def resized(self, widget, rect):
with self._size_lock:
if self._rotation in (0, 180):
ratio = min(
rect.width / self._board_full.props.width,
rect.height / self._board_full.props.height)
else:
ratio = min(
rect.width / self._board_full.props.height,
rect.height / self._board_full.props.width)
ratio = min(ratio, 1.0) # never resize larger than native
if ratio != self._ratio:
# Only resize if necessary (plenty of resizes wind up with the
# same ratio)
self._board_scaled = self._board_full.scale_simple(
self._board_full.props.width * ratio,
self._board_full.props.height * ratio,
GdkPixbuf.InterpType.BILINEAR)
self._grid_scaled = self._grid_full.scale_simple(
self._grid_full.props.width * ratio,
self._grid_full.props.height * ratio,
GdkPixbuf.InterpType.BILINEAR)
self._orient_scaled = self._orient_full.scale_simple(
self._orient_full.props.width * ratio,
self._orient_full.props.height * ratio,
GdkPixbuf.InterpType.BILINEAR)
self._ratio = ratio
评论列表
文章目录