2007-01-04 Matthew Allum <mallum@openedhand.com>

* clutter/clutter-actor.c:
        * clutter/clutter-actor.h:
        Add new set_width/height API calls.
        Tweak scaling by reseting matrix.
        Make set_opactiy() take parent opacity into account.
        Fix clipping.

        * clutter/clutter-alpha.c:
        Add more sine functionality.

        * clutter/clutter-behaviour-opacity.c:
        Dont make a copy of all applied actors but use a foreach()

        * clutter/clutter-behaviour-scale.c:
        Give correct limits to propertys.
        Tweak gravity a little more.
        Update docs.
:
        * clutter/clutter-behaviour.c: (clutter_behaviour_remove):
        Minor warning text change.

        * clutter/clutter-feature.c: (clutter_feature_wait_for_vblank):
        Minor dri ioctl tweak.

        * clutter/clutter-label.c:
        * clutter/clutter-label.h:
        Add new label_full api call.
This commit is contained in:
Matthew Allum 2007-01-04 19:56:01 +00:00
parent 0275345271
commit 83700e97c7
11 changed files with 187 additions and 45 deletions

View File

@ -1,3 +1,33 @@
2007-01-04 Matthew Allum <mallum@openedhand.com>
* clutter/clutter-actor.c:
* clutter/clutter-actor.h:
Add new set_width/height API calls.
Tweak scaling by reseting matrix.
Make set_opactiy() take parent opacity into account.
Fix clipping.
* clutter/clutter-alpha.c:
Add more sine functionality.
* clutter/clutter-behaviour-opacity.c:
Dont make a copy of all applied actors but use a foreach()
* clutter/clutter-behaviour-scale.c:
Give correct limits to propertys.
Tweak gravity a little more.
Update docs.
:
* clutter/clutter-behaviour.c: (clutter_behaviour_remove):
Minor warning text change.
* clutter/clutter-feature.c: (clutter_feature_wait_for_vblank):
Minor dri ioctl tweak.
* clutter/clutter-label.c:
* clutter/clutter-label.h:
Add new label_full api call.
2006-12-27 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/clutter-stage.[ch]:

View File

@ -361,18 +361,20 @@ clutter_actor_paint (ClutterActor *self)
{
ClutterGeometry *clip = &(self->priv->clip);
glClearStencil (0.0f);
glEnable (GL_STENCIL_TEST);
glClearStencil (0.0f);
glClear(GL_STENCIL_BUFFER_BIT);
glStencilFunc (GL_NEVER, 0x1, 0x1);
glStencilOp (GL_INCR, GL_INCR, GL_INCR);
glColor3f(1.0f, 1.0f, 1.0f);
/* render clip geomerty */
glRecti (self->priv->coords.x1 + clip->x,
self->priv->coords.y1 + clip->y,
self->priv->coords.x1 + clip->x + clip->width,
self->priv->coords.y1 + clip->y + clip->height);
glRecti (clip->x,
clip->y,
clip->x + clip->width,
clip->y + clip->height);
glStencilFunc (GL_EQUAL, 0x1, 0x1);
glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP);
@ -386,6 +388,11 @@ clutter_actor_paint (ClutterActor *self)
glDisable (GL_STENCIL_TEST);
}
if (self->priv->scale_x != CFX_ONE || self->priv->scale_y != CFX_ONE)
{
glScaled (1.0, 1.0, 1.0);
}
glPopMatrix();
}
@ -1225,6 +1232,41 @@ clutter_actor_get_height (ClutterActor *self)
return box.y2 - box.y1;
}
/**
* clutter_actor_set_width
* @self: A #ClutterActor
* @width: Requested new width for actor
*
* Requests a new width for actor
*
* since: 2.0
**/
void
clutter_actor_set_width (ClutterActor *self, guint width)
{
clutter_actor_set_size (self,
width,
clutter_actor_get_height (self));
}
/**
* clutter_actor_set_height
* @self: A #ClutterActor
* @height: Requested new height for actor
*
* Requests a new height for actor
*
* since: 2.0
**/
void
clutter_actor_set_height (ClutterActor *self, guint height)
{
clutter_actor_set_size (self,
clutter_actor_get_width (self),
height);
}
/**
* clutter_actor_get_x
* @self: A #ClutterActor
@ -1390,9 +1432,9 @@ clutter_actor_get_opacity (ClutterActor *self)
parent = self->priv->parent_actor;
/* FIXME: need to factor in the actual actors opacity with parents */
/* Factor in the actual actors opacity with parents */
if (parent && clutter_actor_get_opacity (parent) != 0xff)
return clutter_actor_get_opacity(parent);
return (clutter_actor_get_opacity(parent) * self->priv->opacity) / 0xff;
return self->priv->opacity;
}

