Commit Graph

209 Commits

Author SHA1 Message Date
Ell 57eaf91fbc app: improve empty-selection check in GimpSelectionTool
Add a new GimpSelectionTool::have_selection() virtual function,
which determines if the image has a selection (default
implementation), or if the tool will create one upon committing
(implemented by subclasses).  Use this function in
gimp_selection_tool_oper_update() to determine the tool function;
in particular, don't use SELECTION_MOVE and SELECTION_MOVE_COPY
when there's no selection.

Override have_selection() in GimpFreeSelectTool, and return TRUE if
we have a polygon with three or more vertices, which will create a
selection upon committing.
2020-02-03 12:40:54 +02:00
Jehan 8ccd49ac78 Issue #3597: Free selection: CRITICAL when double clicking on a handle.
GIMP_BUTTON_PRESS_DOUBLE press event would be called before the second
release event happens hence the tool control would not be properly
halted. Just pass through the gimp_selection_tool_start_edit() check for
any press events other than GIMP_BUTTON_PRESS_NORMAL.
2019-07-02 15:21:05 +02:00
Jehan 50f8cb8542 app: commit the free selection before floating it.
When using a selection modifier Altr+Ctrl|Shift, we want to commit the
selection. If I do it too late though, and if the polygon was not closed
yet, the computed coordinates for the floating selection end up (0, 0)
because it is based on the selection coordinates (yet an unclosed
polygon does not create a selection yet). So commit the tool from within
GimpSelectionTool instead, as soon as we confirmed that the class is
going to take over with SELECTION_MOVE or SELECTION_MOVE_COPY.

Note: ability of quick copying|cuting an unclosed polygon is very useful
as it removes the additional step for a case where anyway committing the
selection was a prerequisite.
2019-06-16 20:37:07 +02:00
Jehan c9a91b32bc Issue #3514: Free Select tool: Alt-Ctrl|Shift not working unless...
... selection is committed;
Fast copy|cut-paste modifiers in selection tools were not working with
the Free Select tool, even when the polygon was closed. The reason was
that GimpPolygonSelectTool was not properly chaining up with the parent
implementation for oper_update(), and then upon a button press, we need
to check to call gimp_selection_tool_start_edit() to see if the action
should not be handled by GimpSelectionTool.
Of course, since we don't necessarily want all child class of
GimpPolygonSelectTool to support these modifiers (typically we may not
want these in the Foreground select tool), I set allow_move to FALSE,
then set it to TRUE only in the GimpFreeSelectTool subclass.
2019-06-16 20:10:06 +02:00
Ell 71c624c5ab app: flush image when committing free-select tool
In GimpFreeSelectTool, flush the image when committing the tool, if
the seletion is created at the time of the commit (i.e., if the
polygon is not closed prior to the commit).
2019-04-26 03:37:13 -04:00
Ell 6a2bea733b app: fix dirty mask/action in the rectangle- and free-select tools
In GimpRectangleSelectTool and GimpFreeSelectTool, make sure the
tool is committed when the selection is dirty.
2019-04-25 07:08:54 -04:00
Ell 476833b553 Issue #2328 - Free Select tool should create preliminary marching ants selection
In GimpFreeSelectTool, use gimp_selection_tool_{start,end}_change()
to create the selection as soon as the polygon is closed, and
update it when the polygon, or the relevant tool-options, change,
similarly to GimpRectangleSelectTool.
2019-04-25 06:07:58 -04:00
Ell afab7deaa3 app: factor-out common free/fg-select logic into GimpPolygonSelectTool
We currently derive GimpForegroundSelectTool from
GimpFreeSelectTool, which prevents us from making changes that are
limited to the free-select tool.

Factor out the common free-select and foreground-select logic into
a new GimpPolygonSelectTool base-class, and derive both from this
class.
2019-04-25 06:07:57 -04: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 e15733236c Issue #1613 - foreground select tool raises a CRITICAL when committing
Make gimp_free_select_tool_halt() protected, and call it in
gimp_foreground_select_tool_set_trimap(), so that the free-select
subobject of the foreground-select tool is properly shut down
before switching to trimap mode.  In particular, this clears the
free-select tool widget at the right point; failing to do this
leads to CRITICALs later on.
2018-06-14 19:51:27 -04:00
Jehan a89dc87aec Bug 795950 - Foreground selection tool requires use of the Enter key.
It is not obvious that you have to hit Enter to validate the first step
of Foreground Selection tool, i.e. the rough free selection. Adding this
information in status message.

Since Enter would only work once the free selection is closed or that
you have at least 3 points (then Enter closes the selection for you), I
also add gimp_free_select_tool_get_n_points() so that we can know how
many points were created from the Foreground Select tool, and only
update the status message when relevant.
2018-05-13 19:27:26 +02:00
Michael Natterer d60c237805 Bug 785781 - Additional Free Selection step (hitting Enter)...
...is a regression in common cases

Commit the free select tool on double click inside the polygon.

