mirror of
https://github.com/brl/mutter.git
synced 2024-12-25 04:22:05 +00:00
examples/layout-manager: Toggle between states
Instead of using two specific keys, toggle between the circular and grid layouts using a single key.
This commit is contained in:
parent
60dbeb9425
commit
d56da0ace9
@ -35,6 +35,7 @@ GType multi_layout_get_type (void);
|
|||||||
ClutterLayoutManager * multi_layout_new (void);
|
ClutterLayoutManager * multi_layout_new (void);
|
||||||
void multi_layout_set_state (MultiLayout *layout,
|
void multi_layout_set_state (MultiLayout *layout,
|
||||||
MultiLayoutState state);
|
MultiLayoutState state);
|
||||||
|
MultiLayoutState multi_layout_get_state (MultiLayout *layout);
|
||||||
void multi_layout_set_spacing (MultiLayout *layout,
|
void multi_layout_set_spacing (MultiLayout *layout,
|
||||||
float spacing);
|
float spacing);
|
||||||
|
|
||||||
@ -299,6 +300,12 @@ multi_layout_set_state (MultiLayout *self,
|
|||||||
clutter_layout_manager_layout_changed (CLUTTER_LAYOUT_MANAGER (self));
|
clutter_layout_manager_layout_changed (CLUTTER_LAYOUT_MANAGER (self));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MultiLayoutState
|
||||||
|
multi_layout_get_state (MultiLayout *self)
|
||||||
|
{
|
||||||
|
return self->state;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
multi_layout_set_spacing (MultiLayout *self,
|
multi_layout_set_spacing (MultiLayout *self,
|
||||||
float spacing)
|
float spacing)
|
||||||
@ -340,20 +347,23 @@ on_key_press (ClutterActor *stage,
|
|||||||
guint keysym = clutter_event_get_key_symbol (event);
|
guint keysym = clutter_event_get_key_symbol (event);
|
||||||
MultiLayout *layout = (MultiLayout *) clutter_actor_get_layout_manager (box);
|
MultiLayout *layout = (MultiLayout *) clutter_actor_get_layout_manager (box);
|
||||||
|
|
||||||
if (keysym == CLUTTER_KEY_q)
|
|
||||||
{
|
|
||||||
clutter_main_quit ();
|
|
||||||
return CLUTTER_EVENT_STOP;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (keysym)
|
switch (keysym)
|
||||||
{
|
{
|
||||||
case CLUTTER_KEY_g:
|
case CLUTTER_KEY_q:
|
||||||
multi_layout_set_state (layout, MULTI_LAYOUT_GRID);
|
clutter_main_quit ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CLUTTER_KEY_c:
|
case CLUTTER_KEY_t:
|
||||||
|
{
|
||||||
|
MultiLayoutState state = multi_layout_get_state (layout);
|
||||||
|
|
||||||
|
if (state == MULTI_LAYOUT_GRID)
|
||||||
multi_layout_set_state (layout, MULTI_LAYOUT_CIRCLE);
|
multi_layout_set_state (layout, MULTI_LAYOUT_CIRCLE);
|
||||||
|
|
||||||
|
if (state == MULTI_LAYOUT_CIRCLE)
|
||||||
|
multi_layout_set_state (layout, MULTI_LAYOUT_GRID);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -437,8 +447,7 @@ main (int argc, char *argv[])
|
|||||||
|
|
||||||
label = clutter_text_new ();
|
label = clutter_text_new ();
|
||||||
clutter_text_set_text (CLUTTER_TEXT (label),
|
clutter_text_set_text (CLUTTER_TEXT (label),
|
||||||
"Press g\t\342\236\236\tGrid layout\n"
|
"Press t\t\342\236\236\tToggle layout\n"
|
||||||
"Press c\t\342\236\236\tCircular layout\n"
|
|
||||||
"Press q\t\342\236\236\tQuit");
|
"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_X_AXIS, 0.5));
|
||||||
clutter_actor_add_constraint (label, clutter_align_constraint_new (stage, CLUTTER_ALIGN_Y_AXIS, 0.95));
|
clutter_actor_add_constraint (label, clutter_align_constraint_new (stage, CLUTTER_ALIGN_Y_AXIS, 0.95));
|
||||||
|
Loading…
Reference in New Issue
Block a user