mirror of
https://github.com/brl/mutter.git
synced 2025-08-09 01:44:41 +00:00
boxes: Add helper to scale rectangles by a double
And change the similar region scaling helper to use this one. https://gitlab.gnome.org/GNOME/mutter/merge_requests/362
This commit is contained in:

committed by
Georges Basile Stavracas Neto

parent
e1370ee209
commit
36b46af92f
@@ -39,6 +39,12 @@ typedef enum
|
||||
FIXED_DIRECTION_Y = 1 << 1,
|
||||
} FixedDirections;
|
||||
|
||||
typedef enum _MetaRoundingStrategy
|
||||
{
|
||||
META_ROUNDING_STRATEGY_SHRINK,
|
||||
META_ROUNDING_STRATEGY_GROW,
|
||||
} MetaRoundingStrategy;
|
||||
|
||||
/* Output functions -- note that the output buffer had better be big enough:
|
||||
* rect_to_string: RECT_LENGTH
|
||||
* region_to_string: (RECT_LENGTH+strlen(separator_string)) *
|
||||
@@ -219,6 +225,11 @@ GList* meta_rectangle_find_nonintersected_monitor_edges (
|
||||
gboolean meta_rectangle_is_adjecent_to (MetaRectangle *rect,
|
||||
MetaRectangle *other);
|
||||
|
||||
void meta_rectangle_scale_double (const MetaRectangle *rect,
|
||||
double scale,
|
||||
MetaRoundingStrategy rounding_strategy,
|
||||
MetaRectangle *dest);
|
||||
|
||||
static inline ClutterRect
|
||||
meta_rectangle_to_clutter_rect (MetaRectangle *rect)
|
||||
{
|
||||
|
@@ -2044,3 +2044,30 @@ meta_rectangle_is_adjecent_to (MetaRectangle *rect,
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
meta_rectangle_scale_double (const MetaRectangle *rect,
|
||||
double scale,
|
||||
MetaRoundingStrategy rounding_strategy,
|
||||
MetaRectangle *dest)
|
||||
{
|
||||
switch (rounding_strategy)
|
||||
{
|
||||
case META_ROUNDING_STRATEGY_SHRINK:
|
||||
*dest = (MetaRectangle) {
|
||||
.x = (int) ceil (rect->x * scale),
|
||||
.y = (int) ceil (rect->y * scale),
|
||||
.width = (int) floor (rect->width * scale),
|
||||
.height = (int) floor (rect->height * scale),
|
||||
};
|
||||
break;
|
||||
case META_ROUNDING_STRATEGY_GROW:
|
||||
*dest = (MetaRectangle) {
|
||||
.x = (int) floor (rect->x * scale),
|
||||
.y = (int) floor (rect->y * scale),
|
||||
.width = (int) ceil (rect->width * scale),
|
||||
.height = (int) ceil (rect->height * scale),
|
||||
};
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user