Exemplo n.º 1
0
static void
mex_column_view_init (MexColumnView *self)
{
  MexColumnViewPrivate *priv = self->priv = COLUMN_VIEW_PRIVATE (self);

  /* Begin private children */
  clutter_actor_push_internal (CLUTTER_ACTOR (self));

  /* Create the header */
  priv->header = mx_box_layout_new ();
  mx_box_layout_set_orientation ((MxBoxLayout *) priv->header,
                                 MX_ORIENTATION_HORIZONTAL);

  clutter_actor_push_internal (CLUTTER_ACTOR (self));
  clutter_actor_set_parent (priv->header, CLUTTER_ACTOR (self));
  clutter_actor_pop_internal (CLUTTER_ACTOR (self));

  priv->button = mx_button_new ();
  mx_stylable_set_style_class (MX_STYLABLE (priv->button), "Header");
  priv->label = mx_label_new ();
  g_object_set (priv->label, "clip-to-allocation", TRUE, "fade-out", TRUE,
                NULL);

  clutter_actor_add_child (CLUTTER_ACTOR (priv->button), priv->label);

  clutter_actor_add_child (priv->header, priv->button);
  clutter_container_child_set (CLUTTER_CONTAINER (priv->header), priv->button,
                               "expand", TRUE,
                               "x-fill", TRUE,
                               "x-align", MX_ALIGN_START,
                               "y-fill", TRUE,
                               NULL);

  g_signal_connect (priv->button, "clicked",
                    G_CALLBACK (mex_column_header_clicked_cb), self);


  priv->scroll = mex_scroll_view_new ();
  mx_kinetic_scroll_view_set_scroll_policy (MX_KINETIC_SCROLL_VIEW (priv->scroll),
                                            MX_SCROLL_POLICY_VERTICAL);
  mex_scroll_view_set_indicators_hidden (MEX_SCROLL_VIEW (priv->scroll),
                                         TRUE);
  clutter_actor_set_parent (priv->scroll, CLUTTER_ACTOR (self));

  priv->column = mex_column_new ();
  clutter_actor_add_child (CLUTTER_ACTOR (priv->scroll), priv->column);

  g_signal_connect (priv->column, "notify::opened",
                    G_CALLBACK (mex_column_view_opened_cb), self);

  /* End of private children */
  clutter_actor_pop_internal (CLUTTER_ACTOR (self));

  /* Set the column as reactive and enable collapsing */
  clutter_actor_set_reactive (CLUTTER_ACTOR (self), TRUE);
}
Exemplo n.º 2
0
static void
startup_cb (MxApplication *application)
{
  MxWindow *window;
  ClutterActor *scroll, *child;
  gint i;

  window = mx_application_create_window (application, "Test Widgets");

  /* Create scroll view */
  scroll = mx_kinetic_scroll_view_new ();
  mx_kinetic_scroll_view_set_use_grab (MX_KINETIC_SCROLL_VIEW (scroll), TRUE);
  mx_kinetic_scroll_view_set_mouse_button (MX_KINETIC_SCROLL_VIEW (scroll), 3);
  clutter_actor_set_clip_to_allocation (scroll, TRUE);

  child = mx_box_layout_new_with_orientation (MX_ORIENTATION_VERTICAL);

  for (i = 0; i < 10000; i++) {
    ClutterActor *layout, *label, *icon;
    gchar *s = g_strdup_printf ("Row %d", i);

    layout = mx_box_layout_new_with_orientation (MX_ORIENTATION_HORIZONTAL);
    label = mx_label_new_with_text (s);
    clutter_actor_add_child (layout, label);
    g_free (s);

    icon = mx_icon_new ();
    mx_icon_set_icon_name (MX_ICON (icon), "object-rotate-left");
    mx_icon_set_icon_size (MX_ICON (icon), 32);
    clutter_actor_add_child (layout, icon);

    clutter_actor_add_child (child, layout);
  }

  clutter_actor_add_child (scroll, child);

  mx_window_set_child (window, scroll);

  /* show the window */
  mx_window_set_has_toolbar (window, FALSE);
  mx_window_show (window);
}
Exemplo n.º 3
0
static void
mex_grid_view_init (MexGridView *self)
{
  MexGridViewPrivate *priv = self->priv = GRID_VIEW_PRIVATE (self);
  ClutterActor *scroll_view;

  priv->state = STATE_CLOSED;

  /* Create the menu */
  priv->menu_layout = mex_menu_new ();
  mex_resizing_hbox_set_max_depth (MEX_RESIZING_HBOX (priv->menu_layout), 1);

  /* Add a title/icon */
  priv->menu_title = mx_label_new ();

  mx_stylable_set_style_class (MX_STYLABLE (priv->menu_title), "Header");
  clutter_actor_set_name (priv->menu_title, "menu-header");

  priv->menu = (ClutterActor*) mex_menu_get_layout (MEX_MENU (priv->menu_layout));

  clutter_actor_set_width (priv->menu, MENU_MIN_WIDTH);
  clutter_actor_insert_child_at_index (priv->menu, priv->menu_title, 0);


  /* Add the grid */
  priv->grid_layout = mx_box_layout_new ();
  mx_box_layout_set_orientation (MX_BOX_LAYOUT (priv->grid_layout),
                                 MX_ORIENTATION_VERTICAL);

  /* header */
  priv->grid_title = mx_label_new ();
  mx_stylable_set_style_class (MX_STYLABLE (priv->grid_title), "Header");
  clutter_actor_add_child (priv->grid_layout, priv->grid_title);

  /* scroll view */
  scroll_view = mex_scroll_view_new ();
  mx_kinetic_scroll_view_set_scroll_policy (MX_KINETIC_SCROLL_VIEW (scroll_view),
                                            MX_SCROLL_POLICY_VERTICAL);
  mx_stylable_set_style_class (MX_STYLABLE (scroll_view), "Grid");
  mx_box_layout_insert_actor_with_properties (MX_BOX_LAYOUT (priv->grid_layout),
                                              scroll_view, 1,
                                              "expand", TRUE, NULL);

  /* grid */
  priv->grid = mex_grid_new ();
  mx_bin_set_child (MX_BIN (scroll_view), priv->grid);
  clutter_actor_set_opacity (priv->grid, 0);


  /* Name actors so we can style */
  clutter_actor_set_name (CLUTTER_ACTOR (self), "grid-page");
  clutter_actor_set_name (priv->grid_layout, "content");

  clutter_actor_push_internal (CLUTTER_ACTOR (self));

  clutter_actor_set_parent (priv->menu_layout, CLUTTER_ACTOR (self));
  clutter_actor_set_parent (priv->grid_layout, CLUTTER_ACTOR (self));

  clutter_actor_pop_internal (CLUTTER_ACTOR (self));


  /* timeline for animations */
  priv->timeline = clutter_timeline_new (ANIMATION_DURATION);
  priv->alpha = clutter_alpha_new_full (priv->timeline, CLUTTER_EASE_IN_OUT_CUBIC);
  g_signal_connect (priv->timeline, "new-frame",
                    G_CALLBACK (mex_grid_view_timeline_cb), self);
  g_signal_connect (priv->timeline, "completed",
                    G_CALLBACK (mex_grid_view_timeline_complete_cb), self);
}