Commit Graph

257 Commits

Author SHA1 Message Date
Ell 05dd5029ee app: add gimp_paint_tool_set_active()
... which can use to enable/disable certain aspects of
GimpPaintTool (in particular, brush-outline drawing).  Should be
used by subclasses, to temporarily disable the paint tool while in
a non-paint mode (currently, this is only needed by the
perspective-clone tool; see next commit.)
2019-01-31 06:22:45 -05:00
Jehan 4c337353a0 app: make layer picking a generic modifier of the shell.
Instead of having layer picking only on paint tools with alt-click, make
it available everywhere with alt-middle click. Moving through layers is
also a way to navigate an image, so it actually makes sense to be with
other modifiers (panning, zooming, rotating), while making the feature
more generic (this is definitely useful whatever the selected tool).
2019-01-07 23:08:51 +01:00
Jehan 90e9eb3fca app: alt-click to pick a layer will loop through candidate layers.
If you click on a zone filled in several visible layers, you don't
necessarily want the top layer. You may want one below. With this
change, as long as you hold alt, you will loop through all candidate
layers from top to bottom (then looping back top when reaching the
bottom).
In a first alt-click, you will always end up to the top candidate.
2019-01-07 23:08:48 +01:00
Jehan 3b59e6f61e app: allow picking layer in paint tools on alt-click.
When working with a lot of layers, it is common to have to switch easily
between layers. And having to go back to the layer list is annoying and
also sometimes not practical at all when you can't find easily the right
layer. This is a first step in an experiment for such a feature, worked
together with Aryeom as advisor (and originator of the feature idea).
For now I apply this only to paint tools, though we are considering
having it as a generic modifier too, working whatever the tool. Yet we
wouldn't be able to use alt-left click (as it is used already in some
tools).
How it works is simply that in any paint tool, alt-click allows to
switch to the topmost layer having a visible pixel at the clicked
position.
2019-01-07 23:08:48 +01:00
Ell 637105b962 app: in all tools, blink lock box when the current item is locked
In all tools, when the current item can't be edited due to its lock
mask, use gimp_tools_blink_lock_box(), added in the previous
commit,to blink the lock box of the corresponding dockable, in
addition to showing an error message in the status bar, to hint at
the source of the error.
2018-12-10 08:55:17 -05:00
Ell 464bf1b0a9 app: in the paint tools, blink mode box when the current mode is invalid
In the paint tools, when the current paint mode is invalid, i.e.,
when it requires an alpha channel, but the the current drawable has
no alpha channel, or its alpha channel is locked, blink the paint-
mode box widget in the tool options, in addition to showing an
error message in the status bar, to hint at the source of the
error.
2018-12-10 08:55:14 -05:00
Ell 4fefab1798 app: fix line-angle constraint when xres != yres
Fix gimp_constrain_line() and friends to properly constrain line
angles when the image's horizontal and vertical resolutions are
different, and dot-for-dot is disabled.
2018-07-15 19:09:06 -04:00
Michael Natterer b140b283dc app: rename enum GimpColorPickMode to GimpColorPickTarget
This is just some preparation for fixing issue #1805, but actually
"target" is a much better name so I went the full way and also changed
GUI labels and the color picker tool options config property
accordingly.

If anyone notices at all, how horrible is it to lose your saved pick
target...
2018-07-15 14:32:53 +02: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 5c17d2a43b app: in GimpPaintTool, sync brush-outline coords while painting
Add GimpPaintTool::paint_[xy] members, and periodically assign the
paint core's current coords to them in
gimp_paint_tool_paint_timeout(), while the main thread and the
paint thread are synchronized, during painting.

