Esempio n. 1
0
static void
mnb_spinner_constructed (GObject *self)
{
  MnbSpinnerPrivate *priv = MNB_SPINNER (self)->priv;
  MxWidget          *widget = MX_WIDGET (self);
  ClutterTexture    *background;
  ClutterTimeline   *timeline;

  /*
   * Mx does not seem to load the style info until the first show, but we want
   * to get hold of the background asset here to work out the frame count, so
   * we need to force the style loading.
   *
   * NB: mx_widget_ensure_style() does not work here, because the MxWidget
   *     is_style_dirty flag is cleared at this point.
   */
  mx_stylable_style_changed (MX_STYLABLE (widget), MX_STYLE_CHANGED_FORCE);

  if ((background = (ClutterTexture *) mx_widget_get_background_image (widget)))
    {
      gint  tx_w, tx_h;
      guint duration;

      if (!CLUTTER_IS_TEXTURE (background))
        {
          g_critical ("Expected ClutterTexture, but got %s",
                      G_OBJECT_TYPE_NAME (background));
          return;
        }

      /*
       * The background texture is a strip of squares making up the individual
       * frames in the animation, so the width matches the height of the
       * texture.
       */
      clutter_texture_get_base_size (background, &tx_w, &tx_h);

      priv->n_frames = tx_w / tx_h;

      if (tx_w % tx_h)
        g_warning (G_STRLOC ": Expected texture size %d x %d, got %d x %d",
                   tx_h * priv->n_frames, tx_h, tx_w, tx_h);

      /*
       * Setup a looped timeline with a marker that fires everytime we should
       * advance to a new frame.
       *
       * Assume the whole animation is to last 1s.
       */
      duration = 1000/ priv->n_frames;

      timeline = priv->timeline = clutter_timeline_new (duration);

      clutter_timeline_set_loop (timeline, TRUE);
      clutter_timeline_add_marker_at_time (timeline, "next", duration);
      clutter_timeline_stop (timeline);

      g_signal_connect (timeline, "marker-reached",
                        G_CALLBACK (mnb_spinner_marker_reached_cb),
                        self);
    }
  else
    g_warning ("%s did not have background-image set in style !!!",
               G_OBJECT_TYPE_NAME (self));
}
Esempio n. 2
0
int
main (int argc, char *argv[])
{
	ClutterActor *stage, *box, *bg, *bg2, *inset, *labelContainer,
	             *contentContainer, *labelbg, *fixed, *upper, *lower, *lowerInner;
	ClutterLayoutManager *layout, *labelContainer_l, *layoutFixed;
	ClutterTimeline *timeline;
	ClutterContent *canvas, *canvas1;

	ClutterColor color_with_trans = {0,0,0,0};
	clutter_x11_set_use_argb_visual (TRUE);

	if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
	    return (1);

	/* prepare the stage */
	stage = clutter_stage_new ();
	clutter_stage_set_use_alpha (CLUTTER_STAGE (stage), TRUE);
	clutter_stage_set_color (CLUTTER_STAGE (stage), &color_with_trans);
	clutter_stage_set_title (CLUTTER_STAGE (stage), "IPLocation Database");
	clutter_actor_set_background_color (stage, CLUTTER_COLOR_WHITE);
	clutter_actor_set_size (stage, 648, 246);
	clutter_stage_set_user_resizable (CLUTTER_STAGE (stage), TRUE);
	clutter_actor_show (stage);
	g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);

	layout = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
			CLUTTER_BIN_ALIGNMENT_CENTER);

	box = clutter_actor_new ();
	clutter_actor_add_constraint (box, clutter_bind_constraint_new (stage, CLUTTER_BIND_SIZE, 0.0));
	clutter_actor_set_background_color (box, CLUTTER_COLOR_WHITE);
	clutter_actor_set_layout_manager (box, layout);
	clutter_actor_add_constraint (box, clutter_align_constraint_new (stage, CLUTTER_ALIGN_X_AXIS, 1));
	clutter_actor_set_name (box, "box");
	clutter_actor_add_child (stage, box);


	bg = clutter_actor_new ();
	//clutter_actor_set_background_color (bg, clutter_color_new (50, 50, 50, 255));
	clutter_actor_set_name (bg, "background");
	clutter_actor_set_reactive (bg, TRUE);
	//clutter_actor_set_x_expand (bg, TRUE);
	//clutter_actor_set_y_expand (bg, TRUE);
	clutter_actor_set_x_align (bg, CLUTTER_ACTOR_ALIGN_END);
	clutter_actor_set_y_align (bg, CLUTTER_ACTOR_ALIGN_FILL);
	canvas1 = clutter_canvas_new ();
	clutter_canvas_set_size (CLUTTER_CANVAS (canvas1), 300, 300);
	clutter_actor_set_content (bg, canvas1);
	/*clutter_actor_set_content_scaling_filters (bg2,
		 CLUTTER_SCALING_FILTER_TRILINEAR,
		 CLUTTER_SCALING_FILTER_LINEAR);*/
	g_object_unref (canvas1);
	clutter_actor_add_child (box, bg);


	bg2 = clutter_actor_new ();
	//clutter_actor_set_background_color (bg2, clutter_color_new (0, 100, 100, 255*.5));
	clutter_actor_set_name (bg2, "background");
	clutter_actor_set_reactive (bg2, TRUE);
	clutter_actor_set_size (bg2, 0, 0);
	//clutter_actor_set_x_expand (bg2, TRUE);
	//clutter_actor_set_y_expand (bg2, TRUE);
	clutter_actor_set_x_align (bg2, CLUTTER_ACTOR_ALIGN_END);
	clutter_actor_set_y_align (bg2, CLUTTER_ACTOR_ALIGN_FILL);
	clutter_actor_set_clip_to_allocation(bg2, TRUE);
	clutter_actor_add_child (box, bg2);
	clutter_actor_set_layout_manager (bg2, clutter_box_layout_new ());
	canvas = clutter_canvas_new ();
	clutter_canvas_set_size (CLUTTER_CANVAS (canvas), 300, 300);
	clutter_actor_set_content (bg2, canvas);
	/*clutter_actor_set_content_scaling_filters (bg2,
		 CLUTTER_SCALING_FILTER_TRILINEAR,
		 CLUTTER_SCALING_FILTER_LINEAR);*/
	g_object_unref (canvas);


	inset = clutter_actor_new ();
	//clutter_actor_set_background_color (inset, clutter_color_new (255, 0, 0, 255));
	clutter_actor_set_name (inset, "inset");
	clutter_actor_set_reactive (inset, TRUE);


	clutter_actor_set_margin_top (inset, 18);
	clutter_actor_set_margin_right (inset, 18);
	clutter_actor_set_margin_bottom (inset, 18);
	clutter_actor_set_margin_left (inset, 48);
	//clutter_actor_set_x_expand (inset, TRUE);
	//clutter_actor_set_y_expand (inset, TRUE);
	clutter_actor_set_x_align (inset, CLUTTER_ACTOR_ALIGN_FILL);
	clutter_actor_set_y_align (inset, CLUTTER_ACTOR_ALIGN_FILL);
	clutter_actor_set_clip_to_allocation(inset, TRUE);
	clutter_actor_add_child (bg2, inset);


	layout = clutter_box_layout_new ();
	clutter_box_layout_set_vertical (CLUTTER_BOX_LAYOUT (layout),
	                                    TRUE);
	clutter_box_layout_set_spacing (CLUTTER_BOX_LAYOUT (layout), 5);
	clutter_actor_set_layout_manager (inset, layout);


	labelContainer = clutter_actor_new ();
	clutter_actor_set_size (labelContainer, 0, 35);
	//clutter_actor_set_background_color (labelContainer, clutter_color_new (34, 134, 158, 255));
	clutter_actor_set_name (labelContainer, "labelContainer");
	clutter_actor_set_reactive (labelContainer, TRUE);
	//clutter_actor_set_x_expand (labelContainer, TRUE);
	//clutter_actor_set_y_expand (labelContainer, TRUE);
	clutter_actor_add_child (inset, labelContainer);

	labelContainer_l = clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER,
			CLUTTER_BIN_ALIGNMENT_CENTER);
	clutter_actor_set_layout_manager (labelContainer, labelContainer_l);


	labelbg = clutter_actor_new ();
	clutter_actor_set_background_color (labelbg, clutter_color_new (34, 134, 158, 255));
	clutter_actor_set_name (labelbg, "labelbg");
	//clutter_actor_set_x_expand (labelbg, TRUE);
	clutter_actor_set_size (labelbg, 0, 35);
	clutter_actor_set_x_align (labelbg, CLUTTER_ACTOR_ALIGN_START);
	clutter_actor_set_y_align (labelbg, CLUTTER_ACTOR_ALIGN_FILL);
	clutter_actor_add_child (labelContainer, labelbg);


	contentContainer = clutter_actor_new ();
	clutter_actor_set_size (contentContainer, 0, 0);

	clutter_actor_set_background_color (contentContainer, clutter_color_new (0.290196*255, 0.427451*255, 0.462745*255, 255));
	clutter_actor_set_name (contentContainer, "labelContainer");
	//clutter_actor_set_x_expand (contentContainer, TRUE);
	//clutter_actor_set_y_expand (contentContainer, TRUE);
	clutter_actor_set_layout_manager (contentContainer, clutter_fixed_layout_new ());
	clutter_actor_add_child (inset, contentContainer);

	fixed = clutter_actor_new ();
	clutter_actor_set_background_color (fixed, clutter_color_new (9, 53, 71, 255));
	clutter_actor_set_name (fixed, "fixed");
	clutter_actor_set_size (fixed, 582, 210-40);
	clutter_actor_set_position (fixed, 582, 0);
	layoutFixed = clutter_box_layout_new ();
	clutter_box_layout_set_vertical (CLUTTER_BOX_LAYOUT (layoutFixed),
		                                TRUE);
	clutter_box_layout_set_spacing (CLUTTER_BOX_LAYOUT (layoutFixed), 8);
	clutter_actor_set_layout_manager (fixed, layoutFixed);
	clutter_actor_add_child (contentContainer, fixed);


	//------------------------------------------------------------------------//

	lower = clutter_actor_new ();
	clutter_actor_set_size (lower, 0, 0);
	clutter_actor_set_name (lower, "lower");
	//clutter_actor_set_x_expand (lower, TRUE);
	//clutter_actor_set_y_expand (lower, TRUE);
	clutter_actor_set_margin_right (lower, 8);
	clutter_actor_set_margin_top (lower, 8);
	clutter_actor_set_margin_left (lower, 8);
	clutter_actor_set_layout_manager (lower, clutter_fixed_layout_new ());
	clutter_actor_set_clip_to_allocation(lower, TRUE);
	clutter_actor_add_child (fixed, lower);

	lowerInner = clutter_actor_new ();
	clutter_actor_set_background_color (lowerInner, clutter_color_new (255, 255, 255, 30));
	clutter_actor_set_name (lowerInner, "fixed");
	clutter_actor_set_size (lowerInner, 566, 113);
	clutter_actor_set_position (lowerInner, 566, 0);
	clutter_actor_add_child (lower, lowerInner);


	upper = clutter_actor_new ();
	clutter_actor_set_size (upper, 0, 33);
	clutter_actor_set_name (upper, "upper");
	clutter_actor_set_x_expand (upper, TRUE);
	//clutter_actor_set_y_expand (upper, TRUE);
	clutter_actor_set_margin_bottom (upper, 8);
	clutter_actor_set_margin_right (upper, 8);
	clutter_actor_set_margin_left (upper, 8);
	//clutter_actor_set_layout_manager (upper, clutter_fixed_layout_new ());
	clutter_actor_add_child (fixed, upper);


	timeline = clutter_timeline_new (57/24.*1000);
	clutter_timeline_add_marker_at_time(timeline, "first", (40-35)/24.*1000);
	clutter_timeline_add_marker_at_time(timeline, "second", (46-35)/24.*1000);
	clutter_timeline_add_marker_at_time(timeline, "third", (51-35)/24.*1000);
	clutter_timeline_add_marker_at_time(timeline, "fourth", (52-35)/24.*1000);
	clutter_timeline_add_marker_at_time(timeline, "fifth", (58-35)/24.*1000);

	g_signal_connect (timeline, "marker-reached::first", G_CALLBACK (plate1anim), bg);
	g_signal_connect (timeline, "marker-reached::second", G_CALLBACK (plate2anim), bg2);
	g_signal_connect (timeline, "marker-reached::third", G_CALLBACK (plate3anim), labelbg);
	g_signal_connect (timeline, "marker-reached::fourth", G_CALLBACK (plate4anim), fixed);
	g_signal_connect (timeline, "marker-reached::fifth", G_CALLBACK (plate5anim), lowerInner);
	g_signal_connect (canvas1, "draw", G_CALLBACK (draw_1), NULL);
	g_signal_connect (bg, "paint", G_CALLBACK (on_actor_resize), canvas);
	g_signal_connect (canvas, "draw", G_CALLBACK (draw), NULL);
	g_signal_connect (bg2, "paint", G_CALLBACK (on_actor_resize), canvas);


	clutter_content_invalidate (canvas);

	clutter_timeline_start (timeline);
	clutter_main ();

	return (EXIT_SUCCESS);
}
Esempio n. 3
0
static void
mex_column_expand_children (MexColumn    *column,
                            ClutterActor *start_at)
{
  MexColumnPrivate *priv = column->priv;
  guint offset, increment;
  GList *c;
  gchar **markers;
  gint i;
  gboolean start;

  if (priv->n_items < 1)
    return;

  /* Open/close boxes as appropriate */
  offset = 0;
  increment = 150;

  clutter_timeline_set_duration (priv->expand_timeline,
                                 priv->n_items * increment);

  clutter_timeline_set_delay (priv->expand_timeline, 350);

  /* remove the previous markers */
  markers = clutter_timeline_list_markers (priv->expand_timeline, -1, NULL);
  if (markers)
    {
      for (i = 0; markers[i]; i++)
        {
          clutter_timeline_remove_marker (priv->expand_timeline,
                                          markers[i]);
        }
    }
  g_strfreev (markers);

  /* start is TRUE if start_at is NULL, otherwise it is set to TRUE when the
   * start_at item is found */
  start = (start_at == NULL);

  for (c = priv->children; c; c = g_list_next (c))
    {
      gchar signal_name[32+16];
      ClutterActor *child = c->data;

      if (!MEX_IS_CONTENT_BOX (child))
        continue;

      mex_content_box_set_important (MEX_CONTENT_BOX (child), TRUE);
      mex_column_expand_child (child);

      /* continue until the start item has been found */
      if (child == start_at)
        start = TRUE;

      if (!start)
        continue;

      /* Note, 'marker-reached::' is 16 characters long */
      g_snprintf (signal_name, G_N_ELEMENTS (signal_name),
                  "marker-reached::%p", child);

      /* stagger opening */
      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_child),
                                child);

      offset += increment;

    }

    clutter_timeline_start (priv->expand_timeline);
}
Esempio n. 4
0
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);
}