Commit Graph

56 Commits

Author SHA1 Message Date
bfc59da987 Cppcheck fixes
(cherry picked from commit 3e35fe4d80)

# Conflicts:
#	app/widgets/gimpcolordialog.c
#	libgimpwidgets/gimpchainbutton.c
2022-05-06 15:10:06 -04:00
Ell
05341fada3 app: avoid dropping motion events in spin-scales
It looks like GDK motion hints are broken, at least on X, causing
us to drop motion events in GimpSpinScale, if the motion triggers
an operation that blocks the main thread for a significant amount
of time, such as projection invalidation.

Instead, disable motion hints for spin-scales, and use an idle to
perform ad-hoc motion compression.
2020-08-24 12:33:53 +03:00
Ell
0e8b995ba0 app: apply spin-scale gamma to input, not output
In GimpSpinScale, apply the slider gamma to the input [min,max]
range, rather than the output [0,1] range, using an odd gamma
curve, in particular, so that we handle negative values correctly.

(cherry picked from commit 5678153797)
2020-03-22 13:30:30 +02:00
Ell
67b0279091 app: don't show context menu in compact spin scale without focus
Always enter relative adjustment mode when right-clicking an
unfocused compact GimpSpinScale, instead of showing the context
menu, since it otherwise leaves little room to enter relative mode
in narrow spin scales.  The context menu can still be activated for
focused spin scales.
2020-01-09 17:31:33 +02:00
Ell
e27aa6c000 app: snap spin scale to page increments when holding Ctrl
When click-dragging a GimpSpinScale while holding Ctrl, in either
absolute or relative mode, snap the value (or the delta) to the
page increment.
2020-01-09 01:49:08 +02:00
Ell
7fdfe791dd 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.
2020-01-07 20:58:20 +02:00
Ell
8591b5b33f app: add compact style for spin scales
Add a boolean "compact" style property for GimpSpinScale.  When
TRUE, the widget uses a narrower layout, and the different upper/
lower-half behavior is gone.  Instead, the behavior depends on the
mouse button used: left-click is used for absolute adjustment
(similar to the upper-half behavior), middle-click is used for
relative adjustment (similar to the lower-half behavior), and right
click is used for manual value entry (similar for clicking on the
text area).

Add a new "Compact sliders" toggle to the Interface prefernces, to
control the spin-scale style.  Apply the style globally through the
themerc file, and update it when the option changes.

Use the compact style by default, because otherwise no one would
find it.  Theming in GTK3 works differently, and spin scales in
master need more work regardless, so this stays in 2.10 for now.
2020-01-06 23:10:05 +02:00
Ell
2dad85b84f libgimpwidgets, app, plug-ins: use GimpSpinButton everywhere
Replace all direct uses of GtkSpinButton with GimpSpinButton, so
that its modified behavior extends to all our spin buttons.
2019-03-09 07:43:13 -05:00
ffe2fb478c app: new gimp_spin_scale_set_constrain_drag() and use it on paint...
... tools' brush options.
After discussions, it turned out that many people disliked that the spin
scale for brush size (and some other options) get you fractional values.
How often do you actually need to get a 4.32 pixel-size brush? And even
how meaningful is it? On the other hand, you usually want a 4 or a 5
pixel size brush and it's nearly impossible to get (exactly) by dragging
the scale widget.
It is so annoying that some even resort to edit the value with keyboard!
So I am adding an optional "constrain" feature to GimpSpinScale. It will
still be possible to get fractional values when constraining is on, for
instance with keyboard edit (the arrow incrementation also will keep any
fractional part). So the interaction for such scales is simply reversed
so that you get integers easily, and fractional parts with a bit more
effort.

