Commit Graph

23700 Commits

Author SHA1 Message Date
Alx Sa cc3f7afb04 tools: auto-activate transform tools on canvas
This removes the need to click the canvas after selecting a transform
tool before you can start working on the transform.
2022-11-13 17:52:25 +00:00
Øyvind Kolås 06b481a3ec meson, configure, app: depend on babl 0.1.98 2022-11-13 17:31:32 +01:00
Øyvind Kolås b85032d8b6 meson, configure, app: depend on GEGL 0.4.40 2022-11-13 17:16:49 +01:00
Jehan 143496af22 app, menus, pdb: new "Paste as Single Layer( in Place)?" actions.
When the clipboard contains raw image data or single layers, it's the same as
the normal "Paste" (and "Paste In Place" respectively). These actions are useful
if you want to copy a bunch of layers and paste them "merged" into a single
layers (since now the copy-paste of multiple layers will create multiple
layers).
It is somehow similar to the "Copy Visible" action except that it works on
selected layers only and work at paste time, making the action more versatile.
2022-11-12 22:34:51 +01:00
Jehan fc050914ab app, menus, plug-ins: move some advanced paste actions into submenu.
There are so many paste options and I feel that the "Paste into Selection*"
actions are advanved enough that they can go into submenus. So I move them into
"Paste as". The other reason is that I'm going to add 2 more options!

I hesitated to rename the "Paste as" submenu but we couldn't find a good naming
(except just "Paste" but it's redundant with the default action and "Paste…" but
this usually implies a dialog, not a submenu).

Last but not least, I renamed the various paste actions to contain the word
"Paste" in it. E.g. s/New Image/Paste as New Image/. The old naming made sense
when action labels were only displayed in menus. But nowadays they can be shown
in other more independant context, such as the action search (and just
displaying "New Image" in there is very misleading).
2022-11-12 22:34:36 +01:00
Jehan 92cc33d52a app: fix a use of gimp_edit_paste().
When dropping a buffer, we just consider it like common data pasting, hence we
leave the GIMP_PASTE_TYPE_NEW_LAYER_OR_FLOATING algorithm decide what type of
paste it will be.
2022-11-12 19:07:47 +01:00
Jehan 9a2f5b0709 app: rework and fix the logic for copy-pasting multiple drawables.
There were a lot of incertainty of what should happen when we copy layers being
descendant of each other (i.e. when you select a group layer and some of its
children), then when you paste such data. So we sat down with Aryeom and tried
to come up with some consistent behavior which is somewhat expectable, but also
which would allow the most use-case.

Otherwise it was making very weird result when pasting the data, duplicating
some layers and whatnot, which was obviously a buggy behavior and never the
expected result.

We decided that if you select one leaf item, then even if you also selected a
parent item, it would be as though the parent was not selected. This is very
often what you expect anyway when you select a whole bunch of layers and would
work well if, say, you shift-click over many layers in sub-groups. Then you
wouldn't have to manually ctrl-click to unselect every group.

Then what if you were instead expecting to copy many groups? Then you could
shift-click the group arrow, closing all same-level groups. Once they are all
closed, you can shift-click the groups to only select group layers, not their
contents.

This way, both use cases are still quite doable easily with this default choice.
2022-11-12 18:28:58 +01:00
Jehan 18c5b39cf5 app: copying from selection creates layers the size of the selection.
After further discussions with Aryeom, we had to make decisions about a few
problems. The main problem was: what happens when we copy a selection of a layer
whose bounds don't intersect with the selection?

The silent treatment of discarding the layer was not acceptable, because e.g. it
could happen on huge set of selected layers (like say you copy 100 layers with a
selection: you expect 100 created layers and if you realize you don't have them
all — e.g. you have 99! — after hours of work, trying to find the missing one
can be a huge time loss).
The status bar notification (or even error) did not feel right either because
this can typically be missed easily. Also it doesn't give a lot of feedback
(e.g. you might want hint to find the non-intersecting layers, in case it was
not supposed to happen).
An error box was even considered, possibly proposing to ignore the problematic
layers, or even giving easy ways to find them.
Finally what if we let the selection happen regardless the non-intersecting
layers? What should the dimension and offset of said layers be?

In the end, we went with the more consistent behavior of always creating new
layers of the exact same size as the selection. It can be considered as a rule
which would make the behavior predictable. For the non-intersecting layers, we'd
just have new layers with the dimension/offset of the selection bounding box,
and no contents. For other layers, they'd be also this same dimension, possibly
increasing the dimension of the source layers (though any new pixel is fully
transparent obviously). Aryeom wondered if some people might absolutely need for
their workflow that the new layers stick to the origin bounding box. But we felt
it was enough of a stretch that we'd try this way for now.

