Exemplo n.º 1
0
static void
clutter_clone_paint (ClutterActor *self)
{
  ClutterClone *clone = CLUTTER_CLONE (self);
  ClutterClonePrivate *priv = clone->priv;
  ClutterGeometry geom, clone_geom;
  gfloat x_scale, y_scale;
  gboolean was_unmapped = FALSE;

  if (G_UNLIKELY (priv->clone_source == NULL))
    return;

  CLUTTER_NOTE (PAINT,
                "painting clone actor '%s'",
		clutter_actor_get_name (self) ? clutter_actor_get_name (self)
                                              : "unknown");

  /* get our allocated size */
  clutter_actor_get_allocation_geometry (self, &geom);

  /* and get the allocated size of the source */
  clutter_actor_get_allocation_geometry (priv->clone_source, &clone_geom);

  /* We need to scale what the clone-source actor paints to fill our own
   * allocation...
   */
  x_scale = (gfloat) geom.width  / clone_geom.width;
  y_scale = (gfloat) geom.height / clone_geom.height;

  cogl_scale (x_scale, y_scale, 1.0);

  /* The final bits of magic:
   * - We need to make sure that when the clone-source actor's paint
   *   method calls clutter_actor_get_paint_opacity, it traverses to
   *   us and our parent not it's real parent.
   * - We need to stop clutter_actor_paint applying the model view matrix of
   *   the clone source actor.
   */
  _clutter_actor_set_opacity_parent (priv->clone_source, self);
  _clutter_actor_set_enable_model_view_transform (priv->clone_source, FALSE);

  if (!CLUTTER_ACTOR_IS_MAPPED (priv->clone_source))
    {
      _clutter_actor_set_enable_paint_unmapped (priv->clone_source, TRUE);
      was_unmapped = TRUE;
    }

  clutter_actor_paint (priv->clone_source);

  if (was_unmapped)
    _clutter_actor_set_enable_paint_unmapped (priv->clone_source, FALSE);

  _clutter_actor_set_enable_model_view_transform (priv->clone_source, TRUE);
  _clutter_actor_set_opacity_parent (priv->clone_source, NULL);
}
Exemplo n.º 2
0
static void
ensure_visible (ClutterText *text,
                MxGrid      *grid)
{
  GList *children;
  ClutterActor *child;

  const gchar *string = clutter_text_get_text (text);
  gint number = atoi (string) - 1;

  children = clutter_container_get_children (CLUTTER_CONTAINER (grid));
  child = g_list_nth_data (children, number);
  if (child)
    {
      ClutterGeometry geom;
      MxScrollView *scroll = (MxScrollView *)
        clutter_actor_get_parent (CLUTTER_ACTOR (grid));
      clutter_actor_get_allocation_geometry (child, &geom);
      mx_scroll_view_ensure_visible (scroll, &geom);
      printf ("Making child %d visible\n", number);
    }
  else
    printf ("Couldn't make child %d visible\n", number);
  g_list_free (children);
}
Exemplo n.º 3
0
/*<private>
 * _clutter_actor_set_default_paint_volume:
 * @self: a #ClutterActor
 * @check_gtype: if not %G_TYPE_INVALID, match the type of @self against
 *   this type
 * @volume: the #ClutterPaintVolume to set
 *
 * Sets the default paint volume for @self.
 *
 * This function should be called by #ClutterActor sub-classes that follow
 * the default assumption that their paint volume is defined by their
 * allocation.
 *
 * If @check_gtype is not %G_TYPE_INVALID, this function will check the
 * type of @self and only compute the paint volume if the type matches;
 * this can be used to avoid computing the paint volume for sub-classes
 * of an actor class
 *
 * Return value: %TRUE if the paint volume was set, and %FALSE otherwise
 */
