1
0
mirror of https://github.com/brl/mutter.git synced 2025-06-12 16:33:58 +00:00
Files
build
clutter
doc
common
cookbook
examples
Makefile.am
actors-composite-main.c
animations-complex-overlapping.json
animations-complex.c
animations-complex.json
animations-looping-animator.c
animations-looping-implicit.c
animations-looping-state.c
animations-moving-animator.c
animations-moving-implicit.c
animations-moving-state.c
animations-path-circle.c
animations-path-easing.c
animations-path.c
animations-reuse-animation.json
animations-reuse-ui.json
animations-reuse.c
animations-rotating.c
animations-scaling-zoom.c
animations-scaling.c
cb-background-effect.c
cb-background-effect.h
cb-border-effect.c
cb-border-effect.h
cb-button.c
cb-button.h
cb-page-fold-effect.c
cb-page-fold-effect.h
effects-basic.c
effects-built-in.c
effects-custom-deform.c
events-buttons-click.c
events-buttons-lasso.c
events-buttons.c
events-mouse-scroll.c
events-pointer-motion-crossing.c
events-pointer-motion-scribbler.c
events-pointer-motion-stacked.c
events-pointer-motion.c
layouts-bind-constraint-allocation.c
layouts-bind-constraint-overlay.c
layouts-bind-constraint-stage.c
layouts-box-menu.c
layouts-box-property-effects.c
layouts-box.c
layouts-stacking-diff-sized-actors.c
layouts-stacking.c
script-signals.c
script-signals.json
script-states.c
script-states.json
script-ui.c
script-ui.json
smiley.png
text-shadow.c
textures-crossfade-cogl.c
textures-crossfade-slideshow.c
textures-crossfade.c
textures-reflection.c
textures-split-go.c
textures-sub-texture.c
images
videos
Makefile.am
actors.xml
animations.xml
clutter-cookbook.xml.in
effects.xml
events.xml
introduction.xml
layouts.xml
recipe-template.xml
script.xml
text.xml
textures.xml
version.xml.in
reference
AUTHORS.old
CODING_STYLE
HACKING
HACKING.backends
Makefile.am
RELEASING
actor-invariants.txt
size-negotiation.txt
po
tests
.gitignore
COPYING
ChangeLog.pre-git-import
Makefile.am
NEWS
README.in
README.md
autogen.sh
clutter.doap
config.h.win32.in
configure.ac
mutter/doc/cookbook/examples/text-shadow.c
Neil Roberts 7d233241f1 Fix include location for cogl-pango.h
In Cogl, cogl-pango.h has moved to <cogl-pango/cogl-pango.h>. When
using the experimental 2.0 API (which Clutter does) it is no longer
possible to include it under the old name of <cogl/cogl-pango.h> so we
need to update the include location.
2011-05-16 16:04:27 +01:00

65 lines
2.0 KiB
C

#include <stdlib.h>
#include <cogl/cogl.h>
#include <cogl-pango/cogl-pango.h>
#include <clutter/clutter.h>
#define SHADOW_X_OFFSET 3
#define SHADOW_Y_OFFSET 3
static void
_text_paint_cb (ClutterActor *actor)
{
PangoLayout *layout;
guint8 real_opacity;
CoglColor color;
ClutterText *text = CLUTTER_TEXT (actor);
ClutterColor text_color = { 0, };
/* Get the PangoLayout that the Text actor is going to paint */
layout = clutter_text_get_layout (text);
/* Get the color of the text, to extract the alpha component */
clutter_text_get_color (text, &text_color);
/* Composite the opacity so that the shadow is correctly blended */
real_opacity = clutter_actor_get_paint_opacity (actor)
* text_color.alpha
/ 255;
/* Create a #ccc color and premultiply it */
cogl_color_init_from_4ub (&color, 0xcc, 0xcc, 0xcc, real_opacity);
cogl_color_premultiply (&color);
/* Finally, render the Text layout at a given offset using the color */
cogl_pango_render_layout (layout, SHADOW_X_OFFSET, SHADOW_Y_OFFSET, &color, 0);
}
int
main (int argc, char *argv[])
{
ClutterActor *stage;
ClutterActor *text;
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
stage = clutter_stage_new ();
clutter_stage_set_title (CLUTTER_STAGE (stage), "Text shadow");
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
text = clutter_text_new ();
clutter_text_set_text (CLUTTER_TEXT (text), "Hello, World!");
clutter_text_set_font_name (CLUTTER_TEXT (text), "Sans 64px");
clutter_actor_add_constraint (text, clutter_align_constraint_new (stage, CLUTTER_ALIGN_X_AXIS, 0.5));
clutter_actor_add_constraint (text, clutter_align_constraint_new (stage, CLUTTER_ALIGN_Y_AXIS, 0.5));
g_signal_connect (text, "paint", G_CALLBACK (_text_paint_cb), NULL);
clutter_container_add (CLUTTER_CONTAINER (stage), text, NULL);
clutter_actor_show (stage);
clutter_main ();
return EXIT_SUCCESS;
}