예제 #1
0
파일: astro-applet.c 프로젝트: UIKit0/toys
/* GObject stuff */
static void
astro_applet_paint (ClutterActor *applet)
{
  AstroAppletPrivate *priv;
  GList *c;
  gint width = 0;

  g_return_if_fail (ASTRO_IS_APPLET (applet));
  priv = ASTRO_APPLET (applet)->priv;
  
  c = clutter_container_get_children (CLUTTER_CONTAINER (applet));
  
  for (c = c; c; c = c->next)
    {
      gint total = clutter_actor_get_y (c->data) + 
                   clutter_actor_get_width (c->data);
      if (total > width && c->data != priv->texture)
        width = total;
    }
  
  clutter_actor_set_size (priv->texture,
                          width,
                          clutter_actor_get_height (applet));

   c = clutter_container_get_children (CLUTTER_CONTAINER (applet));
   for (c = c; c; c = c->next)
    clutter_actor_paint (c->data);
    
}
예제 #2
0
static gboolean
handle_button_press_event_cb (ClutterActor       *actor,
                              ClutterButtonEvent *event,
                              StScrollBar        *bar)
{
  StScrollBarPrivate *priv = bar->priv;

  if (event->button != 1)
    return FALSE;

  if (!clutter_actor_transform_stage_point (priv->handle,
                                            event->x,
                                            event->y,
                                            &priv->x_origin,
                                            &priv->y_origin))
    return FALSE;

  /* Account for the scrollbar-trough-handle nesting. */
  priv->x_origin += clutter_actor_get_x (priv->trough);
  priv->y_origin += clutter_actor_get_y (priv->trough);

  g_assert (!priv->grabbed);

  clutter_grab_pointer (priv->handle);
  priv->grabbed = TRUE;
  g_signal_emit (bar, signals[SCROLL_START], 0);

  return TRUE;
}
예제 #3
0
파일: astro-appview.c 프로젝트: UIKit0/toys
static void
astro_appview_show (ClutterActor *view)
{
  AstroAppviewPrivate *priv;
  static ClutterTimeline *show_time = NULL;
  
  g_return_if_fail (ASTRO_IS_APPVIEW (view));
  priv = ASTRO_APPVIEW (view)->priv;

  if (CLUTTER_IS_TIMELINE (show_time) &&clutter_timeline_is_playing (show_time))
    {
      clutter_timeline_stop (show_time);
      g_object_unref (show_time);
    }

  clutter_actor_set_x (view, -1* clutter_actor_get_width (view));
  CLUTTER_ACTOR_CLASS (astro_appview_parent_class)->show (view);

  show_time = clutter_effect_move (priv->show_temp,
                                   CLUTTER_ACTOR (view),
                            (CSW()/2)- (priv->active * ASTRO_APPICON_SPACING()),
                             clutter_actor_get_y (CLUTTER_ACTOR (view)),
                                   NULL, NULL);

  g_signal_connect (show_time, "new-frame",
                    G_CALLBACK (on_move_timeline_new_frame), view); 
}
예제 #4
0
/* Dump actors */
static void _xfdashboard_dump_actor_internal(ClutterActor *inActor, gint inLevel)
{
	ClutterActorIter	iter;
	ClutterActor		*child;
	gint				i;

	g_return_if_fail(CLUTTER_IS_ACTOR(inActor));
	g_return_if_fail(inLevel>=0);

	clutter_actor_iter_init(&iter, CLUTTER_ACTOR(inActor));
	while(clutter_actor_iter_next(&iter, &child))
	{
		for(i=0; i<inLevel; i++) g_print("  ");
		g_print("+- %s@%p - name: %s - geometry: %.2f,%.2f [%.2fx%.2f], mapped: %s, visible: %s, children: %d\n",
					G_OBJECT_TYPE_NAME(child), child,
					clutter_actor_get_name(child),
					clutter_actor_get_x(child),
					clutter_actor_get_y(child),
					clutter_actor_get_width(child),
					clutter_actor_get_height(child),
					clutter_actor_is_mapped(child) ? "yes" : "no",
					clutter_actor_is_visible(child) ? "yes" : "no",
					clutter_actor_get_n_children(child));
		if(clutter_actor_get_n_children(child)>0) _xfdashboard_dump_actor_internal(child, inLevel+1);
	}
}
예제 #5
0
파일: astro-appview.c 프로젝트: UIKit0/toys
void
astro_appview_advance (AstroAppview *view,
                       gint          n)
{
  AstroAppviewPrivate *priv;
  static ClutterTimeline *move_time = NULL;
  gint new_active;

  g_return_if_fail (ASTRO_IS_APPVIEW (view));
  priv = view->priv;

  new_active = priv->active + n;
  if (new_active < 0 || new_active >= g_list_length (priv->apps))
    return;
  priv->active = new_active;

  if (CLUTTER_IS_TIMELINE (move_time) &&clutter_timeline_is_playing (move_time))
    {
      clutter_timeline_stop (move_time);
      g_object_unref (move_time);
    }
 
  move_time = clutter_effect_move (priv->move_temp,
                                   CLUTTER_ACTOR (view),
                          (CSW()/2)- (priv->active * ASTRO_APPICON_SPACING ()),
                                    clutter_actor_get_y (CLUTTER_ACTOR (view)),
                                    NULL, NULL);

  g_signal_connect (move_time, "new-frame",
                    G_CALLBACK (on_move_timeline_new_frame), view);
}
예제 #6
0
파일: astro-appview.c 프로젝트: UIKit0/toys
static void
astro_appview_hide (ClutterActor *view)
{
  AstroAppviewPrivate *priv;
  static ClutterTimeline *hide_time = NULL;
  
  g_return_if_fail (ASTRO_IS_APPVIEW (view));
  priv = ASTRO_APPVIEW (view)->priv;

  if (CLUTTER_IS_TIMELINE (hide_time) &&clutter_timeline_is_playing (hide_time))
    {
      clutter_timeline_stop (hide_time);
      g_object_unref (hide_time);
    }
  
  hide_time = clutter_effect_move (priv->hide_temp,
                                   CLUTTER_ACTOR (view),
                                   -1 * clutter_actor_get_width (view),
                                   clutter_actor_get_y (CLUTTER_ACTOR (view)),
                                   NULL, NULL);

  g_signal_connect (hide_time, "new-frame",
                    G_CALLBACK (on_move_timeline_new_frame), view); 
  g_signal_connect (hide_time, "completed",
                    G_CALLBACK (on_hide_timeline_completed), view);
}
예제 #7
0
static gboolean
handle_button_press_event_cb (ClutterActor       *actor,
                              ClutterButtonEvent *event,
                              StScrollBar        *bar)
{
  StScrollBarPrivate *priv = bar->priv;

  if (event->button != 1)
    return FALSE;

  if (!clutter_actor_transform_stage_point (priv->handle,
                                            event->x,
                                            event->y,
                                            &priv->x_origin,
                                            &priv->y_origin))
    return FALSE;

  /* Account for the scrollbar-trough-handle nesting. */
  priv->x_origin += clutter_actor_get_x (priv->trough);
  priv->y_origin += clutter_actor_get_y (priv->trough);

  /* Turn off picking for motion events */
  clutter_set_motion_events_enabled (FALSE);

  priv->capture_handler = g_signal_connect_after (
    clutter_actor_get_stage (priv->trough),
    "captured-event",
    G_CALLBACK (handle_capture_event_cb),
    bar);
  g_signal_emit (bar, signals[SCROLL_START], 0);

  return TRUE;
}
예제 #8
0
static void
clutter_bind_constraint_update_allocation (ClutterConstraint *constraint,
                                           ClutterActor      *actor,
                                           ClutterActorBox   *allocation)
{
  ClutterBindConstraint *bind = CLUTTER_BIND_CONSTRAINT (constraint);
  gfloat source_width, source_height;
  gfloat actor_width, actor_height;
  ClutterVertex source_position = { 0., };

  if (bind->source == NULL)
    return;

  source_position.x = clutter_actor_get_x (bind->source);
  source_position.y = clutter_actor_get_y (bind->source);
  clutter_actor_get_size (bind->source, &source_width, &source_height);

  clutter_actor_box_get_size (allocation, &actor_width, &actor_height);

  switch (bind->coordinate)
    {
    case CLUTTER_BIND_X:
      allocation->x1 = source_position.x + bind->offset;
      allocation->x2 = allocation->x1 + actor_width;
      break;

    case CLUTTER_BIND_Y:
      allocation->y1 = source_position.y + bind->offset;
      allocation->y2 = allocation->y1 + actor_height;
      break;

    case CLUTTER_BIND_POSITION:
      allocation->x1 = source_position.x + bind->offset;
      allocation->y1 = source_position.y + bind->offset;
      allocation->x2 = allocation->x1 + actor_width;
      allocation->y2 = allocation->y1 + actor_height;
      break;

    case CLUTTER_BIND_WIDTH:
      allocation->x2 = allocation->x1 + source_width + bind->offset;
      break;

    case CLUTTER_BIND_HEIGHT:
      allocation->y2 = allocation->y1 + source_height + bind->offset;
      break;

    case CLUTTER_BIND_SIZE:
      allocation->x2 = allocation->x1 + source_width + bind->offset;
      allocation->y2 = allocation->y1 + source_height + bind->offset;
      break;

    default:
      g_assert_not_reached ();
      break;
    }
}
예제 #9
0
파일: main.cpp 프로젝트: aalex/ubuntu-tempi
static gboolean button_press_color_cb(ClutterActor *actor, ClutterEvent *event, gpointer user_data)
{
    App *app = (App *) user_data;
    ClutterColor color;
    clutter_rectangle_get_color(CLUTTER_RECTANGLE(actor), &color);
    int r = color.red;
    int g = color.green;
    int b = color.blue;
    app->setColor(r, g, b);
    app->setSelectionPosition(clutter_actor_get_x(actor), clutter_actor_get_y(actor));
    return TRUE; // handled. Do not propagate to stage
}
예제 #10
0
static void
clutter_bin_layout_allocate (ClutterLayoutManager   *manager,
                             ClutterContainer       *container,
                             const ClutterActorBox  *allocation,
                             ClutterAllocationFlags  flags)
{
  GList *children = clutter_container_get_children (container);
  GList *l;
  gfloat available_w, available_h;

  available_w = clutter_actor_box_get_width (allocation);
  available_h = clutter_actor_box_get_height (allocation);

  for (l = children; l != NULL; l = l->next)
    {
      ClutterActor *child = l->data;
      ClutterLayoutMeta *meta;
      ClutterBinLayer *layer;
      ClutterActorBox child_alloc = { 0, };
      gdouble x_align, y_align;
      gboolean x_fill, y_fill;

      meta = clutter_layout_manager_get_child_meta (manager,
                                                    container,
                                                    child);
      layer = CLUTTER_BIN_LAYER (meta);

      if (layer->x_align == CLUTTER_BIN_ALIGNMENT_FIXED)
        child_alloc.x1 = clutter_actor_get_x (child);
      else
        child_alloc.x1 = 0.0f;

      if (layer->y_align == CLUTTER_BIN_ALIGNMENT_FIXED)
        child_alloc.y1 = clutter_actor_get_y (child);
      else
        child_alloc.y1 = 0.0f;

      child_alloc.x2 = available_w;
      child_alloc.y2 = available_h;

      x_fill = (layer->x_align == CLUTTER_BIN_ALIGNMENT_FILL);
      y_fill = (layer->y_align == CLUTTER_BIN_ALIGNMENT_FILL);
      x_align = get_bin_alignment_factor (layer->x_align);
      y_align = get_bin_alignment_factor (layer->y_align);

      clutter_actor_allocate_align_fill (child, &child_alloc,
                                         x_align, y_align,
                                         x_fill, y_fill,
                                         flags);
    }

  g_list_free (children);
}
예제 #11
0
gboolean
foo_button_pressed_cb (ClutterActor *actor,
                       ClutterEvent *event,
                       gpointer      user_data)
{
  ClutterScript *ui = CLUTTER_SCRIPT (user_data);
  ClutterStage *stage = CLUTTER_STAGE (clutter_script_get_object (ui, "stage"));

  ClutterScript *script;
  ClutterActor *rig;
  ClutterAnimator *animator;

  /* load the rig and its animator from a JSON file */
  script = clutter_script_new ();

  /* use a function defined statically in this source file to load the JSON */
  load_script_from_file (script, ANIMATION_FILE);

  clutter_script_get_objects (script,
                              "rig", &rig,
                              "animator", &animator,
                              NULL);

  /* remove the button press handler from the rectangle */
  g_signal_handlers_disconnect_matched (actor,
                                        G_SIGNAL_MATCH_FUNC,
                                        0,
                                        0,
                                        NULL,
                                        foo_button_pressed_cb,
                                        NULL);

  /* add a callback to clean up the script when the rig is destroyed */
  g_object_set_data_full (G_OBJECT (rig), "script", script, g_object_unref);

  /* add the rig to the stage */
  clutter_container_add_actor (CLUTTER_CONTAINER (stage), rig);

  /* place the rig at the same coordinates on the stage as the rectangle */
  clutter_actor_set_position (rig,
                              clutter_actor_get_x (actor),
                              clutter_actor_get_y (actor));

  /* put the rectangle into the top-left corner of the rig */
  clutter_actor_reparent (actor, rig);

  clutter_actor_set_position (actor, 0, 0);

  /* animate the rig */
  clutter_animator_start (animator);

  return TRUE;
}
예제 #12
0
파일: main.cpp 프로젝트: aalex/ubuntu-tempi
void App::createPalette()
{
    ClutterColor white = { 255, 255, 255, 255 };
    selection_rect_ = clutter_rectangle_new_with_color(&white);
    clutter_actor_set_size(selection_rect_, 55.0f, 55.0f);
    clutter_actor_set_anchor_point_from_gravity(selection_rect_, CLUTTER_GRAVITY_CENTER);
    clutter_container_add_actor(CLUTTER_CONTAINER(stage_), selection_rect_);

    std::vector<std::string> colors;
    colors.push_back(std::string("#c33")); // red
    colors.push_back(std::string("#cc3"));
    colors.push_back(std::string("#3c3")); // green
    colors.push_back(std::string("#3cc"));
    colors.push_back(std::string("#33c")); // blue
    colors.push_back(std::string("#c3c"));
    colors.push_back(std::string("#333")); // black
    colors.push_back(std::string("#999"));
    colors.push_back(std::string("#ccc"));

    // initial color:
    ClutterColor chosen;
    clutter_color_from_string(&chosen, (*colors.begin()).c_str());
    setColor(chosen.red, chosen.green, chosen.blue);

    int i = 0;
    std::vector<std::string>::iterator iter;
    for (iter = colors.begin(); iter != colors.end(); ++iter)
    {
        ClutterColor color;
        clutter_color_from_string(&color, (*iter).c_str());
        ClutterActor *rect = clutter_rectangle_new_with_color(&color);
        clutter_actor_set_size(rect, 50.0f, 50.0f);
        clutter_actor_set_anchor_point_from_gravity(rect, CLUTTER_GRAVITY_CENTER);
        clutter_actor_set_position(rect, 35.0f, i * 60.0f + 30.0f);
        clutter_actor_set_reactive(rect, TRUE);
        clutter_container_add_actor(CLUTTER_CONTAINER(stage_), rect);
        g_signal_connect(rect, "button-press-event", G_CALLBACK(button_press_color_cb), this);

        if (i == 0)
        {
            float x = clutter_actor_get_x(rect);
            float y = clutter_actor_get_y(rect);
            setSelectionPosition(x, y);
        }
        ++i;
    }
}
예제 #13
0
static void
key_focus_in_cb (ClutterActor *actor,
		 gpointer      data)
{
  ClutterActor *focus_box = CLUTTER_ACTOR (data);  

  if (CLUTTER_IS_STAGE (actor))
    clutter_actor_hide (focus_box);
  else
    {
      clutter_actor_set_position (focus_box,
				  clutter_actor_get_x (actor) - 5,
				  clutter_actor_get_y (actor) - 5);

      clutter_actor_set_size (focus_box,
			      clutter_actor_get_width (actor) + 10,
			      clutter_actor_get_height (actor) + 10);
      clutter_actor_show (focus_box);
    }
}
예제 #14
0
static void
clutter_fixed_layout_get_preferred_height (ClutterLayoutManager *manager,
                                           ClutterContainer     *container,
                                           gfloat                for_width,
                                           gfloat               *min_height_p,
                                           gfloat               *nat_height_p)
{
  ClutterActor *actor, *child;
  gdouble min_bottom;
  gdouble natural_bottom;

  min_bottom = 0;
  natural_bottom = 0;

  actor = CLUTTER_ACTOR (container);

  for (child = clutter_actor_get_first_child (actor);
       child != NULL;
       child = clutter_actor_get_next_sibling (child))
    {
      gfloat child_y, child_min, child_natural;

      child_y = clutter_actor_get_y (child);

      clutter_actor_get_preferred_size (child,
                                        NULL, &child_min,
                                        NULL, &child_natural);

      if (child_y + child_min > min_bottom)
        min_bottom = child_y + child_min;

      if (child_y + child_natural > natural_bottom)
        natural_bottom = child_y + child_natural;
    }

  if (min_height_p)
    *min_height_p = min_bottom;

  if (nat_height_p)
    *nat_height_p = natural_bottom;
}
예제 #15
0
//FIXME: ClutterClone seems to have problem rendering children, so badges are stay in grandpar
static void create_window_badge(MosesOverview* self, ClutterActor* parent, int order)
{
    ClutterActor* badge = clutter_actor_new();
    clutter_actor_insert_child_above(clutter_actor_get_parent(parent), badge, NULL);

    gfloat tw, th;
    clutter_actor_get_transformed_size(parent, &tw, &th);

    gfloat w = 60.0, h = 60.0,
            x = (tw - w) / 2.0 + clutter_actor_get_x(parent),
            y = (th - h) / 2.0 + clutter_actor_get_y(parent);
    clutter_actor_set_position(badge, x, y);
    clutter_actor_set_size(badge, w, h);

    g_object_set_qdata(G_OBJECT(badge), moses_overview_window_clone_order(), GINT_TO_POINTER(order));
    g_object_set_qdata(G_OBJECT(parent), moses_overview_window_clone_order(), GINT_TO_POINTER(order));

    ClutterContent* canvas = clutter_canvas_new();
    clutter_canvas_set_size(CLUTTER_CANVAS(canvas), w, h);
    clutter_actor_set_content(badge, canvas);
    g_object_unref(canvas);
    g_signal_connect(canvas, "draw", G_CALLBACK(on_badge_draw), badge);

    clutter_content_invalidate(canvas);

    clutter_actor_set_scale(badge, 0.0, 0.0);

    //do animated show
    clutter_actor_save_easing_state(badge);
    clutter_actor_set_easing_mode(badge, CLUTTER_EASE_OUT_BACK);
    clutter_actor_set_easing_duration(badge, 350);

    clutter_actor_set_pivot_point(badge, 0.5, 0.5);
    clutter_actor_set_scale(badge, 1.0, 1.0);
    clutter_actor_restore_easing_state(badge);

    g_ptr_array_add(self->priv->badges, badge);
}
static gboolean
trough_paging_cb (MxScrollBar *self)
{
  gfloat handle_pos, event_pos, tx, ty;
  gdouble value;
  gdouble page_increment;
  gboolean ret;
  gulong mode;

  if (self->priv->paging_event_no == 0)
    {
      /* Scroll on after initial timeout. */
      mode = CLUTTER_EASE_OUT_CUBIC;
      ret = FALSE;
      self->priv->paging_event_no = 1;
      self->priv->paging_source_id = g_timeout_add (
        PAGING_INITIAL_REPEAT_TIMEOUT,
        (GSourceFunc) trough_paging_cb,
        self);
    }
  else if (self->priv->paging_event_no == 1)
    {
      /* Scroll on after subsequent timeout. */
      ret = FALSE;
      mode = CLUTTER_EASE_IN_CUBIC;
      self->priv->paging_event_no = 2;
      self->priv->paging_source_id = g_timeout_add (
        PAGING_SUBSEQUENT_REPEAT_TIMEOUT,
        (GSourceFunc) trough_paging_cb,
        self);
    }
  else
    {
      /* Keep scrolling. */
      ret = TRUE;
      mode = CLUTTER_LINEAR;
      self->priv->paging_event_no++;
    }

  /* Do the scrolling */
  mx_adjustment_get_values (self->priv->adjustment,
                            &value, NULL, NULL,
                            NULL, &page_increment, NULL);

  if (self->priv->orientation == MX_ORIENTATION_VERTICAL)
    handle_pos = clutter_actor_get_y (self->priv->handle);
  else
    handle_pos = clutter_actor_get_x (self->priv->handle);

  clutter_actor_transform_stage_point (CLUTTER_ACTOR (self->priv->trough),
                                       self->priv->move_x,
                                       self->priv->move_y,
                                       &tx, &ty);

  if (self->priv->orientation == MX_ORIENTATION_VERTICAL)
    event_pos = ty;
  else
    event_pos = tx;

  if (event_pos > handle_pos)
    {
      if (self->priv->paging_direction == NONE)
        {
          /* Remember direction. */
          self->priv->paging_direction = DOWN;
        }
      if (self->priv->paging_direction == UP)
        {
          /* Scrolled far enough. */
          return FALSE;
        }
      value += page_increment;
    }
  else
    {
      if (self->priv->paging_direction == NONE)
        {
          /* Remember direction. */
          self->priv->paging_direction = UP;
        }
      if (self->priv->paging_direction == DOWN)
        {
          /* Scrolled far enough. */
          return FALSE;
        }
      value -= page_increment;
    }

  mx_adjustment_interpolate (self->priv->adjustment, value, 250, mode);

  return ret;
}
예제 #17
0
/* snap size, as affected by resizing lower right corner,
 * will need extension if other corners are to be supported,
 * it seems possible to do all needed alignments through
 * simple workarounds when only snapping for lower right).
 */
