Commit fa9f22ee authored by Matthias Clasen's avatar Matthias Clasen

scale: Bring back marks-related style classes

It turns out that it is too hard (and in some cases, impossible)
to get this information from node positioning, so bring back the
.scale-has-marks-above/below style classes on the main node.

This should allow us to fix the 'pointy sliders'.

https://bugzilla.gnome.org/show_bug.cgi?id=766440
parent f516faae
......@@ -76,13 +76,14 @@
* # CSS nodes
*
* |[<!-- language="plain" -->
* scale[.fine-tune]
* scale[.fine-tune][.scale-has-marks-above][.scale-has-marks-below]
* ├── marks.top
* │ ├── mark
* │ ┊ ├── [label]
* │ ┊ ╰── indicator
* ┊ ┊
* │ ╰── mark
* ├── [value]
* ├── contents
* │ ╰── trough
* │ ├── slider
......@@ -117,6 +118,12 @@
* has a subnode named label. When the mark is either above or left of the
* scale, the label subnode is the first when present. Otherwise, the indicator
* subnode is the first.
*
* The main CSS node gets the 'scale-has-marks-above' and/or 'scale-has-marks-below'
* style classes added depending on what marks are present.
*
* If the scale is displaying the value (see #GtkScale:draw-value), there is
* subnode with name value.
*/
......@@ -2003,6 +2010,7 @@ void
gtk_scale_clear_marks (GtkScale *scale)
{
GtkScalePrivate *priv;
GtkStyleContext *context;
g_return_if_fail (GTK_IS_SCALE (scale));
......@@ -2018,6 +2026,10 @@ gtk_scale_clear_marks (GtkScale *scale)
gtk_css_node_set_parent (gtk_css_gadget_get_node (priv->bottom_marks_gadget), NULL);
g_clear_object (&priv->bottom_marks_gadget);
context = gtk_widget_get_style_context (GTK_WIDGET (scale));
gtk_style_context_remove_class (context, GTK_STYLE_CLASS_SCALE_HAS_MARKS_BELOW);
gtk_style_context_remove_class (context, GTK_STYLE_CLASS_SCALE_HAS_MARKS_ABOVE);
_gtk_range_set_stop_values (GTK_RANGE (scale), NULL, 0);
gtk_widget_queue_resize (GTK_WIDGET (scale));
......@@ -2060,6 +2072,7 @@ gtk_scale_add_mark (GtkScale *scale,
gdouble *values;
gint n, i;
GtkCssNode *widget_node, *marks_node;
GtkStyleContext *context;
g_return_if_fail (GTK_IS_SCALE (scale));
......@@ -2184,6 +2197,12 @@ gtk_scale_add_mark (GtkScale *scale,
g_free (values);
context = gtk_widget_get_style_context (GTK_WIDGET (scale));
if (priv->top_marks_gadget)
gtk_style_context_add_class (context, GTK_STYLE_CLASS_SCALE_HAS_MARKS_ABOVE);
if (priv->bottom_marks_gadget)
gtk_style_context_add_class (context, GTK_STYLE_CLASS_SCALE_HAS_MARKS_BELOW);
gtk_widget_queue_resize (widget);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment