Commit Graph

244 Commits

Author SHA1 Message Date
Ell 37742a9fee Bug 795410 - Deleting a layer group and then undoing the deletion ...
... raises a CRITICAL

gimp_item_{start,end}_move() currently serves two different
purposes:  It is used by GimpLayer to suspend/resume mask resizing
of the layer's ancestors; this is necessary whenever an operation
on a layer might affect the size of its ancestors.  It is also used
by GimpGroupLayer to suspend/resume its own mask resizing; this, on
the other hand, is only necessary before applying one of the
transformation functions to the group, so that mask modification is
handled by GimpLayer.  In other words, the effects of
gimp_item_{start,end}_move() on group layers are only necessary in
a subset of the cases in which these functions are used.

While in itself this isn't a problem, it does cause issues when
removing a group layer:  gimp_image_remove_layer() calls
gimp_item_start_move() before removing the layer, and
gimp_item_end_move() afterwards.  While the former function is
called while the layer is still attached to the image, the latter
function is called after the layer is no longer attached.  Since
GimpGroupLayer pushes an undo step in response to these calls, only
the call to start_move() results in an undo step, while the call to
end_move() doesn't, resulting in an unbalanced
GIMP_UNDO_GROUP_LAYER_START_MOVE undo step on the stack.  This
causes problems when undoing the operation.

Add gimp_item_{start,end}_transform() functions, and corresponding
GimpItem::{start,end}_transform() virtual functions, which are more
specialized versions of gimp_item_{start,end}_move(), which should
be used instead of the former before/after transforming an item; in
other cases, such as when removing ot reordering an item,
gimp_item_{start,end}_move() should still be used.  The default
implementation of GimpItem::{start,end}_transform() calls
gimp_item_{start,end}_move(), respectively, so subclasses that
override these functions don't have to do that themselves.

In GimpGroupLayer, override GimpItem::{start,end}_transform(),
instead of GimpItem::{start,end}_move(), for the same purpose of
suspending mask resize.  This avoids these functions from being
called when removing a layer group, fixing the bug.
2018-04-22 04:05:36 -04:00
Ell 577e17032a app: fix undo when moving a group-layer child outside the group
In gimp_image_reorder_item(), call gimp_item_start/end_move()
before/after reordering the item (and use an undo group, so that
the resulting undo actions are grouped together with the reordering
undo action,) so that if the item is a child of a group layer, and
reordering moves it out of the group in a way that causes the
group's mask to be resized, the mask will be properly restored when
undoing the operation.
2018-04-22 04:05:35 -04:00
Ell 76a88cc60a app: fix layer-group mask cropping during move operation undo
In gimp_group_layer_{start,end}_move(), push corresponding undo
steps, which perform the opposite operation during undo, and make
sure that mask-cropping is frozen during group-layer move
operations.

This fixed erroneous group-layer mask cropping when undoing/redoing
a group-layer move operation multiple times.
2018-03-25 11:46:42 -04:00
Jehan c3ef34b496 Revert "app: "distance-metric" is now a property of GimpContext."
This reverts commit 2c799d4af9.
Ok. I misunderstood Mitch. This belongs in GimpPDBContext.
2018-03-17 20:05:54 +01:00
Jehan 2c799d4af9 app: "distance-metric" is now a property of GimpContext.
Remove the property from Blend tool and make it use the context one.
2018-03-17 18:18:56 +01:00
Jehan 77ed476113 app: add GIMP_MESSAGE_BUG_WARNING + GIMP_MESSAGE_BUG_CRITICAL severity.
Since a few commits, I don't generate the traces anymore in errors.c but
delay this to gui-message.c and rely on the message severity to decide
whether or not generating traces.
Unfortunately none of the current severities are properly describing
this new type of messages. Even GIMP_MESSAGE_ERROR is used everywhere in
our code NOT for actual programming bug, but often for data errors
(which are not bugs but proper messages and should obviously not prompt
a debug trace).
2018-02-12 18:22:15 +01:00
Jehan d5a67cb162 app: make debugging preference finer-grained than a boolean.
Replacing the boolean property "generate-backtrace" by an enum
"debug-policy". This property allows one to choose whether to debug
WARNING, CRITICAL and FATAL (crashes), or CRITICAL and FATAL only, or
only FATAL, or finally nothing.
By default, a stable release will debug CRITICAL and crashes, and
unstable builds will start debugging at WARNINGs.
The reason for the settings is that if you stumble upon a reccurring bug
in your workflow (and this bug is not major enough for data corruption,
and "you can live with it"), you still have to wait for a new release.
At some point, you may want to disable getting a debug dialog, at least
temporarily. Oppositely, even when using a stable build, you may want to
obtain debug info for lesser issues, even WARNINGs, if you wish to help
the GIMP project.
It can be argued though whether the value GIMP_DEBUG_POLICY_NEVER is
really useful. There is nothing to gain from refusing debugging info
when the software crashed anyway. But I could still imagine that someone
is not interested in helping at all. It's sad but not like we are going
to force people to report. Let's just allow disabling the whole
debugging system.
2018-02-08 20:48:16 +01:00
Ell 36dec4e6b0 Bug 51112 - Support layer masks on layer groups
Add layer-mask support for group layers.  Group-layer masks work
similarly to ordinary-layer masks, with the following
considerations:

