[gtk+] cssimage: Make it possible to shrink builtin check/optionmarks



commit 0c37b057167f5da7fb4be1e182d8dda3de413264
Author: Benjamin Otte <otte redhat com>
Date:   Tue May 10 00:58:50 2016 +0200

    cssimage: Make it possible to shrink builtin check/optionmarks
    
    ... below 7px of size.

 gtk/gtkcssimagebuiltin.c |   40 ++++++++++------------------------------
 1 files changed, 10 insertions(+), 30 deletions(-)
---
diff --git a/gtk/gtkcssimagebuiltin.c b/gtk/gtkcssimagebuiltin.c
index 3a65747..fe0f652 100644
--- a/gtk/gtkcssimagebuiltin.c
+++ b/gtk/gtkcssimagebuiltin.c
@@ -45,23 +45,18 @@ gtk_css_image_builtin_draw_check (GtkCssImage *image,
                                   gboolean     inconsistent)
 {
   GtkCssImageBuiltin *builtin = GTK_CSS_IMAGE_BUILTIN (image);
-  gint x, y, exterior_size, interior_size, thickness, pad;
+  gint x, y, exterior_size, interior_size, pad;
 
   exterior_size = MIN (width, height);
 
   if (exterior_size % 2 == 0) /* Ensure odd */
     exterior_size -= 1;
 
-  /* FIXME: thickness */
-  thickness = 1;
-  pad = thickness + MAX (1, (exterior_size - 2 * thickness) / 9);
+  pad = 1 + MAX (1, (exterior_size - 2) / 9);
   interior_size = MAX (1, exterior_size - 2 * pad);
 
   if (interior_size < 7)
-    {
-      interior_size = 7;
-      pad = MAX (0, (exterior_size - interior_size) / 2);
-    }
+    pad = MAX (0, (exterior_size - interior_size) / 2);
 
   x = - (1 + exterior_size - (gint) width) / 2;
   y = - (1 + exterior_size - (gint) height) / 2;
@@ -126,7 +121,7 @@ gtk_css_image_builtin_draw_option (GtkCssImage *image,
                                    gboolean     inconsistent)
 {
   GtkCssImageBuiltin *builtin = GTK_CSS_IMAGE_BUILTIN (image);
-  gint x, y, exterior_size, interior_size, thickness, pad;
+  gint x, y, exterior_size, interior_size, pad;
 
   exterior_size = MIN (width, height);
 
@@ -138,22 +133,16 @@ gtk_css_image_builtin_draw_option (GtkCssImage *image,
 
   gdk_cairo_set_source_rgba (cr, &builtin->fg_color);
 
-  /* FIXME: thickness */
-  thickness = 1;
+  pad = 1 + MAX (1, 2 * (exterior_size - 2) / 9);
+  interior_size = MAX (1, exterior_size - 2 * pad);
+
+  if (interior_size < 7)
+    pad = MAX (0, (exterior_size - interior_size) / 2);
 
   if (inconsistent)
     {
       gint line_thickness;
 
-      pad = thickness + MAX (1, (exterior_size - 2 * thickness) / 9);
-      interior_size = MAX (1, exterior_size - 2 * pad);
-
-      if (interior_size < 7)
-        {
-          interior_size = 7;
-          pad = MAX (0, (exterior_size - interior_size) / 2);
-        }
-
       line_thickness = MAX (1, (3 + interior_size * 2) / 7);
 
       cairo_rectangle (cr,
@@ -163,17 +152,8 @@ gtk_css_image_builtin_draw_option (GtkCssImage *image,
                        line_thickness);
       cairo_fill (cr);
     }
-  if (checked)
+  else if (checked)
     {
-      pad = thickness + MAX (1, 2 * (exterior_size - 2 * thickness) / 9);
-      interior_size = MAX (1, exterior_size - 2 * pad);
-
-      if (interior_size < 5)
-        {
-          interior_size = 7;
-          pad = MAX (0, (exterior_size - interior_size) / 2);
-        }
-
       cairo_new_sub_path (cr);
       cairo_arc (cr,
                  x + pad + interior_size / 2.,


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