static void
penge_grid_view_allocate (ClutterActor          *actor,
                          const ClutterActorBox *box,
                          ClutterAllocationFlags flags)
{
  PengeGridViewPrivate *priv = GET_PRIVATE (actor);
  ClutterActorBox child_box;
  gint fade_height;

  /* Allocate the background to be the same area as the grid view */
  child_box.x1 = 0;
  child_box.y1 = 0;
  child_box.x2 = box->x2 - box->x1;
  child_box.y2 = box->y2 - box->y1;
  clutter_actor_allocate (priv->background, &child_box, flags);


  clutter_texture_get_base_size (CLUTTER_TEXTURE (priv->background_fade),
                                 NULL,
                                 &fade_height);
  child_box.x1 = 0;
  child_box.y1 = 0;
  child_box.x2 = box->x2 - box->x1;
  child_box.y2 = fade_height;
  clutter_actor_allocate (priv->background_fade, &child_box, flags);

  CLUTTER_ACTOR_CLASS (penge_grid_view_parent_class)->allocate (actor,
                                                                box,
                                                                flags);
}
Пример #2
0
static void
st_icon_update_shadow_material (StIcon *icon)
{
  StIconPrivate *priv = icon->priv;

  if (priv->shadow_material)
    {
      cogl_handle_unref (priv->shadow_material);
      priv->shadow_material = COGL_INVALID_HANDLE;
    }

  if (priv->shadow_spec)
   {
     CoglHandle material;
     gint width, height;

     clutter_texture_get_base_size (CLUTTER_TEXTURE (priv->icon_texture),
                                    &width, &height);

     material = _st_create_shadow_material_from_actor (priv->shadow_spec,
                                                       priv->icon_texture);
     priv->shadow_material = material;
     priv->shadow_width = width;
     priv->shadow_height = height;
   }
}
Пример #3
0
static void rc_update_pixbuf(void *renderer, gboolean lazy)
{
	RendererClutter *rc = (RendererClutter *)renderer;
	PixbufRenderer *pr = rc->pr;

	DEBUG_3("rc_update_pixbuf");

	rc_remove_pending_updates(rc);

	rc->last_pixbuf_change = g_get_monotonic_time();
	DEBUG_3("%s change time reset", get_exec_time());

	if (pr->pixbuf)
		{
		gint width = gdk_pixbuf_get_width(pr->pixbuf);
		gint height = gdk_pixbuf_get_height(pr->pixbuf);

		DEBUG_3("pixbuf size %d x %d (%d)", width, height, gdk_pixbuf_get_has_alpha(pr->pixbuf) ? 32 : 24);

		gint prev_width, prev_height;

		if (pr->stereo_data == STEREO_PIXBUF_SBS || pr->stereo_data == STEREO_PIXBUF_CROSS)
			{
			width /= 2;
			}


		clutter_texture_get_base_size(CLUTTER_TEXTURE(rc->texture), &prev_width, &prev_height);

		if (width != prev_width || height != prev_height)
			{
			/* FIXME use CoglMaterial with multiple textures for background, color management, anaglyph, ... */
			CoglHandle texture = cogl_texture_new_with_size(width,
									height,
									COGL_TEXTURE_NO_AUTO_MIPMAP | COGL_TEXTURE_NO_SLICING,
									gdk_pixbuf_get_has_alpha(pr->pixbuf) ? COGL_PIXEL_FORMAT_BGRA_8888 : COGL_PIXEL_FORMAT_BGR_888);

			if (texture != COGL_INVALID_HANDLE)
				{
				clutter_texture_set_cogl_texture(CLUTTER_TEXTURE(rc->texture), texture);
				cogl_handle_unref(texture);
				}
			}
		clutter_actor_set_clip(rc->texture, 0, 0, 0, 0); /* visible area is extended as area_changed events arrive */
		if (!lazy)
			{
			rc_area_changed(renderer, GET_RIGHT_PIXBUF_OFFSET(rc), 0, width, height);
			}
		}

	rc->clut_updated = FALSE;
}
Пример #4
0
static void
mnb_spinner_paint (ClutterActor *self)
{
  MnbSpinnerPrivate *priv   = MNB_SPINNER (self)->priv;
  MxWidget          *widget = MX_WIDGET (self);
  ClutterTexture    *background;

  /*
   * This paints border-image.
   */
  CLUTTER_ACTOR_CLASS (mnb_spinner_parent_class)->paint (self);

  if ((background = (ClutterTexture *) mx_widget_get_background_image (widget)))
    {
      gint            tx_w, tx_h;
      gfloat          tf_x, tf_y, tf_w, tf_h;
      guint8          opacity;
      ClutterActorBox box = { 0, };
      CoglHandle      material;

      if (!CLUTTER_IS_TEXTURE (background))
        return;

      opacity = clutter_actor_get_paint_opacity (self);

      if (opacity == 0)
        return;

      clutter_texture_get_base_size (background, &tx_w, &tx_h);

      material = clutter_texture_get_cogl_material (background);

      cogl_material_set_color4ub (material, opacity, opacity, opacity, opacity);

      clutter_actor_get_allocation_box (self, &box);

      tf_x = (gfloat)priv->frame / (gfloat) priv->n_frames;
      tf_y = 0.0;
      tf_w = tf_x + 1.0 / priv->n_frames;
      tf_h = 1.0;

      /* Paint will have translated us */
      cogl_set_source (material);
      cogl_rectangle_with_texture_coords (0.0, 0.0,
                                          box.x2 - box.x1,
                                          box.y2 - box.y1,
                                          tf_x, tf_y, tf_w, tf_h);
    }
}
Пример #5
0
static void
st_icon_update_shadow_pipeline (StIcon *icon)
{
  StIconPrivate *priv = icon->priv;

  g_clear_pointer (&priv->shadow_pipeline, cogl_object_unref);

  if (priv->shadow_spec)
   {
     gint width, height;

     clutter_texture_get_base_size (CLUTTER_TEXTURE (priv->icon_texture),
                                    &width, &height);

     priv->shadow_pipeline = _st_create_shadow_pipeline_from_actor (priv->shadow_spec, priv->icon_texture);
     priv->shadow_width = width;
     priv->shadow_height = height;
   }
}
Пример #6
0
static void
mnb_spinner_get_preferred_height (ClutterActor *self,
                                  gfloat        for_width,
                                  gfloat       *min_height_p,
                                  gfloat       *natural_height_p)
{
  MxWidget       *widget = MX_WIDGET (self);
  ClutterTexture *background;

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

      if (!CLUTTER_IS_TEXTURE (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);

      if (min_height_p)
        *min_height_p = tx_h;

      if (natural_height_p)
        *natural_height_p = tx_h;

      return;
    }

  if (min_height_p)
    *min_height_p = 0.0;

  if (natural_height_p)
    *natural_height_p = 0.0;
}
Пример #7
0
static void
opt_show_update_position_label (OptShow *show)
{
  OptShowPrivate *priv = show->priv;
  ClutterActor *stage;
  ClutterGeometry stage_geom;
  ClutterGeometry rect_geom;
  gint label_width, label_height;
  gchar *pos;
  
  if (!priv->position_label)
    return;

  stage = clutter_stage_get_default ();
  clutter_actor_get_geometry (stage, &stage_geom);
  
  pos = g_strdup_printf ("%d/%d",
		         priv->current_slide_num + 1,
			 priv->num_slides);

  clutter_text_set_text (CLUTTER_TEXT (priv->position_label), pos);
  clutter_texture_get_base_size (CLUTTER_TEXTURE (priv->position_label),
		                 &label_width,
				 &label_height);

  rect_geom.width = label_width + 50;
  rect_geom.height = label_height + 20;
  rect_geom.x = (stage_geom.width / 2) - (rect_geom.width / 2);
  rect_geom.y = stage_geom.height - rect_geom.height - 10;
  
  clutter_actor_set_geometry (priv->position_rect, &rect_geom);
  clutter_actor_set_position (priv->position_label,
		              rect_geom.x + 25,
			      rect_geom.y + 10);
  
  g_free (pos);
}
Пример #8
0
static void
set_clear_button_size (ClutterActor *clear_button)
{

  /* TODO quick fix for MX port. */
  clutter_actor_set_size (clear_button, 22, 21);

#if 0
  GValue background_image = { 0, };

  g_value_init (&background_image, G_TYPE_STRING);
  mx_stylable_get_property (MX_STYLABLE (clear_button),
                              "background-image", &background_image);
  if (g_value_get_string (&background_image))
    {
      GError        *error = NULL;
      ClutterActor  *background_texture = clutter_texture_new_from_file (
                                            g_value_get_string (&background_image),
                                            &error);
      if (error)
        {
          g_warning ("%s", error->message);
          g_error_free (error);
        }
      else
        {
          gint width, height;
          clutter_texture_get_base_size (CLUTTER_TEXTURE (background_texture),
                                         &width, &height);
          clutter_actor_set_size (clear_button, width, height);
          g_object_unref (background_texture);
        }
      g_value_unset (&background_image);
    }
#endif
}
Пример #9
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));
}
Пример #10
0
static void
tidy_texture_frame_paint (ClutterActor *self)
{
  TidyTextureFramePrivate    *priv;
  ClutterActor                *parent_texture;
  guint                        width, height;
  gint                         pwidth, pheight, ex, ey;
  ClutterFixed                 tx1, ty1, tx2, ty2, tw, th;
  GLenum                       target_type;
  ClutterColor                 col = { 0xff, 0xff, 0xff, 0xff };

  priv = TIDY_TEXTURE_FRAME (self)->priv;

  /* no need to paint stuff if we don't have a texture to reflect */
  if (!clutter_clone_texture_get_parent_texture (CLUTTER_CLONE_TEXTURE(self)))
    return;

  /* parent texture may have been hidden, there for need to make sure its 
   * realised with resources available.  
  */
  parent_texture 
    = CLUTTER_ACTOR 
       (clutter_clone_texture_get_parent_texture(CLUTTER_CLONE_TEXTURE(self)));
  if (!CLUTTER_ACTOR_IS_REALIZED (parent_texture))
    clutter_actor_realize (parent_texture);

  if (clutter_texture_is_tiled (CLUTTER_TEXTURE (parent_texture)))
    {
      g_warning("tiled textures not yet supported...");
      return;
    }

  cogl_push_matrix ();

#define FX(x) CLUTTER_INT_TO_FIXED(x)

  clutter_texture_get_base_size (CLUTTER_TEXTURE(parent_texture), 
				 &pwidth, &pheight); 
  clutter_actor_get_size (self, &width, &height); 

  tx1 = FX (priv->left);
  tx2 = FX (pwidth - priv->right);
  ty1 = FX (priv->top);
  ty2 = FX (pheight - priv->bottom);
  tw = FX (pwidth);
  th = FX (pheight);

  if (clutter_feature_available (CLUTTER_FEATURE_TEXTURE_RECTANGLE))
    {
      target_type = CGL_TEXTURE_RECTANGLE_ARB;
      cogl_enable (CGL_ENABLE_TEXTURE_RECT|CGL_ENABLE_BLEND);
    }
  else
    {
      target_type = CGL_TEXTURE_2D;
      cogl_enable (CGL_ENABLE_TEXTURE_2D|CGL_ENABLE_BLEND);

      tw = clutter_util_next_p2 (pwidth);
      th = clutter_util_next_p2 (pheight);

      tx1 = tx1/tw;
      tx2 = tx2/tw;
      ty1 = ty1/th;
      ty2 = ty2/th;
      tw = FX(pwidth)/tw;
      th = FX(pheight)/th;
    }

  col.alpha = clutter_actor_get_opacity (self);
  cogl_color (&col);

  clutter_texture_bind_tile (CLUTTER_TEXTURE(parent_texture), 0);

  ex = width - priv->right;
  if (ex < 0) 
    ex = priv->right; 		/* FIXME */

  ey = height - priv->bottom;
  if (ey < 0) 
    ey = priv->bottom; 		/* FIXME */

  /* top left corner */
  cogl_texture_quad (0, 
		     priv->left, /* FIXME: clip if smaller */
		     0,
		     priv->top,
		     0,
		     0,
		     tx1,
		     ty1);

  /* top middle */
  cogl_texture_quad (priv->left,
		     ex,
		     0,
		     priv->top,
		     tx1,
		     0,
		     tx2,
		     ty1);

  /* top right */
  cogl_texture_quad (ex,
		     width,
		     0,
		     priv->top,
		     tx2,
		     0,
		     tw,
		     ty1);

  /* mid left */
  cogl_texture_quad (0, 
		     priv->left,
		     priv->top,
		     ey,
		     0,
		     ty1,
		     tx1,
		     ty2);

  /* center */
  cogl_texture_quad (priv->left,
		     ex,
		     priv->top,
		     ey,
		     tx1,
		     ty1,
		     tx2,
		     ty2);

  /* mid right */
  cogl_texture_quad (ex,
		     width,
		     priv->top,
		     ey,
		     tx2,
		     ty1,
		     tw,
		     ty2);

  /* bottom left */
  cogl_texture_quad (0, 
		     priv->left,
		     ey,
		     height,
		     0,
		     ty2,
		     tx1,
		     th);

  /* bottom center */
  cogl_texture_quad (priv->left,
		     ex,
		     ey,
		     height,
		     tx1,
		     ty2,
		     tx2,
		     th);

  /* bottom right */
  cogl_texture_quad (ex,
		     width,
		     ey,
		     height,
		     tx2,
		     ty2,
		     tw,
		     th);

  cogl_pop_matrix ();

#undef FX
}
Пример #11
0
static void
reflect_texture_render_to_gl_quad (ClutterReflectTexture *ctexture, 
				 int             x1, 
				 int             y1, 
				 int             x2, 
				 int             y2)
{
  gint   qx1 = 0, qx2 = 0, qy1 = 0, qy2 = 0;
  gint   qwidth = 0, qheight = 0;
  gint   x, y, i =0, lastx = 0, lasty = 0;
  gint   n_x_tiles, n_y_tiles; 
  gint   pwidth, pheight, rheight;
  float tx, ty, ty2 = 0.0;

  ClutterReflectTexturePrivate *priv = ctexture->priv;
  ClutterActor *parent_texture = CLUTTER_ACTOR(clutter_clone_texture_get_parent_texture(CLUTTER_CLONE_TEXTURE(ctexture)));

  priv = ctexture->priv;

  qwidth  = x2 - x1;
  qheight = y2 - y1;

  rheight = priv->reflection_height;

  if (rheight > qheight)
    rheight = qheight;

  if (!CLUTTER_ACTOR_IS_REALIZED (parent_texture))
      clutter_actor_realize (parent_texture);

  /* Only paint if parent is in a state to do so */
  if (!clutter_texture_has_generated_tiles (CLUTTER_TEXTURE(parent_texture)))
    return;
  
  clutter_texture_get_base_size (CLUTTER_TEXTURE(parent_texture), 
				 &pwidth, &pheight); 

  if (!clutter_texture_is_tiled (CLUTTER_TEXTURE(parent_texture)))
    {
      clutter_texture_bind_tile (CLUTTER_TEXTURE(parent_texture), 0);

      /* NPOTS textures *always* used if extension available
       */
      if (clutter_feature_available (CLUTTER_FEATURE_TEXTURE_RECTANGLE))
	{
	  tx = (float) pwidth;
	  ty = (float) pheight;
	  ty2 = (float)(clutter_actor_get_height (CLUTTER_ACTOR(ctexture)) * rheight) 
                                             / pheight;
	  ty2 = pheight - ty2;

	}
      else
	{
	  tx = (float) pwidth / clutter_util_next_p2 (pwidth);  
	  ty = (float) pheight / clutter_util_next_p2 (pheight);
	}

      qx1 = x1; qx2 = x2;
      qy1 = y1; qy2 = y1 + rheight;

      glBegin (GL_QUADS);

      glColor4ub (255, 255, 255, 
		  clutter_actor_get_opacity (CLUTTER_ACTOR(ctexture)));

      glTexCoord2f (0, ty);   
      glVertex2i   (qx1, qy1);

      glTexCoord2f (tx,  ty);   
      glVertex2i   (qx2, qy1);

      glColor4ub (255, 255, 255, 0);

      glTexCoord2f (tx,  ty2);    
      glVertex2i   (qx2, qy2);
      
      glTexCoord2f (0, ty2);    
      glVertex2i   (qx1, qy2);

      glEnd ();	
      
      return;
    }

  clutter_texture_get_n_tiles (CLUTTER_TEXTURE(parent_texture), 
			       &n_x_tiles, &n_y_tiles); 

  for (x = 0; x < n_x_tiles; x++)
    {
      lasty = 0;

      for (y = 0; y < n_y_tiles; y++)
	{
	  gint actual_w, actual_h;
	  gint xpos, ypos, xsize, ysize, ywaste, xwaste;
	  
	  clutter_texture_bind_tile (CLUTTER_TEXTURE(parent_texture), i);
	 
	  clutter_texture_get_x_tile_detail (CLUTTER_TEXTURE(parent_texture), 
					     x, &xpos, &xsize, &xwaste);

	  clutter_texture_get_y_tile_detail (CLUTTER_TEXTURE(parent_texture), 
					     y, &ypos, &ysize, &ywaste);

	  actual_w = xsize - xwaste;
	  actual_h = ysize - ywaste;

	  tx = (float) actual_w / xsize;
	  ty = (float) actual_h / ysize;

	  qx1 = x1 + lastx;
	  qx2 = qx1 + ((qwidth * actual_w ) / pwidth );
	  
	  qy1 = y1 + lasty;
	  qy2 = qy1 + ((qheight * actual_h) / pheight );

	  glBegin (GL_QUADS);
	  glTexCoord2f (tx, ty);   glVertex2i   (qx2, qy2);
	  glTexCoord2f (0,  ty);   glVertex2i   (qx1, qy2);
	  glTexCoord2f (0,  0);    glVertex2i   (qx1, qy1);
	  glTexCoord2f (tx, 0);    glVertex2i   (qx2, qy1);
	  glEnd ();	

	  lasty += qy2 - qy1;	  

	  i++;
	}
      lastx += qx2 - qx1;
    }
}
Пример #12
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);
}
Пример #13
0
static void
add_pictures (ClutterActor *box)
{
  GList *files = get_pictures ();

  while (files)
    {
      gint w, h, i;
      ClutterActor *drawer, *drawer2, *tile, *texture, *menu, *description;

      gchar *file = files->data;

      /* Create texture */
      texture = clutter_texture_new_from_file (file, NULL);
      clutter_texture_get_base_size (CLUTTER_TEXTURE (texture), &w, &h);
      clutter_actor_set_size (texture, 300, 300.0/w * h);

      /* Create menu */
      menu = mx_box_layout_new ();
      mx_box_layout_set_orientation (MX_BOX_LAYOUT (menu),
                                     MX_ORIENTATION_VERTICAL);
      for (i = 0; i < 4; i++)
        {
          ClutterActor *button, *layout, *icon, *label;

          button = mx_button_new ();

          layout = mx_box_layout_new ();
          icon = mx_icon_new ();
          label = mx_label_new ();

          mx_box_layout_set_spacing (MX_BOX_LAYOUT (layout), 8);

          mx_icon_set_icon_size (MX_ICON (icon), 16);
          clutter_actor_set_size (icon, 16, 16);

          clutter_container_add (CLUTTER_CONTAINER (layout),
                                 icon, label, NULL);
          mx_bin_set_child (MX_BIN (button), layout);
          mx_bin_set_alignment (MX_BIN (button),
                                MX_ALIGN_START,
                                MX_ALIGN_MIDDLE);

          clutter_container_add_actor (CLUTTER_CONTAINER (menu), button);
          mx_box_layout_child_set_x_fill (MX_BOX_LAYOUT (menu), button, TRUE);

          switch (i)
            {
            case 0:
              mx_icon_set_icon_name (MX_ICON (icon), "dialog-information");
              mx_label_set_text (MX_LABEL (label), "This");
              break;

            case 1:
              mx_icon_set_icon_name (MX_ICON (icon), "dialog-question");
              mx_label_set_text (MX_LABEL (label), "is");
              break;

            case 2:
              mx_icon_set_icon_name (MX_ICON (icon), "dialog-warning");
              mx_label_set_text (MX_LABEL (label), "a");
              break;

            case 3:
              mx_icon_set_icon_name (MX_ICON (icon), "dialog-error");
              mx_label_set_text (MX_LABEL (label), "menu");
              break;
            }
        }

      /* Create description */
      description = mx_label_new_with_text ("Here you could put a very "
                                            "long description of whatever "
                                            "is above it. Or you could put "
                                            "another focusable widget here "
                                            "and it'd be navigable, like "
                                            "the menu on the right. Whoo!");
      clutter_text_set_line_wrap ((ClutterText *)mx_label_get_clutter_text (
                                    MX_LABEL (description)), TRUE);

      drawer = mex_expander_box_new ();
      mex_expander_box_set_important_on_focus (MEX_EXPANDER_BOX (drawer), TRUE);
      drawer2 = mex_expander_box_new ();
      mex_expander_box_set_grow_direction (MEX_EXPANDER_BOX (drawer2),
                                          MEX_EXPANDER_BOX_RIGHT);
      mex_expander_box_set_important (MEX_EXPANDER_BOX (drawer2), TRUE);

      tile = mex_tile_new_with_label (file);
      mex_tile_set_important (MEX_TILE (tile), TRUE);
      mx_bin_set_child (MX_BIN (tile), texture);

      clutter_container_add (CLUTTER_CONTAINER (drawer2), tile, menu, NULL);
      clutter_container_add (CLUTTER_CONTAINER (drawer),
                             drawer2, description, NULL);

      g_signal_connect (drawer, "notify::open",
                        G_CALLBACK (sync_drawer2_cb), drawer2);

      clutter_container_add_actor (CLUTTER_CONTAINER (box), drawer);

      clutter_actor_set_reactive (texture, TRUE);
      g_signal_connect (texture, "enter-event",
                        G_CALLBACK (texture_enter_cb), drawer);
      g_signal_connect (texture, "leave-event",
                        G_CALLBACK (texture_leave_cb), drawer);
      g_signal_connect (texture, "button-press-event",
                        G_CALLBACK (texture_clicked_cb), drawer);

      g_free (file);
      files = g_list_delete_link (files, files);
    }
}
Пример #14
0
static void on_gesture_end(ClutterGestureAction *action, ClutterActor *stage, gpointer data) {
	ClutterActor *new_actor, *texture, *actor;
	gfloat x, y, w, h;
	GError *error = NULL;
	GdkColor color;
	guint16 alpha;
	gint iw = 125;
	gint ih = 126;
	gboolean repeat_x = FALSE;
	gboolean repeat_y = TRUE;
	guint bgr;


	new_actor = tmpRect;

	gtk_color_button_get_color(GTK_COLOR_BUTTON(app.colorpicker), &color);
	alpha = gtk_color_button_get_alpha(GTK_COLOR_BUTTON(app.colorpicker));
	ClutterColor col =  {
		CLAMP(((color.red / 65535.0) * 255), 0, 255),
		CLAMP(((color.green / 65535.0) * 255), 0, 255),
		CLAMP(((color.blue / 65535.0) * 255), 0, 255),
		CLAMP(((alpha / 65535.0) * 255), 0, 255),

	};

	clutter_rectangle_set_color(CLUTTER_RECTANGLE(new_actor), &col);
	clutter_rectangle_set_border_width(CLUTTER_RECTANGLE(new_actor), 0);
	tmpRect = NULL;


	clutter_actor_get_position(new_actor, &x, &y);
	clutter_actor_get_size(new_actor, &w, &h);

	if (background_image_file != NULL){

		texture = clutter_texture_new_from_file(background_image_file, &error);
		if (error != NULL){
			g_print("Loading image failed\n");
			g_error_free(error);
		}
		clutter_actor_set_position(texture, x, y);
		clutter_actor_set_size(texture, w, h);
		clutter_actor_add_child(stage, texture);
		clutter_actor_show(texture);

		bgr = gtk_combo_box_get_active(GTK_COMBO_BOX(app.background_repeat_select));
		switch (bgr){
			case 0:
				repeat_x = repeat_y = FALSE;
				break;
			case 1:
				repeat_x = TRUE; repeat_y = FALSE;
				break;
			case 2:
				repeat_x = FALSE; repeat_y = TRUE;
				break;
			case 3:
				repeat_x = repeat_y = TRUE;
				break;
		}
		clutter_texture_get_base_size(CLUTTER_TEXTURE(texture), &iw, &ih);
		clutter_actor_set_clip(texture, 0, 0, repeat_x ? w : iw, repeat_y ? h : ih);
		clutter_texture_set_sync_size(CLUTTER_TEXTURE(texture), TRUE);
		clutter_texture_set_repeat(CLUTTER_TEXTURE(texture), TRUE, TRUE);
		clutter_texture_set_keep_aspect_ratio(CLUTTER_TEXTURE(texture), TRUE);
		actor = texture;
		clutter_actor_destroy(new_actor);
	}
	else {
		actor = new_actor;
	}
	tool = TOOL_SELECT;
	clutter_actor_add_action(actor, clutter_drag_action_new());
	clutter_actor_set_reactive(actor, TRUE);
	actors = g_list_append(actors, actor);
	GdkWindow *gdk_window;
	gdk_window = gtk_widget_get_window(app.stage);
	gdk_window_set_cursor(gdk_window, NULL);
}
Пример #15
0
static void
mex_content_box_set_property (GObject      *object,
                              guint         property_id,
                              const GValue *value,
                              GParamSpec   *pspec)
{
  MexContentBox *self = MEX_CONTENT_BOX (object);
  MexContentBoxPrivate *priv = self->priv;

  switch (property_id)
    {
    case PROP_MEDIA_URL:
      g_free (priv->media_url);
      priv->media_url = g_value_dup_string (value);
      break;

    case PROP_LOGO_URL:
      /* FIXME: We want the logo URL to be file:// to share the same
       * underlying texture. This should be handled by a generic "download
       * queue + texture cache" thingy that caches the same URL to a local
       * file and hands over a ClutterTexure (or a MagicTexture) with the
       * same underlying Cogl texture */
    {
      MxTextureCache *cache;
      ClutterActor *logo, *logo_frame;
      GFile *file;
      gchar *path;
      gint bw, bh;
      gfloat ratio;

      g_free (priv->logo_url);
      priv->logo_url = g_value_dup_string (value);

      if (priv->logo_url == NULL)
        break;

      file = g_file_new_for_uri (priv->logo_url);
      path = g_file_get_path (file);
      g_object_unref (file);
      if (G_UNLIKELY (path == NULL))
        {
          g_warning ("The logo URL provided is not local, refusing to load it");
          break;
        }

      cache = mx_texture_cache_get_default ();
      logo = mx_texture_cache_get_actor (cache, path);
      if (G_UNLIKELY (logo == NULL))
        {
          g_warning ("Could not retrieve texture for %s", path);
          break;
        }

      logo_frame = mex_aspect_frame_new ();
      /* FIXME, had to set the size (for now?) provides some GObject properties
       * to tune that? expose it in the CSS */
      clutter_actor_set_size (logo_frame, 60, 40);
      clutter_texture_get_base_size (CLUTTER_TEXTURE (logo), &bw, &bh);
      ratio = bh / 40.;
      mex_aspect_frame_set_ratio (MEX_ASPECT_FRAME (logo_frame), ratio);
      clutter_container_add_actor (CLUTTER_CONTAINER (logo_frame), logo);

      mex_tile_set_primary_icon (MEX_TILE (priv->tile), logo_frame);
    }
    break;

    case PROP_THUMB_WIDTH:
      priv->thumb_width = g_value_get_int (value);
      g_object_set (G_OBJECT (priv->tile),
                    "thumb-width",
                    priv->thumb_width,
                    NULL);
      break;

    case PROP_THUMB_HEIGHT:
      priv->thumb_height = g_value_get_int (value);
      g_object_set (G_OBJECT (priv->tile),
                    "thumb-height",
                    priv->thumb_height,
                    NULL);
      break;

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
    }
}