It is not turned on by default (some feature actually need precision and
we don't want to break the sliders for these) and for the time being, I
only applied it to all the brush settings in paint tools. Now that it
exist, we may want to apply this to more scales in various parts of
GIMP.

(cherry picked from commit bff3903f37)
2019-01-25 18:34:09 +01:00
Ell
31b369d09f app, libgimp*, modules: don't use g_type_class_add_private() ...
... and G_TYPE_INSTANCE_GET_PRIVATE()

g_type_class_add_private() and G_TYPE_INSTANCE_GET_PRIVATE() were
deprecated in GLib 2.58.  Instead, use
G_DEFINE_[ABSTRACT_]TYPE_WITH_PRIVATE(), and
G_ADD_PRIVATE[_DYNAMIC](), and the implictly-defined
foo_get_instance_private() functions, all of which are available in
the GLib versions we depend on.

This commit only covers types registered using one of the
G_DEFINE_FOO() macros (i.e., most types), but not types with a
custom registration function, of which we still have a few -- GLib
currently only provides a (non-deprecated) public API for adding a
private struct using the G_DEFINE_FOO() macros.

Note that this commit was 99% auto-generated (because I'm not
*that* crazy :), so if there are any style mismatches... we'll have
to live with them for now.
2018-09-18 14:41:35 -04:00
a88c0ffb93 Change the license URL from http://www.gnu.org/licenses/ to https:// 2018-07-11 23:47:19 +02:00
a31ee3ec22 app: fix outer border color of GimpSpinScale to look OK on all themes
it used to be "text" which is almost always too extreme; use "text_aa"
instead which is half way between "text" and "base" and always gives a
reasonable contrast.
2018-04-23 01:28:09 +02:00
4be9f84ed5 app: pass the GdkWindow to gimp_spin_scale_update,clear_target()
Another small thing to make maintaining gtk3-port easier.
2018-02-11 15:45:51 +01:00
Ell
e042393199 app: small cleanup in GimpSpinScale 2017-11-02 09:04:39 -04:00
Ell
ae851c34b4 app: avoid spin scale pointer wrap when value is at upper/loewr limit
When applying a relative adjustment to a spin scale, don't wrap the
pointer around the corresponding screen edge if the spin scale's
value is already minimal/maximal.
2017-11-02 02:36:39 -04:00
Ell
2bdf5372ba app: wrap pointer around screen edges during relative spin scale adjustment
While applying a relative spin scale adjusment (i.e., when dragging
from the lower half of the spin scale), wrap the pointer around the
screen edges (of the current monitor), so that the maximal possible
adjustment amount isn't artifically limited by the screen geometry.
This is especially useful for spin scales in dockables, since
dockables are normally placed near the edge of the screen.

When the mouse is released, move the pointer back to its initial
position (at the beginning of the drag), to allow for subsequent
adjustments.

Unfortunately, moving the pointer programatically isn't supported
on all envrionments (Wayland, Xephyr, ...), and worse yet,
detecting that the pointer failed to move is tricky, so we have to
resort to an ungly hack to maintain the current behavior in this
case.  Gah :P
2017-11-01 15:59:48 -04:00
Ell
90a024be54 app: improve spinscale target calculation
So pedantic... :)
2017-10-18 15:43:34 -04:00
Ell
8d90999814 app: highlight upper/lower halves of spinscales while hovering
When the mouse hovers over the upper or lower half of a spinscale,
highlight the corresponding area, to hint that the two halves
behave differently.  This seems to cause a lot of confusion, so the
different cursors are apparently not enough :P

We use a low-opacity version of the current theme's text color for
the highlight, since it should have a good contrast to both the bar
color and the background color.
2017-10-18 15:01:57 -04:00
0cb3e75f79 app: use a lot of g_clear_object() and g_clear_pointer()
More than 2000 lines of code less in app/, instead of

if (instance->member)
  {
    g_object_unref/g_free/g_whatever (instance->member);
    instance->member = NULL;
  }

we now simply use

g_clear_object/pointer (&instance->member);
2017-07-15 18:42:44 +02:00
aa6024dc93 app: don't leak all results from separate_uline_pattern() in GimpSpinScale 2014-10-06 20:34:22 +02:00
40cbbf8faf app: argh, so much for less stupid 2014-06-19 19:00:23 +02:00
5a4e9d0e03 app: make the new rounding code in GimpSpinScale less totally stupid 2014-06-19 18:56:43 +02:00
be80f49018 app: round mouse-entered GimpSpinScale values to the spinbutton's precision
So the adjustment's value is always what is shown (and can be entered
manually) in the widget. This way a GimpSpinScale will never change
its adjustment on focus-out, and not cause whatever unexpected updates
of its model and whatever is connected to it (like changing the
properties and thus unvalidating the caches of a Gegl graph).
2014-06-19 15:49:27 +02:00
aea161c9a5 app: also include <gegl.h> when we include "libgimpwidgets/gimpwidgets.h" 2013-11-01 22:28:18 +01:00
0a73a787ba app: remove GimpSpinScale's "factor" API again
The method of replacing the spinbutton's adjustment was just waiting
for some future bugs to appear.
2013-06-15 20:53:37 +02:00
0046f0eed6 app: fix gimp_spin_scale_set_factor() to not break if called more than once 2013-06-14 02:22:57 +02:00
766c4a026c app: add an optional "factor" to GimpSpinScale
which allows to display a value different from the original
adjustment's value.

