summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuis de Bethencourt <luis@debethencourt.com>2011-03-20 13:26:50 +0100
committerLuis de Bethencourt <luis@debethencourt.com>2011-03-20 13:26:50 +0100
commit856af0e05bf8bdf432d5e63d892d768d5f74f2e7 (patch)
tree7f1d2ff0d6a75b723eb66fb8302fee5868230a4e
parent4f0615a5e12f7b9a94eaadba1c7543da03069fc6 (diff)
ui: added penalty box timeout
added penalty box timeout for all those ui actions which the mouse movement afterwards can interfere with. for example, when hiding the controls the mouse movement when clicking shouldn't show the controls again.
-rw-r--r--src/user_interface.c37
-rw-r--r--src/user_interface.h4
2 files changed, 38 insertions, 3 deletions
diff --git a/src/user_interface.c b/src/user_interface.c
index c0e323e..7444424 100644
--- a/src/user_interface.c
+++ b/src/user_interface.c
@@ -33,6 +33,7 @@ static gboolean controls_timeout_cb (gpointer data);
static gboolean event_cb (ClutterStage * stage, ClutterEvent * event,
gpointer data);
static void load_controls (UserInterface * ui);
+static gboolean penalty_box (gpointer data);
static gchar * position_ns_to_str (gint64 nanoseconds);
static void progress_timing (UserInterface * ui);
static gboolean progress_update_text (gpointer data);
@@ -216,9 +217,23 @@ event_cb (ClutterStage * stage, ClutterEvent * event, gpointer data)
clutter_actor_set_size (ui->control_seekbar, dist, ui->seek_height);
progress_update_text (ui);
}
- else if (actor == ui->control_bg)
+ else if (actor == ui->control_bg || actor == ui->control_title
+ || actor == ui->control_pos)
{
ui->keep_showing_controls = !ui->keep_showing_controls;
+
+ if (ui->keep_showing_controls)
+ {
+ clutter_stage_hide_cursor (CLUTTER_STAGE (ui->stage));
+ } else {
+ penalty_box (ui);
+ show_controls (ui, FALSE);
+ }
+ }
+ else if (actor == ui->texture || actor == ui->stage)
+ {
+ penalty_box (ui);
+ show_controls (ui, FALSE);
}
}
handled = TRUE;
@@ -227,7 +242,8 @@ event_cb (ClutterStage * stage, ClutterEvent * event, gpointer data)
case CLUTTER_MOTION:
{
- show_controls (ui, TRUE);
+ if (!ui->penalty_box_active)
+ show_controls (ui, TRUE);
handled = TRUE;
break;
}
@@ -350,6 +366,22 @@ load_controls (UserInterface * ui)
update_controls_size (ui);
}
+static gboolean
+penalty_box (gpointer data)
+{
+ UserInterface *ui = (UserInterface *) data;
+
+ if (ui->penalty_box_active)
+ {
+ ui->penalty_box_active = FALSE;
+ } else {
+ g_timeout_add (PENALTY_TIME, penalty_box, ui);
+ ui->penalty_box_active = TRUE;
+ }
+
+ return ui->penalty_box_active;
+}
+
static gchar *
position_ns_to_str (gint64 nanoseconds)
{
@@ -587,6 +619,7 @@ load_user_interface (UserInterface * ui)
ui->stage = clutter_stage_get_default ();
ui->controls_showing = FALSE;
ui->keep_showing_controls = FALSE;
+ ui->penalty_box_active = FALSE;
ui->controls_timeout = 0;
ui->seek_width = ui->stage_width / SEEK_WIDTH_RATIO;
ui->seek_height = ui->stage_height / SEEK_HEIGHT_RATIO;
diff --git a/src/user_interface.h b/src/user_interface.h
index 9f41c65..237de10 100644
--- a/src/user_interface.h
+++ b/src/user_interface.h
@@ -47,6 +47,8 @@
#define SEC_IN_HOUR 3600
#define SEC_IN_MIN 60
+#define PENALTY_TIME 500
+
G_BEGIN_DECLS
typedef struct _UserInterface UserInterface;
@@ -54,7 +56,7 @@ typedef struct _UserInterface UserInterface;
struct _UserInterface
{
gboolean controls_showing, keep_showing_controls;
- gboolean fullscreen;
+ gboolean fullscreen, penalty_box_active;
gint title_length;
guint controls_timeout, progress_id;