Convert border_width, border_radius to integers

This saves the consumers from having to deal with rounding.

https://bugzilla.gnome.org/show_bug.cgi?id=607500
This commit is contained in:
Colin Walters 2010-02-10 21:10:49 -05:00
parent 732ba8576d
commit 3333f30c42
2 changed files with 34 additions and 26 deletions

View File

@ -28,8 +28,8 @@ struct _StThemeNode {
ClutterColor foreground_color; ClutterColor foreground_color;
ClutterColor border_color[4]; ClutterColor border_color[4];
double border_width[4]; int border_width[4];
double border_radius[4]; int border_radius[4];
guint padding[4]; guint padding[4];
int width; int width;
@ -720,6 +720,21 @@ get_length_from_term (StThemeNode *node,
return VALUE_FOUND; return VALUE_FOUND;
} }
static GetFromTermResult
get_length_from_term_int (StThemeNode *node,
CRTerm *term,
gboolean use_parent_font,
gint *length)
{
double value;
GetFromTermResult result;
result = get_length_from_term (node, term, use_parent_font, &value);
if (result != VALUE_NOT_FOUND)
*length = (int) (0.5 + value);
return result;
}
static GetFromTermResult static GetFromTermResult
get_length_internal (StThemeNode *node, get_length_internal (StThemeNode *node,
const char *property_name, const char *property_name,
@ -795,9 +810,9 @@ do_border_radius_term (StThemeNode *node,
gboolean bottomright, gboolean bottomright,
gboolean bottomleft) gboolean bottomleft)
{ {
gdouble value; int value;
if (get_length_from_term (node, term, FALSE, &value) != VALUE_FOUND) if (get_length_from_term_int (node, term, FALSE, &value) != VALUE_FOUND)
return; return;
if (topleft) if (topleft)
@ -877,7 +892,7 @@ do_border_property (StThemeNode *node,
StSide side = (StSide)-1; StSide side = (StSide)-1;
ClutterColor color; ClutterColor color;
gboolean color_set = FALSE; gboolean color_set = FALSE;
double width; int width;
gboolean width_set = FALSE; gboolean width_set = FALSE;
int j; int j;
@ -948,7 +963,7 @@ do_border_property (StThemeNode *node,
if (term->type == TERM_NUMBER) if (term->type == TERM_NUMBER)
{ {
result = get_length_from_term (node, term, FALSE, &width); result = get_length_from_term_int (node, term, FALSE, &width);
if (result != VALUE_NOT_FOUND) if (result != VALUE_NOT_FOUND)
{ {
width_set = result == VALUE_FOUND; width_set = result == VALUE_FOUND;
@ -979,7 +994,7 @@ do_border_property (StThemeNode *node,
if (decl->value == NULL || decl->value->next != NULL) if (decl->value == NULL || decl->value->next != NULL)
return; return;
if (get_length_from_term (node, decl->value, FALSE, &width) == VALUE_FOUND) if (get_length_from_term_int (node, decl->value, FALSE, &width) == VALUE_FOUND)
/* Ignore inherit */ /* Ignore inherit */
width_set = TRUE; width_set = TRUE;
} }
@ -1011,23 +1026,19 @@ do_padding_property_term (StThemeNode *node,
gboolean top, gboolean top,
gboolean bottom) gboolean bottom)
{ {
gdouble value; int value;
int int_value;
if (get_length_from_term (node, term, FALSE, &value) != VALUE_FOUND) if (get_length_from_term_int (node, term, FALSE, &value) != VALUE_FOUND)
return; return;
/* Round the value */
int_value = (int) (0.5 + value);
if (left) if (left)
node->padding[ST_SIDE_LEFT] = int_value; node->padding[ST_SIDE_LEFT] = value;
if (right) if (right)
node->padding[ST_SIDE_RIGHT] = int_value; node->padding[ST_SIDE_RIGHT] = value;
if (top) if (top)
node->padding[ST_SIDE_TOP] = int_value; node->padding[ST_SIDE_TOP] = value;
if (bottom) if (bottom)
node->padding[ST_SIDE_BOTTOM] = int_value; node->padding[ST_SIDE_BOTTOM] = value;
} }
static void static void
@ -1094,10 +1105,7 @@ do_size_property (StThemeNode *node,
CRDeclaration *decl, CRDeclaration *decl,
int *node_value) int *node_value)
{ {
gdouble value; get_length_from_term_int (node, decl->value, FALSE, node_value);
if (get_length_from_term (node, decl->value, FALSE, &value) == VALUE_FOUND)
*node_value = (int) (0.5 + value);
} }
static void static void
@ -1177,7 +1185,7 @@ ensure_geometry (StThemeNode *node)
node->height = node->min_height; node->height = node->min_height;
} }
double int
st_theme_node_get_border_width (StThemeNode *node, st_theme_node_get_border_width (StThemeNode *node,
StSide side) StSide side)
{ {
@ -1189,7 +1197,7 @@ st_theme_node_get_border_width (StThemeNode *node,
return node->border_width[side]; return node->border_width[side];
} }
double int
st_theme_node_get_border_radius (StThemeNode *node, st_theme_node_get_border_radius (StThemeNode *node,
StCorner corner) StCorner corner)
{ {

View File

@ -118,9 +118,9 @@ void st_theme_node_get_background_gradient (StThemeNode *node,
const char *st_theme_node_get_background_image (StThemeNode *node); const char *st_theme_node_get_background_image (StThemeNode *node);
double st_theme_node_get_border_width (StThemeNode *node, int st_theme_node_get_border_width (StThemeNode *node,
StSide side); StSide side);
double st_theme_node_get_border_radius (StThemeNode *node, int st_theme_node_get_border_radius (StThemeNode *node,
StCorner corner); StCorner corner);
void st_theme_node_get_border_color (StThemeNode *node, void st_theme_node_get_border_color (StThemeNode *node,
StSide side, StSide side,