In gimp_paint_tool_draw(), fetch the current coords for the brush
outline from the above members during painting, instead of directly
from the paint core, to avoid a race condition with the paint
thread, so that we always use the correct coordinates at the time
the paint buffer was flushed back to the drawable.
2018-06-08 03:25:21 -04:00
Ell 1910ff8b1a app: warn when alpha-only painting has no effect
Add a GimpPaintTool::is_alpha_only() virtual function, which
subclasses can override to indicate whether painting only affects
the alpha channel (assuming FALSE by default).  Override the
function in Gimp{PaintBrush,Ink,Clone}Tool, returning TRUE when the
current paint mode only affects the alpha (as per
gimp_layer_mode_is_alpha_only(); see the previous commit,) and in
GimpEraserTool, returning TRUE when the target drawable has an
alpha channel.

When the function returns TRUE, and the target drawable doesn't
have an alpha channel, or the alpha channel is locked, show a BAD
cursor modifier, and raise an appropriate warning when attempting
to paint.
2018-05-07 16:53:29 -04:00
Ell e02a339e01 app: reorganize gimppainttool-paint, to allow use by subclasses
We'd like subclasses of GimpPaintTool to be able to issue paint
commands to the tool's paint-core (in particular, see the next
commit.)  Since paint commands should be executed on the paint
thread, the subclasses must not call the paint-core functions
directly, but should rather let gimppainttool-paint issue the
commands on their behalf.

Reorgainze gimppainttool-paint to make it usable for this purpose
by subclasses.  In particular, add
gimp_paint_tool_paint_core_paint() and
gimp_paint_tool_paint_core_interpolate(), which call the
corresponding paint-core functions on the paint thread.

Additionally, rename the {start,end,flush}_paint() virtual
functions of GimpPaintTool to paint_{start,end,flush}(), and rename
gimp_paint_tool_is_painting() to gimp_paint_tool_paint_is_active(),
so that all the gimppainttool-paint-related stuff are grouped under
the same namespace.
2018-04-16 09:56:39 -04:00
Ell 45c172a885 Bug 795257 - Segmentation fault crash using the clone tool
Commit f5cb1fed85, which performed
brush outline generation in GimpPaintTool in synchrony with the
paint thread, wasn't enough, since GimpSourceTool could still call
gimp_brush_tool_create_outline() directly during its
GimpDrawTool::draw() method, leading to the same race condition
when executed concurrently with the paint thread.

Partially revert the above commit, so that outline generation is
handled as before, as far as GimpPaintTool is concenered.  Instead,
add GimpPaintTool::{start,end,flush}_paint() virtual functions; the
first two are called when starting/ending painting using the paint
thread, while the third is called during the display-update
timeout, while the main thread and the paint thread are
synchronized.  This allows subclasses to perform non-thread-safe
actions while the threads are synchronized.

Override these functions in GimpBrushTool, and cache the brush
boundary in the flush() function.  Use the cached boundary in
gimp_brush_tool_create_outline() while painting, to avoid the above
race condition, both when this function is called through
GimpPaintTool, and through GimpSourceTool.
2018-04-14 10:14:58 -04:00
Ell f5cb1fed85 Bug 795081 - Crash when using a brush combined with a dynamics
In GimpPaintTool, brush outline generation took place during
gimp_paint_tool_draw() even while painting.  This function is run
concurrently with the paint thread.  When using dynamics, this
introduced a race conidition between updating the brush mask in the
paint thread, and updating the brush boundary in the main thread.

Move brush outline generation during painting to
gimppainttool-paint.c, and perform it in the display-update
timeout, while the main thread and the paint thread are
synchronized.
2018-04-09 14:27:48 -04:00
Ell e98506b000 app: remove option for paint tools to opt out of a separate thread
After last commit, all paint tools work correctly with a separate
paint thread, so we can remove the option for specific paint tools
to opt out.  Particularly, GimpMybrushTool now uses a separate
paint thread too.

