summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2012-01-15 17:51:58 +0100
committerBenjamin Otte <otte@redhat.com>2012-02-02 03:14:00 +0100
commit0c140daff284c19c8ad01cf011974c33f48e767b (patch)
tree90c4b953af2355c2878764e9a5af9ab7691a65d5
parenta63ff724060c0a9ff9299d294e17b59aab46f81f (diff)
downloadgtk+-0c140daff284c19c8ad01cf011974c33f48e767b.tar.gz
css: Implement support for angles
-rw-r--r--gtk/gtkcssparser.c20
-rw-r--r--gtk/gtkcssparserprivate.h3
-rw-r--r--gtk/gtkcsstypes.c19
-rw-r--r--gtk/gtkcsstypesprivate.h7
4 files changed, 38 insertions, 11 deletions
diff --git a/gtk/gtkcssparser.c b/gtk/gtkcssparser.c
index 6c362533dd..67637dedb2 100644
--- a/gtk/gtkcssparser.c
+++ b/gtk/gtkcssparser.c
@@ -546,14 +546,18 @@ _gtk_css_parser_read_number (GtkCssParser *parser,
GtkCssUnit unit;
GtkCssNumberParseFlags required_flags;
} units[] = {
- { "px", GTK_CSS_PX, GTK_CSS_PARSE_LENGTH },
- { "pt", GTK_CSS_PT, GTK_CSS_PARSE_LENGTH },
- { "em", GTK_CSS_EM, GTK_CSS_PARSE_LENGTH },
- { "ex", GTK_CSS_EX, GTK_CSS_PARSE_LENGTH },
- { "pc", GTK_CSS_PC, GTK_CSS_PARSE_LENGTH },
- { "in", GTK_CSS_IN, GTK_CSS_PARSE_LENGTH },
- { "cm", GTK_CSS_CM, GTK_CSS_PARSE_LENGTH },
- { "mm", GTK_CSS_MM, GTK_CSS_PARSE_LENGTH }
+ { "px", GTK_CSS_PX, GTK_CSS_PARSE_LENGTH },
+ { "pt", GTK_CSS_PT, GTK_CSS_PARSE_LENGTH },
+ { "em", GTK_CSS_EM, GTK_CSS_PARSE_LENGTH },
+ { "ex", GTK_CSS_EX, GTK_CSS_PARSE_LENGTH },
+ { "pc", GTK_CSS_PC, GTK_CSS_PARSE_LENGTH },
+ { "in", GTK_CSS_IN, GTK_CSS_PARSE_LENGTH },
+ { "cm", GTK_CSS_CM, GTK_CSS_PARSE_LENGTH },
+ { "mm", GTK_CSS_MM, GTK_CSS_PARSE_LENGTH },
+ { "rad", GTK_CSS_RAD, GTK_CSS_PARSE_ANGLE },
+ { "deg", GTK_CSS_DEG, GTK_CSS_PARSE_ANGLE },
+ { "grad", GTK_CSS_GRAD, GTK_CSS_PARSE_ANGLE },
+ { "turn", GTK_CSS_TURN, GTK_CSS_PARSE_ANGLE }
};
char *end, *unit;
diff --git a/gtk/gtkcssparserprivate.h b/gtk/gtkcssparserprivate.h
index e5661d54ca..39002a94a1 100644
--- a/gtk/gtkcssparserprivate.h
+++ b/gtk/gtkcssparserprivate.h
@@ -30,7 +30,8 @@ typedef enum /*< skip >*/ {
GTK_CSS_PARSE_PERCENT = (1 << 1),
GTK_CSS_PARSE_NUMBER = (1 << 2),
GTK_CSS_NUMBER_AS_PIXELS = (1 << 3),
- GTK_CSS_PARSE_LENGTH = (1 << 4)
+ GTK_CSS_PARSE_LENGTH = (1 << 4),
+ GTK_CSS_PARSE_ANGLE = (1 << 5)
} GtkCssNumberParseFlags;
typedef struct _GtkCssParser GtkCssParser;
diff --git a/gtk/gtkcsstypes.c b/gtk/gtkcsstypes.c
index 2cb883354e..d714095e14 100644
--- a/gtk/gtkcsstypes.c
+++ b/gtk/gtkcsstypes.c
@@ -76,6 +76,7 @@ _gtk_css_number_compute (GtkCssNumber *dest,
case GTK_CSS_PERCENT:
case GTK_CSS_NUMBER:
case GTK_CSS_PX:
+ case GTK_CSS_DEG:
dest->value = src->value;
dest->unit = src->unit;
break;
@@ -108,6 +109,18 @@ _gtk_css_number_compute (GtkCssNumber *dest,
dest->value = src->value * g_value_get_double (_gtk_style_context_peek_property (context, "font-size"));
dest->unit = GTK_CSS_PX;
break;
+ case GTK_CSS_RAD:
+ dest->value = 360 * src->value / (2 * G_PI);
+ dest->unit = GTK_CSS_DEG;
+ break;
+ case GTK_CSS_GRAD:
+ dest->value = 360 * src->value / 400.0;
+ dest->unit = GTK_CSS_DEG;
+ break;
+ case GTK_CSS_TURN:
+ dest->value = 360 * src->value;
+ dest->unit = GTK_CSS_DEG;
+ break;
}
}
@@ -130,7 +143,11 @@ _gtk_css_number_print (const GtkCssNumber *number,
/* [GTK_CSS_PC] = */ "pc",
/* [GTK_CSS_IN] = */ "in",
/* [GTK_CSS_CM] = */ "cm",
- /* [GTK_CSS_MM] = */ "mm"
+ /* [GTK_CSS_MM] = */ "mm",
+ /* [GTK_CSS_RAD] = */ "rad",
+ /* [GTK_CSS_DEG] = */ "deg",
+ /* [GTK_CSS_GRAD] = */ "grad",
+ /* [GTK_CSS_TURN] = */ "turn",
};
g_ascii_dtostr (buf, sizeof (buf), number->value);
diff --git a/gtk/gtkcsstypesprivate.h b/gtk/gtkcsstypesprivate.h
index 493978f1b8..94f0d3c230 100644
--- a/gtk/gtkcsstypesprivate.h
+++ b/gtk/gtkcsstypesprivate.h
@@ -91,7 +91,12 @@ typedef enum /*< skip >*/ {
GTK_CSS_PC,
GTK_CSS_IN,
GTK_CSS_CM,
- GTK_CSS_MM
+ GTK_CSS_MM,
+ /* CSS term: <angle> */
+ GTK_CSS_RAD,
+ GTK_CSS_DEG,
+ GTK_CSS_GRAD,
+ GTK_CSS_TURN
} GtkCssUnit;
typedef struct _GtkCssNumber GtkCssNumber;