gboolean
_clutter_actor_set_default_paint_volume (ClutterActor       *self,
                                         GType               check_gtype,
                                         ClutterPaintVolume *volume)
{
  ClutterGeometry geometry = { 0, };

  if (check_gtype != G_TYPE_INVALID)
    {
      if (G_OBJECT_TYPE (self) != check_gtype)
        return FALSE;
    }

  /* calling clutter_actor_get_allocation_* can potentially be very
   * expensive, as it can result in a synchronous full stage relayout
   * and redraw
   */
  if (!clutter_actor_has_allocation (self))
    return FALSE;

  clutter_actor_get_allocation_geometry (self, &geometry);

  clutter_paint_volume_set_width (volume, geometry.width);
  clutter_paint_volume_set_height (volume, geometry.height);

  return TRUE;
}
Exemplo n.º 4
0
static void
mnb_launcher_button_pick (ClutterActor       *actor,
                          const ClutterColor *color)
{
  MnbLauncherButtonPrivate *priv = MNB_LAUNCHER_BUTTON (actor)->priv;
  ClutterGeometry geom;

  /* draw a rectangle to conver the entire actor */

  clutter_actor_get_allocation_geometry (actor, &geom);

  cogl_set_source_color4ub (color->red, color->green, color->blue, color->alpha);
  cogl_rectangle (0, 0, geom.width, geom.height);

  if (priv->fav_toggle)
    clutter_actor_paint (priv->fav_toggle);
}
static void
clutter_rectangle_paint (ClutterActor *self)
{
  ClutterRectangle        *rectangle = CLUTTER_RECTANGLE(self);
  ClutterRectanglePrivate *priv;
  ClutterGeometry          geom;
  ClutterColor             tmp_col;

  rectangle = CLUTTER_RECTANGLE(self);
  priv = rectangle->priv;

  CLUTTER_NOTE (PAINT,
                "painting rect '%s'",
		clutter_actor_get_name (self) ? clutter_actor_get_name (self)
                                              : "unknown");
  clutter_actor_get_allocation_geometry (self, &geom);

  CLUTTER_NOTE (PAINT, "paint to x1: %i, y1: %i x2: %i, y2: %i "
                       "opacity: %i",
                geom.x, geom.y, geom.x+geom.width, geom.y+geom.height,
                clutter_actor_get_opacity (self));

  /* parent paint call will have translated us into position so
   * paint from 0, 0
   */
  if (priv->has_border)
    {
      tmp_col.red   = priv->border_color.red;
      tmp_col.green = priv->border_color.green;
      tmp_col.blue  = priv->border_color.blue;
      tmp_col.alpha = clutter_actor_get_paint_opacity (self)
                      * priv->border_color.alpha
                      / 255;

      cogl_color (&tmp_col);

      /* this sucks, but it's the only way to make a border */
      cogl_rectangle (priv->border_width, 0,
                      geom.width - priv->border_width,
                      priv->border_width);

      cogl_rectangle (geom.width - priv->border_width,
                      priv->border_width,
                      priv->border_width,
                      geom.height - priv->border_width);

      cogl_rectangle (0, geom.height - priv->border_width,
                      geom.width - priv->border_width,
                      priv->border_width);

      cogl_rectangle (0, 0,
                      priv->border_width,
                      geom.height - priv->border_width);

      tmp_col.red   = priv->color.red;
      tmp_col.green = priv->color.green;
      tmp_col.blue  = priv->color.blue;
      tmp_col.alpha = clutter_actor_get_paint_opacity (self)
                      * priv->color.alpha
                      / 255;

      cogl_color (&tmp_col);

      cogl_rectangle (priv->border_width, priv->border_width,
                      geom.width - priv->border_width * 2,
                      geom.height - priv->border_width * 2);
    }
  else
    {
      tmp_col.red   = priv->color.red;
      tmp_col.green = priv->color.green;
      tmp_col.blue  = priv->color.blue;
      tmp_col.alpha = clutter_actor_get_paint_opacity (self)
                      * priv->color.alpha
                      / 255;

      cogl_color (&tmp_col);

      cogl_rectangle (0, 0, geom.width, geom.height);
    }
}
Exemplo n.º 6
0
static void
on_paint (ClutterActor *actor, CallbackData *data)
{
  int i;
  ClutterGeometry stage_size;
  gint hand_width, hand_height;
  GSList *node;

  clutter_actor_get_allocation_geometry (data->stage, &stage_size);

  hand_width = cogl_texture_get_width (data->hand);
  hand_height = cogl_texture_get_height (data->hand);

  /* Setup the clipping */
  for (node = data->clips; node; node = node->next)
    {
      Clip *clip = (Clip *) node->data;

      if (clip->type == CLIP_RECTANGLE)
        cogl_clip_push_rectangle (clip->x1,
                                  clip->y1,
                                  clip->x2,
                                  clip->y2);
      else if (clip->type == CLIP_ROTATED_RECTANGLE)
        {
          float size = MIN (ABS (clip->x2 - clip->x1),
                            ABS (clip->y2 - clip->y1));
          int cx = (clip->x1 + clip->x2) / 2;
          int cy = (clip->y1 + clip->y2) / 2;

          size = sqrtf ((size / 2) * (size / 2) * 2);

          cogl_push_matrix ();

          /* Rotate 45° about the centre point */
          cogl_translate (cx, cy, 0.0f);
          cogl_rotate (45.0f, 0.0f, 0.0f, 1.0f);
          cogl_clip_push_rectangle (-size / 2, -size / 2, size / 2, size / 2);

          cogl_pop_matrix ();
        }
      else
        {
          make_clip_path (clip);
          cogl_clip_push_from_path ();
        }
    }

  /* Draw a rectangle filling the entire stage */
  cogl_set_source_color4ub (0x80, 0x80, 0xff, 0xff);
  cogl_rectangle (0, 0, stage_size.width, stage_size.height);

  draw_shapes (10, 10);

  /* Draw the hand at different rotations */
  for (i = -2; i <= 2; i++)
    {
      cogl_push_matrix ();

      cogl_translate (stage_size.width / 2 + stage_size.width / 6 * i,
                      stage_size.height / 2, 0);

      cogl_rotate (i * 40, 0, 1, 0);

      cogl_set_source_color4ub (0xff, 0xff, 0xff, 0xff);

      cogl_set_source_texture (data->hand);
      cogl_rectangle_with_texture_coords ((-hand_width / 2),
                                          (-hand_height / 2),
                                          (hand_width / 2),
                                          (hand_height / 2),
                                          0, 0, 1, 1);

      cogl_pop_matrix ();
    }

  draw_shapes (stage_size.width - 310, stage_size.height - 110);

  /* Remove all of the clipping */
  g_slist_foreach (data->clips, (GFunc) cogl_clip_pop, NULL);

  /* Draw the bounding box for each of the clips */
  for (node = data->clips; node; node = node->next)
    {
      Clip *clip = (Clip *) node->data;

      make_clip_path (clip);
      cogl_set_source_color4ub (0x00, 0x00, 0xff, 0xff);
      cogl_path_stroke ();
    }

  /* Draw the bounding box for the pending new clip */
  if (data->current_clip.type != CLIP_NONE)
    {
      make_clip_path (&data->current_clip);
      cogl_set_source_color4ub (0xff, 0x00, 0x00, 0xff);
      cogl_path_stroke ();
    }
}
Exemplo n.º 7
0
IO_METHOD(IoClutterActor, getAllocationGeometry) {
  ClutterGeometry geom = { 0, };
  clutter_actor_get_allocation_geometry(IOCACTOR(self), &geom);
  return clutter_geometry_to_ioObject(IOSTATE, self, &geom);
}
Exemplo n.º 8
0
static void
clutter_rectangle_paint (ClutterActor *self)
{
  ClutterRectanglePrivate *priv = CLUTTER_RECTANGLE (self)->priv;
  ClutterGeometry geom;
  guint8 tmp_alpha;

  CLUTTER_NOTE (PAINT,
                "painting rect '%s'",
		clutter_actor_get_name (self) ? clutter_actor_get_name (self)
                                              : "unknown");
  clutter_actor_get_allocation_geometry (self, &geom);

  if (priv->has_border)
    {
      /* We paint the border and the content only if the rectangle
       * is big enough to show them
       */
      if ((priv->border_width * 2) < geom.width &&
          (priv->border_width * 2) < geom.height)
        {
          /* compute the composited opacity of the actor taking into
           * account the opacity of the color set by the user
           */
          tmp_alpha = clutter_actor_get_paint_opacity (self)
                    * priv->border_color.alpha
                    / 255;

          /* paint the border */
          cogl_set_source_color4ub (priv->border_color.red,
                                    priv->border_color.green,
                                    priv->border_color.blue,
                                    tmp_alpha);

          /* this sucks, but it's the only way to make a border */
          cogl_rectangle (priv->border_width, 0,
                          geom.width,
                          priv->border_width);

          cogl_rectangle (geom.width - priv->border_width,
                          priv->border_width,
                          geom.width,
                          geom.height);

          cogl_rectangle (0, geom.height - priv->border_width,
                          geom.width - priv->border_width,
                          geom.height);

          cogl_rectangle (0, 0,
                          priv->border_width,
                          geom.height - priv->border_width);

          tmp_alpha = clutter_actor_get_paint_opacity (self)
                    * priv->color.alpha
                    / 255;

          /* now paint the rectangle */
          cogl_set_source_color4ub (priv->color.red,
                                    priv->color.green,
                                    priv->color.blue,
                                    tmp_alpha);

          cogl_rectangle (priv->border_width, priv->border_width,
                          geom.width - priv->border_width,
                          geom.height - priv->border_width);
        }
      else
        {
          /* Otherwise, we draw a rectangle with the same color
           * as the border, since we can only fit that into the
           * allocation.
           */
          tmp_alpha = clutter_actor_get_paint_opacity (self)
                    * priv->border_color.alpha
                    / 255;

          cogl_set_source_color4ub (priv->border_color.red,
                                    priv->border_color.green,
                                    priv->border_color.blue,
                                    tmp_alpha);

          cogl_rectangle (0, 0, geom.width, geom.height);
        }
    }
  else
    {
      /* compute the composited opacity of the actor taking into
       * account the opacity of the color set by the user
       */
      tmp_alpha = clutter_actor_get_paint_opacity (self)
                * priv->color.alpha
                / 255;

      cogl_set_source_color4ub (priv->color.red,
                                priv->color.green,
                                priv->color.blue,
                                tmp_alpha);

      cogl_rectangle (0, 0, geom.width, geom.height);
    }
}
Exemplo n.º 9
0
static void
clutter_rectangle_paint (ClutterActor *self)
{
  ClutterRectanglePrivate *priv = CLUTTER_RECTANGLE (self)->priv;
  ClutterGeometry geom;
  guint8 tmp_alpha;

  CLUTTER_NOTE (PAINT,
                "painting rect '%s'",
		clutter_actor_get_name (self) ? clutter_actor_get_name (self)
                                              : "unknown");
  clutter_actor_get_allocation_geometry (self, &geom);

  /* parent paint call will have translated us into position so
   * paint from 0, 0
   */
  if (priv->has_border)
    {
      /* compute the composited opacity of the actor taking into
       * account the opacity of the color set by the user
       */
      tmp_alpha = clutter_actor_get_paint_opacity (self)
                * priv->border_color.alpha
                / 255;

      /* paint the border */
      cogl_set_source_color4ub (priv->border_color.red,
                                priv->border_color.green,
                                priv->border_color.blue,
                                tmp_alpha);

      /* this sucks, but it's the only way to make a border */
      cogl_rectangle (priv->border_width, 0,
                      geom.width,
                      priv->border_width);

      cogl_rectangle (geom.width - priv->border_width,
                      priv->border_width,
                      geom.width,
                      geom.height);

      cogl_rectangle (0, geom.height - priv->border_width,
                      geom.width - priv->border_width,
                      geom.height);

      cogl_rectangle (0, 0,
                      priv->border_width,
                      geom.height - priv->border_width);

      tmp_alpha = clutter_actor_get_paint_opacity (self)
                * priv->color.alpha
                / 255;

      /* now paint the rectangle */
      cogl_set_source_color4ub (priv->color.red,
                                priv->color.green,
                                priv->color.blue,
                                tmp_alpha);

      cogl_rectangle (priv->border_width, priv->border_width,
                      geom.width - priv->border_width,
                      geom.height - priv->border_width);
    }
  else
    {
      /* compute the composited opacity of the actor taking into
       * account the opacity of the color set by the user
       */
      tmp_alpha = clutter_actor_get_paint_opacity (self)
                * priv->color.alpha
                / 255;

      cogl_set_source_color4ub (priv->color.red,
                                priv->color.green,
                                priv->color.blue,
                                tmp_alpha);

      cogl_rectangle (0, 0, geom.width, geom.height);
    }
}