Note that the separate paint thread can still be disabled through
the GIMP_NO_PAINT_THREAD environment variable.
2018-04-09 14:27:48 -04:00
Ell 2ae16ca604 app: reorganize gimppaintool-paint
Reorganize/clean up gimppainttool-paint.  In particular, move all
paint-core interaction during painting to gimppainttool-paint.c, so
that we can have more control over what's going on; specifically,
enter the drawable into paint mode *before* starting the paint
core, so that it picks up the correct buffer.  This fixes painting
with the paint thread using GimpApplicator, and enables us to use
the paint thread with GimpMybrushTool.
2018-04-09 14:27:48 -04:00
luz.paz 7fdb963e01 Bug 794996 - Misc. typo fixes in comments in app/
Found via `codespell -q 3 --skip="./po*"`
2018-04-08 21:25:56 +02:00
Ell 8e7a34297f app: move painting to a separate thread
Add gimppainttool-paint.[ch], which takes care of painting during
motion events in GimpPaintTool.  Perform the actual painting in a
separate thread, so that display updates, which can have a
significant synchronization overhead, don't stall painting.

Allow specific paint tools to opt-out of a separate paint thread,
and avoid it in GimpMybrushTool, since it doesn't seem to work.

The separate paint thread can be explicitly disabled by setting the
GIMP_NO_PAINT_THREAD environment variable.
2018-04-08 09:42:48 -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
Ell 1d67e0abcf app: In GimpPaintTool, swap get_line_status() coordinates
They got swapped by commit
2069496af3, reporting the angle in
the reverse direction.
2018-01-28 17:28:40 -05:00
Jehan 2069496af3 app: use the new gimp_display_shell_get_line_status() for measure...
... and paint tools (shift-click mode). The feature was already there
but reimplemented twice. Just replace the code to use the same function.
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
Jehan a3cd156265 app: remove useless double space.
I don't think there is any good reason for the distance/angle to be
separated by 2 spaces from the status message.
2017-08-15 21:12:17 +02:00
Jehan 78244f9cb5 Bug 785816 - show angle in degrees when drawing straight lines.
Paint tools in straight line mode (shift click) will now display the
angle in status bar. Angle 0 is considered as the horizontal line from
left to right, and angle is measured counterclockwise from there, which
is the most common convention.
2017-08-15 20:57:50 +02:00
Michael Natterer 33c84f38bc app: GimpPaintTool: don't chain up to start/halt the tool
because the parent class is about to be refactored a bit, and the
actual code executed by chaining up is just 4 lines.
2017-06-30 16:39:28 +02:00
Jehan f24edcded7 Revert "Bug 783108 - Make paint tools draw in all open views"
This reverts commit 2aa246f5e9.
As per Mitch request since painting is already too slow.
This may come back when we make painting fast again, I guess.
2017-05-26 17:48:34 +02:00
Richard McLean 2aa246f5e9 Bug 783108 - Make paint tools draw in all open views
Committed with minor fixes by the reviewer (Jehan).
2017-05-26 12:45:36 +02:00
Jehan 2762662ca9 app: use gimp_unit_get_accurate_digits() in a few places. 2017-01-23 20:59:28 +01:00
Jehan 1835b2ae61 app: improve precision of paint tools' straight line distance...
... in status bar.
Follow-up of commits f836892 and d1c3c3d. With high resolutions, the
distance displayed in the status bar when shift-clicking in a paint tool
may lack digit precision and show the same value (in non-pixel unit) for
several consecutive pixels. Compute a more accurate precision than what
gimp_unit_get_digits() can provide in such cases.
2017-01-20 00:40:41 +01:00
Michael Natterer 014fdb87e5 app: make switching paint tools to color picker mode more robust
Don't rely on the exact modifier being pressed or released. Instead,
check if only the right modifier is pressed after *each* modifier
change, and switch to color picking if it is; disable color picking
otherwise. This greatly reduces the risk of missing the user's wish to
pick colors because of other modifiers being pressed and released in
whatever order.