The group's mask size is the same as group's size (i.e., the
bounding box of its children) at all times.  When the group's size
changes, the mask is cropped to the new size -- areas of the mask
that fall outside of the new bounds are discarded and their data is
lost (sans undo), and newly added areas are filled with black (and
hence are transparent by default).

The new gimp_group_layer_{suspend,resume}_mask() functions can be
used to modify this behavior.  Between the outermost pair of
suspend/resume calls, the old mask data is remembered, and is used
to fill the newly added areas while cropping the mask when the
group is resized.  We override GimpItem::{start,end}_move() for
GimpLayer, to call these functions (suspend() in start_move(), and
resume() in end_move()) for each of the layer's ancestors.

As a result, while moving a layer, or a set of layers, atomically,
such as while dragging with the move tool, or moving linked layers,
the ancestors' mask data is not lost, and is only discarded at the
end of the operation.

This commit also takes care of properly handling undo for group-
layer mask crops, properly invalidating the image when the group
layer's mask is shown, and enabling the mask actions for group
layers (obviously :).
2018-02-05 12:08:54 -05:00
Michael Natterer b05cfc6050 pdb: (try 3) move PDB generation and sources to toplevel/pdb
It never belonged inside "tools". Also rename its "pdb" subdirectory
to "groups". This had to happen before 2.10 so cherry-picking between
branches doesn't become a nightmare in the future.
2017-12-17 14:16:08 -05:00
Piotr Drąg 33d4095fd5 app: fix a typo (transarent) 2017-11-30 16:23:32 +01:00
Ell a08a9171d7 app: modify unabbreviated value descriptions of GimpGradientColor
... to match the old gradient editor menu labels.
2017-11-30 04:45:08 -05:00
Ell d3e527a959 libgimpbase, app: add abbreviations to gradient enums
The value descriptions of GimpGradientColor,
GimpGradientSegmentColor, and GimpGradientSegmentType enums appear
in the on-canvas gradient editor UI, as combo-box items in the tool
GUI overlay.  Since we want to keep the overlay as small as
possible, we previously used abbreviations for these descriptions
(e.g., "FG (t)", instead of "Foreground (transparent)").

Replace the abbreviated descriptions with unabbreviated ones, and
move the abbreviations to the "abbrev" parameter.  This way we get
the abbreviated version in the combo-box, and the full version in
the combo-box's menu.
2017-11-30 03:10:15 -05:00
Michael Natterer f12d0d8c29 Bug 789764 - Please add Paste In Place feature
Add "In Place" variants for all sorts of pasting:

- extend the GimpPasteType enum with IN_PLACE values
- add the needed actions and menu items
- merge the action callbacks into one, taking an enum value as parameter
- refactor the pasting code in gimp-edit.c into smaller functions

We probably have too menu items in the "Edit" menu now, needs to be
sorted out.
2017-11-12 18:41:05 +01:00
Ell 8d12fada8a app: implement blend tool gui for gradient endpoints
Allows setting the endpoint's position, its color, and its color
type.
2017-10-09 12:48:55 -04:00
Michael Natterer ed1ab140fb app, pdb, libgimp: rename values of enum GimpConvertDitherType
being exported to libgimp, and having a non-exported value, this is a
horrible mess like with GimpLayerMode, but at least the cruft value
names are deprecated now.
2017-02-26 20:13:09 +01:00
Ell bb95793eff app: nicer formatting for GIMP_COMPONENT_MASK_ALL 2017-02-20 20:25:59 -05:00
Michael Natterer 2950fecf07 app: move layer mode enums and gimp-layer-modes.[ch] to operations/
and to operations/layer-modes/, respectively.