View File

@ -172,6 +172,14 @@ void clutter_actor_get_abs_position (ClutterActor *sel
gint *y);
guint clutter_actor_get_width (ClutterActor *self);
guint clutter_actor_get_height (ClutterActor *self);
void clutter_actor_set_width (ClutterActor *self,
guint width);
void clutter_actor_set_height (ClutterActor *self,
guint height);
gint clutter_actor_get_x (ClutterActor *self);
gint clutter_actor_get_y (ClutterActor *self);
void clutter_actor_rotate_x (ClutterActor *self,

View File

@ -491,6 +491,30 @@ clutter_ramp_func (ClutterAlpha *alpha,
}
}
static guint32
sinc_func (ClutterAlpha *alpha,
float angle,
float offset)
{
ClutterTimeline *timeline;
gint current_frame_num, n_frames;
gdouble x, sine;
timeline = clutter_alpha_get_timeline (alpha);
current_frame_num = clutter_timeline_get_current_frame (timeline);
n_frames = clutter_timeline_get_n_frames (timeline);
/* FIXME: fixed point, and fixed point sine() */
x = (gdouble) (current_frame_num * angle * M_PI) / n_frames ;
sine = (sin (x - (M_PI / angle)) + offset) * 0.5f;
CLUTTER_NOTE (ALPHA, "sine: %2f\n", sine);
return (guint32) (sine * (gdouble) CLUTTER_ALPHA_MAX_ALPHA);
}
/**
* clutter_sine_func:
* @alpha: a #ClutterAlpha
@ -507,21 +531,24 @@ guint32
clutter_sine_func (ClutterAlpha *alpha,
gpointer dummy)
{
ClutterTimeline *timeline;
gint current_frame_num, n_frames;
gdouble x, sine;
timeline = clutter_alpha_get_timeline (alpha);
current_frame_num = clutter_timeline_get_current_frame (timeline);
n_frames = clutter_timeline_get_n_frames (timeline);
/* FIXME: fixed point, and fixed point sine() */
x = (gdouble) (current_frame_num * 2.0f * M_PI) / n_frames ;
sine = (sin (x - (M_PI / 2.0f)) + 1.0f) * 0.5f;
CLUTTER_NOTE (ALPHA, "sine: %2f\n", sine);
return (guint32) (sine * (gdouble) CLUTTER_ALPHA_MAX_ALPHA);
return sinc_func (alpha, 2.0, 1.0);
}
/**
* clutter_sine_inc_func:
* @alpha: a #ClutterAlpha
* @dummy: unused argument
*
* Convenience alpha function for a sine wave. You can use this
* function as the alpha function for clutter_alpha_set_func().
*
* Return value: an alpha value.
*
* Since: 0.2
*/
guint32
clutter_sine_inc_func (ClutterAlpha *alpha,
gpointer dummy)
{
return sinc_func (alpha, 0.5, 1.0);
}

View File

@ -78,20 +78,23 @@ enum
PROP_OPACITY_END
};
static void
alpha_notify_foreach (ClutterBehaviour *behaviour,
ClutterActor *actor,
gpointer data)
{
clutter_actor_set_opacity (actor, GPOINTER_TO_INT(data));
}
static void
clutter_behaviour_alpha_notify (ClutterBehaviour *behave,
guint32 alpha_value)
{
GSList *actors, *l;
guint8 opacity;
ClutterBehaviourOpacityPrivate *priv;
priv = CLUTTER_BEHAVIOUR_OPACITY (behave)->priv;
actors = clutter_behaviour_get_actors (behave);
if (!actors)
return;
opacity = alpha_value
* (priv->opacity_end - priv->opacity_start)
/ CLUTTER_ALPHA_MAX_ALPHA;
@ -100,14 +103,9 @@ clutter_behaviour_alpha_notify (ClutterBehaviour *behave,
alpha_value,
opacity);
for (l = actors; l; l = l->next)
{
ClutterActor *actor = l->data;
clutter_actor_set_opacity (actor, opacity);
}
g_slist_free (actors);
clutter_behaviour_actors_foreach (behave,
alpha_notify_foreach,
GINT_TO_POINTER((gint)opacity));
}
static void

View File

