Commit Graph

45694 Commits

Author SHA1 Message Date
Jehan 0ab91b9b55 app: "Import Palette" multi-layer aware.
When creating a palette out of an image without checking "Sample
Merged", it will now extract the colors out of each individual selected
layers separately. This allows to create palettes even out of all layers
of an image but still considering these individually.
2020-05-17 18:57:32 +02:00
Jehan 28112bbf9e app: layer pick through canvas click multi-layer aware. 2020-05-17 18:57:32 +02:00
Jehan 83d8fcdd06 app: GimpCanvasLayerBoundary to show all selected layers area.
I am currently unsure of this one. Since GimpCanvasLayerBoundary is a
GimpCanvasRectangle, it now shows the minimum rectangular boundary
containing all selected layers.

Should we instead show all individual layers boundary? I didn't choose
this because it would make the whole canvas much more messy, and also I
figure that layer boundaries are mostly used to get an idea of your
current working space extent, for instance if we were to resize the
canvas. Matter to discuss, I guess.
2020-05-17 18:57:32 +02:00
Jehan e3094b4c86 app: Crop tool now multi-layer aware. 2020-05-17 18:57:32 +02:00
Jehan 5964f72cea app, pdb: layers-merge-layers* and image-merge-layers multi-layer aware.
Multi selection actually only really matter when "Merge within active
groups only" option is checked, in which case we are able to merge
layers within several layer groups simultaneously, and end up with
multi-selected merged layers.

Also not sure why both layers-merge-layers and image-merge-layers exist,
as they are exactly the same (exact same callback called when
activated).
2020-05-17 18:57:32 +02:00
Jehan 0ae4686172 pdb: proper conversions for object arrays in PDB. 2020-05-17 18:57:32 +02:00
Jehan 9dc6b2e9fe app: various "select-*" were already multi-layer aware.
No code change, they don't actually need drawable selection to work.
2020-05-17 18:57:32 +02:00
Jehan 98603c69c9 app, libgimp, pdb: "edit-copy" multi-layer aware.
When several layers are selected, select their render, similar to how
"edit-copy-visible" would have copied an image with only these layers
made visible.
Also apply the same logics to PDB function gimp_edit_copy() which can
now be used on several drawables at once.
2020-05-17 18:57:32 +02:00
Jehan 0534e077b7 app: selection were not displayed when multi-layers selected. 2020-05-17 18:32:16 +02:00
Jehan cb03fa1f08 app: Move tool multi-layer aware.
If several items are selected, they will be moved together. If one of
them is linked, all other linked items will be added to the moved
items.
2020-05-17 18:32:16 +02:00
Jehan 22a86c44ca app: layers-select-* multi-selection aware.
Allows to move multiple selection up and down, within each selected
layer's own depth.
2020-05-17 18:32:16 +02:00
Jehan 8f22f12ee7 app: layers-lock-content and layers-lock-position multi-layer aware. 2020-05-17 18:32:16 +02:00
Jehan 80b74ce9e9 app: raise-layers* and lower-layers* actions multi-selection aware. 2020-05-17 18:32:16 +02:00
Jehan 8a65b9c3b0 app: allow shift-click on GimpContainerTreeView expanders.
Similarly to shift-click on visibility or link toggles, shift-click on
expanders allow to expand/collapse all layer groups at a given level,
but the one initially clicked.
2020-05-17 18:32:16 +02:00
Jehan c3e9aeff8c app: multi-layer awareness for layers-new-group and layers-new.
Also improve a bit layers-new-last-values to also work when no layer is
currently selected (in such case, we just create a top layer at root
depth).
2020-05-17 18:32:16 +02:00
Jehan c1f68c02cf app: fix some GimpContainerTreeView mouse interactions.
- Don't trigger selection when toggling visibility/links.
- Fix some weird selection jump when clicking while editing a layer
  title.
- Return FALSE in GDK_BUTTON_RELEASE so that viewable larger preview
  popup gets closed on mouse release.
