static gboolean _enter_event_cb (ClutterActor *actor, ClutterCrossingEvent *event, gpointer data) { MxFocusable *focusable; MxFocusManager *f_manager; f_manager = mx_focus_manager_get_for_stage (CLUTTER_STAGE (clutter_actor_get_stage (actor))); focusable = mx_focus_manager_get_focused (f_manager); /* hide the hover state on a button that has accepted focus via the default * focus as we're navigating by mouse and not keys we don't want to move * the focus as we may still want it in the place e.g. search bar */ if ((focusable) && (MNB_IS_LAUNCHER_BUTTON (focusable)) && (CLUTTER_ACTOR (focusable) != actor)) mx_stylable_set_style_pseudo_class (MX_STYLABLE (focusable), NULL); mx_stylable_set_style_pseudo_class (MX_STYLABLE (actor), "hover"); return FALSE; }
static void mex_clock_bin_notify_focused_cb (MxFocusManager *manager, GParamSpec *pspec, MexClockBin *self) { ClutterActor *parent = NULL; MexClockBinPrivate *priv = self->priv; ClutterActor *focused = (ClutterActor *) mx_focus_manager_get_focused (manager); while (focused) { parent = clutter_actor_get_parent (focused); if (focused == (ClutterActor *)self) { clutter_actor_animate (CLUTTER_ACTOR (priv->clock_hbox), CLUTTER_EASE_OUT_QUAD, 150, "opacity", 0x00, NULL); return; } focused = parent; } clutter_actor_animate (CLUTTER_ACTOR (priv->clock_hbox), CLUTTER_EASE_OUT_QUAD, 150, "opacity", 0xff, NULL); }
static void mex_menu_notify_focused_cb (MxFocusManager *manager, GParamSpec *pspec, MexMenu *self) { MxBoxLayout *layout; ClutterActor *focused; MexMenuPrivate *priv = self->priv; gint depth; focused = (ClutterActor *)mx_focus_manager_get_focused (manager); /* Check if our child received focus and store which child it was, * or lose focus. */ if (focused) { ClutterActor *parent = clutter_actor_get_parent (focused); while (parent) { if (MX_IS_BOX_LAYOUT (focused)) layout = (MxBoxLayout *)focused; if (parent == (ClutterActor *)self) { /* We have focus, check what depth we should be at */ depth = GPOINTER_TO_INT (g_object_get_qdata (G_OBJECT (layout), mex_menu_depth_quark)); if ((priv->depth > 0) && (depth < priv->depth)) while (mex_menu_pop (self) != depth); else if ((priv->depth < 0) && (depth > priv->depth)) while (mex_menu_push (self) != depth); if (priv->has_focus) priv->focus_on_add = FALSE; else priv->has_focus = TRUE; return; } focused = parent; parent = clutter_actor_get_parent (focused); } } /* We don't have focus, switch to the root depth */ priv->has_focus = priv->focus_on_add = FALSE; if (priv->depth > 0) while (mex_menu_pop (self)); else if (priv->depth < 0) while (mex_menu_push (self)); }
static void mex_tile_notify_focused_cb (MxFocusManager *manager, GParamSpec *pspec, MexTile *self) { ClutterActor *focus; MexTilePrivate *priv = self->priv; focus = (ClutterActor *)mx_focus_manager_get_focused (manager); if (focus) { ClutterActor *parent = clutter_actor_get_parent (focus); while (parent) { if (focus == (ClutterActor *)self) { if (!priv->has_focus) { priv->has_focus = TRUE; mx_stylable_style_pseudo_class_add (MX_STYLABLE (self), "focus"); } return; } focus = parent; parent = clutter_actor_get_parent (focus); } } priv->has_focus = FALSE; mx_stylable_style_pseudo_class_remove (MX_STYLABLE (self), "focus"); }
static gboolean mex_player_key_press_event (ClutterActor *actor, ClutterKeyEvent *event) { MexPlayerPrivate *priv = MEX_PLAYER (actor)->priv; ClutterStage *stage; MxFocusManager *fmanager; stage = (ClutterStage*) clutter_actor_get_stage (actor); fmanager = mx_focus_manager_get_for_stage (stage); switch (event->keyval) { case CLUTTER_KEY_Down: { if (!priv->controls_visible && !priv->info_visible) return mex_player_set_controls_visible (MEX_PLAYER (actor), TRUE); break; } case MEX_KEY_INFO: { MexContent *content; content = priv->content; if (priv->info_visible) { /* hide the info panel */ clutter_actor_animate (priv->info_panel, CLUTTER_EASE_IN_SINE, 250, "opacity", 0x00, NULL); mx_widget_set_disabled (MX_WIDGET (priv->info_panel), TRUE); mx_widget_set_disabled (MX_WIDGET (priv->controls), FALSE); priv->info_visible = FALSE; if (priv->controls_prev_visible) mex_player_set_controls_visible (MEX_PLAYER (actor), TRUE); } else { /* if you're pressing info button while the media controls are up set them as previously visible */ if (priv->controls_visible) priv->controls_prev_visible = TRUE; MxFocusable *focusable; focusable = mx_focus_manager_get_focused (fmanager); if (MEX_IS_CONTENT_TILE (focusable) && priv->controls_prev_visible == TRUE) { content = mex_content_view_get_content (MEX_CONTENT_VIEW (focusable)); /* to avoid any accidental leak */ if (priv->related_tile) { g_object_unref (priv->related_tile); priv->related_tile = NULL; } priv->related_tile = g_object_ref (focusable); } mex_content_view_set_content (MEX_CONTENT_VIEW (priv->info_panel), content); /* show the info panel */ clutter_actor_animate (priv->info_panel, CLUTTER_EASE_IN_SINE, 250, "opacity", 0xff, NULL); mx_widget_set_disabled (MX_WIDGET (priv->info_panel), FALSE); mx_widget_set_disabled (MX_WIDGET (priv->controls), TRUE); priv->info_visible = TRUE; mex_player_set_controls_visible (MEX_PLAYER (actor), FALSE); mex_push_focus (MX_FOCUSABLE (priv->info_panel)); } return TRUE; } } return FALSE; }
static void mex_column_notify_focused_cb (MxFocusManager *manager, GParamSpec *pspec, MexColumn *self) { GList *c; ClutterActor *focused, *focused_cell; gboolean cell_has_focus; MexColumnPrivate *priv = self->priv; focused = (ClutterActor *)mx_focus_manager_get_focused (manager); /* Check if we have focus, and what child is focused */ focused_cell = NULL; cell_has_focus = FALSE; if (focused) { ClutterActor *parent = clutter_actor_get_parent (focused); while (parent) { if (parent == (ClutterActor *)self) { focused_cell = focused; cell_has_focus = TRUE; /* Check whether focus has really moved */ if ((priv->current_focus == focused_cell) && !priv->has_focus_changed) return; priv->current_focus = focused_cell; break; } focused = parent; parent = clutter_actor_get_parent (focused); } } /* Scroll the adjustment to the top */ if (!cell_has_focus && priv->adjustment) mx_adjustment_interpolate (priv->adjustment, 0, 250, CLUTTER_EASE_OUT_CUBIC); if (cell_has_focus) { gboolean open; open = FALSE; for (c = priv->children; c; c = g_list_next (c)) { ClutterActor *child = c->data; if (priv->current_focus == child) open = TRUE; if (open) mex_column_expand_child (child); else mex_column_shrink_child (child); } } priv->has_focus_changed = FALSE; }
static void mex_column_notify_focused_cb (MxFocusManager *manager, GParamSpec *pspec, MexColumn *self) { GList *c; guint offset, increment; ClutterActor *focused, *focused_cell; gboolean cell_has_focus, has_focus, open, set_tile_important; MexColumnPrivate *priv = self->priv; focused = (ClutterActor *)mx_focus_manager_get_focused (manager); /* Check if we have focus, and what child is focused */ focused_cell = NULL; set_tile_important = FALSE; cell_has_focus = has_focus = FALSE; if (focused) { gboolean contains_column = FALSE; ClutterActor *parent = clutter_actor_get_parent (focused); while (parent) { if (parent == (ClutterActor *)self) { has_focus = TRUE; if (!priv->has_focus) { set_tile_important = TRUE; priv->has_focus = TRUE; } if (focused != priv->header) { cell_has_focus = TRUE; focused_cell = focused; } break; } else if (MEX_IS_COLUMN (parent)) { contains_column = TRUE; } focused = parent; parent = clutter_actor_get_parent (focused); } if (!contains_column) has_focus = TRUE; } if (!has_focus && priv->has_focus) { priv->has_focus = FALSE; set_tile_important = TRUE; } /* Scroll the adjustment to the top */ if (!cell_has_focus && priv->adjustment) mx_adjustment_interpolate (priv->adjustment, 0, 250, CLUTTER_EASE_OUT_CUBIC); /* Open/close boxes as appropriate */ offset = 0; increment = 150; /* If we're changing the tile importance, initialise the state manager */ if (set_tile_important && priv->n_items > 0) { if (priv->expand_timeline) g_object_unref (priv->expand_timeline); priv->expand_timeline = clutter_timeline_new (priv->n_items * increment); clutter_timeline_set_delay (priv->expand_timeline, 350); } /* Loop through children and set the expander box important/unimportant * as necessary, and if necessary, do the same for the tile inside the * expander-box. */ open = has_focus && !cell_has_focus; for (c = priv->children; c; c = c->next) { gchar signal_name[32+16]; ClutterActor *child = c->data; if ((!priv->collapse && priv->has_focus) || (child == focused_cell)) open = TRUE; if (!MEX_IS_EXPANDER_BOX (child)) continue; /* Note, 'marker-reached::' is 16 characters long */ g_snprintf (signal_name, G_N_ELEMENTS (signal_name), "marker-reached::%p", child); if (MEX_IS_CONTENT_BOX (child)) { ClutterActor *tile = mex_content_box_get_tile (MEX_CONTENT_BOX (child)); mex_tile_set_important (MEX_TILE (tile), priv->has_focus); } if (!open) { if (priv->expand_timeline) { if (clutter_timeline_has_marker (priv->expand_timeline, signal_name + 16)) clutter_timeline_remove_marker (priv->expand_timeline, signal_name + 16); g_signal_handlers_disconnect_by_func (priv->expand_timeline, mex_column_expand_drawer_cb, child); } mex_expander_box_set_important (MEX_EXPANDER_BOX (child), FALSE); } else if (set_tile_important) { mex_expander_box_set_important (MEX_EXPANDER_BOX (child), FALSE); clutter_timeline_add_marker_at_time (priv->expand_timeline, signal_name + 16, offset); g_signal_connect_swapped (priv->expand_timeline, signal_name, G_CALLBACK (mex_column_expand_drawer_cb), child); offset += increment; } else mex_expander_box_set_important (MEX_EXPANDER_BOX (child), TRUE); } if (priv->expand_timeline && set_tile_important && (offset >= increment)) clutter_timeline_start (priv->expand_timeline); }