wip: spinbutton

This commit is contained in:
Matthias Clasen 2015-10-28 21:55:07 -04:00
parent 811c1c9484
commit ebcad63e31
5 changed files with 276 additions and 223 deletions

View File

@ -3178,6 +3178,25 @@ update_icon_state (GtkWidget *widget,
gtk_css_node_set_state (icon_info->css_node, state);
}
static GtkCssNode *
get_entry_node (GtkWidget *widget)
{
if (GTK_IS_SPIN_BUTTON (widget))
{
const gchar *name;
GtkCssNode *node;
name = I_("entry");
node = gtk_css_node_get_first_child (gtk_widget_get_css_node (widget));
do {
if (gtk_css_node_get_name (node) == name)
return node;
} while ((node = gtk_css_node_get_next_sibling (node)) != NULL);
}
return gtk_widget_get_css_node (widget);
}
static EntryIconInfo*
construct_icon_info (GtkWidget *widget,
GtkEntryIconPosition icon_pos)
@ -3195,7 +3214,7 @@ construct_icon_info (GtkWidget *widget,
icon_info->icon_helper = _gtk_icon_helper_new ();
_gtk_icon_helper_set_force_scale_pixbuf (icon_info->icon_helper, TRUE);
widget_node = gtk_widget_get_css_node (widget);
widget_node = get_entry_node (widget);
icon_info->css_node = gtk_css_node_new ();
gtk_css_node_set_name (icon_info->css_node, I_("image"));
gtk_css_node_set_parent (icon_info->css_node, widget_node);
@ -3771,21 +3790,20 @@ gtk_entry_draw_frame (GtkWidget *widget,
* width equals widget->window's width
* http://bugzilla.gnome.org/show_bug.cgi?id=466000
*/
if (GTK_IS_SPIN_BUTTON (widget))
if (GTK_IS_SPIN_BUTTON (widget) &&
gtk_orientable_get_orientation (GTK_ORIENTABLE (widget)) == GTK_ORIENTATION_VERTICAL)
{
GtkBorder borders;
gtk_entry_get_text_area_size (GTK_ENTRY (widget), &x, NULL, &width, NULL);
gtk_entry_get_text_area_size (GTK_ENTRY (widget), NULL, &y, NULL, &height);
_gtk_entry_get_borders (GTK_ENTRY (widget), &borders);
x -= borders.left;
width += borders.left + borders.right;
y -= borders.top;
height += borders.top + borders.bottom;
}
gtk_render_background (context, cr,
x, y, width, height);
gtk_render_frame (context, cr,
x, y, width, height);
gtk_render_background (context, cr, x, y, width, height);
gtk_render_frame (context, cr, x, y, width, height);
gtk_entry_draw_progress (widget, context, cr);
@ -3913,8 +3931,7 @@ gtk_entry_draw (GtkWidget *widget,
GtkEntryPrivate *priv = entry->priv;
int i;
if (gtk_cairo_should_draw_window (cr,
gtk_widget_get_window (widget)))
if (gtk_cairo_should_draw_window (cr, gtk_widget_get_window (widget)))
{
context = gtk_widget_get_style_context (widget);
@ -10651,7 +10668,7 @@ gtk_entry_ensure_progress_node (GtkEntry *entry)
if (priv->progress_node)
return;
widget_node = gtk_widget_get_css_node (GTK_WIDGET (entry));
widget_node = get_entry_node (GTK_WIDGET (entry));
priv->progress_node = gtk_css_node_new ();
gtk_css_node_set_name (priv->progress_node, I_("progress"));
gtk_css_node_set_parent (priv->progress_node, widget_node);

View File

@ -49,6 +49,8 @@
#include "gtktypebuiltins.h"
#include "gtkwidgetpath.h"
#include "gtkwidgetprivate.h"
#include "gtkstylecontextprivate.h"
#include "gtkcssstylepropertyprivate.h"
#include "a11y/gtkspinbuttonaccessible.h"
@ -151,8 +153,9 @@ struct _GtkSpinButtonPrivate
GdkWindow *down_panel;
GdkWindow *up_panel;
GtkStyleContext *down_panel_context;
GtkStyleContext *up_panel_context;
GtkCssNode *entry_node;
GtkCssNode *down_node;
GtkCssNode *up_node;
GdkWindow *click_child;
GdkWindow *in_child;
@ -248,7 +251,6 @@ static void gtk_spin_button_grab_notify (GtkWidget *widget,
gboolean was_grabbed);
static void gtk_spin_button_state_flags_changed (GtkWidget *widget,
GtkStateFlags previous_state);
static void gtk_spin_button_style_updated (GtkWidget *widget);
static gboolean gtk_spin_button_timer (GtkSpinButton *spin_button);
static gboolean gtk_spin_button_stop_spinning (GtkSpinButton *spin);
static void gtk_spin_button_value_changed (GtkAdjustment *adjustment,
@ -257,6 +259,8 @@ static gint gtk_spin_button_key_release (GtkWidget *widget,
GdkEventKey *event);
static gint gtk_spin_button_scroll (GtkWidget *widget,
GdkEventScroll *event);
static void gtk_spin_button_direction_changed (GtkWidget *widget,
GtkTextDirection previous_dir);
static void gtk_spin_button_activate (GtkEntry *entry);
static void gtk_spin_button_get_text_area_size (GtkEntry *entry,
gint *x,
@ -326,7 +330,7 @@ gtk_spin_button_class_init (GtkSpinButtonClass *class)
widget_class->focus_out_event = gtk_spin_button_focus_out;
widget_class->grab_notify = gtk_spin_button_grab_notify;
widget_class->state_flags_changed = gtk_spin_button_state_flags_changed;
widget_class->style_updated = gtk_spin_button_style_updated;
widget_class->direction_changed = gtk_spin_button_direction_changed;
entry_class->activate = gtk_spin_button_activate;
entry_class->get_text_area_size = gtk_spin_button_get_text_area_size;
@ -547,6 +551,7 @@ gtk_spin_button_class_init (GtkSpinButtonClass *class)
add_spin_binding (binding_set, GDK_KEY_Page_Down, GDK_CONTROL_MASK, GTK_SCROLL_START);
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_SPIN_BUTTON_ACCESSIBLE);
gtk_widget_class_set_css_name (widget_class, "spinbutton");
}
static void
@ -682,10 +687,69 @@ swipe_gesture_update (GtkGesture *gesture,
gtk_spin_button_real_spin (spin_button, -vel_y / 20);
}
static void
node_style_changed_cb (GtkCssNode *node,
GtkCssStyle *old_style,
GtkCssStyle *new_style,
GtkWidget *widget)
{
GtkBitmask *changes;
static GtkBitmask *affects_size = NULL;
if (G_UNLIKELY (affects_size == NULL))
affects_size = _gtk_css_style_property_get_mask_affecting (GTK_CSS_AFFECTS_SIZE | GTK_CSS_AFFECTS_CLIP);
changes = _gtk_bitmask_new ();
changes = gtk_css_style_add_difference (changes, old_style, new_style);
if (_gtk_bitmask_intersects (changes, affects_size))
gtk_widget_queue_resize (widget);
else
gtk_widget_queue_draw (widget);
_gtk_bitmask_free (changes);
}
static void
update_node_ordering (GtkSpinButton *spin_button)
{
GtkSpinButtonPrivate *priv = spin_button->priv;
GtkCssNode *first, *middle, *last;
GtkCssNode *widget_node;
widget_node = gtk_widget_get_css_node (GTK_WIDGET (spin_button));
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
{
if (gtk_widget_get_direction (GTK_WIDGET (spin_button)) == GTK_TEXT_DIR_LTR)
{
first = priv->entry_node;
middle = priv->down_node;
last = priv->up_node;
}
else
{
first = priv->up_node;
middle = priv->down_node;
last = priv->entry_node;
}
}
else
{
first = priv->up_node;
middle = priv->entry_node;
last = priv->down_node;
}
gtk_css_node_insert_before (widget_node, first, middle);
gtk_css_node_insert_after (widget_node, last, middle);
}
static void
gtk_spin_button_init (GtkSpinButton *spin_button)
{
GtkSpinButtonPrivate *priv;
GtkCssNode *widget_node;
GtkStyleContext *context;
spin_button->priv = gtk_spin_button_get_instance_private (spin_button);
@ -710,12 +774,38 @@ gtk_spin_button_init (GtkSpinButton *spin_button)
priv->orientation = GTK_ORIENTATION_HORIZONTAL;
gtk_spin_button_set_adjustment (spin_button, NULL);
context = gtk_widget_get_style_context (GTK_WIDGET (spin_button));
gtk_style_context_add_class (context, GTK_STYLE_CLASS_SPINBUTTON);
_gtk_orientable_set_style_classes (GTK_ORIENTABLE (spin_button));
widget_node = gtk_widget_get_css_node (GTK_WIDGET (spin_button));
priv->entry_node = gtk_css_node_new ();
gtk_css_node_set_name (priv->entry_node, I_("entry"));
gtk_css_node_set_parent (priv->entry_node, widget_node);
gtk_css_node_set_state (priv->entry_node, gtk_css_node_get_state (widget_node));
g_signal_connect_object (priv->entry_node, "style-changed", G_CALLBACK (node_style_changed_cb), spin_button, 0);
g_object_unref (priv->entry_node);
priv->down_node = gtk_css_node_new ();
gtk_css_node_set_name (priv->down_node, I_("button"));
gtk_css_node_add_class (priv->down_node, g_quark_from_static_string (GTK_STYLE_CLASS_BUTTON));
gtk_css_node_set_parent (priv->down_node, widget_node);
gtk_css_node_set_state (priv->down_node, gtk_css_node_get_state (widget_node));
g_signal_connect_object (priv->down_node, "style-changed", G_CALLBACK (node_style_changed_cb), spin_button, 0);
g_object_unref (priv->down_node);
priv->up_node = gtk_css_node_new ();
gtk_css_node_set_name (priv->up_node, I_("button"));
gtk_css_node_add_class (priv->up_node, g_quark_from_static_string (GTK_STYLE_CLASS_BUTTON));
gtk_css_node_set_parent (priv->up_node, widget_node);
gtk_css_node_set_state (priv->up_node, gtk_css_node_get_state (widget_node));
g_signal_connect_object (priv->up_node, "style-changed", G_CALLBACK (node_style_changed_cb), spin_button, 0);
g_object_unref (priv->up_node);
update_node_ordering (spin_button);
gtk_spin_button_set_adjustment (spin_button, NULL);
gtk_widget_add_events (GTK_WIDGET (spin_button), GDK_SCROLL_MASK);
priv->swipe_gesture = gtk_gesture_swipe_new (GTK_WIDGET (spin_button));
@ -736,9 +826,6 @@ gtk_spin_button_finalize (GObject *object)
gtk_spin_button_unset_adjustment (spin_button);
g_clear_object (&priv->up_panel_context);
g_clear_object (&priv->down_panel_context);
g_object_unref (priv->swipe_gesture);
G_OBJECT_CLASS (gtk_spin_button_parent_class)->finalize (object);
@ -782,66 +869,6 @@ gtk_spin_button_unmap (GtkWidget *widget)
}
}
static void
gtk_spin_button_panel_nthchildize_context (GtkSpinButton *spin_button,
GtkStyleContext *context,
gboolean is_down_panel)
{
GtkSpinButtonPrivate *priv = spin_button->priv;
GtkWidget *widget = GTK_WIDGET (spin_button);
GtkWidgetPath *path, *siblings_path;
GtkTextDirection direction;
gint up_pos, down_pos;
/* We are a subclass of GtkEntry, which is not a GtkContainer, so we
* have to emulate what gtk_container_get_path_for_child() would do
* for the button panels
*/
path = _gtk_widget_create_path (widget);
siblings_path = gtk_widget_path_new ();
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
{
direction = gtk_widget_get_direction (widget);
/* flip children order for RTL */
if (direction == GTK_TEXT_DIR_RTL)
{
up_pos = gtk_widget_path_append_type (siblings_path, GTK_TYPE_SPIN_BUTTON);
down_pos = gtk_widget_path_append_type (siblings_path, GTK_TYPE_SPIN_BUTTON);
gtk_widget_path_append_type (siblings_path, GTK_TYPE_ENTRY);
}
else
{
gtk_widget_path_append_type (siblings_path, GTK_TYPE_ENTRY);
down_pos = gtk_widget_path_append_type (siblings_path, GTK_TYPE_SPIN_BUTTON);
up_pos = gtk_widget_path_append_type (siblings_path, GTK_TYPE_SPIN_BUTTON);
}
}
else
{
up_pos = gtk_widget_path_append_type (siblings_path, GTK_TYPE_SPIN_BUTTON);
gtk_widget_path_append_type (siblings_path, GTK_TYPE_ENTRY);
down_pos = gtk_widget_path_append_type (siblings_path, GTK_TYPE_SPIN_BUTTON);
}
gtk_widget_path_iter_add_class (siblings_path, up_pos, GTK_STYLE_CLASS_BUTTON);
gtk_widget_path_iter_add_class (siblings_path, down_pos, GTK_STYLE_CLASS_BUTTON);
/* this allows compatibility for themes that use .spinbutton.button */
gtk_widget_path_iter_add_class (siblings_path, up_pos, GTK_STYLE_CLASS_SPINBUTTON);
gtk_widget_path_iter_add_class (siblings_path, down_pos, GTK_STYLE_CLASS_SPINBUTTON);
if (is_down_panel)
gtk_widget_path_append_with_siblings (path, siblings_path, down_pos);
else
gtk_widget_path_append_with_siblings (path, siblings_path, up_pos);
gtk_style_context_set_path (context, path);
gtk_widget_path_unref (path);
gtk_widget_path_unref (siblings_path);
}
static gboolean
gtk_spin_button_panel_at_limit (GtkSpinButton *spin_button,
GdkWindow *panel)
@ -870,7 +897,7 @@ gtk_spin_button_panel_at_limit (GtkSpinButton *spin_button,
static GtkStateFlags
gtk_spin_button_panel_get_state (GtkSpinButton *spin_button,
GdkWindow *panel)
GdkWindow *panel)
{
GtkStateFlags state;
GtkSpinButtonPrivate *priv = spin_button->priv;
@ -897,37 +924,24 @@ gtk_spin_button_panel_get_state (GtkSpinButton *spin_button,
return state;
}
static GtkStyleContext *
gtk_spin_button_panel_get_context (GtkSpinButton *spin_button,
GdkWindow *panel)
static void
update_node_state (GtkSpinButton *spin_button)
{
GtkSpinButtonPrivate *priv = spin_button->priv;
GtkStyleContext **contextp;
contextp = (panel == priv->down_panel) ?
&priv->down_panel_context : &priv->up_panel_context;
if (*contextp == NULL)
{
*contextp = gtk_style_context_new ();
gtk_spin_button_panel_nthchildize_context (spin_button, *contextp,
panel == priv->down_panel);
}
gtk_style_context_set_screen (*contextp, gtk_widget_get_screen (GTK_WIDGET (spin_button)));
gtk_style_context_set_state (*contextp, gtk_spin_button_panel_get_state (spin_button, panel));
return *contextp;
gtk_css_node_set_state (priv->up_node,
gtk_spin_button_panel_get_state (spin_button, priv->up_panel));
gtk_css_node_set_state (priv->down_node,
gtk_spin_button_panel_get_state (spin_button, priv->down_panel));
}
#include "gtkcsssectionprivate.h"
static void
gtk_spin_button_panel_get_size (GtkSpinButton *spin_button,
GdkWindow *panel,
gint *width,
gint *height)
GdkWindow *panel,
gint *width,
gint *height)
{
GtkSpinButtonPrivate *priv = spin_button->priv;
GtkBorder button_padding, button_border;
GtkStyleContext *context;
GtkStateFlags state;
@ -936,12 +950,18 @@ gtk_spin_button_panel_get_size (GtkSpinButton *spin_button,
gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &w, &h);
icon_size = MAX (w, h);
context = gtk_spin_button_panel_get_context (spin_button, panel);
context = gtk_widget_get_style_context (GTK_WIDGET (spin_button));
state = gtk_style_context_get_state (context);
if (panel == priv->up_panel)
gtk_style_context_save_to_node (context, priv->up_node);
else
gtk_style_context_save_to_node (context, priv->down_node);
gtk_style_context_get_padding (context, state, &button_padding);
gtk_style_context_get_border (context, state, &button_border);
gtk_style_context_restore (context);
if (width)
*width = icon_size + button_padding.left + button_padding.right +
button_border.left + button_border.right;
@ -1036,12 +1056,11 @@ gtk_spin_button_panel_draw (GtkSpinButton *spin_button,
GtkIconHelper *icon_helper;
widget = GTK_WIDGET (spin_button);
context = gtk_widget_get_style_context (widget);
cairo_save (cr);
gtk_cairo_transform_to_window (cr, widget, panel);
context = gtk_spin_button_panel_get_context (spin_button, panel);
height = gdk_window_get_height (panel);
width = gdk_window_get_width (panel);
@ -1050,25 +1069,29 @@ gtk_spin_button_panel_draw (GtkSpinButton *spin_button,
_gtk_icon_helper_set_use_fallback (icon_helper, TRUE);
if (panel == priv->down_panel)
_gtk_icon_helper_set_icon_name (icon_helper, "list-remove-symbolic", GTK_ICON_SIZE_MENU);
{
gtk_style_context_save_to_node (context, priv->down_node);
_gtk_icon_helper_set_icon_name (icon_helper, "list-remove-symbolic", GTK_ICON_SIZE_MENU);
}
else
_gtk_icon_helper_set_icon_name (icon_helper, "list-add-symbolic", GTK_ICON_SIZE_MENU);
{
gtk_style_context_save_to_node (context, priv->up_node);
_gtk_icon_helper_set_icon_name (icon_helper, "list-add-symbolic", GTK_ICON_SIZE_MENU);
}
_gtk_icon_helper_get_size (icon_helper, context,
&icon_width, &icon_height);
_gtk_icon_helper_get_size (icon_helper, context, &icon_width, &icon_height);
gtk_render_background (context, cr,
0, 0, width, height);
gtk_render_frame (context, cr,
0, 0, width, height);
gtk_render_background (context, cr, 0, 0, width, height);
gtk_render_frame (context, cr, 0, 0, width, height);
x = floor ((width - icon_width) / 2.0);
y = floor ((height - icon_height) / 2.0);
_gtk_icon_helper_draw (icon_helper, context, cr,
x, y);
_gtk_icon_helper_draw (icon_helper, context, cr, x, y);
cairo_restore (cr);
gtk_style_context_restore (context);
g_object_unref (icon_helper);
}
@ -1165,6 +1188,7 @@ adjustment_changed_cb (GtkAdjustment *adjustment, gpointer data)
GtkSpinButtonPrivate *priv = spin_button->priv;
priv->timer_step = gtk_adjustment_get_step_increment (priv->adjustment);
update_node_state (spin_button);
gtk_widget_queue_resize (GTK_WIDGET (spin_button));
}
@ -1186,8 +1210,8 @@ gtk_spin_button_unset_adjustment (GtkSpinButton *spin_button)
}
static void
gtk_spin_button_set_orientation (GtkSpinButton *spin,
GtkOrientation orientation)
gtk_spin_button_set_orientation (GtkSpinButton *spin,
GtkOrientation orientation)
{
GtkEntry *entry = GTK_ENTRY (spin);
GtkSpinButtonPrivate *priv = spin->priv;
@ -1206,6 +1230,8 @@ gtk_spin_button_set_orientation (GtkSpinButton *spin,
gtk_entry_get_alignment (entry) == 0.5)
gtk_entry_set_alignment (entry, 0.0);
update_node_ordering (spin);
g_object_notify (G_OBJECT (spin), "orientation");
gtk_widget_queue_resize (GTK_WIDGET (spin));
}
@ -1240,8 +1266,12 @@ gtk_spin_button_get_preferred_width (GtkWidget *widget,
GtkSpinButton *spin_button = GTK_SPIN_BUTTON (widget);
GtkSpinButtonPrivate *priv = spin_button->priv;
GtkEntry *entry = GTK_ENTRY (widget);
GtkStyleContext *context;
context = gtk_widget_get_style_context (widget);
gtk_style_context_save_to_node (context, priv->entry_node);
GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->get_preferred_width (widget, minimum, natural);
gtk_style_context_restore (context);
if (gtk_entry_get_width_chars (entry) < 0)
{
@ -1299,11 +1329,15 @@ gtk_spin_button_get_preferred_height_and_baseline_for_width (GtkWidget *widget,
{
GtkSpinButton *spin_button = GTK_SPIN_BUTTON (widget);
GtkSpinButtonPrivate *priv = spin_button->priv;
GtkStyleContext *context;
context = gtk_widget_get_style_context (widget);
gtk_style_context_save_to_node (context, priv->entry_node);
GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->get_preferred_height_and_baseline_for_width (widget, width,
minimum, natural,
minimum_baseline,
natural_baseline);
gtk_style_context_restore (context);
if (priv->orientation == GTK_ORIENTATION_VERTICAL)
{
@ -1338,9 +1372,14 @@ gtk_spin_button_size_allocate (GtkWidget *widget,
GtkSpinButton *spin = GTK_SPIN_BUTTON (widget);
GtkSpinButtonPrivate *priv = spin->priv;
GtkAllocation down_panel_allocation, up_panel_allocation;
GtkStyleContext *context;
gtk_widget_set_allocation (widget, allocation);
context = gtk_widget_get_style_context (widget);
gtk_style_context_save_to_node (context, priv->entry_node);
GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->size_allocate (widget, allocation);
gtk_style_context_restore (context);
gtk_spin_button_panel_get_allocations (spin, &down_panel_allocation, &up_panel_allocation);
@ -1363,13 +1402,18 @@ gtk_spin_button_size_allocate (GtkWidget *widget,
}
static gint
gtk_spin_button_draw (GtkWidget *widget,
cairo_t *cr)
gtk_spin_button_draw (GtkWidget *widget,
cairo_t *cr)
{
GtkSpinButton *spin = GTK_SPIN_BUTTON (widget);
GtkSpinButtonPrivate *priv = spin->priv;
GtkStyleContext *context;
context = gtk_widget_get_style_context (widget);
gtk_style_context_save_to_node (context, priv->entry_node);
GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->draw (widget, cr);
gtk_style_context_restore (context);
/* Draw the buttons */
gtk_spin_button_panel_draw (spin, cr, priv->down_panel);
@ -1385,10 +1429,11 @@ gtk_spin_button_enter_notify (GtkWidget *widget,
GtkSpinButton *spin = GTK_SPIN_BUTTON (widget);
GtkSpinButtonPrivate *priv = spin->priv;
if ((event->window == priv->down_panel) ||
(event->window == priv->up_panel))
if (event->window == priv->down_panel ||
event->window == priv->up_panel)
{
priv->in_child = event->window;
update_node_state (spin);
gtk_widget_queue_draw (GTK_WIDGET (spin));
}
@ -1405,6 +1450,7 @@ gtk_spin_button_leave_notify (GtkWidget *widget,
if (priv->in_child != NULL)
{
priv->in_child = NULL;
update_node_state (spin);
gtk_widget_queue_draw (GTK_WIDGET (spin));
}
@ -1445,25 +1491,8 @@ gtk_spin_button_state_flags_changed (GtkWidget *widget,
if (gtk_spin_button_stop_spinning (spin))
gtk_widget_queue_draw (GTK_WIDGET (spin));
}
}
static void
gtk_spin_button_style_updated (GtkWidget *widget)
{
GtkSpinButton *spin = GTK_SPIN_BUTTON (widget);
GtkSpinButtonPrivate *priv = spin->priv;
if (priv->down_panel_context)
gtk_spin_button_panel_nthchildize_context (spin,
priv->down_panel_context,
TRUE);
if (priv->up_panel_context)
gtk_spin_button_panel_nthchildize_context (spin,
priv->up_panel_context,
FALSE);
GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->style_updated (widget);
update_node_state (spin);
}
static gint
@ -1703,6 +1732,8 @@ gtk_spin_button_value_changed (GtkAdjustment *adjustment,
g_signal_emit (spin_button, spinbutton_signals[VALUE_CHANGED], 0);
update_node_state (spin_button);
gtk_widget_queue_draw (GTK_WIDGET (spin_button));
g_object_notify (G_OBJECT (spin_button), "value");
@ -1864,11 +1895,11 @@ gtk_spin_button_get_text_area_size (GtkEntry *entry,
GTK_ENTRY_CLASS (gtk_spin_button_parent_class)->get_text_area_size (entry, x, y, width, height);
gtk_spin_button_panel_get_size (GTK_SPIN_BUTTON (entry), priv->up_panel, &up_panel_width, &up_panel_height);
gtk_spin_button_panel_get_size (GTK_SPIN_BUTTON (entry), priv->down_panel, &down_panel_width, &down_panel_height);
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
{
gtk_spin_button_panel_get_size (GTK_SPIN_BUTTON (entry), priv->up_panel, &up_panel_width, &up_panel_height);
gtk_spin_button_panel_get_size (GTK_SPIN_BUTTON (entry), priv->down_panel, &down_panel_width, &down_panel_height);
if (gtk_widget_get_direction (GTK_WIDGET (entry)) == GTK_TEXT_DIR_RTL)
{
if (x)
@ -2801,9 +2832,9 @@ gtk_spin_button_update (GtkSpinButton *spin_button)
}
void
_gtk_spin_button_get_panels (GtkSpinButton *spin_button,
GdkWindow **down_panel,
GdkWindow **up_panel)
_gtk_spin_button_get_panels (GtkSpinButton *spin_button,
GdkWindow **down_panel,
GdkWindow **up_panel)
{
if (down_panel != NULL)
*down_panel = spin_button->priv->down_panel;
@ -2811,3 +2842,12 @@ _gtk_spin_button_get_panels (GtkSpinButton *spin_button,
if (up_panel != NULL)
*up_panel = spin_button->priv->up_panel;
}
static void
gtk_spin_button_direction_changed (GtkWidget *widget,
GtkTextDirection previous_dir)
{
update_node_ordering (GTK_SPIN_BUTTON (widget));
GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->direction_changed (widget, previous_dir);
}

View File

@ -791,9 +791,9 @@ GtkColorButton.button {
* GtkSpinButton *
*****************/
.spinbutton {
spinbutton {
&:not(.vertical) {
.button {
button {
background-image: none;
border-style: none none none solid;
border-color: transparentize($borders_color, 0.7);
@ -828,7 +828,7 @@ GtkColorButton.button {
// OSD horizontal
.osd &:not(.vertical) {
.button {
button {
@include button(undecorated);
color: $osd_fg_color;
border-style: none none none solid;
@ -866,7 +866,7 @@ GtkColorButton.button {
// Vertical
&.vertical {
.button {
button {
padding-top: 8px; // Same vertical padding as image-buttons
padding-bottom: 8px; //
&:first-child {
@ -910,7 +910,7 @@ GtkColorButton.button {
}
// OSD vertical
.osd &.vertical .button:first-child {
.osd &.vertical button:first-child {
@include button(osd);
&:hover { @include button(osd-hover);}
&:active { @include button(osd-active); }

View File

@ -1245,34 +1245,34 @@ GtkColorButton.button, .header-bar GtkColorButton.button.titlebutton,
/*****************
* GtkSpinButton *
*****************/
.spinbutton:not(.vertical) .button {
spinbutton:not(.vertical) button {
background-image: none;
border-style: none none none solid;
border-color: rgba(28, 31, 31, 0.3);
color: #dadad9;
border-radius: 0;
box-shadow: none; }
.spinbutton:not(.vertical) .button:dir(rtl) {
spinbutton:not(.vertical) button:dir(rtl) {
border-style: none solid none none; }
.spinbutton:not(.vertical) .button:hover {
spinbutton:not(.vertical) button:hover {
color: #eeeeec;
background-color: rgba(238, 238, 236, 0.05); }
.spinbutton:not(.vertical) .button:insensitive {
spinbutton:not(.vertical) button:insensitive {
color: rgba(148, 151, 150, 0.3); }
.spinbutton:not(.vertical) .button:active {
spinbutton:not(.vertical) button:active {
box-shadow: inset 0 2px 3px -1px rgba(0, 0, 0, 0.2);
background-color: rgba(0, 0, 0, 0.1); }
.spinbutton:not(.vertical) .button:backdrop {
spinbutton:not(.vertical) button:backdrop {
color: #8a8c8b;
border-color: rgba(31, 34, 34, 0.3);
background-color: transparent; }
.spinbutton:not(.vertical) .button:backdrop:insensitive {
spinbutton:not(.vertical) button:backdrop:insensitive {
background-image: none;
color: rgba(93, 103, 103, 0.3);
border-style: none none none solid; }
.spinbutton:not(.vertical) .button:backdrop:insensitive:dir(rtl) {
spinbutton:not(.vertical) button:backdrop:insensitive:dir(rtl) {
border-style: none solid none none; }
.osd .spinbutton:not(.vertical) .button {
.osd spinbutton:not(.vertical) button {
border-color: transparent;
background-color: transparent;
background-image: none;
@ -1285,9 +1285,9 @@ GtkColorButton.button, .header-bar GtkColorButton.button.titlebutton,
border-radius: 0;
box-shadow: none;
icon-shadow: 0 1px black; }
.osd .spinbutton:not(.vertical) .button:dir(rtl) {
.osd spinbutton:not(.vertical) button:dir(rtl) {
border-style: none solid none none; }
.osd .spinbutton:not(.vertical) .button:hover {
.osd spinbutton:not(.vertical) button:hover {
border-color: transparent;
background-color: transparent;
background-image: none;
@ -1299,7 +1299,7 @@ GtkColorButton.button, .header-bar GtkColorButton.button.titlebutton,
background-color: rgba(238, 238, 236, 0.1);
icon-shadow: 0 1px black;
box-shadow: none; }
.osd .spinbutton:not(.vertical) .button:backdrop {
.osd spinbutton:not(.vertical) button:backdrop {
border-color: transparent;
background-color: transparent;
background-image: none;
@ -1310,7 +1310,7 @@ GtkColorButton.button, .header-bar GtkColorButton.button.titlebutton,
border-color: rgba(0, 0, 0, 0.5);
icon-shadow: none;
box-shadow: none; }
.osd .spinbutton:not(.vertical) .button:insensitive {
.osd spinbutton:not(.vertical) button:insensitive {
border-color: transparent;
background-color: transparent;
background-image: none;
@ -1321,14 +1321,14 @@ GtkColorButton.button, .header-bar GtkColorButton.button.titlebutton,
border-color: rgba(0, 0, 0, 0.5);
icon-shadow: none;
box-shadow: none; }
.osd .spinbutton:not(.vertical) .button:last-child {
.osd spinbutton:not(.vertical) button:last-child {
border-radius: 0 3px 3px 0; }
.osd .spinbutton:not(.vertical) .button:dir(rtl):first-child {
.osd spinbutton:not(.vertical) button:dir(rtl):first-child {
border-radius: 3px 0 0 3px; }
.spinbutton.vertical .button {
spinbutton.vertical button {
padding-top: 8px;
padding-bottom: 8px; }
.spinbutton.vertical .button:first-child {
spinbutton.vertical button:first-child {
color: #eeeeec;
outline-color: rgba(238, 238, 236, 0.3);
border-color: #1c1f1f;
@ -1336,7 +1336,7 @@ GtkColorButton.button, .header-bar GtkColorButton.button.titlebutton,
text-shadow: 0 -1px rgba(0, 0, 0, 0.81176);
icon-shadow: 0 -1px rgba(0, 0, 0, 0.81176);
box-shadow: inset 0 1px rgba(255, 255, 255, 0.1); }
.spinbutton.vertical .button:first-child:active {
spinbutton.vertical button:first-child:active {
color: #eeeeec;
outline-color: rgba(238, 238, 236, 0.3);
border-color: #1c1f1f;
@ -1344,7 +1344,7 @@ GtkColorButton.button, .header-bar GtkColorButton.button.titlebutton,
text-shadow: 0 -1px rgba(0, 0, 0, 0.89176);
icon-shadow: 0 -1px rgba(0, 0, 0, 0.89176);
box-shadow: inset 0 1px rgba(0, 0, 0, 0.07), inset 0 2px 1px -2px rgba(0, 0, 0, 0.6); }
.spinbutton.vertical .button:first-child:hover {
spinbutton.vertical button:first-child:hover {
color: #eeeeec;
outline-color: rgba(238, 238, 236, 0.3);
border-color: #1c1f1f;
@ -1352,44 +1352,42 @@ GtkColorButton.button, .header-bar GtkColorButton.button.titlebutton,
text-shadow: 0 -1px rgba(0, 0, 0, 0.77976);
icon-shadow: 0 -1px rgba(0, 0, 0, 0.77976);
box-shadow: inset 0 1px rgba(255, 255, 255, 0.1); }
.spinbutton.vertical .button:first-child:insensitive {
spinbutton.vertical button:first-child:insensitive {
color: #949796;
border-color: #1c1f1f;
background-image: linear-gradient(to bottom, #333636);
text-shadow: none;
icon-shadow: none;
box-shadow: inset 0 1px rgba(255, 255, 255, 0); }
.spinbutton.vertical .button:first-child:insensitive > .label, .spinbutton.vertical .header-bar .button.titlebutton:first-child:insensitive > .label,
.spinbutton.vertical .titlebar .button.titlebutton:first-child:insensitive > .label {
spinbutton.vertical button:first-child:insensitive > .label {
color: inherit; }
.spinbutton.vertical .button:first-child:backdrop {
spinbutton.vertical button:first-child:backdrop {
color: #949796;
border-color: #1f2222;
background-image: linear-gradient(to bottom, #393f3f);
text-shadow: none;
icon-shadow: none;
box-shadow: inset 0 1px rgba(255, 255, 255, 0); }
.spinbutton.vertical .button:first-child:backdrop:insensitive {
spinbutton.vertical button:first-child:backdrop:insensitive {
color: #5d6767;
border-color: #1f2222;
background-image: linear-gradient(to bottom, #333636);
text-shadow: none;
icon-shadow: none;
box-shadow: inset 0 1px rgba(255, 255, 255, 0); }
.spinbutton.vertical .button:first-child:backdrop:insensitive > .label, .spinbutton.vertical .header-bar .button.titlebutton:first-child:backdrop:insensitive > .label,
.spinbutton.vertical .titlebar .button.titlebutton:first-child:backdrop:insensitive > .label {
spinbutton.vertical button:first-child:backdrop:insensitive > .label {
color: inherit; }
.spinbutton.vertical.entry {
spinbutton.vertical.entry {
border-radius: 0;
padding-left: 3px;
padding-right: 3px; }
.spinbutton.vertical .button:first-child, .spinbutton.vertical .button:first-child:active, .spinbutton.vertical .button:first-child:hover, .spinbutton.vertical .button:first-child:insensitive, .spinbutton.vertical .button:first-child:backdrop {
spinbutton.vertical button:first-child, spinbutton.vertical button:first-child:active, spinbutton.vertical button:first-child:hover, spinbutton.vertical button:first-child:insensitive, spinbutton.vertical button:first-child:backdrop {
border-radius: 3px 3px 0 0;
border-style: solid solid none solid; }
.spinbutton.vertical .button:last-child {
spinbutton.vertical button:last-child {
border-radius: 0 0 3px 3px;
border-style: none solid solid solid; }
.osd .spinbutton.vertical .button:first-child {
.osd spinbutton.vertical button:first-child {
color: #eeeeec;
border-color: rgba(0, 0, 0, 0.7);
background-image: linear-gradient(to bottom, rgba(32, 37, 38, 0.7));
@ -1398,7 +1396,7 @@ GtkColorButton.button, .header-bar GtkColorButton.button.titlebutton,
text-shadow: 0 1px black;
icon-shadow: 0 1px black;
outline-color: rgba(238, 238, 236, 0.3); }
.osd .spinbutton.vertical .button:first-child:hover {
.osd spinbutton.vertical button:first-child:hover {
color: white;
border-color: rgba(0, 0, 0, 0.7);
background-image: linear-gradient(to bottom, rgba(60, 69, 71, 0.7));
@ -1407,7 +1405,7 @@ GtkColorButton.button, .header-bar GtkColorButton.button.titlebutton,
text-shadow: 0 1px black;
icon-shadow: 0 1px black;
outline-color: rgba(238, 238, 236, 0.3); }
.osd .spinbutton.vertical .button:first-child:active {
.osd spinbutton.vertical button:first-child:active {
color: white;
border-color: rgba(0, 0, 0, 0.7);
background-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.7));
@ -1416,7 +1414,7 @@ GtkColorButton.button, .header-bar GtkColorButton.button.titlebutton,
text-shadow: none;
icon-shadow: none;
outline-color: rgba(238, 238, 236, 0.3); }
.osd .spinbutton.vertical .button:first-child:insensitive {
.osd spinbutton.vertical button:first-child:insensitive {
color: #878a89;
border-color: rgba(0, 0, 0, 0.7);
background-image: linear-gradient(to bottom, rgba(53, 57, 58, 0.5));
@ -1424,7 +1422,7 @@ GtkColorButton.button, .header-bar GtkColorButton.button.titlebutton,
box-shadow: none;
text-shadow: none;
icon-shadow: none; }
.osd .spinbutton.vertical .button:first-child:backdrop {
.osd spinbutton.vertical button:first-child:backdrop {
color: #eeeeec;
border-color: rgba(0, 0, 0, 0.7);
background-image: linear-gradient(to bottom, rgba(32, 37, 38, 0.7));
@ -1432,7 +1430,7 @@ GtkColorButton.button, .header-bar GtkColorButton.button.titlebutton,
box-shadow: none;
text-shadow: none;
icon-shadow: none; }
GtkTreeView .spinbutton entry, GtkTreeView .spinbutton entry:focus {
GtkTreeView spinbutton entry, GtkTreeView spinbutton entry:focus {
padding: 1px;
border-width: 1px 0;
border-color: #215d9c;

View File

@ -1245,34 +1245,34 @@ GtkColorButton.button, .header-bar GtkColorButton.button.titlebutton,
/*****************
* GtkSpinButton *
*****************/
.spinbutton:not(.vertical) .button {
spinbutton:not(.vertical) button {
background-image: none;
border-style: none none none solid;
border-color: rgba(161, 161, 161, 0.3);
color: #43484a;
border-radius: 0;
box-shadow: none; }
.spinbutton:not(.vertical) .button:dir(rtl) {
spinbutton:not(.vertical) button:dir(rtl) {
border-style: none solid none none; }
.spinbutton:not(.vertical) .button:hover {
spinbutton:not(.vertical) button:hover {
color: #2e3436;
background-color: rgba(46, 52, 54, 0.05); }
.spinbutton:not(.vertical) .button:insensitive {
spinbutton:not(.vertical) button:insensitive {
color: rgba(142, 145, 146, 0.3); }
.spinbutton:not(.vertical) .button:active {
spinbutton:not(.vertical) button:active {
box-shadow: inset 0 2px 3px -1px rgba(0, 0, 0, 0.2);
background-color: rgba(0, 0, 0, 0.1); }
.spinbutton:not(.vertical) .button:backdrop {
spinbutton:not(.vertical) button:backdrop {
color: #999c9d;
border-color: rgba(169, 169, 169, 0.3);
background-color: transparent; }
.spinbutton:not(.vertical) .button:backdrop:insensitive {
spinbutton:not(.vertical) button:backdrop:insensitive {
background-image: none;
color: rgba(199, 199, 199, 0.3);
border-style: none none none solid; }
.spinbutton:not(.vertical) .button:backdrop:insensitive:dir(rtl) {
spinbutton:not(.vertical) button:backdrop:insensitive:dir(rtl) {
border-style: none solid none none; }
.osd .spinbutton:not(.vertical) .button {
.osd spinbutton:not(.vertical) button {
border-color: transparent;
background-color: transparent;
background-image: none;
@ -1285,9 +1285,9 @@ GtkColorButton.button, .header-bar GtkColorButton.button.titlebutton,
border-radius: 0;
box-shadow: none;
icon-shadow: 0 1px black; }
.osd .spinbutton:not(.vertical) .button:dir(rtl) {
.osd spinbutton:not(.vertical) button:dir(rtl) {
border-style: none solid none none; }
.osd .spinbutton:not(.vertical) .button:hover {
.osd spinbutton:not(.vertical) button:hover {
border-color: transparent;
background-color: transparent;
background-image: none;
@ -1299,7 +1299,7 @@ GtkColorButton.button, .header-bar GtkColorButton.button.titlebutton,
background-color: rgba(238, 238, 236, 0.1);
icon-shadow: 0 1px black;
box-shadow: none; }
.osd .spinbutton:not(.vertical) .button:backdrop {
.osd spinbutton:not(.vertical) button:backdrop {
border-color: transparent;
background-color: transparent;
background-image: none;
@ -1310,7 +1310,7 @@ GtkColorButton.button, .header-bar GtkColorButton.button.titlebutton,
border-color: rgba(0, 0, 0, 0.5);
icon-shadow: none;
box-shadow: none; }
.osd .spinbutton:not(.vertical) .button:insensitive {
.osd spinbutton:not(.vertical) button:insensitive {
border-color: transparent;
background-color: transparent;
background-image: none;
@ -1321,14 +1321,14 @@ GtkColorButton.button, .header-bar GtkColorButton.button.titlebutton,
border-color: rgba(0, 0, 0, 0.5);
icon-shadow: none;
box-shadow: none; }
.osd .spinbutton:not(.vertical) .button:last-child {
.osd spinbutton:not(.vertical) button:last-child {
border-radius: 0 3px 3px 0; }
.osd .spinbutton:not(.vertical) .button:dir(rtl):first-child {
.osd spinbutton:not(.vertical) button:dir(rtl):first-child {
border-radius: 3px 0 0 3px; }
.spinbutton.vertical .button {
spinbutton.vertical button {
padding-top: 8px;
padding-bottom: 8px; }
.spinbutton.vertical .button:first-child {
spinbutton.vertical button:first-child {
color: #2e3436;
outline-color: rgba(46, 52, 54, 0.3);
border-color: #a1a1a1;
@ -1336,7 +1336,7 @@ GtkColorButton.button, .header-bar GtkColorButton.button.titlebutton,
text-shadow: 0 1px rgba(255, 255, 255, 0.76923);
icon-shadow: 0 1px rgba(255, 255, 255, 0.76923);
box-shadow: inset 0 1px white; }
.spinbutton.vertical .button:first-child:active {
spinbutton.vertical button:first-child:active {
color: #2e3436;
outline-color: rgba(46, 52, 54, 0.3);
border-color: #a1a1a1;
@ -1344,7 +1344,7 @@ GtkColorButton.button, .header-bar GtkColorButton.button.titlebutton,
text-shadow: 0 1px rgba(255, 255, 255, 0.76923);
icon-shadow: 0 1px rgba(255, 255, 255, 0.76923);
box-shadow: inset 0 1px rgba(0, 0, 0, 0.07), inset 0 2px 1px -2px rgba(0, 0, 0, 0.6); }
.spinbutton.vertical .button:first-child:hover {
spinbutton.vertical button:first-child:hover {
color: #2e3436;
outline-color: rgba(46, 52, 54, 0.3);
border-color: #a1a1a1;
@ -1352,44 +1352,42 @@ GtkColorButton.button, .header-bar GtkColorButton.button.titlebutton,
text-shadow: 0 1px rgba(255, 255, 255, 0.76923);
icon-shadow: 0 1px rgba(255, 255, 255, 0.76923);
box-shadow: inset 0 1px white; }
.spinbutton.vertical .button:first-child:insensitive {
spinbutton.vertical button:first-child:insensitive {
color: #8e9192;
border-color: #a1a1a1;
background-image: linear-gradient(to bottom, #f4f4f4);
text-shadow: none;
icon-shadow: none;
box-shadow: inset 0 1px rgba(255, 255, 255, 0); }
.spinbutton.vertical .button:first-child:insensitive > .label, .spinbutton.vertical .header-bar .button.titlebutton:first-child:insensitive > .label,
.spinbutton.vertical .titlebar .button.titlebutton:first-child:insensitive > .label {
spinbutton.vertical button:first-child:insensitive > .label {
color: inherit; }
.spinbutton.vertical .button:first-child:backdrop {
spinbutton.vertical button:first-child:backdrop {
color: #8e9192;
border-color: darkgray;
background-image: linear-gradient(to bottom, #ededed);
text-shadow: none;
icon-shadow: none;
box-shadow: inset 0 1px rgba(255, 255, 255, 0); }
.spinbutton.vertical .button:first-child:backdrop:insensitive {
spinbutton.vertical button:first-child:backdrop:insensitive {
color: #c7c7c7;
border-color: darkgray;
background-image: linear-gradient(to bottom, #f4f4f4);
text-shadow: none;
icon-shadow: none;
box-shadow: inset 0 1px rgba(255, 255, 255, 0); }
.spinbutton.vertical .button:first-child:backdrop:insensitive > .label, .spinbutton.vertical .header-bar .button.titlebutton:first-child:backdrop:insensitive > .label,
.spinbutton.vertical .titlebar .button.titlebutton:first-child:backdrop:insensitive > .label {
spinbutton.vertical button:first-child:backdrop:insensitive > .label {
color: inherit; }
.spinbutton.vertical.entry {
spinbutton.vertical.entry {
border-radius: 0;
padding-left: 3px;
padding-right: 3px; }
.spinbutton.vertical .button:first-child, .spinbutton.vertical .button:first-child:active, .spinbutton.vertical .button:first-child:hover, .spinbutton.vertical .button:first-child:insensitive, .spinbutton.vertical .button:first-child:backdrop {
spinbutton.vertical button:first-child, spinbutton.vertical button:first-child:active, spinbutton.vertical button:first-child:hover, spinbutton.vertical button:first-child:insensitive, spinbutton.vertical button:first-child:backdrop {
border-radius: 3px 3px 0 0;
border-style: solid solid none solid; }
.spinbutton.vertical .button:last-child {
spinbutton.vertical button:last-child {
border-radius: 0 0 3px 3px;
border-style: none solid solid solid; }
.osd .spinbutton.vertical .button:first-child {
.osd spinbutton.vertical button:first-child {
color: #eeeeec;
border-color: rgba(0, 0, 0, 0.7);
background-image: linear-gradient(to bottom, rgba(32, 37, 38, 0.7));
@ -1398,7 +1396,7 @@ GtkColorButton.button, .header-bar GtkColorButton.button.titlebutton,
text-shadow: 0 1px black;
icon-shadow: 0 1px black;
outline-color: rgba(238, 238, 236, 0.3); }
.osd .spinbutton.vertical .button:first-child:hover {
.osd spinbutton.vertical button:first-child:hover {
color: white;
border-color: rgba(0, 0, 0, 0.7);
background-image: linear-gradient(to bottom, rgba(60, 69, 71, 0.7));
@ -1407,7 +1405,7 @@ GtkColorButton.button, .header-bar GtkColorButton.button.titlebutton,
text-shadow: 0 1px black;
icon-shadow: 0 1px black;
outline-color: rgba(238, 238, 236, 0.3); }
.osd .spinbutton.vertical .button:first-child:active {
.osd spinbutton.vertical button:first-child:active {
color: white;
border-color: rgba(0, 0, 0, 0.7);
background-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.7));
@ -1416,7 +1414,7 @@ GtkColorButton.button, .header-bar GtkColorButton.button.titlebutton,
text-shadow: none;
icon-shadow: none;
outline-color: rgba(238, 238, 236, 0.3); }
.osd .spinbutton.vertical .button:first-child:insensitive {
.osd spinbutton.vertical button:first-child:insensitive {
color: #878a89;
border-color: rgba(0, 0, 0, 0.7);
background-image: linear-gradient(to bottom, rgba(53, 57, 58, 0.5));
@ -1424,7 +1422,7 @@ GtkColorButton.button, .header-bar GtkColorButton.button.titlebutton,
box-shadow: none;
text-shadow: none;
icon-shadow: none; }
.osd .spinbutton.vertical .button:first-child:backdrop {
.osd spinbutton.vertical button:first-child:backdrop {
color: #eeeeec;
border-color: rgba(0, 0, 0, 0.7);
background-image: linear-gradient(to bottom, rgba(32, 37, 38, 0.7));
@ -1432,7 +1430,7 @@ GtkColorButton.button, .header-bar GtkColorButton.button.titlebutton,
box-shadow: none;
text-shadow: none;
icon-shadow: none; }
GtkTreeView .spinbutton entry, GtkTreeView .spinbutton entry:focus {
GtkTreeView spinbutton entry, GtkTreeView spinbutton entry:focus {
padding: 1px;
border-width: 1px 0;
border-color: #4a90d9;