[clutter] examples/layout-manager: Toggle between states
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter] examples/layout-manager: Toggle between states
- Date: Sun, 11 Jan 2015 17:01:14 +0000 (UTC)
commit d56da0ace9bfcb0948d734b148e7e186eb7150b4
Author: Emmanuele Bassi <ebassi gnome org>
Date: Sun Jan 11 17:00:02 2015 +0000
examples/layout-manager: Toggle between states
Instead of using two specific keys, toggle between the circular and grid
layouts using a single key.
examples/layout-manager.c | 31 ++++++++++++++++++++-----------
1 files changed, 20 insertions(+), 11 deletions(-)
---
diff --git a/examples/layout-manager.c b/examples/layout-manager.c
index 1b76844..909df92 100644
--- a/examples/layout-manager.c
+++ b/examples/layout-manager.c
@@ -35,6 +35,7 @@ GType multi_layout_get_type (void);
ClutterLayoutManager * multi_layout_new (void);
void multi_layout_set_state (MultiLayout *layout,
MultiLayoutState state);
+MultiLayoutState multi_layout_get_state (MultiLayout *layout);
void multi_layout_set_spacing (MultiLayout *layout,
float spacing);
@@ -299,6 +300,12 @@ multi_layout_set_state (MultiLayout *self,
clutter_layout_manager_layout_changed (CLUTTER_LAYOUT_MANAGER (self));
}
+MultiLayoutState
+multi_layout_get_state (MultiLayout *self)
+{
+ return self->state;
+}
+
void
multi_layout_set_spacing (MultiLayout *self,
float spacing)
@@ -340,20 +347,23 @@ on_key_press (ClutterActor *stage,
guint keysym = clutter_event_get_key_symbol (event);
MultiLayout *layout = (MultiLayout *) clutter_actor_get_layout_manager (box);
- if (keysym == CLUTTER_KEY_q)
- {
- clutter_main_quit ();
- return CLUTTER_EVENT_STOP;
- }
switch (keysym)
{
- case CLUTTER_KEY_g:
- multi_layout_set_state (layout, MULTI_LAYOUT_GRID);
+ case CLUTTER_KEY_q:
+ clutter_main_quit ();
break;
- case CLUTTER_KEY_c:
- multi_layout_set_state (layout, MULTI_LAYOUT_CIRCLE);
+ case CLUTTER_KEY_t:
+ {
+ MultiLayoutState state = multi_layout_get_state (layout);
+
+ if (state == MULTI_LAYOUT_GRID)
+ multi_layout_set_state (layout, MULTI_LAYOUT_CIRCLE);
+
+ if (state == MULTI_LAYOUT_CIRCLE)
+ multi_layout_set_state (layout, MULTI_LAYOUT_GRID);
+ }
break;
default:
@@ -437,8 +447,7 @@ main (int argc, char *argv[])
label = clutter_text_new ();
clutter_text_set_text (CLUTTER_TEXT (label),
- "Press g\t\342\236\236\tGrid layout\n"
- "Press c\t\342\236\236\tCircular layout\n"
+ "Press t\t\342\236\236\tToggle layout\n"
"Press q\t\342\236\236\tQuit");
clutter_actor_add_constraint (label, clutter_align_constraint_new (stage, CLUTTER_ALIGN_X_AXIS, 0.5));
clutter_actor_add_constraint (label, clutter_align_constraint_new (stage, CLUTTER_ALIGN_Y_AXIS, 0.95));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]