2020-05-17 18:32:16 +02:00
Jehan 7cdf85693a app: multi-layer aware layers-mask-add and layers-mask-add-button.
These actions raise a GimpViewableDialog. For this to work, I made this
widget work with a list of GimpViewable, not a single viewable anymore
(so maybe the widget class name should change?).
When this list contains only a single GimpViewable, it will display
exactly like before, with a viewable preview. With several viewables,
the preview won't show.

This allows to add masks to all selected layers at once, with the same
basic options for all masks, as set in the dialog.
2020-05-17 18:32:16 +02:00
Jehan 6501c3961d app: multi-layer awareness for layers' lock-alpha, opacity and mode.
Both with the various action layers-lock-alpha, layers-opacity-* and
layers-mode-*, as well as through the layer tree view GUI (alpha lock
icon, opacity slider and layer mode combo box).
2020-05-17 18:32:16 +02:00
Jehan 6916edde0c app: make layers-color-tag-* multi-layer aware. 2020-05-17 18:32:16 +02:00
Jehan a029ef3f97 app: layers-mask-show and layers-mask-disable multi-layer aware.
As for layers-mask-edit, it should only be sensitive in single layer
selection, and multiple selection of layers will get them out of
mask-edit mode.
2020-05-17 18:32:16 +02:00
Jehan 9c277e078c app: make layers-mask-apply and layers-mask-delete multi-layer aware.
Not fully happy of the action sensitivity tests as they check for
content-lock, layer groups and such, but independently. So we could have
a case with 2 layers selected: a group + a content-locked layer. Yet the
layers-mask-apply action would be sensitive.
But instead of make more tests, I am nearly wondering if we should not
make action sensitivity more lax as the actual action will make the
tests anyway and just do nothing.
2020-05-17 18:32:16 +02:00
Jehan b5c8a259c8 app: make layers-mask-add-last-values multi-selection aware. 2020-05-17 18:32:16 +02:00
Jehan b2c11f8e95 app: layers-duplicate now also multi-selection aware. 2020-05-17 18:32:16 +02:00
Jehan 65e2738053 app: add an info label above GimpItemTreeView item list to indicate…
… multi-selected items.
The idea is that with multi-selection now enabled, you may always lose
track and forget you have several items/layers selected. This is
especially true when you have a lot of layers (say you selected one at
the top of the list, another at the bottom; without scrolling, you may
only see one of them). And this can become bad when doing some
destructive action which is allowed on several layers at once (say
deleting several layers while you thought you were deleting only one!).

