Merge lp:~markodolar/audience/preview-fixes into lp:~audience-members/audience/trunk

Proposed by MarkoD
Status: Merged
Approved by: Jeremy Wootten
Approved revision: 740
Merged at revision: 735
Proposed branch: lp:~markodolar/audience/preview-fixes
Merge into: lp:~audience-members/audience/trunk
Diff against target: 147 lines (+45/-21)
2 files modified
src/Widgets/Player/PreviewPopover.vala (+36/-7)
src/Widgets/Player/TimeWidget.vala (+9/-14)
To merge this branch: bzr merge lp:~markodolar/audience/preview-fixes
Reviewer Review Type Date Requested Status
Jeremy Wootten code, function Approve
Review via email: mp+322248@code.launchpad.net

Commit message

fixed preview popover not always pointing to correct location

Description of the change

Preview popover was misaligned when you first hovered over progress scale. It was also slightly off when time label changed size.

To post a comment you must log in.
Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

Some code style comments.

Does this bug occur more with long videos? What length recommended for testing?

review: Needs Fixing (code format)
739. By MarkoD

fixed code style

Revision history for this message
MarkoD (markodolar) wrote :

Yes, video has to be long more than an hour. Then when you watch after 59:59, time label on left changes size and popover starts pointing just a couple pixels off.

I noticed that when trying to fix the first bug - when you place mouse on progress scale and if you don't move it after popover becomes visible it stays in the same position it was last time.

I fixed the code style, ready for another review.

Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

I have not tried it on a very long video but notice the following using a 30 minute .vob file.

There is still a defect near the beginning of the video; when moving the cursor backwards along the progress bar so that the preview stays open, the preview will not go beyond a certain point before the play back point. To preview near the beginning you have to close and reopen the preview by moving the cursor away from the progress track and repositioning nearer the beginning.

If commencing the preview near the beginning (before the playback point) and then moving the cursor forward along the track so that the preview stays open, the preview lags behind the cursor.

review: Needs Fixing (function)
Revision history for this message
MarkoD (markodolar) wrote :

I noticed that also and wasn't able to fix it. I suspect that it might be problem with Gtk Popover.

I tried creating and experimenting with another popover and it behaved just like existing preview. When hitting the edge of the window, it didn't update pointing arrow correctly, it just stayed centred. It does look like there is some part inside of arrow that moves properly.

But, if i called hide() then show() after every popover pointing_to update, arrow followed correctly. Not really a good solution tho, also i think that popover somehow started to move up...

Maybe i can try if it works with newer Gtk version. Do you know if i can do this on loki or would be easier to compile and test on some other distro that has newer libraries?

Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

If the hide()/show() method causes flickering it would probably not be acceptable. It should preferably only be used when necessary (near the edges).

Another work around might be to tweak the start and end points of the progress track so that there is room for the popover with the arrow centred when pointing to the start and end of the video.

It does sound like a possible Gtk issue. I would not recommend changing the Gtk libraries on Loki (at least on a production machine) as it might cause other stuff to stop working.

Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

Try this - it seems to fix it:

=== modified file 'src/Widgets/Player/PreviewPopover.vala'
--- src/Widgets/Player/PreviewPopover.vala 2017-04-08 09:58:00 +0000
+++ src/Widgets/Player/PreviewPopover.vala 2017-04-10 11:44:18 +0000
@@ -131,11 +131,13 @@
         });
     }

- public void update_pointing(int parent_width) {
+ public void update_pointing (int x) {
         if (visible) {
             var pointing = pointing_to;
- pointing.x = (int)(req_progress * parent_width);
- set_pointing_to ((Gdk.Rectangle)pointing);
+ pointing_to.x = x;
+ pointing.x = x;
+ pointing.width = int.min (10, x - 20);
+ set_pointing_to (pointing);
         }
     }

=== modified file 'src/Widgets/Player/TimeWidget.vala'
--- src/Widgets/Player/TimeWidget.vala 2017-04-08 09:40:27 +0000
+++ src/Widgets/Player/TimeWidget.vala 2017-04-10 11:46:00 +0000
@@ -90,12 +90,8 @@
         });

         scale.motion_notify_event.connect ((event) => {
- var pointing = preview_popover.pointing_to;
- pointing.x = (int)event.x;
- pointing.width = 0;
- preview_popover.set_pointing_to ((Gdk.Rectangle)pointing);
             preview_popover.set_preview_progress (((double)event.x)/((double)event.window.get_width ()), !main_playback.playing);
-
+ preview_popover.update_pointing ((int)event.x);
             return false;
         });

Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

Ignore "+ pointing_to.x = x;" in update_pointing (). That should have been taken out.

740. By MarkoD

workaround for gtk popover not updating arrow position when hitting the edge

Revision history for this message
MarkoD (markodolar) wrote :

Wow, nice, how did you came up with that :)

What do you think about last commit? I solved it little differently, your solution moved arrow little to fast on start. What it looks like is you just have to change pointing_to.width and Gtk fully updates the arrow.

I also renamed update_pointing() to realign_pointing() to be more clear then created another update_pointing() to handle all pointing changes.

Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

Yes, your commit works fine :-) and is neater than my solution (I did not spend any time optimising it). I got one hang/crash during testing but it was not reproducible and may not be anything to do with this branch (there are some outstanding crasher bugs reported).

