mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 10:50:10 +00:00
rgba: Add GDK_RGBA() macro
So far it's private, but it's a pretty cute way to use hex colors, so we might conside making it public.
This commit is contained in:
parent
a1d08b4b52
commit
678aa8088f
@ -24,6 +24,17 @@
|
||||
|
||||
#include "gtk/css/gtkcssparserprivate.h"
|
||||
|
||||
#define _GDK_RGBA_DECODE(c) ((unsigned)(((c) >= 'A' && (c) <= 'F') ? ((c)-'A'+10) : \
|
||||
((c) >= 'a' && (c) <= 'f') ? ((c)-'a'+10) : \
|
||||
((c) >= '0' && (c) <= '9') ? ((c)-'0') : \
|
||||
-1))
|
||||
#define _GDK_RGBA_SELECT_COLOR(_str, index3, index6) _GDK_RGBA_DECODE (sizeof(_str) <= 4 ? (_str)[index3] : (_str)[index6])
|
||||
#define GDK_RGBA(str) ((GdkRGBA) {\
|
||||
((_GDK_RGBA_SELECT_COLOR(str, 0, 0) << 4) | _GDK_RGBA_SELECT_COLOR(str, 0, 1)) / 255., \
|
||||
((_GDK_RGBA_SELECT_COLOR(str, 1, 2) << 4) | _GDK_RGBA_SELECT_COLOR(str, 1, 3)) / 255., \
|
||||
((_GDK_RGBA_SELECT_COLOR(str, 2, 4) << 4) | _GDK_RGBA_SELECT_COLOR(str, 2, 5)) / 255., \
|
||||
((sizeof(str) % 4 == 1) ? ((_GDK_RGBA_SELECT_COLOR(str, 3, 6) << 4) | _GDK_RGBA_SELECT_COLOR(str, 3, 7)) : 0xFF) / 255 })
|
||||
|
||||
|
||||
gboolean gdk_rgba_parser_parse (GtkCssParser *parser,
|
||||
GdkRGBA *rgba);
|
||||
|
@ -688,7 +688,7 @@ static GskRenderNode *
|
||||
parse_color_node (GtkCssParser *parser)
|
||||
{
|
||||
graphene_rect_t bounds = GRAPHENE_RECT_INIT (0, 0, 0, 0);
|
||||
GdkRGBA color = { 0, 0, 0, 1 };
|
||||
GdkRGBA color = GDK_RGBA("FF0000");
|
||||
const Declaration declarations[] = {
|
||||
{ "bounds", parse_rect, NULL, &bounds },
|
||||
{ "color", parse_color, NULL, &color },
|
||||
@ -732,7 +732,7 @@ static GskRenderNode *
|
||||
parse_inset_shadow_node (GtkCssParser *parser)
|
||||
{
|
||||
GskRoundedRect outline = GSK_ROUNDED_RECT_INIT (0, 0, 0, 0);
|
||||
GdkRGBA color = { 0, 0, 0, 1 };
|
||||
GdkRGBA color = GDK_RGBA("000000");
|
||||
double dx = 1, dy = 1, blur = 0, spread = 0;
|
||||
const Declaration declarations[] = {
|
||||
{ "outline", parse_rounded_rect, NULL, &outline },
|
||||
@ -753,7 +753,7 @@ parse_border_node (GtkCssParser *parser)
|
||||
{
|
||||
GskRoundedRect outline = GSK_ROUNDED_RECT_INIT (0, 0, 0, 0);
|
||||
float widths[4] = { 1, 1, 1, 1 };
|
||||
GdkRGBA colors[4] = { { 0, 0, 0, 1 }, {0, 0, 0, 1 }, {0, 0, 0, 1 }, { 0, 0, 0, 1 } };
|
||||
GdkRGBA colors[4] = { GDK_RGBA("000"), GDK_RGBA("000"), GDK_RGBA("000"), GDK_RGBA("000") };
|
||||
const Declaration declarations[] = {
|
||||
{ "outline", parse_rounded_rect, NULL, &outline },
|
||||
{ "widths", parse_float4, NULL, &widths },
|
||||
@ -794,7 +794,7 @@ static GskRenderNode *
|
||||
parse_outset_shadow_node (GtkCssParser *parser)
|
||||
{
|
||||
GskRoundedRect outline = GSK_ROUNDED_RECT_INIT (0, 0, 0, 0);
|
||||
GdkRGBA color = { 0, 0, 0, 1 };
|
||||
GdkRGBA color = GDK_RGBA("000000");
|
||||
double dx = 1, dy = 1, blur = 0, spread = 0;
|
||||
const Declaration declarations[] = {
|
||||
{ "outline", parse_rounded_rect, NULL, &outline },
|
||||
@ -1005,7 +1005,7 @@ parse_text_node (GtkCssParser *parser)
|
||||
{
|
||||
PangoFont *font = NULL;
|
||||
graphene_point_t offset = GRAPHENE_POINT_INIT (0, 0);
|
||||
GdkRGBA color = { 0, 0, 0, 1 };
|
||||
GdkRGBA color = GDK_RGBA("000000");
|
||||
PangoGlyphString *glyphs = NULL;
|
||||
const Declaration declarations[] = {
|
||||
{ "font", parse_font, clear_font, &font },
|
||||
|
Loading…
Reference in New Issue
Block a user