Commit Graph

316 Commits

Author SHA1 Message Date
Jehan ca8f4ef0d3 app: remove last usages of return_if_no_layer macro.
- "Discard Text Information" work on all selected text layers.
- "Text to Path" creates as many paths as there are selected text layers.
- "Text along Path" still only works with exactly 1 text layer and 1 path
  selected.
2023-01-10 23:13:49 +01:00
Jehan 563744934a app: layers edit actions are only meant to work on single layers. 2023-01-10 20:12:15 +01:00
Jehan 545b794b72 app: setting color tags actions now multi-item aware. 2023-01-10 20:07:44 +01:00
Jehan 036ba77415 app: actions for lock position of items multi-item aware. 2023-01-10 20:07:44 +01:00
Jehan a602ea7662 app: lock contents of items multi-item aware. 2023-01-10 20:07:44 +01:00
Jehan 7c7c62a1df app: Toggle Layers/Channels/Vectors visibility action multi-item aware. 2023-01-10 20:07:44 +01:00
Jehan ebf99132eb app: create a new pixel-size-set action for Ink and Brush tools.
Once this is done, I got rid of the ugly hack I added over the already
ugly hack used on "*-set" enum actions.
2022-08-17 14:20:18 +02:00
Jehan 43f0147bfe app: allow to change the brush size on alt-right click.
I started from mitch's patch (though code changed so it was not working,
yet I ended up with quite a different direction).

Modified from original proposition in #498:

* Do not mix opacity and brush size in a same action, one on horizontal
  movement, the other on vertical. The problem is that it's hard to stay
  perfectly horizontal or vertical, so you nearly necessarily change one
  while changing the other and this would be frustrating.
* Do not just use modifiers, but modifiers + right click. The logics is
  that left (or whatever is the first button) click is for the tool
  actions. The middle click for navigation (panning, rotation, and even
  layer navigation now). Right click for now is only for menu. With this
  change, let's use right click for various settings-related changes
  too. Also we already have people complaining with things like canvas
  rotation happening unexpectedly even though it requires button clicks.
  Imagine an action just made of modifiers! Many people would hit these
  by mistake all the time!
* Focus on brush size only for now. Instead of just calling the action
  repetitively with the "SElECT_NEXT" action as proposed in the original
  patch by mitch, let's compute the actual size between the press and
  release. This would allow to have a real visual hint and also would
  make it a lot more useful and meaningful to be an on-canvas change.
  Say you want to reproduce a stroke size on canvas. You can click the
  center and expand to retrieve approximately the size without computing
  it in pixels.

Limitations and future work:

* This is a first draft and I still want to test if it works well with
  the "lock brush to view" and with scale factor > 1.
* I want to associate this with work done for #7034 so that visual hint
  still appear even when we have no visual hint set.
* I am not so fond of with the way we use enum actions which doesn't
  really make satisfying logics (I hacked a bit over it, but it's
  getting ugly). I'm considering creating int/double actions to really
  set some values with exact numbers through actions.
* Right now we need to stop the right click first. I want to be able to
  stop the brush sizing with releasing Alt too.
* It would be nice to make this all more customizable, which is why I
  called internal variable "mod1_setting". The goal will be to have
  other types of actions possibly. Also it could be deactivatable for
  people really not liking these or hitting these by mistake (while not
  needing these). Same for the navigation shorcuts.
* Similarly the right-click menu could be deactivatable or switched to
  other actions conditionally (through Preferences). It is doubtful how
  useful it is (compared to using the same menus on top of the GUI)
  though I don't want to just delete the option because some people
  would clearly be used to it.
* I think we should start breaking down the whole tool events code a bit
  more, in particular the function gimp_display_shell_canvas_tool_events().
* For more settings, a small on-canvas GUI could be of interest where
  you could customize various values through sliders and buttons, and
  also where you could put your favorite brushes or dynamics or whatnot.
  It's not replacing the more complete dockable but could be a nice
  quick version for fast editing.
