]> Pileus Git - ~andy/gtk/commitdiff
Fix notebook tab position on Windows win32
authorAndy Spencer <andy753421@gmail.com>
Sat, 16 Mar 2013 00:01:49 +0000 (00:01 +0000)
committerAndy Spencer <andy753421@gmail.com>
Sat, 16 Mar 2013 00:12:13 +0000 (00:12 +0000)
This adds an additional option to -gtk-win32-theme-part() in the CSS
files which can be used to flip/rotate the theme part.

Possible values are:

    rotate(0) - no rotation, for GTK_POS_TOP
    rotate(1) - rotate 90 degrees, for GTK_POS_RIGHT
    rotate(2) - rotate 180 degrees, for GTK_POS_BOTTOM
    rotate(3) - rotate 270 degrees, for GTK_POS_LEFT

gtk/gtk-win32-base.css
gtk/gtkcssimagewin32.c
gtk/gtkcssimagewin32private.h

index 0c86bbb058e25c819eb3e51accc67d1053f6f314..9d0d53e5f5461b9cc6dc18563ab519ff0f447533 100644 (file)
@@ -663,31 +663,46 @@ GtkComboBox .separator {
 
 .notebook tab {
     border-width: 0;
-    background-image: -gtk-win32-theme-part(tab, 1 1);
+}
+
+.notebook tab.top {
     padding: 0px 4px 0px 4px;
+    background-image: -gtk-win32-theme-part(tab, 1 1, rotate(0));
 }
 
-.notebook tab.left, .notebook tab.right {
+.notebook tab.right {
     padding: 4px 0px 4px 0px;
+    background-image: -gtk-win32-theme-part(tab, 1 1, rotate(1));
 }
 
-.notebook tab:active {
-    background-image: -gtk-win32-theme-part(tab, 1 3, margins(0 0 -1 0));
+.notebook tab.bottom {
+    padding: 0px 4px 0px 4px;
+    background-image: -gtk-win32-theme-part(tab, 1 1, rotate(2));
 }
-.notebook tab:active.top {
-    padding: 2px 4px 1px 4px;
+
+.notebook tab.left{
+    padding: 4px 0px 4px 0px;
+    background-image: -gtk-win32-theme-part(tab, 1 1, rotate(3));
 }
 
-.notebook tab:active.bottom {
-    padding: 1px 4px 2px 4px;
+.notebook tab:active.top {
+    padding: 2px 4px 1px 4px;
+    background-image: -gtk-win32-theme-part(tab, 1 3, margins(0 0 -1 0), rotate(0));
 }
 
 .notebook tab:active.right {
     padding: 4px 4px 4px 1px;
+    background-image: -gtk-win32-theme-part(tab, 1 3, margins(0 0 -1 0), rotate(1));
+}
+
+.notebook tab:active.bottom {
+    padding: 1px 4px 2px 4px;
+    background-image: -gtk-win32-theme-part(tab, 1 3, margins(0 0 -1 0), rotate(2));
 }
 
 .notebook tab:active.left {
     padding: 4px 1px 4px 4px;
+    background-image: -gtk-win32-theme-part(tab, 1 3, margins(0 0 -1 0), rotate(3));
 }
 
 /* Toolbar */
index aa1f4afe5aea860ac530d50bcbe3f9ce4d61d898..f7b6e48111a534c799bb65f1c514f50963d220b6 100644 (file)
@@ -35,6 +35,13 @@ gtk_css_image_win32_draw (GtkCssImage        *image,
   cairo_surface_t *surface;
   int dx, dy;
 
+  if (wimage->rotate == 1 || wimage->rotate == 3)
+    {
+      double tmp = width;
+      width = height;
+      height = tmp;
+    }
+
   surface = _gtk_win32_theme_part_create_surface (wimage->theme, wimage->part, wimage->state, wimage->margins,
                                                  width, height, &dx, &dy);
   
@@ -57,6 +64,15 @@ gtk_css_image_win32_draw (GtkCssImage        *image,
       cairo_surface_destroy (surface2);
     }
 
+  if (wimage->rotate == 1)
+      cairo_translate (cr, height, 0);
+  if (wimage->rotate == 2)
+      cairo_translate (cr, width, height);
+  if (wimage->rotate == 3)
+      cairo_translate (cr, 0, width);
+  if (wimage->rotate)
+      cairo_rotate (cr, wimage->rotate * (G_PI / 2));
+
   cairo_set_source_surface (cr, surface, dx, dy);
   cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_NONE);
   cairo_rectangle (cr, 0, 0, width, height);
@@ -189,6 +205,28 @@ gtk_css_image_win32_parse (GtkCssImage  *image,
               return FALSE;
             }
         }
+      else if ( _gtk_css_parser_try (parser, "rotate", TRUE))
+        {
+          if (!_gtk_css_parser_try (parser, "(", TRUE))
+            {
+              _gtk_css_parser_error (parser,
+                                     "Expected '(' after 'over'");
+              return FALSE;
+            }
+
+          if (!_gtk_css_parser_try_int (parser, &wimage->rotate))
+            {
+              _gtk_css_parser_error (parser, "Expected a valid integer value");
+              return FALSE;
+            }
+
+          if (!_gtk_css_parser_try (parser, ")", TRUE))
+            {
+              _gtk_css_parser_error (parser,
+                                     "Expected ')' at end of 'over'");
+              return FALSE;
+            }
+        }
       else
         {
           _gtk_css_parser_error (parser,
index e62f88b5ffff8c4c341c192e324f4a3ad3d2475e..fd1d944252af6c1e3560af6424fde6f6d860c27f 100644 (file)
@@ -48,6 +48,8 @@ struct _GtkCssImageWin32
 
   gint margins[4];
 
+  int rotate;
+
   HTHEME theme;
 };