[pitivi] timeline: Zoom around playhead with alt+scroll
- From: Thibault Saunier <tsaunier src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] timeline: Zoom around playhead with alt+scroll
- Date: Thu, 17 Dec 2015 10:04:49 +0000 (UTC)
commit 1a395586185e1c54410db91807a23e330494365b
Author: Alexandru Băluț <alexandru balut gmail com>
Date: Thu Dec 3 00:01:42 2015 +0100
timeline: Zoom around playhead with alt+scroll
Reviewed-by: Thibault Saunier <tsaunier gnome org>
Differential Revision: https://phabricator.freedesktop.org/D575
pitivi/timeline/timeline.py | 20 ++++++++++++++------
1 files changed, 14 insertions(+), 6 deletions(-)
---
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index 9d00376..3d545d2 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -213,6 +213,7 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
"""
Contains the layer controls and the layers representation.
+ @type parent: L{pitivi.timeline.timeline.TimelineContainer}
@type _project: L{pitivi.project.Project}
"""
@@ -567,18 +568,25 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
self.parent.scroll_down()
elif delta_y < 0:
self.parent.scroll_up()
- elif event.get_state() & Gdk.ModifierType.CONTROL_MASK:
- # Remember the time at the mouse position so it remains
- # in the same position.
+ elif event.get_state() & (Gdk.ModifierType.CONTROL_MASK |
+ Gdk.ModifierType.MOD1_MASK):
x -= CONTROL_WIDTH
- mouse_position = self.pixelToNs(x + self.hadj.get_value())
+ # Figure out first where to scroll at the end
+ if event.get_state() & Gdk.ModifierType.CONTROL_MASK:
+ # The time at the mouse cursor.
+ position = self.pixelToNs(x + self.hadj.get_value())
+ else:
+ # The time at the playhead.
+ position = self.__last_position
if delta_y > 0:
Zoomable.zoomOut()
elif delta_y < 0:
Zoomable.zoomIn()
- if delta_y > 0 or delta_y < 0:
+ self.__setLayoutSize()
+ if delta_y:
self.queue_draw()
- self.hadj.set_value(self.nsToPixel(mouse_position) - x)
+ # Scroll so position is at the current mouse cursor position.
+ self.hadj.set_value(self.nsToPixel(position) - x)
else:
if delta_y > 0:
self.parent.scroll_right()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]