@ -118,7 +118,10 @@ scale_frame_foreach (ClutterBehaviour *behaviour,
break;
case CLUTTER_GRAVITY_CENTER:
CLUTTER_NOTE (MISC, "gravity %i vs %i\n", sw, w);
clutter_actor_move_by (actor, sw - w, sh - h);
/*
* FIXME: This is actually broken for anything other than 0,0
*/
clutter_actor_set_position (actor, (w - sw)/2, (h - sh)/2);
default:
break;
}
@ -223,7 +226,7 @@ clutter_behaviour_scale_class_init (ClutterBehaviourScaleClass *klass)
g_param_spec_double ("scale-begin",
"Scale Begin",
"Initial scale",
1.0, G_MAXDOUBLE,
0.0, G_MAXDOUBLE,
1.0,
CLUTTER_PARAM_READWRITE));
/**
@ -238,7 +241,7 @@ clutter_behaviour_scale_class_init (ClutterBehaviourScaleClass *klass)
g_param_spec_double ("scale-end",
"Scale End",
"Final scale",
1.0, G_MAXDOUBLE,
0.0, G_MAXDOUBLE,
1.0,
CLUTTER_PARAM_READWRITE));
/**
@ -276,7 +279,7 @@ clutter_behaviour_scale_init (ClutterBehaviourScale *self)
* @alpha: a #ClutterAlpha
* @scale_begin: initial scale factor
* @scale_end: final scale factor
* @gravity: FIXME
* @gravity: FIXME: Not currently implemented
*
* Creates a new #ClutterBehaviourScale instance.
*
@ -301,7 +304,7 @@ clutter_behaviour_scale_new (ClutterAlpha *alpha,
* @alpha: a #ClutterAlpha
* @scale_begin: initial scale factor
* @scale_end: final scale factor
* @gravity: FIXME
* @gravity: FIXME: Not currently implemented
*
* A fixed point implementation of clutter_behaviour_scale_new()
*

View File

@ -233,7 +233,7 @@ clutter_behaviour_remove (ClutterBehaviour *behave,
if (!g_slist_find (behave->priv->actors, actor))
{
g_warning ("The behaviour of type %s does not apply "
g_warning ("The behaviour of type %s is not applied "
"to the actor of type %s",
g_type_name (G_OBJECT_TYPE (behave)),
g_type_name (G_OBJECT_TYPE (actor)));
@ -378,7 +378,9 @@ clutter_behaviour_set_alpha (ClutterBehaviour *behave,
* clutter_behaviour_get_actors:
* @behave: a #ClutterBehaviour
*
* Retrieves all the actors to which @behave applies.
* Retrieves all the actors to which @behave applies. It is not recommended
* derived classes use this in there alpha notify method but use
* #clutter_behaviour_actors_foreach as it avoids alot of needless allocations.
*
* Return value: a list of actors. You should free the returned list
* with g_slist_free() when finished using it.

View File

@ -381,6 +381,7 @@ clutter_feature_wait_for_vblank (void)
drm_wait_vblank_t blank;
blank.request.type = DRM_VBLANK_RELATIVE;
blank.request.sequence = 1;
blank.request.signal = 0;
drm_wait_vblank (__features->dri_fd, &blank);
}
break;

View File

@ -484,6 +484,31 @@ clutter_label_new_with_text (const gchar *font_name,
return label;
}
/**
* clutter_label_new_full:
* @font_name: the name (and size) of the font to be used
* @text: the text to be displayed
* @color: #ClutterColor for text
*
* Creates a new #ClutterLabel displaying @text with color @color
* using @font_name.
*
* Return value: a #ClutterLabel
*/
ClutterActor*
clutter_label_new_full (const gchar *font_name,
const gchar *text,
ClutterColor *color)
{
/* FIXME: really new_with_text should take color argument... */
ClutterActor *label;
label = clutter_label_new_with_text (font_name, text);
clutter_label_set_color (CLUTTER_LABEL(label), color);
return label;
}
/**
* clutter_label_new:
*

View File

@ -81,6 +81,11 @@ struct _ClutterLabelClass
GType clutter_label_get_type (void) G_GNUC_CONST;
ClutterActor * clutter_label_new (void);
ClutterActor* clutter_label_new_full (const gchar *font_name,
const gchar *text,
ClutterColor *color);
ClutterActor * clutter_label_new_with_text (const gchar *font_name,
const gchar *text);
void clutter_label_set_text (ClutterLabel *label,

View File

@ -307,6 +307,7 @@ clutter_redraw (void)
((float) stage_color.blue / 0xff * 1.0),
0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
glDisable(GL_LIGHTING);
glDisable(GL_DEPTH_TEST);