2022-08-17 14:20:18 +02:00
Jehan e72f5614da app: properly blink the right locked layer when pixels are locked.
In particular, if painting on a layer whose parent's pixels are locked,
we were blinking an empty lock spot, which is confusing. Now
gimp_item_is_content_locked() will also return the proper item (when
relevant, i.e. when returning TRUE) which is locked. It may or may not
the same item as passed in (it may also be a parent item in particular).
2022-02-15 22:08:23 +01:00
Jehan d9846ac9dd app: get rid of all "*-linked" actions.
I.e.: "layers-linked", "channels-linked", "vectors-linked" and
"drawable-linked".
2021-12-23 13:39:43 +01:00
Jehan 9d23216566 app: remove the "Linked" switch from the item options dialog. 2021-12-23 13:39:42 +01:00
Jehan fcd59784e0 app: improve "Select Top|Bottom Layer" actions.
Similarly to how I improved "Select Top|Bottom Channel", we should set
the actions sensitive not only when the selected layers are not the
top/bottom ones, but also when there are no selected layers at all.
2021-12-23 12:55:11 +01:00
Jehan 58302ee332 app, pdb: get rid of various gimp_image_get_active_channel().
Replace them with gimp_image_get_selected_channels().
2021-12-23 12:55:11 +01:00
Stanislav Grinkov b21865328c
gui: Add pixel density selector to canvas size dialog ...
which will be shown when selected template pixel density don't
match the image pixel density.

Then user can either keep current image ppi and scale the
template or set image ppi to match the template ppi.

Density selector displayed only when template and image ppi
differs and template unit is matches one of real world units
(e.g. inch, mm, etc).