Note: of course if some day we get infinite canvas/layers, this whole discussion
could be less of a problem anyway! This was Aryeom's conclusion! Ahahah!
2022-11-11 00:04:38 +01:00
Jehan 363facef5e app: fix one case in gimp_edit_paste_get_top_item().
I was forgetting to store the path for the first item, which in particular was
making a problem when the top item was the first one in the list.
2022-11-10 23:29:23 +01:00
Jehan 1b64fdf52d app: pasting selection from multiple layers should still create multiple layers.
This is also work-in-progress for better copy-paste handling for multi-items.
Until now, I had decided that, if a selection existed, a copy would copy a
merged version of the selected items. But sometimes you want to have a piece of
each layer, each piece in its own layer. Also you may always merge the pasted
layers afterwards.

So now we will indeed create as many layers out as there are layers in. Being
able to copy a merged down version of all selected layers is still an
interesting feature though. We might add a dedicated "Copy Merged" action,
similarly to the fact we have a "Copy Visible" (which does the same thing but
for all visible layers, not specifically the selected ones).
2022-11-10 22:49:47 +01:00
Jehan bd186d56ee app: fix position of pasted data.
Position of pasted image data was getting very bad lately, especially with the
multi-item selection logic which confused the hell out of the legacy algorithm.
So I reviewed it a bit, in light of the multi-item abilities, as well as the
recent no-floating-selection paste changes.

One of the particularly wrong paste position was when pasting one or several
pieces (through selection) of existing layers. The positionning was really bad
and sometimes even off-canvas (which was explicitly forbidden by the algorithm,
except it was broken now).

Now the behavior is much more reliable and consistent, by centering on viewport
or on target drawables. If there are several such targets, their bounding box is
used as target position (and the bounding box of all source drawables is also
used now). An interesting consequence of this is that copy-pasting quickly
without removing a selection paste "in-place" since the target this time will
use the selection bounding box.

Aryeom and I are doing some work on specifying copy-paste (based on existing
logic, we tried not to disrupt too much years of logic, but also keeping
consistency and new logic for recent changes, such as multi-items). It will all
be written down into the GIMP developer website, section "Specifications".
2022-11-10 22:49:47 +01:00
Jehan 3453c8bd55 app, pdb: paste layers over the top selected drawable.
When several drawables were selected, it was pasting at the top of the layer
stack. Instead, paste over the top selected layer ("top" visually in the Layers
dockable).

There was the question of: what should we do when pasting over a layer group.
Should we consistently paste the new layers above the group or inside the group?
After discussions with Aryeom, we decided to stay consistent and paste above, at
least for now.
2022-11-09 17:22:35 +01:00
Jehan 6083fd81a1 app, desktop: prepare AppData <release/> item for upcoming GIMP 2.99.14. 2022-11-09 15:31:39 +01:00
Jehan b674fd33f0 app: fix a critical for release demos with a dockable and no specific widget.
Fixes:

> GLib-CRITICAL **: 13:39:39.804: g_strchug: assertion 'string != NULL' failed
2022-11-09 15:22:05 +01:00
Jehan 51fe025afb app: update sensitivity rules of distribute buttons.
Distribute features do not care about the reference object anymore. All we care
about is whether we have more than 2 objects.
2022-11-09 13:20:31 +01:00
Jehan c3e1197ec9 app: fix a CRITICAL.
We should look at the display stored on the GimpDrawTool.
2022-11-09 13:04:51 +01:00
Jehan 28457ce337 app: display the floating mask over the layer mask.
It would make using floating masks a lot easier as it is visually understandable
that it applies to the layer mask.
2022-11-09 02:15:41 +01:00
Alx Sa 2c4f91f585 app: Paste as new layer by default
This changes the default selection pasting behavior to be a new layer,
rather than a floating selection. It also removes the
"Paste as New Layer" submenu options as they are now redundant.
2022-11-09 00:31:00 +00:00
Jehan f6dd7f9b3a app: get rid of return_if_no_drawable() macro and…
… gimp_image_get_active_drawable() function!

Also fixing some memory leaks from previous usages of the multi version
return_if_no_drawables().
2022-11-09 01:24:34 +01:00
Jehan 5d75c79c89 app: remove compat registration for gimp-image-get-active-drawable.
Now we must use gimp-image-get-selected-drawables which is not a compatible
signature, as it returns an array of drawables.
2022-11-09 00:59:59 +01:00
Jehan ddec8e2255 app: remove the last usage of gimp_image_get_active_layer().
The histogram is still not multi-drawable aware. In the future, it would be nice
to add ability to generate histogram for all selected layers (merged and as
separate images) as well as the whole visible image, therefore 3 possible cases.