Probably fixes bug #734743.
2016-11-16 13:16:24 +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 ecaf485f85 app: draw the paint tool fallback crosshair only as last resort
if there was no outline drawn, no line preview, no circle, and no
cursor is shown. All these cases, if drawn, never need a crosshair.
2014-11-19 19:55:22 +01:00
Alexia Death 59364ea76d app: separate fallback cursor from primary indicator cursor
Separate fallback use of a cursor from using a plain size
indicator cursor. Ink tool uses a plain circle as primary
drawing indicator instead of outline, totally different
use than a fallback, when brush is too small to be drawn.

Conflicts:
	app/tools/gimppainttool.c
2014-11-19 00:41:43 +02:00
Michael Natterer c17e8b0412 app: add crosshair drawing to GimpCanvasAnchor and use it in GimpPaintTool
instead of drawing the crosshair cursor manually.
2014-11-18 23:06:43 +01:00
Alexia Death 5442421a34 app: crosshairs type fallback brush cursor
Replaces circular fallback cursor with a less distracting
crosshairs type cursor.
2014-11-18 21:18:29 +02:00
Michael Natterer 1397b9aae7 app: use gimp_draw_tool_add_arc() for the GimpPaintTool brush circle
because add_handle() doesn't scale with the image.
2014-04-20 22:03:17 +02:00
Michael Natterer 0bdb74710a app: rename the value-1...value-4 actions to opacity, size, aspect, angle 2014-04-19 20:09:39 +02:00
Michael Natterer 6d5b6a648d app: turn the paint tool fallback cursor cross into a circle 2014-04-12 22:17:55 +02:00
Michael Natterer 2a9b6bf569 app: make blend's and straight line's start-line-end drawing look nicer
Use circle handles instead of crosses, and put the items into a stroke
group so they don't look ugly when drawing over each other.
2014-04-12 22:10:26 +02:00
Michael Natterer 693d0d082b app: don't draw a redundant fallback crosshair when a line preview is shown
and introduce some local variables is gimp_paint_tool_draw() to reduce
clutter.
2014-04-12 15:26:11 +02:00
Michael Natterer d897188e32 app: also move the "draw brush outline" logic from brush to paint tool
So all paint tools honor the setting.

Add GimpPaintTool::get_outline() which either returns an outline, or
calls gimp_paint_tool_set_draw_cursor() and implement it in
GimpBrushTool and GimpInkTool. Handle all brush/circle/fallback
drawing in gimp_paint_tool_draw().
2014-04-12 15:03:15 +02:00
Michael Natterer 1ade034c49 app: move "show paint tool cursor" logic from GimpBrushTool to GimpPaintTool
Now all paint tools (also ink and mypaint brush) honor the setting and
can work without mouse cursor.
2014-04-12 12:54:08 +02:00
Michael Natterer 703c2c78c4 app: add gimp_paint_tool_set_draw_circle()
which enables drawing a circle with a given radius at the cursor
location.
2014-04-09 15:27:31 +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
Michael Natterer d1795ac204 Bug 700193 - undoing paint tools doesn't update last_coords properly
paint_core->start_coords is in fact the last stroke's endpoint and
only used for storing it in GimpPaintCoreUndo, so the last endpoint
can be resotred for straight-line painting after an undo. Make the
code actually doing that.
2013-07-15 00:41:43 +02:00
darkraid1 ac5428787e Bug 598523 - Protect hidden layers from editing
Don't allow tool operations on invisible items, just like we do for
group layers or locked items.

Cleaned up and enhanced the patch a bit --Mitch
2013-05-13 23:29:43 +02:00
Michael Natterer 908f727f0a Chain up unconditionally in GObject::constructed()
It's supported since GLib 2.28.
2012-11-12 21:51:22 +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
Alexia Death d32fa80d1d app: Move smooth to painttool and clean up the rest 2011-09-14 20:44:45 +03:00
Michael Natterer aa7c31b802 app: s/gdouble inertia_factor/gboolean event_fill/ in eval_event()
Also remove "gdouble max_coord_smooth" from GimpTool and simply use
the existing motion mode for deciding whether or not to fill in
events.
2011-04-17 19:59:31 +02:00