gtk-css-engine r106 - in trunk: . libccd/ccd themes/gtk-css-test/gtk-2.0



Author: robsta
Date: Mon Sep 15 09:35:36 2008
New Revision: 106
URL: http://svn.gnome.org/viewvc/gtk-css-engine?rev=106&view=rev

Log:
* libccd/ccd/ccd-border.c:
* libccd/ccd/ccd-border.h:
* libccd/ccd/ccd-gtk-style.c:
Fix glitches for gap-boxes with insanely big border radii.


Modified:
   trunk/   (props changed)
   trunk/ChangeLog
   trunk/libccd/ccd/ccd-border.c
   trunk/libccd/ccd/ccd-border.h
   trunk/libccd/ccd/ccd-gtk-style.c
   trunk/themes/gtk-css-test/gtk-2.0/styles.css

Modified: trunk/libccd/ccd/ccd-border.c
==============================================================================
--- trunk/libccd/ccd/ccd-border.c	(original)
+++ trunk/libccd/ccd/ccd-border.c	Mon Sep 15 09:35:36 2008
@@ -666,6 +666,29 @@
 	return draw_solid_join;
 }
 
+void
+ccd_border_clamp_radii (double	 x,
+			double	 y,
+			double	 width,
+			double	 height,
+			double	*left_top,
+			double	*top_right,
+			double	*right_bottom,
+			double	*bottom_left)
+{
+	if (height > 0 && *left_top > height / 2.) *left_top = height / 2.;
+	if (width > 0 && *left_top > width / 2.) *left_top = width / 2.;
+
+	if (height > 0 && *top_right > height / 2.) *top_right = height / 2.;
+	if (width > 0 && *top_right > width / 2.) *top_right = width / 2.;
+
+	if (height > 0 && *right_bottom > height / 2.) *right_bottom = height / 2.;
+	if (width > 0 && *right_bottom > width / 2.) *right_bottom = width / 2.;
+
+	if (height > 0 && *bottom_left > height / 2.) *bottom_left = height / 2.;
+	if (width > 0 && *bottom_left > width / 2.) *bottom_left = width / 2.;
+}
+
 static void
 border (ccd_border_stroke_t const	*left,
 	ccd_border_join_t const		*left_top,
@@ -691,22 +714,14 @@
 	double		rlt, rtr, rrb, rbl;
 	bool		have_segment;
 
-	/* Clamp radii to 50% of length. */
 	rlt = left_top && left_top->radius_spec ? left_top->radius : 0;
-	if (height > 0 && rlt > height / 2.) rlt = height / 2.;
-	if (width > 0 && rlt > width / 2.) rlt = width / 2.;
-
 	rtr = top_right && top_right->radius_spec ? top_right->radius : 0;
-	if (height > 0 && rtr > height / 2.) rtr = height / 2.;
-	if (width > 0 && rtr > width / 2.) rtr = width / 2.;
-
 	rrb = right_bottom && right_bottom->radius_spec ? right_bottom->radius : 0;
-	if (height > 0 && rrb > height / 2.) rrb = height / 2.;
-	if (width > 0 && rrb > width / 2.) rrb = width / 2.;
-
 	rbl = bottom_left && bottom_left->radius_spec ? bottom_left->radius : 0;
-	if (height > 0 && rbl > height / 2.) rbl = height / 2.;
-	if (width > 0 && rbl > width / 2.) rbl = width / 2.;
+	if (!(CCD_BORDER_ROUNDING_UNRESTRICTED & visibility_flags)) {
+		ccd_border_clamp_radii (x, y, width, height, 
+					&rlt, &rtr, &rrb, &rbl);
+	}
 
 	have_segment = false;
 

Modified: trunk/libccd/ccd/ccd-border.h
==============================================================================
--- trunk/libccd/ccd/ccd-border.h	(original)
+++ trunk/libccd/ccd/ccd-border.h	Mon Sep 15 09:35:36 2008
@@ -51,8 +51,10 @@
 	CCD_BORDER_VISIBILITY_HIDE_RIGHT	= 1 << 4,
 	CCD_BORDER_VISIBILITY_HIDE_RIGHT_BOTTOM	= 1 << 5,
 	CCD_BORDER_VISIBILITY_HIDE_BOTTOM	= 1 << 6,
-	CCD_BORDER_VISIBILITY_HIDE_BOTTOM_LEFT	= 1 << 7
-} ccd_border_visibility_t;
+	CCD_BORDER_VISIBILITY_HIDE_BOTTOM_LEFT	= 1 << 7,
+
+	CCD_BORDER_ROUNDING_UNRESTRICTED	= 1 << 8
+} ccd_border_drawing_flags_t;
 
 /*
  * Remember which properties were set explicitely, e.g. using "border-top", 
@@ -78,7 +80,7 @@
 	CCD_BORDER_FLAGS_SPECIFIC_RADIUS = 1 << 7,
 	CCD_BORDER_FLAGS_RADIUS_MASK	= CCD_BORDER_FLAGS_COMMON_RADIUS |
 					  CCD_BORDER_FLAGS_SPECIFIC_RADIUS
-} ccd_border_flags_t;
+} ccd_border_priority_flags_t;
 
 #define CCD_BORDER_STROKE_ASSIGN(lhs_, rhs_) {		\
 	lhs_.width	= rhs_.width;			\
@@ -130,6 +132,10 @@
 bool ccd_border_parse (ccd_border_t *self, char const *property, 
 				CRTerm const *values);
 
+void ccd_border_clamp_radii (double x, double y, double width, double height,
+			     double *left_top, double *top_right,
+			     double *right_bottom, double *bottom_left);
+
 void ccd_border_path (ccd_border_stroke_t const *left, 
 		      ccd_border_join_t const *left_top,
 		      ccd_border_stroke_t const *top, 

Modified: trunk/libccd/ccd/ccd-gtk-style.c
==============================================================================
--- trunk/libccd/ccd/ccd-gtk-style.c	(original)
+++ trunk/libccd/ccd/ccd-gtk-style.c	Mon Sep 15 09:35:36 2008
@@ -91,6 +91,10 @@
 	if (right_bottom.radius < 0)	right_bottom.radius = 0;
 	if (bottom_left.radius < 0)	bottom_left.radius = 0;
 
+	ccd_border_clamp_radii (x, y, width, height,
+				&left_top.radius, &top_right.radius,
+				&right_bottom.radius, &bottom_left.radius);
+
 	ccd_border_path (&self->left, &left_top, 
 			 &self->top, &top_right,
 			 &self->right, &right_bottom,
@@ -102,22 +106,31 @@
 
 	cairo_new_path (cr);
 
+	/* Drawing functions start at bottom-left corder and
+	 * proceed clock-wise. */
 	switch (gap_side) {
 	case GTK_POS_LEFT:
 		/* Draw gap only if it's not over the whole border. */
 		if (gap_start > y || gap_width < height) {
-			/* With Gtk+ the portion following the gap might not be visible. */
-			if (gap_start + gap_width < height) {
+			/* Rounding reaches until start of gap?
+			 * With Gtk+ the portion following the gap might not be visible. */
+			if (bottom_left.radius < height - gap_start - gap_width &&
+			    gap_start + gap_width < height) {
 				ccd_border_draw (&self->left, NULL, NULL, NULL,
 					 NULL, NULL, NULL, &bottom_left,
-					 CCD_BORDER_VISIBILITY_HIDE_BOTTOM_LEFT,
+					 CCD_BORDER_VISIBILITY_HIDE_BOTTOM_LEFT |
+					 CCD_BORDER_ROUNDING_UNRESTRICTED,
 					 cr, x, y + gap_start + gap_width, 
 					 0, height - gap_start - gap_width);
 			}
-			ccd_border_draw (&self->left, &left_top, NULL, NULL,
+			/* Rounding reaches until start of gap? */
+			if (left_top.radius < gap_start) {
+				ccd_border_draw (&self->left, &left_top, NULL, NULL,
 					 NULL, NULL, NULL, NULL,
-					 CCD_BORDER_VISIBILITY_HIDE_LEFT_TOP,
+					 CCD_BORDER_VISIBILITY_HIDE_LEFT_TOP |
+					 CCD_BORDER_ROUNDING_UNRESTRICTED,
 					 cr, x, y, 0, gap_start);
+			}
 		}
 		ccd_border_draw (&self->left, &left_top,
 				 &self->top, &top_right,
@@ -129,15 +142,22 @@
 	case GTK_POS_TOP:
 		/* Draw gap only if it's not over the whole border. */
 		if (gap_start > x || gap_width < width) {
-			ccd_border_draw (NULL, &left_top, &self->top, NULL,
+			/* Rounding reaches until start of gap? */
+			if (left_top.radius < gap_start) {
+				ccd_border_draw (NULL, &left_top, &self->top, NULL,
 					 NULL, NULL, NULL, NULL,
-					 CCD_BORDER_VISIBILITY_HIDE_LEFT_TOP,
+					 CCD_BORDER_VISIBILITY_HIDE_LEFT_TOP |
+					 CCD_BORDER_ROUNDING_UNRESTRICTED,
 					 cr, x, y, gap_start, 0);
-			/* With Gtk+ the portion following the gap might not be visible. */
-			if (gap_start + gap_width < width) {
+			}
+			/* Rounding reaches until start of gap?
+			 * With Gtk+ the portion following the gap might not be visible. */
+			if (top_right.radius < width - gap_start - gap_width &&
+			    gap_start + gap_width < width) {
 				ccd_border_draw (NULL, NULL, &self->top, &top_right,
 					 NULL, NULL, NULL, NULL,
-					 CCD_BORDER_VISIBILITY_HIDE_TOP_RIGHT,
+					 CCD_BORDER_VISIBILITY_HIDE_TOP_RIGHT |
+					 CCD_BORDER_ROUNDING_UNRESTRICTED,
 					 cr, x + gap_start + gap_width, y, 
 					 width - gap_start - gap_width, 0);
 			}
@@ -152,15 +172,22 @@
 	case GTK_POS_RIGHT:
 		/* Draw gap only if it's not over the whole border. */
 		if (gap_start > y || gap_width < height) {
-			ccd_border_draw (NULL, NULL, NULL, &top_right,
+			/* Rounding reaches until start of gap? */
+			if (top_right.radius < gap_start) {
+				ccd_border_draw (NULL, NULL, NULL, &top_right,
 					 &self->right, NULL, NULL, NULL,
-					 CCD_BORDER_VISIBILITY_HIDE_TOP_RIGHT,
+					 CCD_BORDER_VISIBILITY_HIDE_TOP_RIGHT |
+					 CCD_BORDER_ROUNDING_UNRESTRICTED,
 					 cr, x + width, y, 0, gap_start);
-			/* With Gtk+ the portion following the gap might not be visible. */
-			if (gap_start + gap_width < height) {
+			}
+			/* Rounding reaches until start of gap?
+			 * With Gtk+ the portion following the gap might not be visible. */
+			if (right_bottom.radius < height - gap_start - gap_width &&
+			    gap_start + gap_width < height) {
 				ccd_border_draw (NULL, NULL, NULL, NULL,
 					 &self->right, &right_bottom, NULL, NULL,
-					 CCD_BORDER_VISIBILITY_HIDE_RIGHT_BOTTOM,
+					 CCD_BORDER_VISIBILITY_HIDE_RIGHT_BOTTOM |
+					 CCD_BORDER_ROUNDING_UNRESTRICTED,
 					 cr, x + width, y + gap_start + gap_width, 
 					 0, height - gap_start - gap_width);
 			}
@@ -175,18 +202,25 @@
 	case GTK_POS_BOTTOM:
 		/* Draw gap only if it's not over the whole border. */
 		if (gap_start > x || gap_width < width) {
-			ccd_border_draw (NULL, NULL, NULL, NULL,
-					 NULL, NULL, &self->bottom, &bottom_left,
-					 CCD_BORDER_VISIBILITY_HIDE_BOTTOM_LEFT,
-					 cr, x, y + height, gap_start, 0);
-			/* With Gtk+ the portion following the gap might not be visible. */
-			if (gap_start + gap_width < width) {
+			/* Rounding reaches until start of gap? &&
+			 * With Gtk+ the portion following the gap might not be visible. */
+			if (right_bottom.radius < width - gap_start - gap_width &&
+			    gap_start + gap_width < width) {
 				ccd_border_draw (NULL, NULL, NULL, NULL,
 					 NULL, &right_bottom, &self->bottom, NULL,
-					 CCD_BORDER_VISIBILITY_HIDE_RIGHT_BOTTOM,
+					 CCD_BORDER_VISIBILITY_HIDE_RIGHT_BOTTOM |
+					 CCD_BORDER_ROUNDING_UNRESTRICTED,
 					 cr, x + gap_start + gap_width, y + height,
 					 width - gap_start - gap_width, 0);
 			}
+			/* Rounding reaches until start of gap? */
+			if (bottom_left.radius < gap_start) {
+				ccd_border_draw (NULL, NULL, NULL, NULL,
+					 NULL, NULL, &self->bottom, &bottom_left,
+					 CCD_BORDER_VISIBILITY_HIDE_BOTTOM_LEFT |
+					 CCD_BORDER_ROUNDING_UNRESTRICTED,
+					 cr, x, y + height, gap_start, 0);
+			}
 		}
 		ccd_border_draw (&self->left, &left_top,
 				 &self->top, &top_right,

Modified: trunk/themes/gtk-css-test/gtk-2.0/styles.css
==============================================================================
--- trunk/themes/gtk-css-test/gtk-2.0/styles.css	(original)
+++ trunk/themes/gtk-css-test/gtk-2.0/styles.css	Mon Sep 15 09:35:36 2008
@@ -110,8 +110,8 @@
 
 box {
 	background: khaki;
-	border: 1px solid black;
-	border-radius: 15;
+	border: 2px solid black;
+	border-radius: 60;
 }
 
 shadow {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]