But for now, it's alright like this (no more, but no less feature than before)
and at least we got rid of the last usage of functions assuming single item
selection.
2022-11-09 00:53:17 +01:00
Jehan bd87766170 app: various Alignement tool strings update.
- Option dockable is named "Align and Distribute" rather than "Alignment".
  First, because it's not just about alignment; also because this way, it looks
  like other software, such as Inkscape; lastly because it's more consistent
  with other tool options ("Move", "Rotate", etc.).
- Add a tooltip to the Anchor Point widget to explain what it's used for.
- Rewrite various align/distribute button tooltips to make clearer that we are
  aligning anchor points with specific edges (or distributing these anchor
  points).
- Rename the first section to simpler "Targets".
- Some more rewording of other texts.
2022-11-09 00:40:44 +01:00
Jehan 6a63091e68 app: remove the offset feature in the Align/Distribute tool.
It's clearly broken right now. I can see it might have been used even to
progressively shift aligned items, but this was not used anymore. As for being
used while distributing, it doesn't make any sense anymore with the new logic of
not moving the extreme (first/last in coordinates) items.

I can see how an additional concept of offset can be useful in some situations,
but for now, let's get rid of this. We'll see in the future if someone asks for
it and provides valid use cases to work from.
2022-11-09 00:08:16 +01:00
Jehan e48b002c84 app, icons, libgimpwidgets: add "distribute with evenly gaps" options.
There was one case in Inkscape which we could not do: distributing objects
keeping even gaps between them. Until now, we could only distribute keeping even
distance between anchor points (top, left, bottom, right or center).

With these 2 additional distribute options, I believe that GIMP is able to do
all the Alignment and Distribution options available in Inkscape (not the
"Rearrange" or node features, neither the text align/distrib; I just mean the
common align/distribute on objects), and even a bit more thanks to the anchor
point system (e.g. in Inkscape, we can't left or right-align to a reference
object/image center, or we can't center to a reference left/right/bottom/top
border; but we can do it in GIMP).

The icons are hopefully temporary, until we can make better ones.
2022-11-08 23:48:32 +01:00
Jacob Boerema 9ba5b8dbd6 app: fix issues in gimpmodifiersmanager.c found by coverity
- buttons_key doesn't get freed.
- modifiers could theoretically be used uninitialized.
2022-11-08 16:57:04 -05:00
Jehan 09543af82a app: distribute while keeping extreme objects unmoved.
After discussing with Aryeom, we decided that "Distribute" should work within
the current horizontal or vertical bounds, as this is how it is usually done in
other software (e.g. Inkscape). For instance, if there are 4 items, the first
and last (coordinate-wise) stay untouched, and only the 2 intermediate items get
distributed evenly.

Since the Reference is not relevant anymore for "Distribute", I undo part of my
previous commit, where I was organizing the reference setting into its own
section of the Alignment tool options. This setting is back as part of the
"Align" section.
2022-11-08 21:39:58 +01:00
Jehan 2b0928d895 app: big UI rework of the align/distribute tool.
- Adding a separate pivot widget to allow choosing which point of the items we
  align or distribute. E.g. until now, we could only align the right side of
  objects to the right side of the reference object, left to left and center to
  center. Now these are independent. Therefore I can align the left side of
  objects to the right border of a selection or a layer, and so on.
- Only keep 2 "distribute" buttons (for now). Most of the distribution actions
  were basically broken or extremely hard to understand. Also they were
  apparently mixing concepts of alignments with distributions. Now let's
  basically only keep the bases: horizontal or vertical distributions.
  Everything is still possible using a mix of alignment and distribution
  buttons, and it's much clearer.
- Since the GimpAlignmentType was used nearly only there (except for some usage
  like to store dock side or filter preview split direction, but these
  GIMP_ARRANGE_* values were unused there), I removed the various enum values
  which we don't use anymore.
- The Reference settings gets its own subsection in the Align tool options.
  Until now, it looked like it only applied to alignment, whereas it applies to
  distribution too.

Note: this is still work-in-progress, mostly some initial dev work to put some
algorithmic bases. We had some UI and specification discussions with Aryeom
already and some things might still change a lot.
2022-11-08 19:19:55 +01:00
Jehan 63dc7dee8a app: redraw handles when needed.
There were various cases when the reference's on-canvas handles were not
redrawn, or drawn at all:

