scale: Use top/left/bottom/right style classes on value label
authorTimm Bäder <mail@baedert.org>
Mon, 26 Aug 2019 16:56:04 +0000 (18:56 +0200)
committerTimm Bäder <mail@baedert.org>
Mon, 9 Sep 2019 15:36:25 +0000 (17:36 +0200)
Just top/bottom is not enough anymore.

77769a52b3cc0b836b226457963d7b5fe92ee115 broke e.g. horizontal scales
with the value on top/bottom, adding too much space.

gtk/gtkscale.c
gtk/theme/Adwaita/_common.scss

index fafcfab3bb57380453452a1d0ec479525e50f5bc..7a007c4e6b9f4c05b0fd10e74afd08244888cea4 100644 (file)
@@ -85,7 +85,7 @@
  * │   ┊    ╰── indicator
  * ┊   ┊
  * │   ╰── mark
- * ├── [value][.top][.bottom]
+ * ├── [value][.top][.right][.bottom][.left]
  * ├── trough
  * │   ├── [fill]
  * │   ├── [highlight]
@@ -1049,15 +1049,19 @@ update_value_position (GtkScale *scale)
 
   context = gtk_widget_get_style_context (priv->value_widget);
 
-  if (priv->value_pos == GTK_POS_TOP || priv->value_pos == GTK_POS_LEFT)
-    {
-      gtk_style_context_remove_class (context, GTK_STYLE_CLASS_BOTTOM);
-      gtk_style_context_add_class (context, GTK_STYLE_CLASS_TOP);
-    }
-  else
+  gtk_style_context_remove_class (context, GTK_STYLE_CLASS_TOP);
+  gtk_style_context_remove_class (context, GTK_STYLE_CLASS_RIGHT);
+  gtk_style_context_remove_class (context, GTK_STYLE_CLASS_BOTTOM);
+  gtk_style_context_remove_class (context, GTK_STYLE_CLASS_LEFT);
+
+  switch (priv->value_pos)
     {
-      gtk_style_context_remove_class (context, GTK_STYLE_CLASS_TOP);
-      gtk_style_context_add_class (context, GTK_STYLE_CLASS_BOTTOM);
+    case GTK_POS_TOP:    gtk_style_context_add_class (context, GTK_STYLE_CLASS_TOP); break;
+    case GTK_POS_RIGHT:  gtk_style_context_add_class (context, GTK_STYLE_CLASS_RIGHT); break;
+    case GTK_POS_BOTTOM: gtk_style_context_add_class (context, GTK_STYLE_CLASS_BOTTOM); break;
+    case GTK_POS_LEFT:   gtk_style_context_add_class (context, GTK_STYLE_CLASS_LEFT); break;
+
+    default: g_assert_not_reached ();
     }
 }
 
index ad400fbe1a82be41a61b72630dbe1a53b8ff25c3..8bc9f71c913f68c64a43d00b9ab735e1319ce9ad 100644 (file)
@@ -3197,8 +3197,8 @@ scale {
       }
     }
 
-    >value.top    { margin-bottom: 9px; }
-    >value.bottom { margin-top: 9px; }
+    > value.left  { margin-right: 9px; }
+    > value.right { margin-left: 9px; }
 
     &.fine-tune >marks {
       &.top { margin-top: 3px; }
@@ -3221,8 +3221,8 @@ scale {
       }
     }
 
-    >value.top    { margin-bottom: 9px; }
-    >value.bottom { margin-top: 9px; }
+    > value.top    { margin-bottom: 9px; }
+    > value.bottom { margin-top: 9px; }
 
     &.fine-tune >marks {
       &.top { margin-left: 3px; }