Done by implementing GimpCanvasItem::hit() in GimpCanvasPolygon, using
ugly code.
2017-12-01 22:19:42 +01:00
Michael Natterer a5e1dd84fd app: implement GimpToolActiveModifiers in GimpTool
Change gimp_tool_set_active_modifier_state() to honor the new
GimpToolControlSetting. Explicitly set the mode to SEPARATE in
all tools that require modifier keys during a stroke.

And here comes the actual fix: change GimpTransformTool and
GimpToolTransformGrid to use SAME mode, and remove their
active_modifer_key() and hover_modifier() impls, so it makes no
difference whether a modifier is pressed before of after mouse button
press/release.
2017-10-29 16:42:53 +01:00
Michael Natterer ef294f4a54 app: clean up how tools are COMMITed and HALTed
Call HALT generically in gimp_tool_control() after calling COMMIT, and
remove all hacks in tools that call both COMMIT and HALT or call
halt() from commit().

Some tools interact with their subclasses (e.g. filter tool and
operation tool), and it's essential that COMMIT runs through the
entire class hierarchy before HALT.

Probably breaks something, please test.
2017-07-09 16:25:42 +02:00
Michael Natterer e51915a340 app: rename all tools' widget members to simply "widget"
instead of "line", "polygon", "compass" etc. Good for consistency and
for copy & paste :)
2017-06-27 22:50:50 +02:00
Michael Natterer a7e706f7b5 app: must set GimpDrawTool's widget to NULL when a tools is halted
We were leaking all tool widgets set with gimp_draw_tool_set_widget(),
and those having signal connections to e.g. the display shell were
doing things when they were supposed to be gone. Fixes make check.
2017-06-27 22:32:35 +02:00
Michael Natterer 4b103eb966 app: factor out widget creation to start() functions
in crop, free select and rectangle select.
2017-06-27 20:34:31 +02:00
Michael Natterer a89e6eeaea app: connect to GimpToolWidget::status and ::status-coords in GimpDrawTool
and remove the callbacks from subclasses.
2017-06-26 20:49:14 +02:00
Michael Natterer 0d3f719381 app: add gimp_draw_tool_set_widget() and use it in all ported tools
which so far manages drawing of the widget's GimpCanvasItem. Remove
GimpDrawTool::draw() implementations from most of the affected tools.
2017-06-26 19:50:31 +02:00
Michael Natterer 00ea73f29a app: add a generic GimpToolWidget::response() signal
and a default key_press() handler that emits CONFIRM, CANCEL and RESET
responses. Remove code with the same purpose from all subclasses.

Change tools feed key_press() to the widget and connect to its
"response" instead of implementing key_press() themselves. This will
only be better and less code after the tool side of this is done
generically.
2017-06-25 23:23:27 +02:00
Michael Natterer 3d7716aed4 app: use a GimpToolPolygon in GimpFreeSelectTool 2017-06-23 01:59:37 +02:00
Michael Natterer 546bbe1e14 app: add a transform matrix to GimpCanvasPolygon and all API using it 2017-06-19 21:53:49 +02:00
Michael Natterer dda54c1df8 Deprecate stock items for good and change all icon defines to GIMP_ICON_*
Try to sort all GIMP_ICON_* defines into FDO categories like in
https://specifications.freedesktop.org/icon-naming-spec/latest/ar01s04.html

Add defines for all icons we override, rename some icons to their FDO
standard names, and mark the ones we duplicate with a comment so we
don't forget to rename those to standard names in 3.0.
2017-03-05 16:01:59 +01:00
Michael Natterer fbb6b5d425 app: cleanup in GimpFreeSelectTool
Mainly reduction of excessive micro utility functions by folding them
into their single (or two) caller(s). A bit more readable now.
2016-10-06 22:44:07 +02:00
Michael Natterer 2ef8719cbe app: rename more stuff from "floating sel" to "floating selection" 2016-05-20 16:46:26 +02:00
Michael Natterer 9cde7572b4 Bug 757905 - using select tool on image in one tab causes user to lose...
...selection on image in another tab

Make the free select tool behave when switching between displays.
Also clean up the code a bit and reduce utility function
fragmentation.
2015-11-20 19:17:45 +01:00
Michael Natterer 7ec04e4afe app: get rid of hardcoding GDK_SHIFT_MASK in tools/
gimp_suggest_modifiers(): change "shift_format" and "control_format"
parameters to "extend_selection_format" and "toggle_behavior_format",
which fixes the longstanding problem that the function did the right
thing only by accident.

tools: use gimp_get_extend_selection_mask() instead of GDK_SHIFT_MASK
which is not 100% semantically correct in all cases, but at least a
step in the right direction to make the tool modifiers easier to
improve.
2015-10-17 15:31:08 +02:00
Michael Natterer 2068c61a85 Bug 730862 - Preview frozen while dragging selection tools...
...(crop, rectangle, etc) in large image zoomed-to-fit

Default to GIMP_MOTION_MODE_COMPRESS in all tools, and override it to
GIMP_MOTION_MODE_EXACT if the tool really needs the exact path of
motion events. This greatly reduces the events processed by the
rectangle tools and makes them much more responsive.
2014-06-02 20:55:33 +02:00
Michael Natterer d695c98d74 app: free select: start the draw tool more subclass-friendly 2014-04-17 10:51:50 +02:00
Michael Natterer 88e4d7e468 app: commit ongoing tool operations on tool change instead of cancelling
On tool change, we used to simply halt tools before switching to the
new one, which meant losing ongoing live-previewed tool changes, like
transforms, warps and color corrections. This change makes them being
applied to the image instead before switching to the new tool:

Add enum value GIMP_TOOL_ACTION_COMMIT that is passed to
GimpTool::control() before tool switching. Handle the new enum value
in all tools, and actually commit the previewed stuff. This changes
the behavior of GimpCageTool, GimpImageMapTool, GimpTransformTool and
GimpWarpTool.
2014-04-04 22:34:26 +02:00
Ville Skyttä 6b0d1038cc Bug 692641 - Various spelling fixes 2013-01-27 18:59:02 +01:00
Michael Natterer 9b927ba0cd Bug 683791 - Free select tool constraint key
Fix condition that constrains angles to 15°, its bracketing was wrong.
2012-09-14 11:04:21 +02:00
Michael Natterer 57dd302ee8 app: don't redundantly set GimpToolControl->scroll_lock to FALSE 2011-12-10 23:15:03 +01:00
Michael Natterer 38b8f0596d app: use the new modifier API instead of constants in all tools
There are still many uses of literal SHIFT and MOD1 left, but all uses
of CONTROL are gone. Should work exactly as before on Win/X11, and
still has some glitches on OSX.
2011-10-06 21:59:07 +02:00
Michael Natterer d27b7a985c app: make gimp_selection_tool_start_edit() much easier to use correctly
- Add a "display" parameter and ignore tool->display
- Require the tool to be inactive, not active when calling it

This exactly matches all its use cases, which is "delegate to
GimpEditSelection tool if we are not doing anything ourselves", and
enables removing all delegate_button_press() functions because they
became one-liners after adapting to this change.
2011-06-03 09:49:40 +02:00
Michael Natterer 492e0f9cfd app: some more mostly cosmetic tool cleanup 2011-04-04 08:19:12 +02:00
Michael Natterer 6f4be58716 app: GimpFreeSelectTool: highlight the hovered handle 2011-04-02 08:29:53 +02:00
Michael Natterer efbbe39734 app: rmove gimp_free_select_tool_update_button_state()
and priv->button1_down. Use gimp_tool_control_is_active() instead
because it now has exactly that meaning.
2011-04-02 08:24:24 +02:00
Michael Natterer 813392cafd app: move shutdown code from gimp_free_select_tool_halt() to control(HALT) 2011-04-01 22:56:33 +02:00
Michael Natterer 96c8c35575 app: GimpFreeSelectTool: remove if (tool->display != display) checks
This can't happen in motion() and release() because they won't be
called if we didn't activate the tool.
2011-03-30 19:01:11 +02:00
Michael Natterer 7c60bb5181 app: use more of the new GDK_KEY_foo key names
and move the compat defines from display-enums.h to widgets-enums.h
2011-03-29 17:24:08 +02:00
Michael Natterer 9b5dc7559a app: set GimpFreeSelectTool active only while mouse-1 is down
First step towards tightening the tool state machine...
2011-02-28 21:04:42 +01:00
Michael Natterer ca618093cf app: don't show the line to the next free select point when not in proximity
like when leaving the canvas or crossing a window above (tools receive
one oper_update() with proximity = FALSE to indicate the pointer
leaving the canvas).
2011-02-27 11:49:54 +01:00
Michael Natterer cf0402f069 app: consistent handle sizes for tool drawing
Replace a myriad of defines in different tools by three consistent
sizes defined in gimpdrawtool.h.
2010-11-08 22:37:00 +01:00
Michael Natterer 22db39afd2 app: fix incomplete earlier s/GtkAnchorType/GimpHandleAnchor/ change 2010-10-18 20:13:09 +02:00
Michael Natterer b693269060 app: simplify creating of stroke and fill groups a lot
- add gimp_draw_tool_push_group()/pop_group() which manage a stack
  of groups; all items automatically get added to the stack's top group
- use push_group()/pop_group() all over the place, which saves a lot
  of code in most cases
- return GimpCanvasGroup not GimpCanvasItem pointers from
  gimp_draw_tool_add_stroke_group() and fill_group()

Unrelated:

- add GipmCanvasGroup parameter to gimp_rectangle_tool_draw()
- put rect select's round corners into the stroke group to
  avoid ugly overdrawing (the mis-alignment of arcs becomes
  very visible now however, will fix that soon)
2010-10-04 14:03:37 +02:00
Michael Natterer 33ab94517f app: add gimp_draw_tool_add_stroke_group() and add_fill_group()
and use it in all tools which have groups.
2010-10-01 14:24:46 +02:00
Michael Natterer 201bfe3e25 app: add a "shell" property to GimpCanvasItem
and pass it to all constructors. The GimpDisplayShell is needed
because items are going to become more powerful soon.
2010-10-01 14:13:45 +02:00
Michael Natterer a306a46d45 app: make the code that puts the lines into a stroke group nicer
This much lesss feels like we need new API, let's see...
2010-09-26 15:43:59 +02:00