[longomatch] Fix throtlling time updates
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Fix throtlling time updates
- Date: Mon, 7 Jul 2014 11:22:40 +0000 (UTC)
commit 69671929924f011dc6ac0eba2dd50ea085159a84
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Wed May 21 18:18:02 2014 +0200
Fix throtlling time updates
LongoMatch.GUI/Gui/Component/Timeline.cs | 33 ++++++++++++++++++++----------
1 files changed, 22 insertions(+), 11 deletions(-)
---
diff --git a/LongoMatch.GUI/Gui/Component/Timeline.cs b/LongoMatch.GUI/Gui/Component/Timeline.cs
index 69c4262..2faa4c3 100644
--- a/LongoMatch.GUI/Gui/Component/Timeline.cs
+++ b/LongoMatch.GUI/Gui/Component/Timeline.cs
@@ -42,14 +42,15 @@ namespace LongoMatch.Gui.Component
public event RenderPlaylistHandler RenderPlaylist;
const int TIMERULE_HEIGHT = 30;
+ const uint TIMEOUT_MS = 100;
PlaysTimeline timeline;
Timerule timerule;
CategoriesLabels labels;
MediaFile projectFile;
- DateTime lastUpdate;
double secondsPerPixel;
- Time currentTime;
+ uint timeoutID;
+ Time currentTime, nextCurrentTime;
public Timeline ()
{
@@ -68,7 +69,7 @@ namespace LongoMatch.Gui.Component
hbox1.HeightRequest = TIMERULE_HEIGHT;
scrolledwindow1.Vadjustment.ValueChanged += HandleScrollEvent;
scrolledwindow1.Hadjustment.ValueChanged += HandleScrollEvent;
- lastUpdate = DateTime.Now;
+ timeoutID = 0;
}
public TimeNode SelectedTimeNode {
@@ -78,14 +79,7 @@ namespace LongoMatch.Gui.Component
public Time CurrentTime {
set {
- DateTime now = DateTime.Now;
- this.currentTime = value;
- if ((now - lastUpdate).TotalMilliseconds > 100) {
- timeline.CurrentTime = value;
- timerule.CurrentTime = value;
- QueueDraw ();
- lastUpdate = now;
- }
+ nextCurrentTime = value;
}
protected get {
return currentTime;
@@ -97,9 +91,16 @@ namespace LongoMatch.Gui.Component
labels.LoadProject (project, filter);
if(project == null) {
+ if (timeoutID != 0) {
+ GLib.Source.Remove (timeoutID);
+ timeoutID = 0;
+ }
return;
}
+ if (timeoutID == 0) {
+ timeoutID = GLib.Timeout.Add (TIMEOUT_MS, UpdateTime);
+ }
focusscale.Value = 6;
projectFile = project.Description.File;
timerule.Duration = new Time ((int)project.Description.File.Length);
@@ -120,6 +121,16 @@ namespace LongoMatch.Gui.Component
QueueDraw ();
}
+ bool UpdateTime () {
+ if (nextCurrentTime != currentTime) {
+ currentTime = nextCurrentTime;
+ timeline.CurrentTime = currentTime;
+ timerule.CurrentTime = currentTime;
+ QueueDraw ();
+ }
+ return true;
+ }
+
void HandleScrollEvent(object sender, System.EventArgs args)
{
if(sender == scrolledwindow1.Vadjustment)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]