- When the reference is an image, we now draw them. It may seem redundant as
  it's the image bounds, but it's still useful to see what are the reference
  bounds in a glimpse. Moreover in "Show All" mode, it's even more useful.
- Start the tool, hence draw the reference handles, in oper_update() if not
  started yet.
- When the "align-reference" property changes.
- When the display (active image) changes.
2022-11-08 13:05:56 +01:00
Jehan 4c09f194d1 app: more fine-grained align/distribute button sensitivity.
When the reference is a guide in particular, no distribution is possible (on one
dimension, the size is 0, on the other, it's infinite) and alignment is only
possible in one direction (depending on guide orientation).
2022-11-07 22:48:30 +01:00
Jehan 947130f2cb app: make a copy of selected items before gimp_container_view_select_items().
Otherwise the selected items might change and invalidate the pointer, eventually
leading to a segfault.
2022-11-01 22:57:21 +01:00
Jehan 04810ec95e app: name the "Floating Selection" differently depending it floats a layer or…
… a layer mask.

This is a first step to make a clearer difference between the 2 use cases.
2022-11-01 22:57:21 +01:00
Jehan fa2fa71619 app: add a tooltip to "_Don't ask me again" checkbox.
I find these options always a bit unwise when people have no idea how to change
their mind. Therefore adding a tooltip with the information (though maybe we
should even do it even more clearly and adding that in checkbox text too?).
2022-11-01 17:36:45 +01:00
Jehan 092627fdb3 Issue #8697: do not make conversion to another profile the default behavior.
For this to happen, I've updated the main question to be "Keep the Embedded
Working Space?" instead of "Convert to * Working Space?". Basically now we put
emphasis on keeping the image's color profile as being the proposed action.
Therefore "Keep" is the default answer, on the right.
Yet "Convert" stays on the right too. There is no "Cancel" button anymore
because it is not a question we can really escape even though "Esc" still works,
and it still corresponds to "Keep", same as Enter now. The reason is that "Keep"
is actually the non-destructive option. So if someone really doesn't want to
answer and make an explicit choice, we do it for them with the only
non-destructive choice possible.

Also I'm changing "Convert" mnemonic to 'c'. I guess that earlier devs might
have used 'o' because it is the usual mnemonic for "OK", so it was right when
the question was "Convert?". But since now the question is the opposite, there
is no reason to make it look like "OK". Let's just use the first letter, which
is easier to guess (and not taken by any other button here).

I've been hesitating because I don't think "Convert" was the right default
anymore with our anyRGB move. Until now, it was kinda implying that sRGB (when
no preferred color profile was set) was kinda the recommended space. It's not.
If a file already has another space, it's probably much better to keep it.
First because "Convert" is often a destructive change (even more if the target
is sRGB), so for people who don't necessarily understand all the ins and outs,
we were kinda promoting a destructive default behavior.

On the other hand (and that's why I was hesitating):

* "Keep" is also what happens when we hit "Esc" so some might complain that
  there is no easy "Convert" key anymore (there is alt-c, but it's for sure not
  as easy as Esc or Enter). Basically it makes the "Convert" option always a
  much more explicit choice (yet it is likely for the best for people who care
  about their colors).
* There might have been many people who would just use the default (Convert
  until now) without thinking too much of what was asked, and that was working
  good because they would just publish on the web or similar basic usage. If
  they continue just accepting with Enter without reading and understanding what
  is asked, now they could publish images with a color profile (and we know it
  doesn't always work perfectly on the web).
  In other words, it might be the best default for professional usage now, yet
  it requires to understand a bit what you are doing.

It's really a hard call!
2022-11-01 17:24:22 +01:00
Jehan f686d2afbf app: zlib saving is now multi-threaded too!
For the same file, which was saving in ~50 secs in RLE (now ~12), and ~80 secs
in zlib. It now saves zlib-encoded XCF in ~35 secs on the same machine with 8
threads.
2022-10-25 20:15:43 +02:00
Jehan 52d1743924 app: reorganized multi-thread saving code.
Contributed code was not wrong, far from it! But the whole memory management was
a bit on the hard-to-read side. For maintainability, I prefer some simpler code,
which contains a bit more allocation but it's reasonable and at least much less
indexes to play with.

Also instead of gegl_parallel_distribute(), then waiting for each set of batches
to entirely finish, I'm using a GThreadPool which I progressively fill with new
batch data. And finally I'm running the gegl_buffer_get() inside the threads (I
know that we have only reads on the buffer at this point; also GEGL has an
internal lock mechanism anyway).
These actually do not provide a huge additional speedup (compared to the initial
speedup by just going multi-threaded), most likely because the I/O are now the
bottleneck anyway (which is quite a good thing!).
2022-10-25 20:15:43 +02:00
Jehan b35bdd2dc9 app: cleaning the previous commit for fast saving of RLE XCF.
- Coding style fixes.
- Removing gimp_gegl_num_processors unknown variable which didn't exist (coming
  from another patch from suzu. See discussion in #4985).
- Removing the `cleanup()` attribute to keep our code as generic as possible
  without specific compiler extensions. Just free memory manually as is expected
  in C.

Testing on a 115MiB XCF file, saving went down (on my machine, as average on
saving a few times) from about 50 seconds to 15 seconds.
This first version is already pretty neat, though we can probably do even
better.
2022-10-25 20:15:43 +02:00
suzu_11 a51434beb4 Issue #4985: Parallelize xcf_save_tile_rle to reduce time when saving xcf file. 2022-10-25 20:15:43 +02:00
Michael Schumacher 149358021e app: Add GDK_SCROLL_MASK to gimpviewablebutton initialization.
This makes these buttons respond to scroll wheels again, a regression encountered in GIMP 2.99.x.
Code location and fix found by Massimo Valentini.

Fixes issue #6929.
2022-10-24 00:27:13 +02:00
Jehan 831cb91303 app: remove gimp_image_get_active_drawable() usage in colormap actions. 2022-10-20 23:17:07 +02:00
Jehan 81969a0651 app, devel-docs: add a new "Vectors Structure" in the XCF format.
Instead of storing vectors as properties, they have their own structure, which
make them able to store and load all the usual and common properties of other
items. In other words, it makes XCF now able to store locks, color tags and
several selected paths.
2022-10-20 23:17:07 +02:00
Jehan a77c64fafe app, pdb: fixing gimp_vectors_export*() libgimp API.
It seems I forgot to fix some usage of core gimp_vectors_export*(),
which now take a list of paths (not a single path anymore since commit
9fc8260c7c), as these were used by PDB functions.
2022-10-20 19:07:16 +02:00
Jehan 759ee663f0 app, pdb: fix a few "incompatible pointer type" conversions.
That's the problem when there are still too many old warnings hiding the
new ones!
2022-10-20 18:56:24 +02:00
Jehan b73278f1a8 app, libgimp, pdb: add missing functions for selected items.
Missing functions were:
* gimp_image_get_selected_channels()
* gimp_image_get_selected_vectors()
* gimp_image_list_selected_channels()
* gimp_image_list_selected_vectors()
* gimp_image_set_selected_channels()
* gimp_image_set_selected_vectors()
* gimp_image_take_selected_channels()
* gimp_image_take_selected_vectors()

There are discussions of renaming GimpVectors to GimpPath, which would
also be consistent with the GUI and make the always-plural less akward
in API. We'll see. For now keeping named like this.
2022-10-20 18:25:43 +02:00
Jehan 6dc48f571c app: fix logic in gimp_edit_selection_tool_translate().
We should not check if all items are locked, but if one item is locked. It is
enough to forbid the translation from happening.
Otherwise it is currently possible to bypass position lock by using keyboard
arrows for layers or channels.
2022-10-19 15:47:11 +02:00
Jehan 789f52c412 app: make moving vectors with keyboard arrows multi-selection aware.
And this is one less usage of gimp_image_get_active_vectors()!
2022-10-19 15:41:23 +02:00
Jehan 48bebb8a27 app: replace one more usage of gimp_image_get_active_drawable(). 2022-10-19 15:14:14 +02:00
Jehan 74b4951e50 app: remove a gimp_image_get_active_drawable() in select actions.
The action "select-float" should probably only work for a single selected
drawable anyway since a floating selection can only be stacked on one drawable
at a time.
2022-10-19 15:09:38 +02:00
Jehan 6716d06aa1 app: remove one more gimp_image_get_active_drawable().
Actions "vectors-fill*" and "vectors-stroke*" require a single drawable to paint
to. So action logic is unchange. I only replace gimp_image_get_active_drawable()
by gimp_image_get_selected_drawables() and counting the drawables.
2022-10-18 22:36:24 +02:00
Jehan 6eb78ca11f app: remaining drawable actions are now multi-layer aware. 2022-10-18 22:19:44 +02:00
Jehan 85adfb46c8 app: make "drawable-lock-content|position" multi-drawable aware. 2022-10-18 22:06:21 +02:00