[StThemeNode] Add helper method to get the paint allocation
StThemeNodes may have properties - namely shadows - which paint outside an actor's allocation. This is not a problem unless drawing is redirected to an offscreen buffer, in which case the actually painted size is needed in advance when setting up the buffer. Add a convenience method to calculate an allocation large enough to paint the node. https://bugzilla.gnome.org/show_bug.cgi?id=619025
This commit is contained in:
parent
24a4ca0c6d
commit
af3ca027a1
@ -77,6 +77,35 @@ st_shadow_free (StShadow *shadow)
|
||||
g_slice_free (StShadow, shadow);
|
||||
}
|
||||
|
||||
/**
|
||||
* st_shadow_get_box:
|
||||
* @shadow: a #StShadow
|
||||
* @actor_box: the box allocated to a #ClutterAlctor
|
||||
* @shadow_box: computed box occupied by @shadow
|
||||
*
|
||||
* Gets the box used to paint @shadow, which will be partly
|
||||
* outside of @actor_box
|
||||
*/
|
||||
void
|
||||
st_shadow_get_box (StShadow *shadow,
|
||||
const ClutterActorBox *actor_box,
|
||||
ClutterActorBox *shadow_box)
|
||||
{
|
||||
g_return_if_fail (shadow != NULL);
|
||||
g_return_if_fail (actor_box != NULL);
|
||||
g_return_if_fail (shadow_box != NULL);
|
||||
|
||||
shadow_box->x1 = actor_box->x1 + shadow->xoffset
|
||||
- shadow->blur - shadow->spread;
|
||||
shadow_box->x2 = actor_box->x2 + shadow->xoffset
|
||||
+ shadow->blur + shadow->spread;
|
||||
shadow_box->y1 = actor_box->y1 + shadow->yoffset
|
||||
- shadow->blur - shadow->spread;
|
||||
shadow_box->y2 = actor_box->y2 + shadow->yoffset
|
||||
+ shadow->blur + shadow->spread;
|
||||
}
|
||||
|
||||
|
||||
GType
|
||||
st_shadow_get_type (void)
|
||||
{
|
||||
|
@ -41,6 +41,10 @@ StShadow *st_shadow_new (ClutterColor *color,
|
||||
StShadow *st_shadow_copy (const StShadow *shadow);
|
||||
void st_shadow_free (StShadow *shadow);
|
||||
|
||||
void st_shadow_get_box (StShadow *shadow,
|
||||
const ClutterActorBox *actor_box,
|
||||
ClutterActorBox *shadow_box);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __ST_SHADOW__ */
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "st-shadow.h"
|
||||
#include "st-theme-private.h"
|
||||
#include "st-theme-context.h"
|
||||
#include "st-texture-cache.h"
|
||||
@ -822,14 +823,7 @@ paint_shadow_with_opacity (CoglHandle shadow_material,
|
||||
ClutterActorBox shadow_box;
|
||||
CoglColor color;
|
||||
|
||||
shadow_box.x1 = box->x1 + shadow_spec->xoffset
|
||||
- shadow_spec->blur - shadow_spec->spread;
|
||||
shadow_box.y1 = box->y1 + shadow_spec->yoffset
|
||||
- shadow_spec->blur - shadow_spec->spread;
|
||||
shadow_box.x2 = box->x2 + shadow_spec->xoffset
|
||||
+ shadow_spec->blur + shadow_spec->spread;
|
||||
shadow_box.y2 = box->y2 + shadow_spec->yoffset
|
||||
+ shadow_spec->blur + shadow_spec->spread;
|
||||
st_shadow_get_box (shadow_spec, box, &shadow_box);
|
||||
|
||||
cogl_color_set_from_4ub (&color,
|
||||
shadow_spec->color.red * paint_opacity / 255,
|
||||
|
@ -2508,6 +2508,44 @@ st_theme_node_get_content_box (StThemeNode *node,
|
||||
content_box->y2 = (int)(0.5 + content_box->y1 + content_height);
|
||||
}
|
||||
|
||||
/**
|
||||
* st_theme_node_get_paint_box:
|
||||
* @node: a #StThemeNode
|
||||
* @allocation: the box allocated to a #ClutterAlctor
|
||||
* @paint_box: computed box occupied when painting the actor
|
||||
*
|
||||
* Gets the box used to paint the actor, including the area occupied by
|
||||
* properties which paint outside the actor's assigned allocation
|
||||
* (currently only st-shadow). When painting @node to an offscreen buffer,
|
||||
* this function can be used to determine the necessary size of the buffer.
|
||||
*/
|
||||
void
|
||||
st_theme_node_get_paint_box (StThemeNode *node,
|
||||
const ClutterActorBox *actor_box,
|
||||
ClutterActorBox *paint_box)
|
||||
{
|
||||
StShadow *shadow;
|
||||
|
||||
g_return_if_fail (ST_IS_THEME_NODE (node));
|
||||
g_return_if_fail (actor_box != NULL);
|
||||
g_return_if_fail (paint_box != NULL);
|
||||
|
||||
shadow = st_theme_node_get_shadow (node);
|
||||
if (shadow)
|
||||
{
|
||||
ClutterActorBox shadow_box;
|
||||
|
||||
st_shadow_get_box (shadow, actor_box, &shadow_box);
|
||||
|
||||
paint_box->x1 = MIN (actor_box->x1, shadow_box.x1);
|
||||
paint_box->x2 = MAX (actor_box->x2, shadow_box.x2);
|
||||
paint_box->y1 = MIN (actor_box->y1, shadow_box.y1);
|
||||
paint_box->y2 = MAX (actor_box->y2, shadow_box.y2);
|
||||
}
|
||||
else
|
||||
*paint_box = *actor_box;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* st_theme_node_geometry_equal:
|
||||
|
@ -169,6 +169,10 @@ void st_theme_node_adjust_preferred_height (StThemeNode *node,
|
||||
void st_theme_node_get_content_box (StThemeNode *node,
|
||||
const ClutterActorBox *actor_box,
|
||||
ClutterActorBox *content_box);
|
||||
/* Helper for StThemeNodeTransition */
|
||||
void st_theme_node_get_paint_box (StThemeNode *node,
|
||||
const ClutterActorBox *actor_box,
|
||||
ClutterActorBox *paint_box);
|
||||
|
||||
gboolean st_theme_node_geometry_equal (StThemeNode *node,
|
||||
StThemeNode *other);
|
||||
|
Loading…
Reference in New Issue
Block a user