review: Approve (code, function)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Widgets/Player/PreviewPopover.vala'
2--- src/Widgets/Player/PreviewPopover.vala 2016-11-02 23:59:41 +0000
3+++ src/Widgets/Player/PreviewPopover.vala 2017-04-10 17:09:38 +0000
4@@ -39,6 +39,8 @@
5 uint show_timer_id = 0;
6 uint hide_timer_id = 0;
7 uint idle_id = 0;
8+ double req_progress = -1;
9+ bool req_loop = false;
10
11 public PreviewPopover (ClutterGst.Playback main_playback) {
12 opacity = GLOBAL_OPACITY;
13@@ -101,8 +103,11 @@
14 cancel_loop_timer ();
15 }
16
17- public void set_preview_progress (double progress, bool loop = false, bool force = false) {
18- if (idle_id > 0) {
19+ public void set_preview_progress (double progress, bool loop = false) {
20+ req_progress = progress;
21+ req_loop = loop;
22+
23+ if (!visible || idle_id > 0) {
24 return;
25 }
26
27@@ -116,7 +121,7 @@
28 playback.playing = loop;
29 if (loop) {
30 loop_timer_id = Timeout.add_seconds (5, () => {
31- set_preview_progress (progress, true, true);
32+ set_preview_progress (progress, true);
33 loop_timer_id = 0;
34 return false;
35 });
36@@ -126,6 +131,27 @@
37 });
38 }
39
40+ public void update_pointing (int x) {
41+ var pointing = pointing_to;
42+ pointing.x = x;
43+
44+ // changing the width properly updates arrow position when popover hits the edge
45+ if (pointing.width == 0) {
46+ pointing.width = 2;
47+ pointing.x -= 1;
48+ } else {
49+ pointing.width = 0;
50+ }
51+
52+ set_pointing_to (pointing);
53+ }
54+
55+ public void realign_pointing (int parent_width) {
56+ if (visible) {
57+ update_pointing ((int)(req_progress * parent_width));
58+ }
59+ }
60+
61 public void schedule_show () {
62 if (show_timer_id > 0) {
63 return;
64@@ -133,10 +159,13 @@
65 cancel_timer (ref hide_timer_id);
66
67 show_timer_id = Timeout.add (300, () => {
68- show_all ();
69- show_timer_id = 0;
70- return false;
71- });
72+ show_all ();
73+ if (req_progress >= 0) {
74+ set_preview_progress (req_progress, req_loop);
75+ }
76+ show_timer_id = 0;
77+ return false;
78+ });
79 }
80
81 public void schedule_hide () {
82
83=== modified file 'src/Widgets/Player/TimeWidget.vala'
84--- src/Widgets/Player/TimeWidget.vala 2016-11-02 23:59:41 +0000
85+++ src/Widgets/Player/TimeWidget.vala 2017-04-10 17:09:38 +0000
86@@ -27,7 +27,6 @@
87 private Audience.Widgets.PreviewPopover preview_popover;
88 private bool released = true;
89 private uint timeout_id = 0;
90- private int original = 0;
91
92 public TimeWidget (ClutterGst.Playback main_playback) {
93 this.main_playback = main_playback;
94@@ -36,6 +35,7 @@
95 halign = Gtk.Align.CENTER;
96 progression_label = new Gtk.Label ("");
97 time_label = new Gtk.Label ("");
98+ scale = new Gtk.Scale.with_range (Gtk.Orientation.HORIZONTAL, 0, 1, 0.1);
99
100 main_playback.notify["progress"].connect (progress_callback);
101
102@@ -49,11 +49,10 @@
103 sensitive = (main_playback.duration != 0);
104 if (sensitive) {
105 preview_popover = new Audience.Widgets.PreviewPopover (main_playback);
106- preview_popover.relative_to = this;
107+ preview_popover.relative_to = scale;
108 }
109 });
110
111- scale = new Gtk.Scale.with_range (Gtk.Orientation.HORIZONTAL, 0, 1, 0.1);
112 scale.expand = true;
113 scale.draw_value = false;
114 scale.can_focus = false;
115@@ -90,18 +89,9 @@
116 return false;
117 });
118
119- // XXX: Store the original size because the popover doesn't update his x=0 position when resizing.
120 scale.motion_notify_event.connect ((event) => {
121- if (original == 0)
122- original = event.window.get_width ();
123-
124- if (preview_popover.visible) {
125- var pointing = preview_popover.pointing_to;
126- var distance = original - event.window.get_width ();
127- pointing.x = (int)(event.x) - event.window.get_width ()/2 - distance/2;
128- preview_popover.set_pointing_to ((Gdk.Rectangle)pointing);
129- preview_popover.set_preview_progress (((double)event.x)/((double)event.window.get_width ()), !main_playback.playing);
130- }
131+ preview_popover.update_pointing ((int) event.x);
132+ preview_popover.set_preview_progress (event.x / ((double) event.window.get_width ()), !main_playback.playing);
133 return false;
134 });
135
136@@ -111,6 +101,11 @@
137 return false;
138 });
139
140+ scale.size_allocate.connect ((alloc_rect) => {
141+ if (preview_popover != null)
142+ preview_popover.realign_pointing (alloc_rect.width);
143+ });
144+
145 add (progression_label);
146 add (scale);
147 add (time_label);

Subscribers

People subscribed via source and target branches

to all changes: