[gtk+/wip/cosimoc/range-gadget] wip
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/cosimoc/range-gadget] wip
- Date: Sat, 27 Feb 2016 23:46:44 +0000 (UTC)
commit 1ae7a4506c06fcb89b1e7b99e6b41f885ef90c1b
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Sat Feb 27 15:46:22 2016 -0800
wip
gtk/gtkscale.c | 104 +++++++++++++++++++++++++++++++++++++-------------------
1 files changed, 69 insertions(+), 35 deletions(-)
---
diff --git a/gtk/gtkscale.c b/gtk/gtkscale.c
index 10c55fa..7c3175c 100644
--- a/gtk/gtkscale.c
+++ b/gtk/gtkscale.c
@@ -176,13 +176,6 @@ static void gtk_scale_get_preferred_height (GtkWidget *widget,
static void gtk_scale_style_updated (GtkWidget *widget);
static void gtk_scale_get_range_border (GtkRange *range,
GtkBorder *border);
-static void gtk_scale_get_mark_label_size (GtkScale *scale,
- gint *count_top,
- gint *width_top,
- gint *height_top,
- gint *count_bottom,
- gint *width_bottom,
- gint *height_bottom);
static void gtk_scale_finalize (GObject *object);
static void gtk_scale_screen_changed (GtkWidget *widget,
GdkScreen *old_screen);
@@ -876,11 +869,13 @@ gtk_scale_get_range_border (GtkRange *range,
GtkWidget *widget;
GtkScale *scale;
gint w, h;
-
+ gint value_spacing;
+
widget = GTK_WIDGET (range);
scale = GTK_SCALE (range);
priv = scale->priv;
+ gtk_widget_style_get (widget, "value-spacing", &value_spacing, NULL);
gtk_scale_get_value_size (scale, &w, &h);
border->left = 0;
@@ -890,9 +885,6 @@ gtk_scale_get_range_border (GtkRange *range,
if (priv->draw_value)
{
- gint value_spacing;
- gtk_widget_style_get (widget, "value-spacing", &value_spacing, NULL);
-
switch (priv->value_pos)
{
case GTK_POS_LEFT:
@@ -912,30 +904,51 @@ gtk_scale_get_range_border (GtkRange *range,
if (priv->marks)
{
- gint value_spacing;
- gint n_top, w_top, h_top, n_bottom, w_bottom, h_bottom;
-
- gtk_widget_style_get (widget,
- "value-spacing", &value_spacing,
- NULL);
-
- gtk_scale_get_mark_label_size (scale,
- &n_top, &w_top, &h_top,
- &n_bottom, &w_bottom, &h_bottom);
+ int size;
if (gtk_orientable_get_orientation (GTK_ORIENTABLE (scale)) == GTK_ORIENTATION_HORIZONTAL)
{
- if (h_top > 0)
- border->top += h_top + value_spacing;
- if (h_bottom > 0)
- border->bottom += h_bottom + value_spacing;
+ if (priv->top_marks_gadget)
+ {
+ gtk_css_gadget_get_preferred_size (priv->top_marks_gadget,
+ GTK_ORIENTATION_VERTICAL, -1,
+ &size, NULL,
+ NULL, NULL);
+ if (size > 0)
+ border->top += size + value_spacing;
+ }
+
+ if (priv->bottom_marks_gadget)
+ {
+ gtk_css_gadget_get_preferred_size (priv->bottom_marks_gadget,
+ GTK_ORIENTATION_VERTICAL, -1,
+ &size, NULL,
+ NULL, NULL);
+ if (size > 0)
+ border->bottom += size + value_spacing;
+ }
}
else
{
- if (w_top > 0)
- border->left += w_bottom + value_spacing;
- if (w_bottom > 0)
- border->right += w_bottom + value_spacing;
+ if (priv->top_marks_gadget)
+ {
+ gtk_css_gadget_get_preferred_size (priv->top_marks_gadget,
+ GTK_ORIENTATION_HORIZONTAL, -1,
+ &size, NULL,
+ NULL, NULL);
+ if (size > 0)
+ border->left += size + value_spacing;
+ }
+
+ if (priv->bottom_marks_gadget)
+ {
+ gtk_css_gadget_get_preferred_size (priv->bottom_marks_gadget,
+ GTK_ORIENTATION_HORIZONTAL, -1,
+ &size, NULL,
+ NULL, NULL);
+ if (size > 0)
+ border->right += size + value_spacing;
+ }
}
}
}
@@ -1079,6 +1092,7 @@ gtk_scale_measure_marks (GtkCssGadget *gadget,
GtkScale *scale = GTK_SCALE (widget);
GtkScalePrivate *priv = scale->priv;
GtkCssGadget *slider_gadget = gtk_range_get_slider_gadget (GTK_RANGE (scale));
+ GtkOrientation scale_orientation = gtk_orientable_get_orientation (GTK_ORIENTABLE (scale));
int n_top, w_top, h_top, n_bottom, w_bottom, h_bottom;
int slider_length;
@@ -1092,17 +1106,37 @@ gtk_scale_measure_marks (GtkCssGadget *gadget,
if (gadget == priv->top_marks_gadget)
{
- if (orientation == GTK_ORIENTATION_HORIZONTAL)
- *minimum = *natural = (n_top - 1) * w_top + MAX (w_top, slider_length);
+ if (scale_orientation == GTK_ORIENTATION_HORIZONTAL)
+ {
+ if (scale_orientation == GTK_ORIENTATION_HORIZONTAL)
+ *minimum = *natural = (n_top - 1) * w_top + MAX (w_top, slider_length);
+ else
+ *minimum = *natural = h_top;
+ }
else
- *minimum = *natural = (n_top - 1) * h_top + MAX (h_top, slider_length);
+ {
+ if (orientation == GTK_ORIENTATION_HORIZONTAL)
+ *minimum = *natural = w_top;
+ else
+ *minimum = *natural = (n_top - 1) * h_top + MAX (h_top, slider_length);
+ }
}
else
{
- if (orientation == GTK_ORIENTATION_HORIZONTAL)
- *minimum = *natural = (n_bottom - 1) * w_bottom + MAX (w_bottom, slider_length);
+ if (scale_orientation == GTK_ORIENTATION_HORIZONTAL)
+ {
+ if (orientation == GTK_ORIENTATION_HORIZONTAL)
+ *minimum = *natural = (n_bottom - 1) * w_bottom + MAX (w_bottom, slider_length);
+ else
+ *minimum = *natural = h_bottom;
+ }
else
- *minimum = *natural = (n_bottom - 1) * h_bottom + MAX (h_bottom, slider_length);
+ {
+ if (orientation == GTK_ORIENTATION_HORIZONTAL)
+ *minimum = *natural = w_bottom;
+ else
+ *minimum = *natural = (n_bottom - 1) * h_bottom + MAX (h_bottom, slider_length);
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]