static void glide_image_paint (ClutterActor *self) { GlideImage *image = GLIDE_IMAGE (self); GlideImagePrivate *priv = image->priv; ClutterActorBox box = {0, }; gfloat t_w, t_h; guint8 paint_opacity = clutter_actor_get_paint_opacity (self); if (paint_opacity == 0) { return; } GLIDE_NOTE (PAINT, "painting image '%s'", GLIDE_ACTOR_DISPLAY_NAME (self)); cogl_material_set_color4ub (priv->material, paint_opacity, paint_opacity, paint_opacity, paint_opacity); clutter_actor_get_allocation_box (self, &box); GLIDE_NOTE (PAINT, "paint to x1: %f, y1: %f x2: %f, y2: %f " "opacity: %i", box.x1, box.y1, box.x2, box.y2, clutter_actor_get_opacity (self)); t_w = 1.0; t_h = 1.0; cogl_set_source (priv->material); cogl_rectangle_with_texture_coords (0, 0, box.x2 - box.x1, box.y2 - box.y1, 0, 0, t_w, t_h); }
static void st_icon_update (StIcon *icon) { StIconPrivate *priv = icon->priv; StThemeNode *theme_node; StTextureCache *cache; if (priv->pending_texture) { clutter_actor_destroy (priv->pending_texture); g_object_unref (priv->pending_texture); priv->pending_texture = NULL; priv->opacity_handler_id = 0; } theme_node = st_widget_peek_theme_node (ST_WIDGET (icon)); if (theme_node == NULL) return; cache = st_texture_cache_get_default (); if (priv->gicon) { priv->pending_texture = st_texture_cache_load_gicon (cache, (priv->icon_type != ST_ICON_APPLICATION && priv->icon_type != ST_ICON_DOCUMENT) ? theme_node : NULL, priv->gicon, priv->icon_size); } else if (priv->icon_name) { priv->pending_texture = st_texture_cache_load_icon_name (cache, theme_node, priv->icon_name, priv->icon_type, priv->icon_size); } if (priv->pending_texture) { g_object_ref_sink (priv->pending_texture); if (clutter_actor_get_opacity (priv->pending_texture) != 0 || priv->icon_texture == NULL) { /* This icon is ready for showing, or nothing else is already showing */ st_icon_finish_update (icon); } else { /* Will be shown when fully loaded */ priv->opacity_handler_id = g_signal_connect (priv->pending_texture, "notify::opacity", G_CALLBACK (opacity_changed_cb), icon); } } else if (priv->icon_texture) { clutter_actor_destroy (priv->icon_texture); priv->icon_texture = NULL; } }
static void bjb_editor_toolbar_fade_in (BjbEditorToolbar *self) { BjbEditorToolbarPrivate *priv = self->priv; guint8 opacity; opacity = clutter_actor_get_opacity (priv->actor); if (opacity != 0) return; clutter_actor_set_opacity (priv->actor, 255); }
static void clutter_reflect_texture_paint (ClutterActor *self) { ClutterReflectTexturePrivate *priv; ClutterActor *parent_texture; gint x1, y1, x2, y2; GLenum target_type; priv = CLUTTER_REFLECT_TEXTURE (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); /* FIXME: figure out nicer way of getting at this info... */ if (clutter_feature_available (CLUTTER_FEATURE_TEXTURE_RECTANGLE) && clutter_texture_is_tiled (CLUTTER_TEXTURE (parent_texture)) == FALSE) { 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); } cogl_push_matrix (); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4ub (255, 255, 255, clutter_actor_get_opacity (self)); clutter_actor_get_coords (self, &x1, &y1, &x2, &y2); /* Parent paint translated us into position */ reflect_texture_render_to_gl_quad (CLUTTER_REFLECT_TEXTURE (self), 0, 0, x2 - x1, y2 - y1); cogl_pop_matrix (); }
/* turn overlay opacity on/off */ static void click_cb (ClutterClickAction *action, ClutterActor *actor, gpointer user_data) { ClutterActor *overlay = CLUTTER_ACTOR (user_data); guint8 opacity = clutter_actor_get_opacity (overlay); if (opacity < OVERLAY_OPACITY_ON) opacity = OVERLAY_OPACITY_ON; else opacity = OVERLAY_OPACITY_OFF; clutter_actor_set_opacity (overlay, opacity); }
static void timeline_complete (ClutterTimeline *timeline, ClutterActor *expander) { guchar opacity; MxExpanderPrivate *priv = MX_EXPANDER (expander)->priv; g_signal_emit (expander, expander_signals[EXPAND_COMPLETE], 0); /* if the expander is now closed, update the style */ if (!priv->expanded) { clutter_actor_set_name (priv->arrow, "mx-expander-arrow-closed"); mx_stylable_set_style_class (MX_STYLABLE (expander), "closed-expander"); clutter_actor_queue_relayout (expander); } if (!priv->child) return; /* continue only if we are "opening" */ if (!priv->expanded) return; /* we can't do an animation if there is already one in progress, * because we cannot get the actors original opacity */ if (clutter_actor_get_transition (priv->child, "opacity")) { clutter_actor_show (priv->child); return; } opacity = clutter_actor_get_opacity (priv->child); clutter_actor_set_opacity (priv->child, 0); clutter_actor_show (priv->child); clutter_actor_save_easing_state (priv->child); clutter_actor_set_easing_mode (priv->child, CLUTTER_EASE_IN_SINE); clutter_actor_set_easing_duration (priv->child, 100); clutter_actor_set_opacity (priv->child, opacity); clutter_actor_restore_easing_state (priv->child); }
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); } }
void mex_shell_present (MexShell *shell, ClutterActor *actor, MexShellDirection in) { GList *l; ClutterActor *stage; ClutterActorBox box; MexShellPrivate *priv; MexShellChildData *data; gfloat x, y, width, height; g_return_if_fail (MEX_IS_SHELL (shell)); g_return_if_fail (CLUTTER_IS_ACTOR (actor)); priv = shell->priv; l = g_list_find_custom (priv->children, actor, mex_shell_find_child); if (!l) { g_warning (G_STRLOC ": Attempted to present an unknown child."); return; } data = l->data; clutter_actor_get_allocation_box (CLUTTER_ACTOR (shell), &box); width = box.x2 - box.x1; height = box.y2 - box.y1; x = 0; y = 0; if (clutter_actor_get_opacity (data->child) == 0x00) { switch (in) { case MEX_SHELL_DIRECTION_NONE: clutter_actor_set_position (data->child, 0, 0); break; case MEX_SHELL_DIRECTION_TOP: clutter_actor_set_position (data->child, x, -height); break; case MEX_SHELL_DIRECTION_RIGHT: clutter_actor_set_position (data->child, width, y); break; default: case MEX_SHELL_DIRECTION_BOTTOM: clutter_actor_set_position (data->child, x, height); break; case MEX_SHELL_DIRECTION_LEFT: clutter_actor_set_position (data->child, -width, y); break; } data->last_direction = in; } clutter_animator_remove_key (data->animator, (GObject *)data->child, NULL, -1); clutter_animator_set (data->animator, data->child, "x", CLUTTER_LINEAR, 0.0, 0.f, data->child, "x", CLUTTER_EASE_OUT_QUAD, 1.0, x, data->child, "y", CLUTTER_LINEAR, 0.0, 0.f, data->child, "y", CLUTTER_EASE_OUT_QUAD, 1.0, y, data->child, "opacity", CLUTTER_LINEAR, 0.0, 0x00, data->child, "opacity", CLUTTER_EASE_OUT_QUAD, 0.1, 0xff, NULL); clutter_animator_property_set_ease_in (data->animator, (GObject *)data->child, "x", TRUE); clutter_animator_property_set_ease_in (data->animator, (GObject *)data->child, "y", TRUE); clutter_animator_property_set_ease_in (data->animator, (GObject *)data->child, "opacity", TRUE); data->start_animator = TRUE; if (priv->presented && (priv->presented != actor)) { MexShellDirection dir; l = g_list_find_custom (priv->children, priv->presented, mex_shell_find_child); if (!l) { g_warning (G_STRLOC ": Former presented actor is unknown"); return; } data = l->data; x = y = 0; switch (in) { case 0: x = y = 0; dir = 0; break; case MEX_SHELL_DIRECTION_TOP: y = height; dir = MEX_SHELL_DIRECTION_BOTTOM; break; case MEX_SHELL_DIRECTION_RIGHT: x = -width; dir = MEX_SHELL_DIRECTION_LEFT; break; case MEX_SHELL_DIRECTION_BOTTOM: y = -height; dir = MEX_SHELL_DIRECTION_TOP; break; default: case MEX_SHELL_DIRECTION_LEFT: x = width; dir = MEX_SHELL_DIRECTION_RIGHT; break; } data->last_direction = dir; clutter_animator_remove_key (data->animator, (GObject *)data->child, NULL, -1); clutter_animator_set (data->animator, data->child, "x", CLUTTER_LINEAR, 0.0, 0.f, data->child, "x", CLUTTER_EASE_OUT_QUAD, 1.0, x, data->child, "y", CLUTTER_LINEAR, 0.0, 0.f, data->child, "y", CLUTTER_EASE_OUT_QUAD, 1.0, y, data->child, "opacity", CLUTTER_LINEAR, 0.9, 0xff, data->child, "opacity", CLUTTER_EASE_OUT_QUAD, 1.0, 0x00, NULL); clutter_animator_property_set_ease_in (data->animator, (GObject *)data->child, "x", TRUE); clutter_animator_property_set_ease_in (data->animator, (GObject *)data->child, "y", TRUE); clutter_animator_property_set_ease_in (data->animator, (GObject *)data->child, "opacity", TRUE); data->start_animator = TRUE; } priv->presented = actor; stage = clutter_actor_get_stage (actor); if (stage) { MxFocusManager *manager = mx_focus_manager_get_for_stage ((ClutterStage *)stage); if (manager) { if (MX_IS_FOCUSABLE (actor)) mx_focus_manager_push_focus_with_hint (manager, MX_FOCUSABLE (shell), MX_FOCUS_HINT_PRIOR); else mx_focus_manager_move_focus (manager, MX_FOCUS_DIRECTION_OUT); } } clutter_actor_queue_redraw (CLUTTER_ACTOR (shell)); }
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 }
static gboolean actor_manipulator_press (ClutterActor *stage, ClutterEvent *event, gpointer data) { ClutterActor *actor; actor = clutter_stage_get_actor_at_pos (CLUTTER_STAGE (stage), CLUTTER_PICK_ALL, event->button.x, event->button.y); if (actor == stage || CLUTTER_IS_GROUP (actor)) { if (event->button.button == 3) { popup_nuke (stage, event->button.x, event->button.y); popup_add ("+rectangle", "bar", G_CALLBACK ( action_add_rectangle), scene_get_group ()); popup_add ("+circle", "bar", G_CALLBACK ( action_add_circle), scene_get_group ()); popup_add ("+triangle", "bar", G_CALLBACK ( action_add_triangle), scene_get_group ()); popup_add ("+text", "bar", G_CALLBACK ( action_add_text), scene_get_group ()); popup_add ("+image", "bar", G_CALLBACK ( action_add_image), scene_get_group ()); #if 0 popup_add ("+block-tree", "bar", G_CALLBACK ( action_add_block_tree), scene_get_group ()); #endif popup_add ("zero gravity", "bar", G_CALLBACK ( action_zero_gravity), scene_get_group ()); } return TRUE; } if (actor == NULL) { return FALSE; } if (event->button.button == 3) { popup_nuke (stage, event->button.x, event->button.y); popup_add ("remove", "bar", G_CALLBACK (action_remove), actor); popup_add ("set linear velocity", "bar", G_CALLBACK (action_set_linear_velocity), actor); popup_add ("set dynamic", "bar", G_CALLBACK (action_set_dynamic), actor); popup_add ("set static", "bar", G_CALLBACK (action_set_static), actor); popup_add_slider ("opacity", "hm", 0.0, 255.0, clutter_actor_get_opacity (actor) * 1.0, G_CALLBACK (set_opacity), actor); popup_add_slider ("rotation", "hm", 0.0, 360.0, clutter_actor_get_rotation (actor, CLUTTER_Z_AXIS, NULL, NULL, NULL), G_CALLBACK (set_rotation), actor); popup_add ("ok", "bar", NULL, NULL); return TRUE; } if (!should_be_manipulated (actor)) return FALSE; manipulated_actor = actor; clutter_actor_get_position (actor, &orig_x, &orig_y); orig_rotation = clutter_actor_get_rotation (actor, CLUTTER_Z_AXIS, NULL, NULL, NULL); start_x = (event->button.x); start_y = (event->button.y); clutter_actor_transform_stage_point ( clutter_actor_get_parent (manipulated_actor), start_x, start_y, &start_x, &start_y); mode = Direct; #ifdef BOX2D_MANIPULATION /* Use Box2D manipulation if the actor is dynamic, and the physics * engine is running */ if (CLUTTER_IS_BOX2D (scene_get_group ()) && clutter_box2d_get_simulating (CLUTTER_BOX2D (scene_get_group ()))) { ClutterBox2D *box2d = CLUTTER_BOX2D (scene_get_group ()); /*ClutterVertex target = { start_x, start_y };*/ gint type; clutter_container_child_get (CLUTTER_CONTAINER (box2d), manipulated_actor, "mode", &type, NULL); if (type == CLUTTER_BOX2D_DYNAMIC) { #if 0 mouse_joint = clutter_box2d_add_mouse_joint (CLUTTER_BOX2D ( scene_get_group ()), manipulated_actor, &target); #endif mode = None; /*Box2D;*/ manipulated_actor = NULL; return FALSE; } } #endif clutter_set_motion_events_enabled (FALSE); return TRUE; }
IO_METHOD(IoClutterActor, getOpacity) { return IONUMBER(clutter_actor_get_opacity(IOCACTOR(self))); }
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; } }
static void clutter_x11_texture_pixmap_paint (ClutterActor *self) { ClutterX11TexturePixmap *texture = CLUTTER_X11_TEXTURE_PIXMAP (self); ClutterX11TexturePixmapPrivate *priv = texture->priv; gint x_1, y_1, x_2, y_2; ClutterColor col = { 0xff, 0xff, 0xff, 0xff }; ClutterFixed t_w, t_h; GList *shape; CoglHandle cogl_texture; g_return_if_fail (CLUTTER_X11_IS_TEXTURE_PIXMAP (texture)); /* If we have no shapes, just call what we had before */ if (priv->shapes==0) { CLUTTER_ACTOR_CLASS(clutter_x11_texture_pixmap_parent_class)->paint(self); return; } if (!CLUTTER_ACTOR_IS_REALIZED (CLUTTER_ACTOR(texture))) clutter_actor_realize (CLUTTER_ACTOR(texture)); CLUTTER_NOTE (PAINT, "painting X11 texture '%s'", clutter_actor_get_name (self) ? clutter_actor_get_name (self) : "unknown"); col.alpha = clutter_actor_get_paint_opacity (self); cogl_color (&col); clutter_actor_get_allocation_coords (self, &x_1, &y_1, &x_2, &y_2); CLUTTER_NOTE (PAINT, "paint to x1: %i, y1: %i x2: %i, y2: %i " "opacity: %i", x_1, y_1, x_2, y_2, clutter_actor_get_opacity (self)); t_w = CFX_ONE; t_h = CFX_ONE; cogl_texture = clutter_texture_get_cogl_texture(CLUTTER_TEXTURE(self)); if (cogl_texture == COGL_INVALID_HANDLE) return; /* so now we go through our shapes and render */ for (shape = priv->shapes; shape; shape = shape->next) { gint w = x_2 - x_1; gint h = y_2 - y_1; ClutterGeometry *geo = (ClutterGeometry*)shape->data; cogl_texture_rectangle ( cogl_texture, CLUTTER_INT_TO_FIXED(w * geo->x / priv->pixmap_width), CLUTTER_INT_TO_FIXED(h * geo->y / priv->pixmap_height), CLUTTER_INT_TO_FIXED(w * (geo->x+geo->width) / priv->pixmap_width), CLUTTER_INT_TO_FIXED(h * (geo->y+geo->height) / priv->pixmap_height), t_w * geo->x / priv->pixmap_width, t_h * geo->y / priv->pixmap_height, t_w * (geo->x+geo->width) / priv->pixmap_width, t_h * (geo->y+geo->height) / priv->pixmap_height); } }
void clutter_dominatrix_handle_event (ClutterDominatrix *dominatrix, ClutterEvent *event) { ClutterDominatrixPrivate * priv = dominatrix->priv; switch (event->type) { case CLUTTER_BUTTON_PRESS: { gint x, y; ClutterActor * actor = priv->slave; ClutterVertex v[4]; ClutterVertex v1, v2; ClutterFixed xp, yp; ClutterFixed zang; gint32 xmin, xmax, ymin, ymax; gint i; gint width, height; gint mhandle_width = priv->mhandle_width; gint mhandle_height = priv->mhandle_height; gint rhandle_width = priv->rhandle_width; gint rhandle_height = priv->rhandle_height; if (((ClutterButtonEvent *)event)->click_count == 2) { clutter_dominatrix_restore (dominatrix); break; } clutter_event_get_coords (event, &x, &y); clutter_actor_raise_top (priv->slave); priv->old_opacity = clutter_actor_get_opacity (priv->slave); g_signal_emit (dominatrix, dmx_signals[MANIPULATION_STARTED], 0); priv->prev_x = x; priv->prev_y = y; /* Check that the handle size are sensible in relationship to the * projected size of our slave, otherwise if the user reduces the size * of the slave too much, s/he will not be able to expand it again * -- we practice safe bondage only in this house ;). * * Allow the movement handle to be at most half of the width/height * and the rotation handles to be at most a quarter of width/height. */ clutter_actor_get_vertices (actor, v); xmin = xmax = v[0].x; ymin = ymax = v[0].y; for (i = 1; i < 4; ++i) { if (xmin > v[i].x) xmin = v[i].x; if (xmax < v[i].x) xmax = v[i].x; if (ymin > v[i].y) ymin = v[i].y; if (ymax < v[i].y) ymax = v[i].y; } width = CLUTTER_FIXED_INT (xmax - xmin); height = CLUTTER_FIXED_INT (ymax - ymin); /* FIXME -- make this work when the actor is rotated */ if (width < 2 * mhandle_width) { mhandle_width = width >> 1; g_debug ("Adjusted mhandle width to %d", mhandle_width); } if (height < 2 * mhandle_height) { mhandle_height = height >> 1; g_debug ("Adjusted mhandle height to %d", mhandle_height); } if (width < 4 * rhandle_width) { rhandle_width = width >> 2; g_debug ("Adjusted rhandle width to %d", rhandle_width); }
static void clutter_reflect_texture_paint (ClutterActor *actor) { ClutterReflectTexturePrivate *priv; ClutterReflectTexture *texture; ClutterClone *clone; ClutterTexture *parent; guint width, height; gfloat fwidth, fheight; gint r_height; gint opacity; gint bottom; CoglHandle cogl_texture; CoglTextureVertex tvert[4]; CoglFixed rty; texture = CLUTTER_REFLECT_TEXTURE (actor); clone = CLUTTER_CLONE (actor); parent = (ClutterTexture*) clutter_clone_get_source (clone); if (!parent) return; if (!CLUTTER_ACTOR_IS_REALIZED (parent)) clutter_actor_realize (CLUTTER_ACTOR (parent)); cogl_texture = clutter_texture_get_cogl_texture (parent); if (cogl_texture == COGL_INVALID_HANDLE) return; priv = texture->priv; clutter_actor_get_size (CLUTTER_ACTOR(parent), &fwidth, &fheight); width = fwidth; height = fheight; if (!height) // probably won't happen, but just in case, to avoid divide by zero. return; r_height = priv->reflection_height; bottom = priv->reflect_bottom; opacity = clutter_actor_get_opacity(actor); if (r_height < 0 || r_height > height) r_height = height; #define FX(x) COGL_FIXED_FROM_INT(x) rty = COGL_FIXED_FAST_DIV(FX(bottom ? height-r_height : r_height),FX(height)); /* clockise vertices and tex coords and colors! */ tvert[0].x = tvert[0].y = tvert[0].z = 0; tvert[0].tx = 0; tvert[0].ty = bottom ? COGL_FIXED_1 : rty; tvert[0].color.red = tvert[0].color.green = tvert[0].color.blue = 0xff; tvert[0].color.alpha = bottom ? opacity : 0; tvert[1].x = FX(width); tvert[1].y = tvert[1].z = 0; tvert[1].tx = COGL_FIXED_1; tvert[1].ty = bottom ? COGL_FIXED_1 : rty; tvert[1].color.red = tvert[1].color.green = tvert[1].color.blue = 0xff; tvert[1].color.alpha = bottom ? opacity : 0; tvert[2].x = FX(width); tvert[2].y = FX(r_height); tvert[2].z = 0; tvert[2].tx = COGL_FIXED_1; tvert[2].ty = bottom ? rty : 0; tvert[2].color.red = tvert[2].color.green = tvert[2].color.blue = 0xff; tvert[2].color.alpha = bottom ? 0 : opacity; tvert[3].x = 0; tvert[3].y = FX(r_height); tvert[3].z = 0; tvert[3].tx = 0; tvert[3].ty = bottom ? rty : 0; tvert[3].color.red = tvert[3].color.green = tvert[3].color.blue = 0xff; tvert[3].color.alpha = bottom ? 0 : opacity; cogl_push_matrix (); cogl_set_source_texture(cogl_texture); /* FIXME: this does not work as expected */ /* cogl_polygon(tvert, 4, TRUE); */ cogl_pop_matrix (); }
static void st_icon_update (StIcon *icon) { StIconPrivate *priv = icon->priv; StThemeNode *theme_node; StTextureCache *cache; gint scale; ClutterActor *stage; StThemeContext *context; if (priv->pending_texture) { clutter_actor_destroy (priv->pending_texture); g_object_unref (priv->pending_texture); priv->pending_texture = NULL; priv->opacity_handler_id = 0; } theme_node = st_widget_peek_theme_node (ST_WIDGET (icon)); if (theme_node == NULL) return; stage = clutter_actor_get_stage (CLUTTER_ACTOR (icon)); context = st_theme_context_get_for_stage (CLUTTER_STAGE (stage)); g_object_get (context, "scale-factor", &scale, NULL); cache = st_texture_cache_get_default (); if (priv->gicon != NULL) priv->pending_texture = st_texture_cache_load_gicon (cache, theme_node, priv->gicon, priv->icon_size, scale); if (priv->pending_texture == NULL && priv->fallback_gicon != NULL) priv->pending_texture = st_texture_cache_load_gicon (cache, theme_node, priv->fallback_gicon, priv->icon_size, scale); if (priv->pending_texture) { g_object_ref_sink (priv->pending_texture); if (clutter_actor_get_opacity (priv->pending_texture) != 0 || priv->icon_texture == NULL) { /* This icon is ready for showing, or nothing else is already showing */ st_icon_finish_update (icon); } else { /* Will be shown when fully loaded */ priv->opacity_handler_id = g_signal_connect_object (priv->pending_texture, "notify::opacity", G_CALLBACK (opacity_changed_cb), icon, 0); } } else if (priv->icon_texture) { clutter_actor_destroy (priv->icon_texture); priv->icon_texture = NULL; } }