Add gimp_layer_modes_init() which asserts on the correct order of the
GimpLayerModeInfo array, and switch to accessing the array directly in
gimp_layer_mode_info().
2017-02-05 15:59:29 +01:00
Ell 8f4700b839 app: add "hard mix" blend mode
Similar to the Photoshop mode of the same name.  Assigns
either 0 or 1 to each of the channels, depending on whether the
sum of source and destination channel values is less than, or
greater than (or equals to), one, respectively.

This is equivalent to inverting the source, and using it to perform
per-pixel, per-channel threshold against the destination, which is
useful for various effects.
2017-02-04 21:30:56 -05:00
Michael Natterer 9397aff96f app: add GIMP_LAYER_MODE_LUMA_DARKEN_ONLY and _LUMA_DARKEN_ONLY
which are perceptual versions of the new LUMINANCE_DARKEN_ONLY and
LUMINANCE_LIGHTEN_ONLY modes. Add the new modes to the UI.
2017-01-30 22:07:51 +01:00
Øyvind Kolås e9a6d93197 app: add darken only, lighten only that uses luminance
These variations on darken only and lighten only have the advantage over the
componentvise versions that they always use the full triplet of either original
or new layer - meaning no new colors/hues will be introduced. This is similar
to how these modes operated/operates in picture publisher and photo-paint.
2017-01-29 22:27:28 +01:00
Michael Natterer 5389e8e417 app, libgimp: rename GIMP_LAYER_MODE_NORMAL to NORMAL_LINEAR
and NORMAL_NON_LINEAR to NORMAL, so it's consistent with all other
modes.
2017-01-28 21:38:52 +01:00
Michael Natterer a6545cc363 app: add enum value GIMP_LAYER_MODE_GROUP_DEFAULT
and change the labels of the NORMAL and NORMAL_NON_LINEAR modes.
2017-01-26 17:15:27 +01:00
Michael Natterer 31241a984e app, libgimp: remove GIMP_LAYER_MODE_DARKEN,LIGHTEN_ONLY_LINEAR
There is no _LINEAR variant, the modes always do the same.
2017-01-25 22:08:06 +01:00
Michael Natterer 5dbf9cd4f4 app: add new enum GimpLayerModeGroup { LINEAR, PERCEPTUAL, LEGACY }
and a new function gimp_layer_mode_get_group() which will be used for
the soon-to-appear GimpLayerModeComboBox.
2017-01-24 17:12:52 +01:00
Øyvind Kolås 09af91763c app: fix label of LINEAR_BURN blend mode 2017-01-24 00:44:13 +01:00
Øyvind Kolås d836d94114 app: implement non-legacy blend modes in GimpOperationLayerMode
For operations needing to override default behavior sub-classes should still be
used.