static void snap_size (ClutterActor *actor,
                       gfloat        in_width,
                       gfloat        in_height,
                       gfloat       *out_width,
                       gfloat       *out_height)
{
  *out_width = in_width;
  *out_height = in_height;

  ClutterActor *parent;

  parent = clutter_actor_get_parent (actor);

  if (CLUTTER_IS_CONTAINER (parent))
    {
      gfloat in_x = clutter_actor_get_x (actor);
      gfloat in_y = clutter_actor_get_y (actor);
      gfloat in_end_x = in_x + in_width;
      gfloat in_end_y = in_y + in_height;


      gfloat best_x = 0;
      gfloat best_x_diff = 4096;
      gfloat best_y = 0;
      gfloat best_y_diff = 4096;
      GList *children, *c;
      children = clutter_container_get_children (CLUTTER_CONTAINER (parent));

      hor_pos = 0;
      ver_pos = 0;

      /* We only search our siblings for snapping...
       * perhaps we should search more.
       */

      for (c=children; c; c = c->next)
        {
          gfloat this_x = clutter_actor_get_x (c->data);
          gfloat this_width = clutter_actor_get_width (c->data);
          gfloat this_height = clutter_actor_get_height (c->data);
          gfloat this_end_x = this_x + this_width;
          gfloat this_y = clutter_actor_get_y (c->data);
          gfloat this_end_y = this_y + this_height;

          /* skip self */
          if (c->data == actor)
            continue;

/*
 end aligned with start
                    this_x     this_mid_x     this_end_x
in_x    in_mid_x    in_end_x
*/
          if (abs (this_x - in_end_x) < best_x_diff)
            {
              best_x_diff = abs (this_x - in_end_x);
              best_x = this_x;
              hor_pos=3;
            }
          if (abs (this_y - in_end_y) < best_y_diff)
            {
              best_y_diff = abs (this_y - in_end_y);
              best_y = this_y;
              ver_pos=3;
            }
/*
 ends aligned
                    this_x     this_mid_x     this_end_x
                          in_x    in_mid_x    in_end_x
*/
          if (abs (this_end_x - in_end_x) < best_x_diff)
            {
              best_x_diff = abs (this_end_x - in_end_x);
              best_x = this_end_x;
              hor_pos=3;
            }
          if (abs (this_end_y - in_end_y) < best_y_diff)
            {
              best_y_diff = abs (this_end_y - in_end_y);
              best_y = this_end_y;
              ver_pos=3;
            }
        }

        {
          if (best_x_diff < SNAP_THRESHOLD)
            {
              *out_width = best_x-in_x;
            }
          else
            {
              hor_pos = 0;
            }
          if (best_y_diff < SNAP_THRESHOLD)
            {
              *out_height = best_y-in_y;
            }
          else
            {
              ver_pos = 0;
            }
        }
    }
}
예제 #18
0
G_MODULE_EXPORT int
test_scale_main (int argc, char *argv[])
{
  ClutterActor    *stage, *rect;
  ClutterColor     stage_color = { 0x0, 0x0, 0x0, 0xff };
  ClutterColor     rect_color = { 0xff, 0xff, 0xff, 0x99 };
  ClutterColor     white_color = { 0xff, 0xff, 0xff, 0xFF };
  ClutterTimeline *timeline;
  ClutterAlpha    *alpha;
  ClutterBehaviour *behave;

  clutter_init (&argc, &argv);

  stage = clutter_stage_get_default ();

  clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
  clutter_actor_set_size (stage, 300, 300);

  rect = clutter_rectangle_new_with_color (&rect_color);
  clutter_actor_set_size (rect, 100, 100);
  clutter_actor_set_position (rect, 100, 100);

  clutter_group_add (CLUTTER_GROUP (stage), rect);

  label = clutter_text_new_with_text ("Sans 20px", "");
  clutter_text_set_color (CLUTTER_TEXT (label),
                           &white_color);
  clutter_actor_set_position (label,
                              clutter_actor_get_x (rect),
                              clutter_actor_get_y (rect)
                              + clutter_actor_get_height (rect));

  clutter_group_add (CLUTTER_GROUP (stage), label);

  rect_color.alpha = 0xff;
  rect = clutter_rectangle_new_with_color (&rect_color);
  clutter_actor_set_position (rect, 100, 100);
  clutter_actor_set_size (rect, 100, 100);
  set_next_gravity (rect);

  clutter_group_add (CLUTTER_GROUP (stage), rect);

  timeline = clutter_timeline_new (750);
  alpha    = clutter_alpha_new_with_func (timeline,
				          my_ramp_func,
				          NULL, NULL);

  behave = clutter_behaviour_scale_new (alpha,
					0.0, 0.0,  /* scale start */
					1.0, 1.0); /* scale end */

  clutter_behaviour_apply (behave, rect);

  clutter_timeline_set_loop (timeline, TRUE);
  g_signal_connect_swapped (timeline, "completed",
                            G_CALLBACK (set_next_gravity), rect);
  clutter_timeline_start (timeline);

  clutter_actor_show_all (stage);

  clutter_main();

  g_object_unref (timeline);
  g_object_unref (behave);

  return EXIT_SUCCESS;
}
예제 #19
0
파일: IoClutterActor.c 프로젝트: Akiyah/io
IO_METHOD(IoClutterActor, getY) {
  return IONUMBER(clutter_actor_get_y(IOCACTOR(self)));
}
예제 #20
0
G_MODULE_EXPORT int
test_scale_main (int argc, char *argv[])
{
  ClutterActor    *stage, *rect;
  ClutterColor     rect_color = { 0xff, 0xff, 0xff, 0x99 };
  ClutterTimeline *timeline;
  ClutterAlpha    *alpha;
  ClutterBehaviour *behave;

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

  stage = clutter_stage_new ();
  clutter_stage_set_title (CLUTTER_STAGE (stage), "Scaling");
  clutter_actor_set_background_color (stage, CLUTTER_COLOR_Black);
  clutter_actor_set_size (stage, 300, 300);
  g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);

  rect = clutter_rectangle_new_with_color (&rect_color);
  clutter_actor_set_size (rect, 100, 100);
  clutter_actor_set_position (rect, 100, 100);

  clutter_container_add_actor (CLUTTER_CONTAINER (stage), rect);

  label = clutter_text_new_with_text ("Sans 20px", "");
  clutter_text_set_color (CLUTTER_TEXT (label), CLUTTER_COLOR_White);
  clutter_actor_set_position (label,
                              clutter_actor_get_x (rect),
                              clutter_actor_get_y (rect)
                              + clutter_actor_get_height (rect));

  clutter_container_add_actor (CLUTTER_CONTAINER (stage), label);

  rect_color.alpha = 0xff;
  rect = clutter_rectangle_new_with_color (&rect_color);
  clutter_actor_set_position (rect, 100, 100);
  clutter_actor_set_size (rect, 100, 100);
  set_next_gravity (rect);

  clutter_container_add_actor (CLUTTER_CONTAINER (stage), rect);

  timeline = clutter_timeline_new (750);
  alpha    = clutter_alpha_new_with_func (timeline,
				          my_ramp_func,
				          NULL, NULL);

  behave = clutter_behaviour_scale_new (alpha,
					0.0, 0.0,  /* scale start */
					1.0, 1.0); /* scale end */

  clutter_behaviour_apply (behave, rect);

  clutter_timeline_set_repeat_count (timeline, -1);
  g_signal_connect_swapped (timeline, "completed",
                            G_CALLBACK (set_next_gravity), rect);
  clutter_timeline_start (timeline);

  clutter_actor_show_all (stage);

  clutter_main();

  g_object_unref (timeline);
  g_object_unref (behave);

  return EXIT_SUCCESS;
}
예제 #21
0
static gboolean
trough_paging_cb (StScrollBar *self)
{
  gfloat handle_pos, event_pos, tx, ty;
  gdouble value;
  gdouble page_increment;
  gboolean ret;

  gulong mode;
  ClutterAnimation *a;
  GValue v = { 0, };
  ClutterTimeline *t;

  if (self->priv->paging_event_no == 0)
    {
      /* Scroll on after initial timeout. */
      mode = CLUTTER_EASE_OUT_CUBIC;
      ret = FALSE;
      self->priv->paging_event_no = 1;
      self->priv->paging_source_id = g_timeout_add (
        PAGING_INITIAL_REPEAT_TIMEOUT,
        (GSourceFunc) trough_paging_cb,
        self);
    }
  else if (self->priv->paging_event_no == 1)
    {
      /* Scroll on after subsequent timeout. */
      ret = FALSE;
      mode = CLUTTER_EASE_IN_CUBIC;
      self->priv->paging_event_no = 2;
      self->priv->paging_source_id = g_timeout_add (
        PAGING_SUBSEQUENT_REPEAT_TIMEOUT,
        (GSourceFunc) trough_paging_cb,
        self);
    }
  else
    {
      /* Keep scrolling. */
      ret = TRUE;
      mode = CLUTTER_LINEAR;
      self->priv->paging_event_no++;
    }

  /* Do the scrolling */
  st_adjustment_get_values (self->priv->adjustment,
                            &value, NULL, NULL,
                            NULL, &page_increment, NULL);

  if (self->priv->vertical)
    handle_pos = clutter_actor_get_y (self->priv->handle);
  else
    handle_pos = clutter_actor_get_x (self->priv->handle);

  clutter_actor_transform_stage_point (CLUTTER_ACTOR (self->priv->trough),
                                       self->priv->move_x,
                                       self->priv->move_y,
                                       &tx, &ty);

  if (self->priv->vertical)
    event_pos = ty;
  else
    event_pos = tx;

  if (event_pos > handle_pos)
    {
      if (self->priv->paging_direction == NONE)
        {
          /* Remember direction. */
          self->priv->paging_direction = DOWN;
        }
      if (self->priv->paging_direction == UP)
        {
          /* Scrolled far enough. */
          return FALSE;
        }
      value += page_increment;
    }
  else
    {
      if (self->priv->paging_direction == NONE)
        {
          /* Remember direction. */
          self->priv->paging_direction = UP;
        }
      if (self->priv->paging_direction == DOWN)
        {
          /* Scrolled far enough. */
          return FALSE;
        }
      value -= page_increment;
    }

  if (self->priv->paging_animation)
    {
      clutter_animation_completed (self->priv->paging_animation);
    }

  /* FIXME: Creating a new animation for each scroll is probably not the best
  * idea, but it's a lot less involved than extenind the current animation */
  a = self->priv->paging_animation = g_object_new (CLUTTER_TYPE_ANIMATION,
                                                   "object", self->priv->adjustment,
                                                   "duration", (guint)(PAGING_SUBSEQUENT_REPEAT_TIMEOUT * st_slow_down_factor),
                                                   "mode", mode,
                                                   NULL);
  g_value_init (&v, G_TYPE_DOUBLE);
  g_value_set_double (&v, value);
  clutter_animation_bind (self->priv->paging_animation, "value", &v);
  t = clutter_animation_get_timeline (self->priv->paging_animation);
  g_signal_connect (a, "completed", G_CALLBACK (animation_completed_cb),
                    self->priv);
  clutter_timeline_start (t);

  return ret;
}
예제 #22
0
void
scroll_view_main (ClutterContainer *stage)
{
  gint width, height;
  MxAdjustment *hadjust, *vadjust;
  ClutterActor *label, *elastic, *overshoot, *scroll, *kinetic, *view, *texture;

  scroll = mx_scroll_view_new ();

  /* Make sure something underneath the kinetic scroll view swallows events
   * so that we don't end up moving the window.
   */
  g_signal_connect (scroll, "button-press-event", G_CALLBACK (true_cb), NULL);

  kinetic = mx_kinetic_scroll_view_new ();

  clutter_container_add_actor (stage, scroll);
  clutter_actor_set_position (scroll, 10, 10);
  clutter_actor_set_size (scroll, 300, 300);

  view = mx_viewport_new ();
  mx_viewport_set_sync_adjustments (MX_VIEWPORT (view), FALSE);
  clutter_container_add_actor (CLUTTER_CONTAINER (kinetic), view);
  clutter_container_add_actor (CLUTTER_CONTAINER (scroll), kinetic);


  texture = clutter_texture_new_from_file ("redhand.png", NULL);
  clutter_container_add_actor (CLUTTER_CONTAINER (view), texture);
  g_object_set (texture, "repeat-x", TRUE, "repeat-y", TRUE, NULL);
  clutter_actor_set_size (texture, 1280, 1280);

  clutter_texture_get_base_size (CLUTTER_TEXTURE (texture),
                                 &width, &height);
  mx_scrollable_get_adjustments (MX_SCROLLABLE (view),
                                 &hadjust, &vadjust);
  mx_adjustment_set_values (hadjust,
                            0,
                            0,
                            1280,
                            width,
                            width * 3,
                            300);
  mx_adjustment_set_values (vadjust,
                            0,
                            0,
                            1280,
                            height,
                            height * 3,
                            300);

  label = mx_label_new_with_text ("Toggle over-shooting:");
  overshoot = mx_toggle_new ();
  clutter_actor_set_position (label, 320, 10);
  clutter_actor_set_position (overshoot, 330 + clutter_actor_get_width (label),
                              10);
  clutter_container_add (stage, label, overshoot, NULL);

  g_signal_connect (overshoot, "notify::active",
                    G_CALLBACK (notify_overshoot_cb), kinetic);

  label = mx_label_new_with_text ("Toggle elasticity:");
  elastic = mx_toggle_new ();
  clutter_actor_set_position (label, 320,
                              20 + clutter_actor_get_height (overshoot));
  clutter_actor_set_position (elastic, clutter_actor_get_x (overshoot),
                              clutter_actor_get_y (label));
  clutter_container_add (stage, label, elastic, NULL);

  g_signal_connect (elastic, "notify::active",
                    G_CALLBACK (notify_elastic_cb), kinetic);
}
static void
clutter_bin_layout_allocate (ClutterLayoutManager   *manager,
                             ClutterContainer       *container,
                             const ClutterActorBox  *allocation,
                             ClutterAllocationFlags  flags)
{
  gfloat allocation_x, allocation_y;
  gfloat available_w, available_h;
  ClutterActor *actor, *child;
  ClutterActorIter iter;
  gboolean use_animations;
  ClutterAnimationMode easing_mode;
  guint easing_duration, easing_delay;

  clutter_actor_box_get_origin (allocation, &allocation_x, &allocation_y);
  clutter_actor_box_get_size (allocation, &available_w, &available_h);

  actor = CLUTTER_ACTOR (container);

  use_animations = clutter_layout_manager_get_easing_state (manager,
                                                            &easing_mode,
                                                            &easing_duration,
                                                            &easing_delay);
  clutter_actor_iter_init (&iter, actor);
  while (clutter_actor_iter_next (&iter, &child))
    {
      ClutterLayoutMeta *meta;
      ClutterBinLayer *layer;
      ClutterActorBox child_alloc = { 0, };
      gdouble x_align, y_align;
      gboolean x_fill, y_fill;

      meta = clutter_layout_manager_get_child_meta (manager,
                                                    container,
                                                    child);
      layer = CLUTTER_BIN_LAYER (meta);

      if (layer->x_align == CLUTTER_BIN_ALIGNMENT_FIXED)
        child_alloc.x1 = clutter_actor_get_x (child);
      else
        child_alloc.x1 = allocation_x;

      if (layer->y_align == CLUTTER_BIN_ALIGNMENT_FIXED)
        child_alloc.y1 = clutter_actor_get_y (child);
      else
        child_alloc.y1 = allocation_y;

      child_alloc.x2 = available_w;
      child_alloc.y2 = available_h;

      if (clutter_actor_needs_expand (child, CLUTTER_ORIENTATION_HORIZONTAL))
        {
          ClutterActorAlign align;

          align = _clutter_actor_get_effective_x_align (child);
          x_fill = align == CLUTTER_ACTOR_ALIGN_FILL;
          x_align = get_actor_align_factor (align);
        }
      else
        {
          x_fill = (layer->x_align == CLUTTER_BIN_ALIGNMENT_FILL);
          x_align = get_bin_alignment_factor (layer->x_align);
        }

      if (clutter_actor_needs_expand (child, CLUTTER_ORIENTATION_VERTICAL))
        {
          ClutterActorAlign align;

          align = clutter_actor_get_y_align (child);
          y_fill = align == CLUTTER_ACTOR_ALIGN_FILL;
          y_align = get_actor_align_factor (align);
        }
      else
        {
          y_fill = (layer->y_align == CLUTTER_BIN_ALIGNMENT_FILL);
          y_align = get_bin_alignment_factor (layer->y_align);
        }

      if (use_animations)
        {
          clutter_actor_save_easing_state (child);
          clutter_actor_set_easing_mode (child, easing_mode);
          clutter_actor_set_easing_duration (child, easing_duration);
          clutter_actor_set_easing_delay (child, easing_delay);
        }

      clutter_actor_allocate_align_fill (child, &child_alloc,
                                         x_align, y_align,
                                         x_fill, y_fill,
                                         flags);

      if (use_animations)
        clutter_actor_restore_easing_state (child);
    }
}
예제 #24
0
static void
ntf_tray_notification_closed_cb (NtfNotification *ntf, NtfTray *tray)
{
  NtfTrayPrivate   *priv = tray->priv;
  ClutterActor     *ntfa = CLUTTER_ACTOR (ntf);
  ClutterAnimation *anim;

  priv->n_notifiers--;

  if (priv->n_notifiers < 0)
    {
      g_warning ("Bug in notifier accounting, attempting to fix");
      priv->n_notifiers = 0;
    }

  /* fade out closed notifier */
  if (ntfa == priv->active_notifier)
    {
      anim = clutter_actor_animate (CLUTTER_ACTOR (ntfa),
                                    CLUTTER_EASE_IN_SINE,
                                    FADE_DURATION,
                                    "opacity", 0,
                                    NULL);

      g_signal_connect_after (anim,
                        "completed",
                        G_CALLBACK
                        (ntf_tray_hide_ntf_completed_cb),
                        tray);
    }
  else
    {
      clutter_actor_destroy (ntfa);
    }

  /* Fade in newer notifier from below stack */
  if (ntfa == priv->active_notifier && priv->n_notifiers > 0)
    {
      gint prev_height, new_height;
      GList *notifiers;

      prev_height = clutter_actor_get_height (ntfa);

      notifiers =
        clutter_container_get_children (CLUTTER_CONTAINER (priv->notifiers));

      priv->active_notifier = notifiers->next != NULL ?
        (ClutterActor *) notifiers->next->data : NULL;

      g_list_free (notifiers);

      if (priv->active_notifier)
        {
          clutter_actor_set_opacity (priv->active_notifier, 0);
          clutter_actor_show (CLUTTER_ACTOR (priv->active_notifier));
          clutter_actor_animate (CLUTTER_ACTOR (priv->active_notifier),
                                 CLUTTER_EASE_IN_SINE,
                                 FADE_DURATION,
                                 "opacity", 0xff,
                                 NULL);

          new_height = clutter_actor_get_height (priv->active_notifier);

          if (prev_height != new_height && priv->n_notifiers > 1)
            {
              gfloat new_y;

              new_y = clutter_actor_get_y (priv->control)
                - (prev_height - new_height);

              clutter_actor_animate (priv->control,
                                     CLUTTER_EASE_IN_SINE,
                                     FADE_DURATION,
                                     "y", new_y,
                                     NULL);
            }
        }
    }

  if (priv->n_notifiers == 0)
    {
      priv->active_notifier = NULL;
#pragma TODO
      /* mnb_notification_gtk_hide (); */
    }
  else if (priv->n_notifiers == 1)
    {
      /* slide the control out of view */
      ClutterAnimation *anim;

      anim = clutter_actor_animate (priv->control,
                                    CLUTTER_EASE_IN_SINE,
                                    FADE_DURATION,
                                    "opacity", 0x0,
                                    "y",
                                    clutter_actor_get_height (priv->active_notifier)
                                    - clutter_actor_get_height (priv->control),
                                    NULL);

      g_signal_connect_after (anim,
                        "completed",
                        G_CALLBACK
                        (ntf_tray_control_hide_completed_cb),
                        tray);
    }
  else
    {
      /* Just Update control text */
      gchar *msg;
      msg = g_strdup_printf (_("%i pending messages"), priv->n_notifiers);
      mx_label_set_text (MX_LABEL (priv->control_text), msg);
      g_free (msg);
    }
}
예제 #25
0
static void
clutter_bin_layout_allocate (ClutterLayoutManager   *manager,
                             ClutterContainer       *container,
                             const ClutterActorBox  *allocation,
                             ClutterAllocationFlags  flags)
{
  gfloat allocation_x, allocation_y;
  gfloat available_w, available_h;
  ClutterActor *actor, *child;
  ClutterActorIter iter;

  clutter_actor_box_get_origin (allocation, &allocation_x, &allocation_y);
  clutter_actor_box_get_size (allocation, &available_w, &available_h);

  actor = CLUTTER_ACTOR (container);

  clutter_actor_iter_init (&iter, actor);
  while (clutter_actor_iter_next (&iter, &child))
    {
      ClutterLayoutMeta *meta;
      ClutterBinLayer *layer;
      ClutterActorBox child_alloc = { 0, };
      gdouble x_align, y_align;
      gboolean x_fill, y_fill, is_fixed_position_set;
      float fixed_x, fixed_y;

      if (!clutter_actor_is_visible (child))
        continue;

      meta = clutter_layout_manager_get_child_meta (manager,
                                                    container,
                                                    child);
      layer = CLUTTER_BIN_LAYER (meta);

      fixed_x = fixed_y = 0.f;
      g_object_get (child,
                    "fixed-position-set", &is_fixed_position_set,
                    "fixed-x", &fixed_x,
                    "fixed-y", &fixed_y,
                    NULL);

      /* XXX:2.0 - remove the FIXED alignment, and just use the fixed position
       * of the actor if one is set
       */
      if (is_fixed_position_set ||
          layer->x_align == CLUTTER_BIN_ALIGNMENT_FIXED)
	{
          if (is_fixed_position_set)
            child_alloc.x1 = fixed_x;
          else
            child_alloc.x1 = clutter_actor_get_x (child);
	}
      else
        child_alloc.x1 = allocation_x;

      if (is_fixed_position_set ||
          layer->y_align == CLUTTER_BIN_ALIGNMENT_FIXED)
	{
	  if (is_fixed_position_set)
            child_alloc.y1 = fixed_y;
          else
	    child_alloc.y1 = clutter_actor_get_y (child);
	}
      else
        child_alloc.y1 = allocation_y;

      child_alloc.x2 = allocation_x + available_w;
      child_alloc.y2 = allocation_y + available_h;

      if (clutter_actor_needs_expand (child, CLUTTER_ORIENTATION_HORIZONTAL))
        {
          ClutterActorAlign align;

          align = clutter_actor_get_x_align (child);
          x_fill = align == CLUTTER_ACTOR_ALIGN_FILL;
          x_align = get_actor_align_factor (align);
        }
      else
        {
          ClutterTextDirection text_dir;

          x_fill = (layer->x_align == CLUTTER_BIN_ALIGNMENT_FILL);

          text_dir = clutter_actor_get_text_direction (child);

          if (!is_fixed_position_set)
            x_align = get_bin_alignment_factor (layer->x_align, text_dir);
          else
            x_align = 0.0;
        }

      if (clutter_actor_needs_expand (child, CLUTTER_ORIENTATION_VERTICAL))
        {
          ClutterActorAlign align;

          align = clutter_actor_get_y_align (child);
          y_fill = align == CLUTTER_ACTOR_ALIGN_FILL;
          y_align = get_actor_align_factor (align);
        }
      else
        {
          y_fill = (layer->y_align == CLUTTER_BIN_ALIGNMENT_FILL);

          if (!is_fixed_position_set)
            y_align = get_bin_alignment_factor (layer->y_align,
                                                CLUTTER_TEXT_DIRECTION_LTR);
          else
            y_align = 0.0;
        }

      clutter_actor_allocate_align_fill (child, &child_alloc,
                                         x_align, y_align,
                                         x_fill, y_fill,
                                         flags);
    }
}