[gimp/gimp-2-10] app: improve compact spin-scale behavior
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] app: improve compact spin-scale behavior
- Date: Tue, 7 Jan 2020 18:58:22 +0000 (UTC)
commit 7fdfe791dd2348d50cbe51cee72d8c4bec8ddd36
Author: Ell <ell_se yahoo com>
Date: Tue Jan 7 20:45:42 2020 +0200
app: improve compact spin-scale behavior
GimpSpinScale now always grabs focus in response to a button press
in compact mode. However, like before, the left button is always
used for absolute adjustment, even when pressed over the text,
instead of controlling the text cursor.
The right button is now used both for relative adjustment, and to
select the entire text. Alternatively, the same can be achieved
with Shift+left-button.
The middle button has no special function.
Regardless, if a button-press event over the text triggers a
context menu, this overrides any of the above.
app/config/gimprc-blurbs.h | 4 +--
app/widgets/gimpspinscale.c | 63 +++++++++++++++++++++------------------------
2 files changed, 30 insertions(+), 37 deletions(-)
---
diff --git a/app/config/gimprc-blurbs.h b/app/config/gimprc-blurbs.h
index 43d70407ce..9702d716b0 100644
--- a/app/config/gimprc-blurbs.h
+++ b/app/config/gimprc-blurbs.h
@@ -50,9 +50,7 @@ _("How to handle embedded color profiles when opening a file.")
_("Sets the default folder path for all color profile file dialogs.")
#define COMPACT_SLIDERS_BLURB \
-_("Use compact style for sliders. In this mode, left-click is used for " \
- "absolute adjustment, middle-click is used for relative adjustment, and " \
- "right-click is used for manual entry.")
+_("Use compact style for sliders.")
#define CURSOR_MODE_BLURB \
_("Sets the type of mouse pointers to use.")
diff --git a/app/widgets/gimpspinscale.c b/app/widgets/gimpspinscale.c
index 83acc1cc9f..cff875a803 100644
--- a/app/widgets/gimpspinscale.c
+++ b/app/widgets/gimpspinscale.c
@@ -31,6 +31,7 @@
#include "widgets-types.h"
#include "gimpspinscale.h"
+#include "gimpwidgets-utils.h"
#include "gimp-intl.h"
@@ -571,10 +572,10 @@ gimp_spin_scale_expose (GtkWidget *widget,
}
static SpinScaleTarget
-gimp_spin_scale_get_target (GtkWidget *widget,
- gdouble x,
- gdouble y,
- gint button)
+gimp_spin_scale_get_target (GtkWidget *widget,
+ gdouble x,
+ gdouble y,
+ GdkEventButton *event)
{
GimpSpinScalePrivate *private = GET_PRIVATE (widget);
GtkAllocation allocation;
@@ -582,6 +583,9 @@ gimp_spin_scale_get_target (GtkWidget *widget,
gint layout_x;
gint layout_y;
+ if (private->compact && ! event)
+ return TARGET_UPPER;
+
gtk_widget_get_allocation (widget, &allocation);
gtk_entry_get_layout_offsets (GTK_ENTRY (widget), &layout_x, &layout_y);
pango_layout_get_pixel_extents (gtk_entry_get_layout (GTK_ENTRY (widget)),
@@ -589,22 +593,26 @@ gimp_spin_scale_get_target (GtkWidget *widget,
if (x >= layout_x && x < layout_x + logical.width &&
y >= layout_y && y < layout_y + logical.height &&
- (! private->compact || gtk_widget_has_focus (widget)))
+ (! private->compact ||
+ gdk_event_triggers_context_menu ((GdkEvent *) event)))
{
return TARGET_NUMBER;
}
if (private->compact)
{
- switch (button)
+ switch (event->button)
{
- default:
- return TARGET_UPPER;
+ case 1:
+ if (event->state & gimp_get_extend_selection_mask ())
+ return TARGET_LOWER;
+ else
+ return TARGET_UPPER;
- case 2:
+ case 3:
return TARGET_LOWER;
- case 3:
+ default:
return TARGET_NUMBER;
}
}
@@ -618,16 +626,16 @@ gimp_spin_scale_get_target (GtkWidget *widget,
}
static void
-gimp_spin_scale_update_target (GtkWidget *widget,
- GdkWindow *window,
- gdouble x,
- gdouble y,
- gint button)
+gimp_spin_scale_update_target (GtkWidget *widget,
+ GdkWindow *window,
+ gdouble x,
+ gdouble y,
+ GdkEventButton *event)
{
GimpSpinScalePrivate *private = GET_PRIVATE (widget);
SpinScaleTarget target;
- target = gimp_spin_scale_get_target (widget, x, y, button);
+ target = gimp_spin_scale_get_target (widget, x, y, event);
if (target != private->target)
{
@@ -779,7 +787,7 @@ gimp_spin_scale_button_press (GtkWidget *widget,
if (event->window == gtk_entry_get_text_window (GTK_ENTRY (widget)))
{
gimp_spin_scale_update_target (widget, event->window,
- event->x, event->y, event->button);
+ event->x, event->y, event);
gtk_widget_queue_draw (widget);
@@ -788,8 +796,7 @@ gimp_spin_scale_button_press (GtkWidget *widget,
case TARGET_UPPER:
private->changing_value = TRUE;
- if (! private->compact)
- gtk_widget_grab_focus (widget);
+ gtk_widget_grab_focus (widget);
gimp_spin_scale_change_value (widget, event->x);
@@ -798,8 +805,7 @@ gimp_spin_scale_button_press (GtkWidget *widget,
case TARGET_LOWER:
private->changing_value = TRUE;
- if (! private->compact)
- gtk_widget_grab_focus (widget);
+ gtk_widget_grab_focus (widget);
private->relative_change = TRUE;
private->start_x = event->x;
@@ -811,17 +817,6 @@ gimp_spin_scale_button_press (GtkWidget *widget,
return TRUE;
- case TARGET_NUMBER:
- if (private->compact && ! gtk_widget_has_focus (widget))
- {
- gtk_editable_select_region (GTK_EDITABLE (widget), 0, -1);
-
- gtk_widget_grab_focus (widget);
-
- return TRUE;
- }
- break;
-
default:
break;
}
@@ -857,7 +852,7 @@ gimp_spin_scale_button_release (GtkWidget *widget,
if (private->hover)
gimp_spin_scale_update_target (widget, event->window,
- event->x, event->y, 0);
+ event->x, event->y, NULL);
else
gimp_spin_scale_clear_target (widget, event->window);
@@ -995,7 +990,7 @@ gimp_spin_scale_motion_notify (GtkWidget *widget,
private->hover)
{
gimp_spin_scale_update_target (widget, event->window,
- event->x, event->y, 0);
+ event->x, event->y, NULL);
}
return FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]