This commit also enables pinligh, vividlight and linearlight blend mode modes
2017-01-23 23:47:56 +01:00
Michael Natterer 5eb0fa816a app, libgimp: add LINEAR variants of more layer modes
for completeness/consistency, even if they don't make much sense for
prectical use.
2017-01-15 16:02:10 +01:00
Michael Natterer 50669fe6d4 app, libgimp: rename BEHIND enum values to be consistent with others
Also update gimplayermodefunctions.c which I forgot before.
2017-01-15 00:01:09 +01:00
Michael Natterer 6bf9e47ba8 app, libgimp: add linear variants of most layer modes
and reorder gimp_gegl_mode_node_set_mode() and friends.
2017-01-14 22:56:54 +01:00
Michael Natterer 5951d39938 app, libgimp: reorder enum GimpLayerMode
so LEGACY and new modes have the same order, if possible.
2017-01-14 21:52:54 +01:00
Øyvind Kolås 4df1af2534 app: add linear variant of behind mode 2017-01-12 14:27:15 +01:00
Øyvind Kolås ec1f7a94e3 app: split legacy out of grain extract and merge 2017-01-11 04:40:26 +01:00
Øyvind Kolås 8f3842434c app: split legacy out of soft and hard light 2017-01-11 04:10:06 +01:00
Øyvind Kolås 784a8ee224 app: split legacy out of burn and divide 2017-01-11 03:17:53 +01:00
Øyvind Kolås 71030f49e9 app: duplicate hsv layer modes, and fix alpha handling 2017-01-10 21:48:03 +01:00
Øyvind Kolås c3e5e30450 app: split legacy lighten only and darken only ops 2017-01-10 11:18:52 +01:00
Øyvind Kolås 5a7fd54d34 app: split addition and subract in legacy and new 2017-01-10 01:40:14 +01:00
Øyvind Kolås b6be1b768e app: duplicate difference mode, new and legacy 2017-01-09 23:49:08 +01:00
Øyvind Kolås 3a50cdcd4f app: split screen op in legacy and new 2017-01-09 23:19:29 +01:00
Øyvind Kolås 076621dd75 app: split dodge op in legacy and new 2017-01-09 20:10:17 +01:00
Øyvind Kolås c2583faa5a app: add new multiply op 2017-01-09 20:10:04 +01:00
Øyvind Kolås 735887286a app: do not let pixel encoding determine layer modes
See bug #757485 - woth noting that this also enables linear and thus correct
compositing when using 8bpc perceptual gamma as the layer storage format.
2017-01-09 20:09:50 +01:00
Michael Natterer 152adbb1bd Rename GIMP_LAYER_MODE_FOO_BROKEN to GIMP_LAYER_MODE_FOO_LEGACY
"Broken" sounds like it needs fixing, but it's legacy compat stuff
that will have to stay for all eternity.
2017-01-09 01:27:20 +01:00
Michael Natterer 66060e3307 app, libgimp*, plug-ins: replace enum GimpLayerModeEffects by GimpLayerMode
with proper value names. Mark most values as _BROKEN because they use
weird alpha compositing that has to die. Move GimpLayerModeEffects to
libgimpbase, deprecate it, and set it as compat enum for GimpLayerMode.
Add the GimpLayerModeEffects values as compat constants to script-fu
and pygimp.
2017-01-08 23:00:19 +01:00
Hartmut Kuhse 66bc98d299 Revert "New GimpMetadata as subclass of GExiv2Metadata"
This reverts commit 3ab08c8bfd.
2017-01-03 19:36:22 +01:00
Hartmut Kuhse 3ab08c8bfd New GimpMetadata as subclass of GExiv2Metadata 2017-01-03 19:26:35 +01:00
Michael Natterer 31fcd79dd9 Bug 769738 - Add color tags/labels for layers/channels/paths
Add property "color-tag" of type enum GimpColorTag to GimpItem so all
layers, channels and paths can be tagged with a color.

For interoperability, use the color list from Krita which is a
superset of Photoshop's colors.

Features a "Color Tag" submenu in the layers, channels and paths
menus, a row of color radio buttons in the properties dialogs,
undo and PDB API.

As a side effect, some common code is now factores out into
items-actions.[ch] and items-commands.[ch] which adds visible, linked
and lock actions for layers and channels.
2016-10-29 17:02:16 +02:00
Michael Natterer 67863dabf9 Bug 637313 - Should be possible to copy/paste whole layers in a single step
Use the newly added clipboard for entire images to copy/paste layers
(we only create single-layer clipboard images, and use only the first
layer of any recieved image, the layers can be arbitrarily complex
though):

- change gimp_edit_copy,cut,paste() to return/take a GimpObject
  that can be a GimpImage or GimpBuffer
- cut/copy the whole layer if there is no selection
- always paste layers as new layers, not floating selections
- always paste news layers on top of the active layer, where
  we would attach a floating selection
- add enum GimpPasteType { FLOATING, FLOATING_INTO, NEW_LAYER }
- add GimpPasteType parameter to gimp_edit_paste() and handle all
  three cases there because there is now a lot of common code
  involved
- change all callers accordingly, use only legacy buffer pasting
  from the PDB for now
2016-09-20 00:20:07 +02:00
Michael Natterer 954f50a097 app: fix description of GIMP_COLOR_PROFILE_POLICY_CONVERT in the header
it was only fixed in the generated .c file.
2016-07-08 15:07:41 +02:00
Michael Natterer 9fb70a44f2 app: rename GimpImageMap to GimpDrawableFilter
and gimpdrawable-filter.[ch] to gimpdrawable-filters.[ch] because of
the name clash.
2016-05-12 01:49:53 +02:00