Commit Graph

32 Commits

Author SHA1 Message Date
Niels De Graef 878804fb01 Cleanup GObject signal marshallers
* Don't generate our own marshallers if they are available in GLib
  already
* Don't set the c_marshaller parameter in `g_signal_new()` if it's a
  default marshaller provided by GLib. See commit message of commit
  39e4aa3c57 on why this is the case.
2020-04-01 21:20:01 +00:00
Ell 3b0040c043 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:39:56 -04:00
Michael Natterer 5f700549e7 Change the license URL from http://www.gnu.org/licenses/ to https:// 2018-07-11 23:29:46 +02:00
Ell 52a92a34d8 app: implement GimpToolWidget::hit() in all tool widgets
... and move the common functionality of their hit() and hover()
implementation to a separate function.
2018-06-05 04:04:47 -04:00
Ell 5e736c697f app: implement GimpToolWidget::leave_notify() in various tool widgets
... by having them disable item highlights, and any other proximity
indication, when the cursor leaves the widget.
2018-06-05 04:04:47 -04:00
Ell 49089fc427 app: respond to "focus-changed" signal in various tool widgets
... by disabling persistent item highlights when unfocused.
2018-06-05 04:04:47 -04:00
Michael Natterer 539927ebfa app: replace all g_assert() by the newly added gimp_assert()
which is just a #define to g_assert for now, but can now easily be
turned into something that does some nicer debugging using our new
stack trace infrastructure. This commit also reverts all constructed()
functions to use assert again.
2018-02-11 22:23:10 +01:00
Jehan 5f00c189e6 app: also show line info (distance, angle) when moving an endpoint.
When you move an endpoint in the Blend Tool, angle and distance
information are especially important, in case you want to draw a
gradient with specific values.
2017-12-22 23:41:40 +01:00
Jehan e1621c32d3 app: use gimp_display_shell_get_line_status() for GimpToolLine.
Currently Blend tool only shows the vector coordinates whose usefulness
is a bit of a question. Now it will also show distance (in current shell
unit) and angle!
2017-12-22 23:24:24 +01:00
Ell 984ed6cefd app: constrain line angles in display space, not image space
Add an offset_angle parameter to gimp_constrain_line(), which
offsets the radial lines by a given angle.

Add gimpdisplayshell-utils.[ch], with two new functions:

  - gimp_display_shell_get_constrained_line_offset_angle():
    Returns the offset angle to be passed to
    gimp_constrain_line(), in order to constrain line angles in
    display space, according to the shell's rotation angle and
    flip mode.

  - gimp_display_shell_constrain_line():  A convenience function
    which calls gimp_constrain_line() with the said offset angle.

Use the new functions in all instances where we constrain line
angles, so that angles are constrained in display space, rather
than image space.

The only exception is GimpEditSelectionTool, which keeps
constraining angles in image space, since it's not entirely obvious
that we want to constrain angles of dragged layers/selections in
display space.
2017-12-22 06:32:24 -05:00
Ell 507bc43716 app: improve status messages of GimpToolLine
... to cover all the new stuff.
2017-10-09 12:48:50 -04:00
Ell dad521e334 app: add misc. parameters to GimpControllerSlider
Add parameters, controlling the behavior and appearance of sliders,
to GimpControllerSlider.  The macro GIMP_CONTROLLER_SLIDER_DEFAULT
expands to a nonmodifiable lvalue of type GimpControllerSlider,
whose members are initialized with the most common default values.

Handle the new parameters in GimpToolLine.  A slider using the new
"autohide" mode is only visible when selected, or when the cursor
is close enough to the line, between the slider's min and max
values, and no other handle is grabbed or hovered-over.
2017-10-09 12:48:50 -04:00
Ell 9e26d7ea5f app: add handle-clicked signal to GimpToolLine
... which is emitted when a handle is single/double/tripple clicked.

The signal handler returns a boolean value.  A return value of TRUE
stops further event processing, while a return value of FALSE allows
it.
2017-10-09 12:48:50 -04:00
Ell 50acb6690d app: add prepare-to-remove-slider signal to GimpToolLine
The signal is emitted when a slider is dragged away from the line,
and will be removed when the button is released, and when the
slider is dragged back to the vicinity of the line, and won't be
removed.  The last parameter of the signal is a boolean flag
differentiating between the two cases.

Note that a remove-slider signal may be emitted without a preceeding
prepare-to-remove-slider signal, however, is a prepare-to-remove-
slider signal is emitted with a TRUE last parameter, it must be
eventually followed by a remove-slider signal, or by another
prepare-to-remove-slider signal with a FALSE last parameter.
2017-10-09 12:48:49 -04:00
Ell bac7dac4ba app: allow adding and removing sliders to/from a GimpToolLine
Add support for adding and removing sliders to/from a GimpToolLine,
using three new signals:

  - can-add-slider:  Takes a double argument in the range [0,1],
    indicating a location along the line, and returns a boolean
    value, indicating whether a slider can be added at that
    location.

  - add-slider:  Takes a double argument in the range [0,1],
    indicating a location along the line, for which can-add-slider
    returned TRUE.  In response, should add a new slider at that
    location, and return its index, or a negative value if no
    slider was added.

  - remove-slider:  Takes a slider index.  In response, may remove
    the slider.

