gtk-css-engine r31 - in bzr-playground: . libccd/ccd
- From: robsta svn gnome org
- To: svn-commits-list gnome org
- Subject: gtk-css-engine r31 - in bzr-playground: . libccd/ccd
- Date: Mon, 18 Aug 2008 13:51:12 +0000 (UTC)
Author: robsta
Date: Mon Aug 18 13:51:12 2008
New Revision: 31
URL: http://svn.gnome.org/viewvc/gtk-css-engine?rev=31&view=rev
Log:
Fall back to using `color' when no border color specified.
Modified:
bzr-playground/ (props changed)
bzr-playground/libccd/ccd/Makefile.am
bzr-playground/libccd/ccd/ccd-block.h
bzr-playground/libccd/ccd/ccd-border.c
bzr-playground/libccd/ccd/ccd-border.h
bzr-playground/libccd/ccd/ccd-color.h
bzr-playground/libccd/ccd/ccd-gtk-style.c
bzr-playground/libccd/ccd/ccd-parser.c
bzr-playground/libccd/ccd/ccd-selector.c
bzr-playground/libccd/ccd/ccd-style.c
bzr-playground/libccd/ccd/ccd-style.h
bzr-playground/libccd/ccd/ccd.h
Modified: bzr-playground/libccd/ccd/Makefile.am
==============================================================================
--- bzr-playground/libccd/ccd/Makefile.am (original)
+++ bzr-playground/libccd/ccd/Makefile.am Mon Aug 18 13:51:12 2008
@@ -9,8 +9,13 @@
libccd_1_la_LDFLAGS = -no-undefined -version-info $(LT_VERSION_INFO)
headersdir = $(includedir)/libccd-1/ccd
headers_DATA = \
+ ccd-background.h \
+ ccd-border.h \
+ ccd-color.h \
+ ccd-function.h \
ccd.h \
ccd-node.h \
+ ccd-property.h \
ccd-selector-group.h \
ccd-style.h \
ccd-stylesheet.h
Modified: bzr-playground/libccd/ccd/ccd-block.h
==============================================================================
--- bzr-playground/libccd/ccd/ccd-block.h (original)
+++ bzr-playground/libccd/ccd/ccd-block.h Mon Aug 18 13:51:12 2008
@@ -23,8 +23,10 @@
#include <glib.h>
#include <cairo.h>
#include <ccd/ccd-features.h>
+#include <ccd/ccd-color.h>
#include <ccd/ccd-background.h>
#include <ccd/ccd-border.h>
+#include <ccd/ccd-property.h>
G_BEGIN_DECLS
@@ -32,6 +34,8 @@
/*< private >*/
ccd_background_t background;
ccd_border_t border;
+ ccd_color_t color;
+ ccd_property_spec_t color_spec;
} ccd_block_t;
ccd_block_t * ccd_block_new (void);
Modified: bzr-playground/libccd/ccd/ccd-border.c
==============================================================================
--- bzr-playground/libccd/ccd/ccd-border.c (original)
+++ bzr-playground/libccd/ccd/ccd-border.c Mon Aug 18 13:51:12 2008
@@ -375,25 +375,25 @@
draw_f draw_func;
double off;
- if (left) {
+ if (left && left->flags) {
draw_func = get_draw_func (left);
off = left->width / 2.;
draw_func (left, cr, x + off, y, x + off, y + height);
}
- if (top) {
+ if (top && top->flags) {
draw_func = get_draw_func (top);
off = top->width / 2.;
draw_func (top, cr, x, y + off, x + width, y + off);
}
- if (right) {
+ if (right && right->flags) {
draw_func = get_draw_func (right);
off = right->width / 2.;
draw_func (right, cr, x + width - off, y, x + width - off, y + height);
}
- if (bottom) {
+ if (bottom && bottom->flags) {
draw_func = get_draw_func (bottom);
off = bottom->width / 2.;
draw_func (bottom, cr, x + width, y + height - off, x, y + height - off);
Modified: bzr-playground/libccd/ccd/ccd-border.h
==============================================================================
--- bzr-playground/libccd/ccd/ccd-border.h (original)
+++ bzr-playground/libccd/ccd/ccd-border.h Mon Aug 18 13:51:12 2008
@@ -60,6 +60,16 @@
CCD_BORDER_FLAGS_COLOR_MASK = CCD_BORDER_FLAGS_COMMON_COLOR | CCD_BORDER_FLAGS_SPECIFIC_COLOR
} ccd_border_flags_t;
+#define CCD_BORDER_STROKE_ASSIGN(lhs_, rhs_) { \
+ lhs_.width = rhs_.width; \
+ lhs_.width_spec = rhs_.width_spec; \
+ lhs_.style = rhs_.style; \
+ lhs_.style_spec = rhs_.style_spec; \
+ lhs_.color = rhs_.color; \
+ lhs_.color_spec = rhs_.color_spec; \
+ lhs_.flags = rhs_.flags; \
+}
+
typedef struct {
double width;
ccd_property_spec_t width_spec;
Modified: bzr-playground/libccd/ccd/ccd-color.h
==============================================================================
--- bzr-playground/libccd/ccd/ccd-color.h (original)
+++ bzr-playground/libccd/ccd/ccd-color.h Mon Aug 18 13:51:12 2008
@@ -28,6 +28,12 @@
G_BEGIN_DECLS
+#define CCD_COLOR_ASSIGN(lhs_, rhs_) { \
+ (lhs_).red = (rhs_).red; \
+ (lhs_).green = (rhs_).green; \
+ (lhs_).blue = (rhs_).blue; \
+}
+
typedef struct {
double red;
double green;
Modified: bzr-playground/libccd/ccd/ccd-gtk-style.c
==============================================================================
--- bzr-playground/libccd/ccd/ccd-gtk-style.c (original)
+++ bzr-playground/libccd/ccd/ccd-gtk-style.c Mon Aug 18 13:51:12 2008
@@ -51,50 +51,50 @@
case GTK_POS_LEFT:
if (gap_start > y || gap_width < height) {
/* Draw gap only if it's not over the whole border. */
- ccd_border_draw (self->left, NULL, NULL, NULL, cr,
- x, y, 0, gap_start);
- ccd_border_draw (self->left, NULL, NULL, NULL, cr,
- x, y + gap_start + gap_width,
+ ccd_border_draw (&self->left, NULL, NULL, NULL,
+ cr, x, y, 0, gap_start);
+ ccd_border_draw (&self->left, NULL, NULL, NULL,
+ cr, x, y + gap_start + gap_width,
0, height - gap_start - gap_width);
}
- ccd_border_draw (NULL, self->top, self->right, self->bottom, cr,
- x, y, width, height);
+ ccd_border_draw (NULL, &self->top, &self->right, &self->bottom,
+ cr, x, y, width, height);
break;
case GTK_POS_TOP:
if (gap_start > x || gap_width < width) {
/* Draw gap only if it's not over the whole border. */
- ccd_border_draw (NULL, self->top, NULL, NULL, cr,
- x, y, gap_start, 0);
- ccd_border_draw (NULL, self->top, NULL, NULL, cr,
- x + gap_start + gap_width, y,
+ ccd_border_draw (NULL, &self->top, NULL, NULL,
+ cr, x, y, gap_start, 0);
+ ccd_border_draw (NULL, &self->top, NULL, NULL,
+ cr, x + gap_start + gap_width, y,
width - gap_start - gap_width, 0);
}
- ccd_border_draw (self->left, NULL, self->right, self->bottom, cr,
- x, y, width, height);
+ ccd_border_draw (&self->left, NULL, &self->right, &self->bottom,
+ cr, x, y, width, height);
break;
case GTK_POS_RIGHT:
if (gap_start > y || gap_width < height) {
/* Draw gap only if it's not over the whole border. */
- ccd_border_draw (self->left, NULL, NULL, NULL, cr,
+ ccd_border_draw (&self->left, NULL, NULL, NULL, cr,
x + width, y, 0, gap_start);
- ccd_border_draw (self->left, NULL, NULL, NULL, cr,
+ ccd_border_draw (&self->left, NULL, NULL, NULL, cr,
x + width, y + gap_start + gap_width,
0, height - gap_start - gap_width);
}
- ccd_border_draw (self->left, self->top, NULL, self->bottom, cr,
- x, y, width, height);
+ ccd_border_draw (&self->left, &self->top, NULL, &self->bottom,
+ cr, x, y, width, height);
break;
case GTK_POS_BOTTOM:
if (gap_start > x || gap_width < width) {
/* Draw gap only if it's not over the whole border. */
- ccd_border_draw (NULL, NULL, NULL, self->bottom, cr,
- x, y + height, gap_start, 0);
- ccd_border_draw (NULL, NULL, NULL, self->bottom, cr,
- x + gap_start + gap_width, y + height,
+ ccd_border_draw (NULL, NULL, NULL, &self->bottom,
+ cr, x, y + height, gap_start, 0);
+ ccd_border_draw (NULL, NULL, NULL, &self->bottom,
+ cr, x + gap_start + gap_width, y + height,
width - gap_start - gap_width, 0);
}
- ccd_border_draw (self->left, self->top, self->right, NULL, cr,
- x, y, width, height);
+ ccd_border_draw (&self->left, &self->top, &self->right, NULL,
+ cr, x, y, width, height);
break;
default:
g_assert_not_reached ();
Modified: bzr-playground/libccd/ccd/ccd-parser.c
==============================================================================
--- bzr-playground/libccd/ccd/ccd-parser.c (original)
+++ bzr-playground/libccd/ccd/ccd-parser.c Mon Aug 18 13:51:12 2008
@@ -21,7 +21,9 @@
#include <string.h>
#include <libcroco/libcroco.h>
#include "ccd-block.h"
+#include "ccd-color.h"
#include "ccd-parser.h"
+#include "ccd-property.h"
#include "ccd-selector.h"
#include "ccd-selector-group-priv.h"
@@ -167,12 +169,15 @@
g_assert (info && info->block);
property = cr_string_peek_raw_str (name);
- if (0 == strcmp ("border", property) ||
- 0 == strncmp ("border-", property, sizeof ("border-") - 1)) {
- ccd_border_parse (&info->block->border, property, values);
- } else if (0 == strcmp ("background", property) ||
- 0 == strncmp ("background-", property, sizeof ("background-") - 1)) {
+ if (0 == strcmp ("background", property) ||
+ 0 == strncmp ("background-", property, sizeof ("background-") - 1)) {
ccd_background_parse (&info->block->background, property, values);
+ } else if (0 == strcmp ("border", property) ||
+ 0 == strncmp ("border-", property, sizeof ("border-") - 1)) {
+ ccd_border_parse (&info->block->border, property, values);
+ } else if (0 == strcmp ("color", property)) {
+ info->block->color_spec = ccd_color_parse (&info->block->color,
+ &values);
}
}
Modified: bzr-playground/libccd/ccd/ccd-selector.c
==============================================================================
--- bzr-playground/libccd/ccd/ccd-selector.c (original)
+++ bzr-playground/libccd/ccd/ccd-selector.c Mon Aug 18 13:51:12 2008
@@ -885,6 +885,8 @@
{
g_return_val_if_fail (self && self->block && style, false);
+ /* apply */
+
switch (self->block->background.bg_color.spec) {
case CCD_PROPERTY_SPEC_UNSET:
/* do nothing */
@@ -922,13 +924,54 @@
}
if (self->block->border.left.flags)
- style->left = &self->block->border.left;
+ CCD_BORDER_STROKE_ASSIGN (style->left, self->block->border.left);
if (self->block->border.top.flags)
- style->top = &self->block->border.top;
+ CCD_BORDER_STROKE_ASSIGN (style->top, self->block->border.top);
if (self->block->border.right.flags)
- style->right = &self->block->border.right;
+ CCD_BORDER_STROKE_ASSIGN (style->right, self->block->border.right);
if (self->block->border.bottom.flags)
- style->bottom = &self->block->border.bottom;
+ CCD_BORDER_STROKE_ASSIGN (style->bottom, self->block->border.bottom);
+
+ switch (self->block->color_spec) {
+ case CCD_PROPERTY_SPEC_UNSET:
+ /* do nothing */
+ break;
+ case CCD_PROPERTY_SPEC_NONE:
+ /* reset */
+ style->color = NULL;
+ style->color_spec = self->block->color_spec;
+ break;
+ case CCD_PROPERTY_SPEC_INHERIT:
+ /* not implemented */
+ g_assert_not_reached ();
+ break;
+ case CCD_PROPERTY_SPEC_SET:
+ /* use */
+ style->color = &self->block->color;
+ style->color_spec = self->block->color_spec;
+ break;
+ }
+
+ /* fixup */
+
+ if (style->color) {
+ if (CCD_PROPERTY_SPEC_UNSET == style->left.color_spec) {
+ CCD_COLOR_ASSIGN (style->left.color, *style->color);
+ style->left.color_spec = style->color_spec;
+ }
+ if (CCD_PROPERTY_SPEC_UNSET == style->top.color_spec) {
+ CCD_COLOR_ASSIGN (style->top.color, *style->color);
+ style->top.color_spec = style->color_spec;
+ }
+ if (CCD_PROPERTY_SPEC_UNSET == style->right.color_spec) {
+ CCD_COLOR_ASSIGN (style->right.color, *style->color);
+ style->right.color_spec = style->color_spec;
+ }
+ if (CCD_PROPERTY_SPEC_UNSET == style->bottom.color_spec) {
+ CCD_COLOR_ASSIGN (style->bottom.color, *style->color);
+ style->bottom.color_spec = style->color_spec;
+ }
+ }
return true;
}
Modified: bzr-playground/libccd/ccd/ccd-style.c
==============================================================================
--- bzr-playground/libccd/ccd/ccd-style.c (original)
+++ bzr-playground/libccd/ccd/ccd-style.c Mon Aug 18 13:51:12 2008
@@ -55,24 +55,26 @@
double off;
if (y1 == y2) {
- /* Horizontal: try to use top, then bottom border. */
- stroke = self->top ? self->top : self->bottom;
+ /* Horizontal: try to use top, then bottom border.
+ * Fallback based on flags is flawed, however. */
+ stroke = self->top.flags ? &self->top : &self->bottom;
if (stroke) {
/* Unlike borders, lines are not drawn inside the box,
* account for that. */
- off =stroke->width / 2.;
+ off = stroke->width / 2.;
ccd_border_draw (NULL, stroke, NULL, NULL,
cr, x1, y1 - off, x2 - x1, 0);
}
} else {
- /* Vertical: try to use left, then right border. */
- stroke = self->left ? self->left : self->right;
+ /* Vertical: try to use left, then right border.
+ * Fallback based on flags is flawed, however. */
+ stroke = self->left.flags ? &self->left : &self->right;
if (stroke) {
/* Unlike borders, lines are not drawn inside the box,
* account for that. */
- off = self->left->width / 2.;
+ off = stroke->width / 2.;
ccd_border_draw (stroke, NULL, NULL, NULL,
cr, x1 - off, y1, 0, y2 - y1);
@@ -101,7 +103,7 @@
int32_t width,
int32_t height)
{
- ccd_border_draw (self->left, self->top, self->right, self->bottom,
+ ccd_border_draw (&self->left, &self->top, &self->right, &self->bottom,
cr, x, y, width, height);
}
@@ -127,7 +129,7 @@
ccd_background_draw (self->bg_color, self->bg_image,
cr, x, y, width, height);
- ccd_border_draw (self->left, self->top, self->right, self->bottom,
+ ccd_border_draw (&self->left, &self->top, &self->right, &self->bottom,
cr, x, y, width, height);
}
@@ -144,13 +146,13 @@
ccd_background_color_dump (self->bg_color);
if (self->bg_image)
ccd_background_image_dump (self->bg_image);
- if (self->left)
- ccd_border_stroke_dump (self->left);
- if (self->top)
- ccd_border_stroke_dump (self->top);
- if (self->right)
- ccd_border_stroke_dump (self->right);
- if (self->bottom)
- ccd_border_stroke_dump (self->bottom);
+ if (self->left.flags)
+ ccd_border_stroke_dump (&self->left);
+ if (self->top.flags)
+ ccd_border_stroke_dump (&self->top);
+ if (self->right.flags)
+ ccd_border_stroke_dump (&self->right);
+ if (self->bottom.flags)
+ ccd_border_stroke_dump (&self->bottom);
}
Modified: bzr-playground/libccd/ccd/ccd-style.h
==============================================================================
--- bzr-playground/libccd/ccd/ccd-style.h (original)
+++ bzr-playground/libccd/ccd/ccd-style.h Mon Aug 18 13:51:12 2008
@@ -26,6 +26,8 @@
#include <ccd/ccd-features.h>
#include <ccd/ccd-background.h>
#include <ccd/ccd-border.h>
+#include <ccd/ccd-color.h>
+#include <ccd/ccd-property.h>
G_BEGIN_DECLS
@@ -41,10 +43,12 @@
/*< private >*/
ccd_background_color_t const *bg_color;
ccd_background_image_t const *bg_image;
- ccd_border_stroke_t const *left;
- ccd_border_stroke_t const *top;
- ccd_border_stroke_t const *right;
- ccd_border_stroke_t const *bottom;
+ ccd_border_stroke_t left;
+ ccd_border_stroke_t top;
+ ccd_border_stroke_t right;
+ ccd_border_stroke_t bottom;
+ ccd_color_t const *color;
+ ccd_property_spec_t color_spec;
} ccd_style_t;
void ccd_style_init (ccd_style_t *self);
Modified: bzr-playground/libccd/ccd/ccd.h
==============================================================================
--- bzr-playground/libccd/ccd/ccd.h (original)
+++ bzr-playground/libccd/ccd/ccd.h Mon Aug 18 13:51:12 2008
@@ -26,6 +26,10 @@
#include <ccd/ccd-features.h>
#include <ccd/ccd-function.h>
+#include <ccd/ccd-background.h>
+#include <ccd/ccd-border.h>
+#include <ccd/ccd-color.h>
+#include <ccd/ccd-function.h>
#include <ccd/ccd-node.h>
#include <ccd/ccd-style.h>
#include <ccd/ccd-stylesheet.h>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]