summaryrefslogtreecommitdiff
path: root/clutter/deprecated/clutter-texture.c
diff options
context:
space:
mode:
Diffstat (limited to 'clutter/deprecated/clutter-texture.c')
-rw-r--r--clutter/deprecated/clutter-texture.c76
1 files changed, 75 insertions, 1 deletions
diff --git a/clutter/deprecated/clutter-texture.c b/clutter/deprecated/clutter-texture.c
index 448c884..5e81afd 100644
--- a/clutter/deprecated/clutter-texture.c
+++ b/clutter/deprecated/clutter-texture.c
@@ -117,6 +117,8 @@ struct _ClutterTexturePrivate
guint pick_with_alpha : 1;
guint pick_with_alpha_supported : 1;
guint seen_create_pick_pipeline_warning : 1;
+
+ gint crop_top, crop_width, crop_height, crop_left;
};
#define ASYNC_STATE_LOCKED 1
@@ -167,6 +169,10 @@ enum
PROP_LOAD_ASYNC,
PROP_LOAD_DATA_ASYNC,
PROP_PICK_WITH_ALPHA,
+ PROP_CROP_TOP,
+ PROP_CROP_WIDTH,
+ PROP_CROP_HEIGHT,
+ PROP_CROP_LEFT,
PROP_LAST
};
@@ -578,6 +584,7 @@ gen_texcoords_and_draw_cogl_rectangle (ClutterActor *self)
ClutterTexturePrivate *priv = texture->priv;
ClutterActorBox box;
float t_w, t_h;
+ float t_x, t_y;
clutter_actor_get_allocation_box (self, &box);
@@ -591,10 +598,20 @@ gen_texcoords_and_draw_cogl_rectangle (ClutterActor *self)
else
t_h = 1.0;
+ t_x = priv->crop_left ? priv->crop_left / (float) priv->image_width : 0;
+ t_y = priv->crop_top ? priv->crop_top / (float) priv->image_height : 0;
+
+ if (priv->crop_width) {
+ t_w = MIN (t_w, t_x + priv->crop_width/(float) priv->image_width);
+ }
+ if (priv->crop_height) {
+ t_h = MIN (t_h, t_y + priv->crop_height/(float) priv->image_height);
+ }
+
cogl_rectangle_with_texture_coords (0, 0,
box.x2 - box.x1,
box.y2 - box.y1,
- 0, 0, t_w, t_h);
+ t_x, t_y, t_w, t_h);
}
static CoglPipeline *
@@ -890,6 +907,18 @@ clutter_texture_set_property (GObject *object,
clutter_texture_set_pick_with_alpha (texture,
g_value_get_boolean (value));
break;
+ case PROP_CROP_TOP:
+ priv->crop_top = g_value_get_int (value);
+ break;
+ case PROP_CROP_WIDTH:
+ priv->crop_width = g_value_get_int (value);
+ break;
+ case PROP_CROP_HEIGHT:
+ priv->crop_height = g_value_get_int (value);
+ break;
+ case PROP_CROP_LEFT:
+ priv->crop_left = g_value_get_int (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -958,6 +987,18 @@ clutter_texture_get_property (GObject *object,
case PROP_FILENAME:
g_value_set_string (value, priv->filename);
break;
+ case PROP_CROP_TOP:
+ g_value_set_int (value, priv->crop_top);
+ break;
+ case PROP_CROP_WIDTH:
+ g_value_set_int (value, priv->crop_width);
+ break;
+ case PROP_CROP_HEIGHT:
+ g_value_set_int (value, priv->crop_height);
+ break;
+ case PROP_CROP_LEFT:
+ g_value_set_int (value, priv->crop_left);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -1169,6 +1210,39 @@ clutter_texture_class_init (ClutterTextureClass *klass)
obj_props[PROP_PICK_WITH_ALPHA] = pspec;
g_object_class_install_property (gobject_class, PROP_PICK_WITH_ALPHA, pspec);
+ pspec = g_param_spec_int ("crop-top",
+ "Crop Top",
+ "How many pixels to crop on the top of the image",
+ 0, G_MAXINT, 0,
+ CLUTTER_PARAM_READWRITE);
+ obj_props[PROP_CROP_TOP] = pspec;
+ g_object_class_install_property (gobject_class, PROP_CROP_TOP, pspec);
+
+ pspec = g_param_spec_int ("crop-width",
+ "Crop Width",
+ "width of the cropped image",
+ 0, G_MAXINT, 0,
+ CLUTTER_PARAM_READWRITE);
+ obj_props[PROP_CROP_WIDTH] = pspec;
+ g_object_class_install_property (gobject_class, PROP_CROP_WIDTH, pspec);
+
+ pspec = g_param_spec_int ("crop-height",
+ "Crop Height",
+ "Height of the cropped image",
+ 0, G_MAXINT, 0,
+ CLUTTER_PARAM_READWRITE);
+ obj_props[PROP_CROP_HEIGHT] = pspec;
+ g_object_class_install_property (gobject_class, PROP_CROP_HEIGHT, pspec);
+
+ pspec = g_param_spec_int ("crop-left",
+ "Crop Left",
+ "How many pixels to crop on the left of the image",
+ 0, G_MAXINT, 0,
+ CLUTTER_PARAM_READWRITE);
+ obj_props[PROP_CROP_LEFT] = pspec;
+ g_object_class_install_property (gobject_class, PROP_CROP_LEFT, pspec);
+
+
/**
* ClutterTexture::size-change:
* @texture: the texture which received the signal