On the UI side, when the cursor is close enough to the line, but
not within the hit area of an existing handle, GimpToolLine checks
if a slider can be added at the cursor position, using can-add-
slider.  If a slider can be added, a dashed circle appears at the
cursor position along the line, indicating where a slider will be
added.  The cursor is added by clicking, which emits an add-slider
signal; if the signal returns a slider index, the new slider is
selected, and can be subsequently dragged.

Removing a slider is done by either selecting the slider and
pressing backspace (or delete, although we don't actually forward
it to the tool atm,) or by "tearing" the slider: when dragging
the slider, if the cursor is far enough from the liner, a dashed
circle appears around the slider, and releasing the mouse removes
the slider.
2017-10-09 12:48:49 -04:00
Ell 63ccbc4fb0 app: add keyboard control to GimpToolLine
Add support for moving the selected handle using the arrow keys,
with the same modifiers as GimpToolPath.
2017-10-09 12:48:49 -04:00
Ell d4cb1623ea app: add persistent handle selection to GimpToolLine
En route to on-canvas gradient editing, add support for persistent
handle selection to GimpToolLine (a handle being either an endpoint
or a slider).  Handles are selected through clicking, however,
unlike before, the selection persists after the mouse is released.
A new "selection" property specifies the currently-selected handle
(who knows, maybe in the future we'll add multi-selection), and a
new "selection-changed" signal is emitted when the selection changes.

The visual feedback has been changed to better suit the new behavior,
and the behaviors yet to be added:  The selected handle is marked
using highlighting; the highlighting doesn't change while hovering
over other handles.  Only the hit-test circle is used as hover
indication, however, we use a fixed-size circle, and only show the
circle for the currently hovered-over handle -- no more trippy
expanding circles :)

A few minor changes along the way:

  - The selected handle is now the (first) one that's closest to the
    cursor, instead of the first one to pass hit-testing.

  - We don't move the selectd handle upon button-press, only upon
    motion, so that handles can be selected without moving them.

  - Show a MOVE cursor modifier when hovering over a handle.
2017-10-09 12:48:49 -04:00
Ell 042650e18c app: rename slider-value variables in GimpToolLine
Rename the "t" variables, representing slider values, to "value".
2017-10-09 12:48:49 -04:00
Ell fb31a592c6 app: add gimp_tool_line_get_slider()
... and use it instead of using g_array_index() on the slider array
directly.
2017-10-09 12:48:48 -04:00
Ell 2d11d29157 app: improve GimpToolLine slider motion clamping/constraint
During constrained motion, round the slider value before clamping
it, so that the slider limits are always enforced.  Additionally,
snap the slider to 1/12-ths of the line length, rather than
1/24-ths.

Make sure that sliders can never have negative-zero values, which
can result in a -inf base for spiral.
2017-07-30 14:03:03 -04:00
Michael Natterer 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
Ell bfb51b0782 app: don't compute slider values for 0-length lines while dragging
... to avoid getting NaNs.
2017-07-04 10:43:01 -04:00
Ell 04b407a019 app: s/slider_count/n_sliders/ in GimpToolLine and firends
Yep yep yep.
2017-07-03 18:10:30 -04:00
Ell 60586a8817 app: add sliders to GimpToolLine; add slider-line controller
Add supprt for placing sliders on a GimpToolLine -- handles that can
be dragged over the line.  The sliders are accesible through a new
"sliders" property, and via the gimp_tool_line_{get,set}_sliders()
functions.

Add a slider-line controller, which works like a line controller,
but whose callback also supplies/takes an array of sliders.

Note that the data type for individual sliders is called
GimpControllerSlider (in particular, it's not line specific), so
that we may use it with other controller/tool-widget types in the
future.
2017-07-03 15:10:47 -04:00
Michael Natterer 2da59e7ba3 app: add a "status-title" string property to GimpToolLine
which defaults to "Line: ". Set it to "Blend: " in the blend tool.
2017-07-03 01:02:23 +02:00
Michael Natterer 3a0aab71b6 app: gimp_tool_widget_get_cursor(): rename "cursor_modifier" to just "modifier"
The same in all subclasses.
2017-06-26 22:13:00 +02:00
Michael Natterer a3acb7422d app: move status message setting from GimpBlendTool to GimpToolLine 2017-06-26 21:48:43 +02:00
Michael Natterer d2bfbfb748 app: some more cleanup in GimpToolLine
it was already working perfectly, but it's so simple I'd like to make
it "perfect" as a GimpToolWidget implementation example.
2017-06-20 19:07:24 +02:00
Michael Natterer 625ec4b773 app: add utility function gimp_canvas_handle_calc_size()
which is the code that calculates handle size based on pointer
proximity. Use the new function in GimpToolHandleGrid and
GimpToolLine, and clean up some stuff in GimpToolLine.
2017-06-20 01:02:23 +02:00
Michael Natterer 44d33bfd3b app: change return value of GimpToolWidget::button_press() from gboolean to gint
so widgets can return which handle was clicked. The values boolean
semantics stay the same so if(retval) gives the same result. This is
useful for the upcoming transform tool widgets.
2017-06-16 20:55:02 +02:00
Michael Natterer 3c5d7075c1 app: add gimp_canvas_handle_set_size() and use it in GimpToolLine 2017-06-11 18:46:30 +02:00
Michael Natterer 6fe578f269 app: add GimpToolLine, an subclass of GimpToolWidet
Implements the "line with handles" known from the blend tool, behind a
simple "x1, y1, x2, y2" interface.
2017-06-10 23:51:06 +02:00