I got the idea from Thunderbird GUI which also displays the number of
selected conversations in the email list. Same as in Thunderbird, I also
wanted to theme the label similarly to a selected item in the item list
below. This was hard because there is no way to reference the parent
theme colors from within GIMP one. Instead I made so that the label is
always shown as a fully selected text (which is a bit ugly semantically,
but I could not find better). Why I wanted this styling is to give *a
bit* of focus to this info so that it is not too invisible. Otherwise
purpose is defeated. Yet this label is still more subtle than
Thunderbird one (don't want to take all attention toward it). Hopefully
this got the right in-between style.
2020-05-17 18:32:16 +02:00
Jehan 86af7c3fa2 app: make "layers-new-last-values" multi-selection aware.
It allows to create several layers at once, by adding them all with
default generated names above each respectively selected layer.
2020-05-17 18:32:16 +02:00
Jehan 7e0adbc282 devel-docs: update XCF docs with XCF 14 changes. 2020-05-17 18:32:16 +02:00
Jehan 592cea6b87 app: actually implement XCF multi-layer selection saving/loading.
Since XCF up to now was assuming single-selection, adding
multi-selection in XCF means bumping its version to XCF 14.
2020-05-17 18:32:16 +02:00
Jehan d3139e0f7c app: support saving/exporting with multi-selection.
This commit just changes our saving API (i.e. the GimpSaveProcedure
class) to take an array of drawables as argument instead of a single
drawable.

It actually doesn't matter much for exporting as the whole API seems
more or less bogus there and all formats plug-ins mostly care only
whether they will merge/flatten all visible layers (the selected ones
don't really matter) or if the format supports layers of some sort. It
may be worth later strengthening a bit this whole logics, and maybe
allow partial exports for instance.

As for saving, it was not even looking at the passed GimpDrawable either
and was simply re-querying the active layer anyway.
Note that I don't implement the multi-selection saving in XCF yet in
this commit. I only updated the API. The reason is that the current
commit won't be backportable to gimp-2-10 because it is an API break. On
the other hand, the code to save multi-selection can still be backported
even though the save() API will only pass a single drawable (as I said
anyway, this argument was mostly bogus until now, hence it doesn't
matter much for 2.10 logics).
2020-05-17 18:32:16 +02:00
Jehan 795e18b9c9 app: fix running procedures with parameter array types in code code…
… with gimp_pdb_execute_procedure_by_name().

While using gimp_pdb_execute_procedure_by_name_args(), you would create
the GValue-s manually, gimp_pdb_execute_procedure_by_name() is supposed
to create them for us from common C/glib types.

C arrays in particular don't have length information and we can't just
G_VALUE_COLLECT() them (it ends up in broken array with length 0). By
convention, the array length will be the previous parameter. So let's
use this information and create the GValue with gimp_value_set_*_array()
instead.
2020-05-17 18:32:16 +02:00
Jehan 9bd530a2b1 app: add gimp_image_get_selected_drawables().
It is meant to replace gimp_image_get_active_drawable() in the end.
Note that I am not fully sure yet what we should do with multiple layers
selected, when some of them have a mask which is being edited.
2020-05-17 18:32:16 +02:00
Jehan ac56b1ed14 app, libgimp, pdb: add PDB function gimp_image_get_selected_layers().
Also add gimp_image_list_selected_layers() which is the GList version.
2020-05-17 18:32:16 +02:00
Jehan 45a87e62ff app: fix double-click tree view cell editing.
This got broken by some actions now performed on GDK_BUTTON_RELEASE,
i.e. after GDK_2BUTTON_PRESS. Let's shortcut these actions on specific
case when we edit a cell.
2020-05-17 18:32:16 +02:00
Jehan bcacf6e2ae app: "active item" concept => "selected items".
After much thought, tests and discussions with Aryeom, we decided adding
back an active item concept additionally to the selected items ones is a
bad idea as it makes only usage unecessarily complex.
We will just have selected layers. Some kind of operations will work
when more than one item (layers, channels, vectors) are selected while
others will require exacty one item.

In particular, let's replace instances of gimp_image_(s|g)et_active_*()
by corresponding gimp_image_(s|g)et_selected_*(). Also replace single
item in various undo classes by GList of items.
Also "active-*-changed" GimpImage signals are no more, fully replaced by
"selected-*s-changed".

This is still work-in-progress.
2020-05-17 18:32:16 +02:00
Jehan 309ccf71b4 app: allow multi-item drop on GimpContainerView buttons.
This was already implemented for the new button which had its own drag'n
drop handler, and now also for other buttons (in particular the delete
button which is multi-item aware).
2020-05-17 18:32:15 +02:00
Jehan f5dcfbacbb app: better logics to remove multiple layers.
This fixes weird removal failure depending on selection order.
2020-05-17 18:32:15 +02:00
Jehan dbae0e436c app: new function gimp_item_is_ancestor(). 2020-05-17 18:32:15 +02:00
Jehan c2023f3aa1 app: s/insert_item_after()/insert_items_after() in GimpContainerView.
In the middle of multi-item insertion, you don't want to run
gimp_container_view_select_items() as was being done in
gimp_item_tree_view_insert_item_after(). As it turns out, this is the
only implementation for this virtual function, and it doesn't need to be
run on the specific inserted viewable, just make it a call to run when
all insertions are done.
2020-05-17 18:32:15 +02:00
Jehan 5b4c2dac7a app: implement multi-selection code for channels and vectors.
I have not enabled actual multi-selection yet for these 2 item types,
but at least implement enough to not crash!
2020-05-17 18:32:15 +02:00
Jehan cc51c05b80 app: group undo steps when doing multiple layer drops. 2020-05-17 18:32:15 +02:00
Jehan 5e008eb92f app: show number of dragged layers in dnd box for multi-layer drags.
For single drawable drag, we still display the name of this only layer.

Also apply some basic markups, showing the drawable count as italic
subscript in parentheses to differentiate it from a drawable name.
2020-05-17 18:32:15 +02:00
Jehan e11245b1d8 app: button press on a non-selected item changes selection.
I was changing selection only on button release because we don't know if
the initial button press is not going to actually become a drag'n drop
operation. Nevertheless it had a counter-intuitive effect when
multi-selecting some layers then trying to drag another (non-selected)
layer.
To fix this, I actually change the selection on *press* event but only
if the pressed item is currently non-selected.
2020-05-17 18:32:15 +02:00
Jehan f7b86c9062 app: fix selection after a drag'n drop move.
Though it's not finished yet, I am changing "active layer" into
"selected layers" logics. Probably the "active layer" concept will be
back eventually (i.e. even in a multi-selection a specific layer could
be said "active", highlighted in the list a bit differently, hence one
could edit this specific layer only). But for simplicity, for now, it's
better to first get rid of it, otherwise it's just messy.
2020-05-17 18:32:15 +02:00
Jehan 83b3d9e52e app: make drag'n drop multi-drawable selection aware.
This whole drag'n drop code is quite overwhelming, I'm pretty sure this
commit introduced various bugs, and there are already several areas of
improvements I noticed. But at some point, I need to split at a not-too
broken code state or I'll just make things worse.
2020-05-17 18:32:15 +02:00
Jehan 48410d9ea4 app: actually enable multi-selection.
I wanted to enable it in the end, but it makes my work tree messy. Just
commit this now. Multi-selection basically works but there are still a
lot of broken features which are to be taken care of one by one.

Only enabled for layer tree so far.
2020-05-17 18:32:15 +02:00
Jehan 5621182d87 app: do not notify of "active-item" change in GimpItemTree.
Right now, the active item concept is just a weird (and broken)
subconcept of "selected-items". Do not notify for this as it breaks
multi-selection. This can be re-notified later when we will make a
proper concept which won't mean "selection of 1 item".
2020-05-17 18:32:15 +02:00
Jehan 3bc1d09c30 app: do not lose multi item selection when dragging or right-clicking.
Basically the single click selection must happen on mouse button
release, not initial press, otherwise it would cancel your multiple
selection when you were actually about to drag the items.

As for contextual menu, it should trigger a selection only when the
clicked item is not in the current multiple selection.
2020-05-17 18:32:15 +02:00
Jehan 288bec3b79 app: add a "select-items" signal to GimpContainerView.
Properly pass the multi-selection information through the container
classes. Previous implementation was incomplete (most code paths with
multiple item selected were just ignored) and data was passed through
the "select-item" signal with the GimpViewable to NULL and the data to a
list of items (instead of being a GtkTreeIter otherwise). Having a
pointer data which changes meaning in the same function/class is not the
best idea. So instead "select-items" will have 2 list as parameters: a
list of items and a list of GtkTreePath to be used similarly and with
less ambiguity.
2020-05-17 18:32:15 +02:00
Jehan 15113782fd app: warp tool also only works on single layers.
Output relevant warnings when multiple layers are selected and prevent
critical errors.
2020-05-17 18:32:15 +02:00
Jehan 1f733bcb1f app: make paint tools multiple-draware aware.
Paint tools are for now forbidden to work when several drawables are
selected and will output a relevant error when you try to paint.
2020-05-17 18:32:15 +02:00
Jehan 178f32f6a5 app: adds multi-selection support to "layers-delete" action. 2020-05-17 18:32:15 +02:00