Closes: GNOME/gimp#1140
2021-04-08 22:09:26 +06:00
Thomas Manni b94121f53f app/actions: fix Apply Layer Mask 2020-11-26 17:54:41 +01:00
Jehan 057b94f5f5 app: use gimp_viewable_is_ancestor() instead of gimp_item_is_ancestor().
I had recently created gimp_item_is_ancestor() but realize it duplicates
gimp_viewable_is_ancestor() (which works on GimpItem since it's a parent
class). No need for duplicate code.
2020-10-22 12:45:33 +02:00
Felix Yan fe085200c3 Correct typos in layers-commands.c 2020-08-08 10:41:20 +00:00
Jehan 696fb34cc5 app: layers-mask-edit only works with a single layer selected. 2020-07-31 17:42:39 +02:00
Jehan 0f1f8b7b45 app: layers-resize and layers-scale work on one layer at once.
Making these actions multi-layer aware here means checking only exactly
1 layer is selected as these actions have GUI which shows dimensions and
preview (for the layer dimension action, i.e. layers-resize).
2020-07-30 21:26:13 +02:00
Jehan 62eedd41b4 app: layers-alpha-add|remove multi-layer aware. 2020-07-30 21:03:03 +02:00
Jehan 4b3348dffe app: layers-crop-to-selection and layers-crop-to-content multi-layers…
… aware.
2020-07-30 18:36:18 +02:00
Jehan 5565a6a389 app: layers-resize-to-image action multi-layer aware. 2020-07-01 01:00:48 +02:00
Jehan 955aecab92 app, pdb: layers-merge-down action now multi-layer aware.
When several layers are selected, each layer will merge down with the
layer below it. This is similar to running Merge Down several times, one
for each selected layer.
2020-06-30 23:29:05 +02:00
Jehan 7233464664 app: Alpha to Selection will warn when the resulting selection is empty.
Proposed by Aryeom to make it more obvious of a possible issue when
running "Alpha to Selection" and ending up with an empty selection
(which is useless hence may means there might have been a problem in
one's workflow).
This warning will also occur for similar actions (i.e. the
Add|Substract|Intersect Alpha to|from|with Selection actions).
2020-05-26 14:15:17 +02:00
Jehan ae4abbabfd app: layers-merge-group multi-layer aware.
Also layers-flatten-image does not care about the layer selection and
layers-anchor works anyway only when there is a floating selection,
which means only one layer selected.
2020-05-21 15:08:28 +02:00
Jehan 5c221df99f app: layers-blend-space-* & layers-composite-space|mode-* multi-layer…
… aware.
2020-05-21 00:04:37 +02:00
Jehan 338ac504df app: "layers-mask-selection-*" multi-layers aware.
All selected layers' masks are combined first as union, then the result
is combined with the image selection according to requested boolean
operation.
Also use new gimp_channel_combine_items() function.
2020-05-20 22:59:34 +02:00
Jehan 081ebf19f0 app: more accurate undo names.
Don't just name all alpha-selection actions the same "Alpha to
Selection". Have some more accurate naming like "Substract Alpha from
Selection", etc.

Also improve the action names to make them more accurate as these names
are not only in menus anymore, but also in search actions (and we want
to avoid duplicate naming).
2020-05-20 21:20:39 +02:00
Jehan 32740ac0de app: improve alpha to selection with multiple items.
I created a new function gimp_channel_combine_items() which combines a
list of items with a channel. The list of items is first combined
together as an union set, then only combined with the channel with the
desired operation (this is important for operations such as intersect
which was broken in my previous commit because all items would be
intersected with each other and the selection, whereas we actually want
the union of all items to be intersected with the selection). This new
function is now used for "Alpha to Selection".

Also similarly to copy or color-pick on multi-layers, alpha to selection
will now use the composited result of the multi-layers as visible. In
particular it means that opacity, modes and visible properties on the
layers are taken into account. Alpha to selection on a single layer
though still works as previously, only taking the non-composited layer
data into account.
I am actually struggling if alpha to selection on uncomposited layers
(just an union on alpha to selection result for each layer) would not
make sense to on some workflows. To be experimented.

Finally it is to be noted that this function should also work on
channels and vectors (both single or multiple; and of course in such
cases, compositing does not matter) though I haven't tested yet. It
could even work with a source mix of layers, channels and vectors,
though our GUI does not allow such action currently.
2020-05-20 18:45:44 +02:00
Jehan 645d80123a app: make "Alpha to Selection" multi-layer aware.
Allows to select several layers and have their alpha channel to replace
the selection, or substract from it, etc.
2020-05-18 12:22:08 +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 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 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 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 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 178f32f6a5 app: adds multi-selection support to "layers-delete" action. 2020-05-17 18:32:15 +02:00
Michael Natterer 50257e9f7e Issue #4696 - Keyboard shortcuts for layer opacity are not working
layers_opacity_cmd_callback(): get the select_type from
the GVariant instead of using the GVariant as an enum
directly (missed when porting, spotted by Massimo).

Fix the same bug in channels_select_cmd_callback()
and layers_mode_cmd_callback().
2020-04-29 13:32:41 +02:00
Ell e7479cad47 app: add "show all" support to "Layer -> New from Visible"
When in "show all" mode and canvas padding is disabled, have the
"layers-new-from-visible" action create a new layer from the full
image content, rather than just the canvas content.
2019-09-19 20:24:38 +03:00
Michael Natterer 3b6b3fc189 app: GtkAction -> GAction madness part two
Change all action callbacks so they can be invoked by a GAction:

- add GimpActionCallback typedef:
  void (* cb) (GimpAction*, GVariant*, gpointer)
- change all action callbacks to the GimpActionCallback signature
- add "gimp-activate" and "gimp-change-state" signals to GimpAction,
  with the same signature as the resp. GAction signals
- remove all other custom action signals and only use the new
  GimpAction signals
- pass around appropriate GVariants containing booleans, int32,
  strings
- badly hack around to force a GimpProcedure pointer into a
  uint64 variant
- remove all G_CALLBACK() casts from all action callbacks,
  they all have the same signature now
2019-07-04 01:11:48 +02:00
Michael Natterer b9d47f2d1f app: change all action callback signatures to use GimpAction
instead of GtkAction, which is correct now because all our actions
implement the GimpAction interface.
2019-07-02 16:12:18 +02:00
Michael Natterer 86e07c16b5 app: start porting away from GtkAction and friends
Step one: get rid of all those deprecation warnings that make
it hard to see any other warnings:

- add a lot of dummy API to GimpAction, GimpActionGroup, GimpUIManager
  etc. which simply forwards to the deprecated GTK functions, they
  will all go away again later
- rename GimpAction to GimpActionImpl
- add interface GimpAction that is implemented by all action classes,
  creates a common interface and allows to remove some duplicated
  logic from GimpToggleAction and GimpRadioAction, and at the same
  time adds more features
2019-07-02 14:21:32 +02:00
Ell e83d8ac4f2 app: merge layers in chunks, and show progress
In gimp_image_merge_layers() -- the internal function used by the
various layer-merging/flattenning functions -- process the merged-
layer graph in chunks, using gimp_gegl_apply_operation(), instead
of in one go, using gegl_node_blit_buffer().  Processing in chunks
better utilizes the cache, since it reduces the size of
intermediate buffers, reducing the chances of hitting the swap when
merging large images (see, for example, issue #3012.)

Additionally, this allows us to show progress indication.  Have the
relevant gimpimage-merge functions take a GimpProgress, and pass it
down to gimp_image_merge_layers().  Adapt all callers.
2019-02-25 05:10:50 -05:00