This is sortof a hack but insanely useful to map normalized config
values to a nicer range (e.g. 0.0 -> 1.0 to 0 ->100).
2013-05-28 23:45:45 +02:00
bf3a1c89ef app: GimpSpinScale: the "none" keyval is GDK_KEY_VoidSymbol. not 0 2013-05-28 23:13:13 +02:00
4c0169aaaf app: add mnemonic support for GimpSpinScale's label 2013-05-28 22:46:22 +02:00
6940c00774 app: add gimp_spin_scale_set_label() and get_label() 2013-05-28 15:29:44 +02:00
fb6239320e app: reorder functions in GimpSpinScale so getter and setter are together 2013-05-28 15:19:04 +02:00
ce8ae69440 Bug 695687 - GimpSpinScale's label is unreadable on dark themes
Draw the label like GtkEntry draws its text: with different colors
inside and outside the progress bar.
2013-05-14 02:00:20 +02:00
85a099f988 Bug 688305 - drag and drop for guides broken if 'gtk-enable-tooltips = 0' is set
Fix GimpSpinScale too: add the needed events ourselves, and handle
motion hints (which the parent classes add) in motion().
2012-11-18 20:02:51 +01:00
f80b6a067a app: anal 2012-05-02 17:50:47 +02:00
8994acc6a8 app: handle negative fractions correctly in spinscale 2012-05-02 17:50:45 +02:00
d7e9c6b7fe app: git_spin_scale invoke value_changed when setting gamma 2012-05-02 17:50:44 +02:00
5666697362 app: initialize gamma of spin scale to 1.0 2012-05-02 17:50:44 +02:00
7181402a62 app: clean up warning in spinscale 2012-05-02 17:50:44 +02:00
553b7c7c03 app: add configurable nonlinear mapping (gamma) to spinscale widget
The default value is 1.0 which is linear and the old behavior, values above
1.0 gives finer control in the lower portions of the range, the lower half of
the widget behaves like before doing small relative adjustments.
2012-05-02 17:50:44 +02:00
b1483144cf app: remove unused variable in GimpSpinScale 2012-02-22 23:38:35 +01:00
aadfc82f11 app: various GimpSpinScale fixes
- make it respect RTL mode better, something is still weird though
- don't fiddle with the entry's inner_border
- place label and number on the same line
- adjust size_request to respect the label's requisition
- set the label to ellipsize
2012-02-22 22:48:42 +01:00
4a8fa1ab2a app: make GimpSpinScale RTL aware 2011-04-20 20:12:21 +02:00
3edf0cb531 app: GimpSpinScale: don't create two cairo_t in expose() 2011-04-20 00:43:30 +02:00
6dd463fb02 app: gimp_spin_scale_change_value(): remove "+ lower" from step calculation
It was never noticed because lower is 0.0 or 1.0 in all use cases.
2011-04-18 21:21:45 +02:00
d300ec6556 app: add a "scale_limit" API to GimpSpinScale
which allows to restrict the scale to a range that is smaller than
that of the model GtkAdjustment. This way we can enter large values in
the entry or by dragging beyond the end of the scale, but keep a
reasonably usable scale range for "normal" values.
2011-04-18 21:01:48 +02:00
854dd5b6ad app: correct cast for spinbutton 2011-04-16 11:52:49 +02:00
924d647284 app: set GimpSpinScale to numeric-only input
It's the right thing to do, but also works around focus issues in SWM,
at least while the widget has the focus.
2011-04-16 02:09:37 +02:00
24ee3370b8 Depend on GTK+ >= 2.24.3, cairo >= 1.20.1, gdk-pixbuf >= 2.22.1
and completely separate configure and sanity checks for gdk-pixbuf
from GTK+, because it's now distributed as a separate package. Remove
all sorts of conditional compiling based on GDK_CHECK_VERSION() and
CAIRO_VERSION.
2011-04-06 19:58:24 +02:00
39fa147c17 app: unset GimpSpinScale's context sensitive cursor when the pointer leaves 2011-04-04 01:10:44 +02:00
61aa1854fd app: make GimpSpinScale's slow part change the value 10x slower than the fast part 2011-03-18 15:42:50 +01:00