Fix zoom via mouse wheel in media event editor selectionwidget (#835)
also fixes zooming with scroll bars always present Fixes #11198
This commit is contained in:
parent
72d8d2d3cf
commit
80749afd09
@ -297,7 +297,7 @@ class SelectionWidget(Gtk.ScrolledWindow):
|
|||||||
self.original_image_size = (self.pixbuf.get_width(),
|
self.original_image_size = (self.pixbuf.get_width(),
|
||||||
self.pixbuf.get_height())
|
self.pixbuf.get_height())
|
||||||
|
|
||||||
viewport_size = self.viewport.get_allocation()
|
viewport_size = self.get_allocation()
|
||||||
self.old_viewport_size = viewport_size
|
self.old_viewport_size = viewport_size
|
||||||
self.scale = scale_to_fit(self.pixbuf.get_width(),
|
self.scale = scale_to_fit(self.pixbuf.get_width(),
|
||||||
self.pixbuf.get_height(),
|
self.pixbuf.get_height(),
|
||||||
@ -321,7 +321,7 @@ class SelectionWidget(Gtk.ScrolledWindow):
|
|||||||
Handles size-allocate' events from Gtk.
|
Handles size-allocate' events from Gtk.
|
||||||
"""
|
"""
|
||||||
if self.pixbuf:
|
if self.pixbuf:
|
||||||
viewport_size = self.viewport.get_allocation()
|
viewport_size = self.get_allocation()
|
||||||
if viewport_size.height != self.old_viewport_size.height or \
|
if viewport_size.height != self.old_viewport_size.height or \
|
||||||
viewport_size.width != self.old_viewport_size.width or \
|
viewport_size.width != self.old_viewport_size.width or \
|
||||||
not self.image.get_pixbuf():
|
not self.image.get_pixbuf():
|
||||||
@ -495,7 +495,7 @@ class SelectionWidget(Gtk.ScrolledWindow):
|
|||||||
Translates image coordinates to viewport coordinates using the current
|
Translates image coordinates to viewport coordinates using the current
|
||||||
scale and viewport size.
|
scale and viewport size.
|
||||||
"""
|
"""
|
||||||
viewport_rect = self.viewport.get_allocation()
|
viewport_rect = self.get_allocation()
|
||||||
image_rect = self.scaled_size
|
image_rect = self.scaled_size
|
||||||
if image_rect[0] < viewport_rect.width:
|
if image_rect[0] < viewport_rect.width:
|
||||||
offset_x = (image_rect[0] - viewport_rect.width) / 2
|
offset_x = (image_rect[0] - viewport_rect.width) / 2
|
||||||
@ -513,7 +513,7 @@ class SelectionWidget(Gtk.ScrolledWindow):
|
|||||||
Translates viewport coordinates to original (unscaled) image coordinates
|
Translates viewport coordinates to original (unscaled) image coordinates
|
||||||
using the current scale and viewport size.
|
using the current scale and viewport size.
|
||||||
"""
|
"""
|
||||||
viewport_rect = self.viewport.get_allocation()
|
viewport_rect = self.get_allocation()
|
||||||
image_rect = self.scaled_size
|
image_rect = self.scaled_size
|
||||||
if image_rect[0] < viewport_rect.width:
|
if image_rect[0] < viewport_rect.width:
|
||||||
offset_x = (image_rect[0] - viewport_rect.width) / 2
|
offset_x = (image_rect[0] - viewport_rect.width) / 2
|
||||||
@ -606,7 +606,7 @@ class SelectionWidget(Gtk.ScrolledWindow):
|
|||||||
cr.set_source_rgba(1.0, 1.0, 1.0, SHADING_OPACITY)
|
cr.set_source_rgba(1.0, 1.0, 1.0, SHADING_OPACITY)
|
||||||
cr.rectangle(offset_x, offset_y, x1 - offset_x, y1 - offset_y)
|
cr.rectangle(offset_x, offset_y, x1 - offset_x, y1 - offset_y)
|
||||||
cr.rectangle(offset_x, y1, x1 - offset_x, y2 - y1)
|
cr.rectangle(offset_x, y1, x1 - offset_x, y2 - y1)
|
||||||
cr.rectangle(offset_x, y2, x1 - offset_x, h - y2 + offset_y)
|
cr.rectangle(offset_x, y2, x1 - offset_x, h - y2 + offset_y + 1)
|
||||||
cr.rectangle(x1, y2 + 1, x2 - x1 + 1, h - y2 + offset_y)
|
cr.rectangle(x1, y2 + 1, x2 - x1 + 1, h - y2 + offset_y)
|
||||||
cr.rectangle(x2 + 1, y2 + 1, w - x2 + offset_x, h - y2 + offset_y)
|
cr.rectangle(x2 + 1, y2 + 1, w - x2 + offset_x, h - y2 + offset_y)
|
||||||
cr.rectangle(x2 + 1, y1, w - x2 + offset_x, y2 - y1 + 1)
|
cr.rectangle(x2 + 1, y1, w - x2 + offset_x, y2 - y1 + 1)
|
||||||
@ -818,6 +818,11 @@ class SelectionWidget(Gtk.ScrolledWindow):
|
|||||||
self.zoom_in()
|
self.zoom_in()
|
||||||
elif event.direction == Gdk.ScrollDirection.DOWN:
|
elif event.direction == Gdk.ScrollDirection.DOWN:
|
||||||
self.zoom_out()
|
self.zoom_out()
|
||||||
|
elif event.direction == Gdk.ScrollDirection.SMOOTH:
|
||||||
|
if event.delta_y < 0:
|
||||||
|
self.zoom_in()
|
||||||
|
else:
|
||||||
|
self.zoom_out()
|
||||||
|
|
||||||
# ======================================================
|
# ======================================================
|
||||||
# helpers for mouse event handlers
|
# helpers for mouse event handlers
|
||||||
|
Loading…
Reference in New Issue
Block a user