[gtk+] scale: Bring back marks-related style classes
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] scale: Bring back marks-related style classes
- Date: Wed, 18 May 2016 17:01:06 +0000 (UTC)
commit fa9f22eec4fafd9a484864f45e0ac26ba584f0ef
Author: Matthias Clasen <mclasen redhat com>
Date: Wed May 18 12:59:39 2016 -0400
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
gtk/gtkscale.c | 21 ++++++++++++++++++++-
1 files changed, 20 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkscale.c b/gtk/gtkscale.c
index 6d71292..5b3ff9b 100644
--- a/gtk/gtkscale.c
+++ b/gtk/gtkscale.c
@@ -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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]