Commit Graph

6187 Commits

Author SHA1 Message Date
Jehan 5ac6d57b7b app: add a preferences for choosing your prefered search pattern format.
The 3 available formats are: simple text search, regular expressions and
glob patterns (cf. previous commit). I did a small step back from
previous commit by getting "is-pattern" property back in GimpItemList
instead of having this case as a value of GimpSelectMethod. The reason
is that it would render a useless value in the Preferences combo box.

Text search is the default.
2021-12-23 13:39:42 +01:00
Jehan 01b47863c2 app: GimpItemList supports glob, regular expression and simple text…
… search syntaxes.

The layer tree view is only using regexp so far, but the core code is
updated to allow more.

Simple text search is actually a bit more than "simple". It implies
tokenization of the text, Unicode normalization and case-folding. It
will also search with ASCII alternatives when possible. This includes
things like non-accented ASCII characters matching accented variants
which is neat.

Now it's not perfect. For instance tokenization seems very limited to
writing systems with spaces or alike. In particular, I tested with
Japanese and since you would typically write without spaces, a whole
group of several words would be one token. Since the text search
algorithm only search from token start, this is quite a failure as you
can't search with intermediate words only.
2021-12-23 12:55:11 +01:00
Jehan 5c63c2478f app: duplicate and delete channel actions multi-channel aware. 2021-12-23 12:55:11 +01:00
Jehan b9eb289b5c app: implement multi-paths selection.
For now, highlighting, snapping and moving (position change with move
tool) have been implemented.
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
Jehan 18fab4e257 app: add Alt-click on visibility and locks for exclusive switch within…
… the selected items only.
This is the exact same algorithm as Shift-click, except that Shift-click
switch exclusivity within the whole level of items. Alt-click does the
same but only within selected items in the list.
2021-12-23 12:47:28 +01:00
Jehan cd7f399006 app: implement exclusive lock switching (Shift-click).
Similar to exclusive visibility switch on layers, now for locks too, if
one wants to lock all layers within a same level for instance by
Shift-clicking the lock icon.

Also once again I factorized the exclusive switching code to ensure it
will always works the same for all similar features (visibility and all
locks).
2021-12-23 12:47:28 +01:00
Jehan 302bf53a67 app: blink the lock cell when failing to switch visibility (eye). 2021-12-23 12:20:43 +01:00
Jehan b356ea6aac app: show lock state as cell icon in Layers dockable…
… and drop the link cell (the lock cell takes the space).

This is an experiment with the following logics:
* I am getting rid on the linked item logics, so the icon cell
  disappears anyway.
* The lock buttons are not so visible above the Layers dockable and so
  many have I seen people frustrated of not being able to do some action
  until they realize they locked something in the layer (even sometimes
  advanced users).
  The icon next to the eye is much more visible. Also I will now display
  different icons depending on the type of locks. If a single lock is in
  effect, I show the corresponding icon. If 2 or more locks are in
  effect, I show a generic lock icon.
* With multi-selection of items in particular, this top lock row was a
  lot more weird and could show inconsistent state (some of the
  selection is locked, other is not). Now the per-row lock icon allows a
  much nicer granularity.
2021-12-23 12:20:43 +01:00
Jehan 9492affda3 app: add an item visibility lock.
Sometimes one may want to lock visibility of a given layer. This is very
useful in particular when shift-clicking a layer visibility. In this
case, it won't be included in the list of layer to update. This can be
used for instance if you want some layers always visible (or always
hidden) while setting exclusive visibility of some other layers only.
2021-12-23 12:20:43 +01:00
Jehan a0fc5a025a app: allow storing regular expression-based item sets.
Instead of just storing list of layers, I created a new simple type
GimpItemList (actually GimpItemSet would be better named, but
unfortunately we use this name for an enum type). So far, this new class
can handle 2 types of item sets: named fixed sets and pattern-generated
sets.
2021-12-23 12:20:43 +01:00
Jehan da987a1485 app: add layer selection by regular expression.
I am unsure if regular expression is the right choice as it may
obviously be a bit too technical. I hesitated with glob-type match for a
while. We'll see!
2021-12-23 12:20:43 +01:00
Jehan 25adf686a5 app: add logical operations on layer sets. 2021-12-23 12:20:43 +01:00
Jehan 4fad4bf89f app: new concept of sets of layers stored in GimpImage.
The eventual goal is to replace the "linked layers" concept, which is
why I am using similar vocabulary. The point is that linked layers are
mostly useless/redundant now with multiplie layer selection, except for
one thing: they kind of serve like a way to "save" a selection of layers
(to be moved/transformed together mostly). Apart from this, multiple
selection is more powerful on any way. You can do much more than
transforming the layers together (you can reorganize them together,
delete them, crop them and so on).

Therefore this new feature is the way to fill the only weakness of layer
selection: its ephemerality. Now we can save a given set of layers, not
even only one, but as many as we want, and under a meaningful name, for
later reuse.
Moreover it will make layer-handling core code much simpler as we
currently have 2 concepts of layer set: multiple selection and links.
The new stored links are only a way to recreate multiple selections.

More is to come, for instance right now, these are not stored in the XCF
format. Also it would be awesome to add logical operators (Shift for
union of layer sets, Ctrl for subtraction and Shift-Ctrl for
intersection). And finally I was thinking about a way to select by
pattern (regular expression? Shell-style glob patterns?) and even store
these patterns. So if you save a "Marmot .*" selection pattern, then
when you select it later, new layers matching this pattern will be
included too (instead of fixed-in-time list of layers).
2021-12-23 12:20:43 +01:00
Jacob Boerema d2c5591088 app: fix #383 Large PBM files exported from GIMP are blank
Fix as suggested by Massimo with formatting adjustments by me.
The use of gulong and glong is not cross platform safe: on Windows it is
32-bit and on most other platforms 64-bit.

Let's use guint64 and gint64 instead.
2021-11-14 18:06:56 -05:00
Emily Gonyer 3afa37cbc6 app, libgimp*, plug-ins: Changed gendered terms to be gender-neutral
Changed a handful of gendered terms to be gender-neutral, and one typo 
of 'he' to 'the' where appropriate.
2021-11-14 11:22:24 +00:00
Jehan 7e3cab1475 app: replace a g_free_error() by g_clear_error().
As a review fix of MR !470 since the contributor Andrzej Hunt is
unfortunately not responding.
2021-10-12 20:13:20 +02:00
Andrzej Hunt 76b11a5f69 gimptagcache: free error to avoid leak
If gimp_xml_parser_parse_gfile returns FALSE, we know that error might
be set. Therefore we add a g_error_free to avoid leaking the error.
2021-10-12 20:13:20 +02:00
Stanislav Grinkov 8516221662
app: Correctly place merged down layer...
when the image is in indexed color mode, and bottom layer doesn't
have an alpha channel.

Resolves: #4945
2021-09-02 13:04:13 +06:00
Jehan 49e534247a app, libgimp*, pdb, plug-ins: use g_memdup2() instead of g_memdup()
Since it appeared with GLib 2.68.0, we could not change this until we
bumped the dependency which has only become possible a few days ago
(since Debian testing is our baseline for dependency bumps). Cf.
previous commit.

As this is a drop-in replacement (just a guint parameter changed to
gsize to avoid integer overflow), search-and-replace with:

> sed -i 's/g_memdup\>/g_memdup2/g' `grep -rIl 'g_memdup\>' *`

… followed by a few manual alignment tweaks when necessary.

This gets rid of the many deprecation warnings which we had lately when
building with a recent GLib version.
2021-08-26 17:32:09 +02:00
Luca Bacci 012df8514a
Add a config enum for the pointer input API to use on Windows 2021-08-25 18:24:54 +02:00
Jehan f888a6f2f0 app: update menurc migration.
- Migrate "view-rotate-reset" to "view-reset" (there is a
  "view-rotate-reset" in GIMP 3, but it will be only for rotate; what
  was really doing the same-named action in 2.10 is now what
  "view-reset" does).
- Make sure we don't migrate "file-export" from a 2.10 config. From a
  2.8 or below, we don't to migrate it (same as for 2.8 to 2.10), but in
  a 2.10 config, it is already the same action as the one in GIMP 3.
2021-08-23 19:10:27 +02:00
Jehan 753e994e1d app: forgot to also properly migrate the docks size.
Same as last commit, avoiding to end up with twice too big docks.
2021-08-23 13:57:38 +02:00
Jehan c43de62e99 app: config folder migration update for GIMP 3.
Fix the search for previous folders, which was broken as it was
specifically expecting 1-digit numbers so far.

The differences of the GIMP 3 config import are:

- update sizes and positions in the sessionrc according to the scale
  factor, because GTK2 doesn't have scale support. It means that, e.g.
  with a 2× display, all sizes and positions in GIMP 2.x must be divided
  by 2 (otherwise the first thing many people will get when testing GIMP
  3 for the first time is an off-screen window).
  Of course, I even wondered if it would not be nice to just drop the
  sessionrc altogether and start with a nice blank slate, but then you
  also lose the opened dock and their organization and some settings
  (such as whether you chose single or multi window mode, etc.).
- scripts/ and plug-ins/ are not imported. Probably makes no sense so
  far as they would end up broken (but maybe it's not true for all
  script-fu scripts?).
2021-08-23 13:37:11 +02:00
Jehan 4336b7a8e3 app: fix memory leak reported by Massimo. 2021-08-16 18:57:21 +02:00
Jehan abb904d64d app: improve/fix the most-recently used layers stack management.
A few issues existed in the code:
- When the layers selection is changed, make sure we remove all
  duplicates (not only the first one). This should not be a problem
  anyway because we also do this duplication cleanup elsewhere now, but
  still…
- Fix gimp_image_layer_stack_cmp(): we were comparing a GList element to
  the data of another, so we were actually never finding duplicates.
- Add gimp_image_clean_layer_stack() for internal layers stack
  management/cleanup. It takes care of recursively making sure we don't
  leave duplicates, and remove all empty lists.
- Now use this new cleanup function inside
  gimp_image_remove_from_layer_stack() instead of doing some incomplete
  and broken element removal. This was especially broken as we were
  removing a GSList element from a list we were iterating on (so we were
  dereferencing a now freed element). This last issue was reported by
  Massimo, and this is how I found the more general failure in this
  layers stack management.
2021-08-16 15:06:00 +02:00
Stanislav Grinkov 619cb91230 Remove unnecessary gimpmarshal.h and gimpwidgetsmarshal.h includes. 2021-08-13 18:01:13 +00:00
Jacob Boerema 317b5d9cff app: improve error message loading pattern that is too large
As noted in issue #6032 the error message when trying to open a pattern
file with dimension larger than supported could be a little clearer.

We do this by adding the maximum allowed dimensions to the error message.
2021-08-09 18:08:33 -04:00
Jacob Boerema f130fe1917 app: disallow saving of patterns larger than max allowed dimensions
For GIMP patterns we have maximum allowed dimensions which we check when
loading a pattern. However, we did not check this when saving a pattern.
See issue #6032.

This commit adds a check when saving a pattern and adds a descriptive
error to make clear why saving fails.
2021-08-09 16:37:28 -04:00
Jehan 7982a5d18c Issue #5386: Gimp crashes when setting AdobeRGB image to Indexed colors.
Similar to the fix of commit c0e605ef for RGB images with a profile as
notified by Massimo.
2021-08-05 18:53:15 +02:00
lloyd konneker 37593d6da3 Fix #6979 meson build fails link libexecinfo on Alpine 2021-08-04 18:21:22 +00:00
Jehan f2fb98cb69 Issue #6610: crashes on free select for images of certain dimensions.
g_alloca() is unadvised. Even though it might be more efficient in some
specific cases, it is pretty subject to stack overflow when a lot of
memory is requested.

Let's allocate dynamic memory instead. To avoid doing it too much, let's
just reuse the same pointer especially since region of interest will
usually be the same size when iterating a buffer, except for border
ones (which would usually be smaller, so we can use the same allocated
buffer again). I still make size checks, just in case.
2021-08-04 14:41:44 +00:00
Jehan cc57860837 Issue #7115: properly chaining up finalize() methods.
Thanks to Massimo Valentini for finding these.
Fixes:

> GLib-GObject-CRITICAL **: 13:21:53.256: Object 0x5485140 of type GimpLineArt not finalized correctly.
> GLib-GObject-CRITICAL **: 13:21:57.472: Object 0x231f520 of type GimpExtension not finalized correctly.

Outputted when glib is built with -Dglib_debug=enabled and GIMP is run
with GOBJECT_DEBUG=objects.
2021-08-04 01:59:41 +02:00
Jehan 086ae77929 app: new gimp_display_grab_focus() function.
The goal of this function is to give the focus to the active image
display. This is implemented as a core GimpDisplay virtual function
(with the actual implementation in GimpDisplayImpl), allowing to be used
even in core code, without actual GUI code (this was not necessary right
now, but I think it will be useful in future use).

This function is now called from the toolbox code (cf. 2 commits
earlier), avoiding code duplication. I also added a usage at the end of
toolbox_paste_received() so that a newly opened image by middle-click
paste in the toolbox directly gains focus.
2021-07-05 15:31:36 +02:00
Stanislav Grinkov 203393a9fc core: function documentation clarification
Update api documentation of GimpObject and GimpThumbnail classes to
clarify who and when will take care of disposing passed strings.
2021-05-24 11:04:44 +00:00
Jehan 7eaa4f1ca9 app, libgimp, pdb: new gimp_display_present() PDB call. 2021-04-30 03:46:52 +02:00
Jehan ef2402bf8e app, libgimp, pdb, plug-ins: allow pasting multiple full layers.
When a selection exists, we are copying then pasting the selection
contents. In particular, with multi-layer selection, it means pasting a
merged result of the selected layers (like a sample merged but limited
to selected layers).

Yet when no selection exists, with a single layer selected, a cut in
particular would remove the layer fully, then a paste would copy it
elsewhere (in the same image or even on a different image). This was
still working, but not with multiple layers. This is now fixed and we
can now copy/cut then paste several layers (without merge), which is
sometimes a very practical way to move layers (sometimes simpler than
drag'n drop, especially between images).

As a consequence, the PDB function gimp_edit_paste() now also returns an
array of layers (not a single layer).
2021-04-24 23:22:58 +02:00
Jehan d6dac25579 Issue #5008: Always true condition (i>=0) inside fill_inverse_cmap_gray.
Removing useless condition, add a g_return_if_fail() assertion for the
only (impossible unless bug) case which we don't expect. Also set
default mindist to G_MAXLONG instead of a magic number (which was ok now
but might become a problem if some day colormap allowed more than 16-bit
per channel colors).
Finally break when we reach a distance of 0 since we won't get lower
anyway, so better stop early.

Thanks to Rafał Mikrut and Øyvind Kolås for code commenting.
2021-04-24 14:48:22 +02:00
Jehan c0e605ef96 app: fix an assertion when converting grayscale images to indexed.
We cannot just compare the drawable format with the model-type specs of
the color model. We need to include the space now.
In my case, some random screenshot converted to gray then indexed would
assert because the format is "Y' u8-space-gray-sRGB" (or for layers with
alpha: "Y'A u8-space-gray-sRGB"), hence indexed conversion failed and
ended up dark.
2021-04-24 14:12:57 +02:00
Michael Schumacher 530dc883ca app, libgimp*: glib-genmarshal warns about --header --body
Using --header --body is mentioned as being deprecated, the way to get the desired result said to be
--prototypes --body now.
2021-04-17 22:50:49 +02:00
Jehan 70a9576f27 app, devel-docs, libgimpbase: s/gimp_parasite_name/gimp_parasite_get_name/…
… and s/gimp_parasite_flags/gimp_parasite_get_flags/

It is better to have a consistent API and the fact is that most
getter/setter functions use the _get|set_ naming, but these didn't.

I wondered if this was such a great idea to rename these anyway because
even though we are breaking API in GIMP 3, is it the best idea to rename
when no functional change happened? After discussing with Wormnest, we
still agreed it was still better to go for consistency rather than
regret later (and be stuck with these names for many more years).

Also this fixes these warnings:

> [649/1205] Generating gimp-3.0.vapi with a custom command
> Gimp-3.0.gir:24162.7-24162.56: warning: Field `Gimp.Parasite.flags' conflicts with method of the same name
> Gimp-3.0.gir:24318.7-24318.52: warning: Field `Gimp.Parasite.name' conflicts with method of the same name
2021-04-05 18:36:44 +02:00
Jehan 5e68a953ee app: fix the test for XCF version with off-canvas guides. 2021-03-30 23:53:02 +02:00
luz paz 6457394069 Issue #6446: Typo fixes. 2021-02-24 12:33:03 +01:00
Jehan 02fa354254 app: replace more gimp_(s|g)et_active_layer() to *_selected_layers(). 2021-02-22 00:00:47 +01:00
Niels De Graef dffab0e9a4 Remove GimpInt16Array
It isn't being used by any plug-in or any code in GIMP at all even.
Let's get rid of it while we can still break API, so we can cut down on
all the complexity of the gimp-param stuff a bit.
2021-02-18 11:32:45 +00:00
Jehan 015f49467d Issue #6435: Off canvas guides.
Allow guides with off-canvas position since we can now view and work
outside the canvas.

The guide deletion interaction does not change too much, except you
don't delete a guide because it's dropped off-canvas but off the display
viewport area instead.

The XCF format is technically unchanged as PROP_GUIDES was already
expecting an int32 coordinate (with max value at GIMP_MAX_IMAGE_SIZE,
way below uint32 max anyway). Yet our code and XCF docs was explicitly
asking to ignore negative coordinate guides, which makes a change in
behavior for the XCF parser, hence a new version XCF 15. Loading will
still ignore negative position guides (even also bigger than image
dimension guides now) for XCF 14 and below, but will now accept any
position for XCF 15 and above.
2021-02-15 22:52:27 +01:00
Jehan 82438728fb Issue #288: Point snapping to guides does not work outside the canvas.
This commit also makes snap to grid and snap to vectors work off-canvas.
Since we now have off-canvas viewing, it just makes sense that snapping
would work there too.

Note that I disable snap to grid when "Show All" is OFF. I am actually
unsure this is right (as "Show All" is a view action, and we usually
don't change behavior based on view actions; for instance snap to guides
are not disabled if guides are hidden). Yet I noticed we do this in
various other features when off-canvas. We kind of use this view flag as
a switch for features working off-canvas (for instance, color picking
works off-canvas only when "Show All" is ON). So let's keep the same
logics for now at least.

Snap to guide or snap to vectors will always work though, because guides
and vectors are always visible off-canvas (even when "Show All" is OFF).
They always have been (visible, not snappable off-canvas; now they are
both).
2021-02-13 13:02:48 +01:00
Jehan b7e7561583 app: fix wrong enum type bug. 2021-02-03 21:34:26 +01:00
Thomas Manni b8abac1777 app: fix crash when deleting channel 2021-01-31 10:16:59 +01:00
Jehan ee26a39049 app: replace gimp_parasite_data*() with gimp_parasite_get_data(). 2021-01-29 23:52:03 +01:00
Jehan e813d90fbb app: allow 0.0 precision for gimp_coords_interpolate_bezier().
All it will mean is that we are looking for perfectly straight lines
when deciding if a bezier curve can be considered straight. It's a fair
condition and represents perfectly what a precision of 0.0 would mean.
2021-01-20 20:14:06 +01:00
Niels De Graef 4d100cc20c app: Use g_object_notify_by_pspec for GimpItem
`g_object_notify()` actually takes a global lock to look up the property
by its name, which means there is a performance hit (albeit tiny) every
time this function is called. For this reason, we should try to use
`g_object_notify_by_pspec()` instead.
2020-12-29 22:37:24 +01:00
Jehan d9b25b8b50 app: do not ask about conversion for an image using a preferred profile.
If setting a RGB or Grayscale "preferred" profile, it usually means
these are profiles we are commonly working with, and it is to be
expected that images one might load may already have said profile. In
this case, don't ask what to do with this profile (keep, convert…). The
graphist kind of already answered this by explicitly listing this
profile as a "preferred" one.

Note that I also check for the built-in profile equality, though it
doesn't look like it is useful (gimp_image_get_color_profile() will
return NULL for an imported image which uses the built-in profile).
This is mostly to be thorough.
2020-12-20 02:04:51 +01:00
Jehan 12348f5241 app: fix some RGB/sRGB mixup in 2 labels. 2020-12-19 21:43:09 +01:00
Jehan b659d3ba4f app: different undo labels for various "Alpha to Selection" operations.
gimp_channel_select_alpha() was creating the same undo label "Alpha to
Selection" whatever the actual operation (add, remove, replace,
intersect). Select the right label depending on the actual operation.
2020-12-14 14:01:58 +01:00
Jehan 6f09e099d6 Issue #5992: Mask to Selection isn't selecting the right place. 2020-11-26 16:18:04 +01:00
Jehan 0e8acc5dd6 Issue #5985: GIMP crashed when deleting paths. 2020-11-26 02:16:59 +01:00
luz paz bb322d94d7 Fix typos
Found via:
```
codespell -q 3 -S ./ChangeLog*,*.po,./.git,./NEWS* -L als,ang,ba,chello,daa,doubleclick,foto,hist,iff,inport,klass,mut,nd,ower,paeth,params,pard,pevent,sinc,thru,tim,uint
```
2020-11-19 21:56:25 +01:00
Jehan a86ed68870 app: wait for the software to be fully initialized before processing…
… DBus calls.
In particular, Aryeom would start GIMP and directly double click some
image to be loaded in GIMP in the very short while when splash is
visible. Previous code would wait for the `restored` flag to be TRUE.
This was nearly it as we can actually start loading images as soon as
the 'restore' signal has passed. Yet the flag is set in the main
handler, but we actually also need the <Image> UI manager to exist,
which is created in gui_restore_after_callback() (so also a 'restore'
handler, yet after the main signal handler, i.e. after `restored` is set
to TRUE). Without this, gui_display_create() would fail with a CRITICAL,
hence file_open_with_proc_and_display() as well.

I could have tried to set the `restored` flag later, maybe with some
clever signal handling trick (and handle both the GUI and non-GUI cases,
i.e. I cannot set the flag inside gui_restore_after_callback() as it
would break the non-GUI cases). Instead I go for a simpler logics with a
new `initialized` flag which is only meant to be set once, once
everything has been loaded, i.e. once you can consider GIMP to be fully
running hence ready to process any common runtime command.
2020-11-10 21:51:57 +01:00
Jehan 68cea84658 app: fix AppStream tag localization.
As AppStream docs says, <description> "tag should be translated
by-paragraph" in upstream metadata, which is what we have always done
(i.e. <_p> tags which becomes <p xml:lang="xy">).

Unfortunately as_app_get_description() is optimized to work for
Collection Metadata where the 'tag is translated "as a whole"' (again
cf. specs) for faster parsing. So we were ending up with a text mixing
the original and all localized texts.
I have opened a bug report to appstream-glib:
https://github.com/hughsie/appstream-glib/issues/381

While waiting for this to be fixed (i.e. when the function will handle
both cases accordingly to the metadata source), this code makes my own
locale extraction (defaulting to original text which is assumed to be
the previous same level tag with no xml:lang if no tag with the exact
lang attribute was found).
2020-10-23 00:24:16 +02: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
Jehan 1a90a2df32 app: fix alpha to selection on single layer with offset. 2020-10-21 17:36:58 +02:00
Jehan 3e0be2046e app: fix wrong extension active state on exit.
First the deserialize data of extensionrc was wrong. I need to edit the
pointer to the GList (and dereference it when I need).

Also when inserting an extension into the `running_extensions` hash
table, I could not reuse the same string as in the `processed` list
(because this string is going to be freed at end of initialization).
Just always use the GimpObject name of the extension, since it will stay
alive for as long as the object is alive.
2020-10-09 15:30:54 +02:00
Jehan 9c4860b31e app: check extensionrc existence before trying to parse it.
On first run, it would not exist (which is normal) which was producing
an error message on stderr.
2020-10-09 15:30:54 +02:00
Jehan c04c2d841d app: fix file comparison.
g_list_find_custom() uses a GCompareFunc which has a return value
similar to strcmp(), i.e. with 0 for equality (and not a boolean, which
is basically the opposite).
2020-10-08 03:20:05 +02:00
Jehan 09fa321074 app: new profile conversion policy to preferred color profile.
Our Preferences exposes a concept of "Preferred color profile" (for RGB,
grayscale and CMYK), which is used in some places to be proposed as
default alternative to built-in profiles. But it was not used in the
import color profile dialog (only 2 choices were: keep the image profile
or convert to built-in RGB).
This commit now adds this third choice, which is even made default when
hitting the "Convert" button directly, without tweaking with the dialog.
Because we can assume that if someone made the explicit choice to label
such a profile as "Preferred", this is more likely the one to convert to
(if one even wants to convert from an embedded profile anyway).

As for the `Preferences > Image Import & Export > Color profile policy`,
they now propose 4 choices: Ask, Keep embedded profile, Convert to
built-in or preferred profiles.
2020-09-24 16:27:34 +02:00
Jehan 67e2e1b5bb app, libgimp, plug-ins: move Orientation metadata handling into core.
Orientation is now handled by core code, just next to profile conversion
handling.

One of the first consequence is that we don't need to have a non-GUI
version gimp_image_metadata_load_finish_batch() in libgimp, next to a
GUI version of the gimp_image_metadata_load_finish() function in
libgimpui. This makes for simpler API.
Also a plug-in which wishes to get access to the rotation dialog
provided by GIMP without loading ligimpui/GTK+ (for whatever reason)
will still have the feature.

The main advantage is that the "Don't ask me again" feature is now
handled by a settings in `Preferences > Image Import & Export` as the
"Metadata rotation policy". Until now it was saved as a global parasite,
which made it virtually non-editable once you checked it once (no easy
way to edit parasites except by scripts). So say you refused the
rotation once while checking "Don't ask again", and GIMP will forever
discard the rotation metadata without giving you a sane way to change
your mind. Of course, I could have passed the settings to plug-ins
through the PDB, but I find it a lot better to simply handle such
settings core-side.

The dialog code is basically the same as an app/dialogs/ as it was in
libgimp, with the minor improvement that it now takes the scale ratio
into account (basically the maximum thumbnail size will be bigger on
higher density displays).

Only downside of the move to the core is that this rotation dialog is
raised only when you open an image from the core, not as a PDB call. So
a plug-in which makes say a "file-jpeg-load" PDB call, even in
INTERACTIVE run mode, won't have rotation processed. Note that this was
already the same for embedded color profile conversion. This can be
wanted or not. Anyway some additional libgimp calls might be of interest
to explicitly call the core dialogs.
2020-09-24 12:43:41 +02:00
Jehan 84e587d255 app: GimpSelectionEditor multi-drawable aware.
When clicking on the selection mask (in the dockable view) or when
dropping a color on this same view, we can now select by color based on
the selected layer composition (not only one single layer, nor the whole
image as sample merged, but also a specific list of composited layers).

gimp_channel_select_by_color() is made multi-drawable aware as a
consequence of this.
2020-08-17 18:22:19 +02:00
Jehan 892fbafdf8 app: some more gimp_image_get_active_drawable() removed.
No logics changed. These are places where we expect single layer
selected.
2020-08-02 01:10:13 +02:00
Jehan 5357628df2 app, pdb: fix pdb and generated code.
Oups! The meson build failing to properly generate code is annoying!
2020-08-01 16:36:27 +02:00
Jehan 2ba6ac6286 app: selection stroke and "Stroke Path" now multi-layer aware.
This includes "select-stroke*" actions and "Stroke Path" feature of the
Vector tool.
2020-08-01 14:02:24 +02:00
Jehan 6b829c7008 app: Selection fill and "Fill Path" now multi-layer aware.
This includes the actions "select-fill*" as well as the "Fill Path"
feature in the Vector tool which were using common code.
2020-08-01 13:12:21 +02:00
Jehan 62eedd41b4 app: layers-alpha-add|remove multi-layer aware. 2020-07-30 21:03:03 +02:00
Ell 95b69dd77b app: in GimpBacktrace Windows backend, return NULL backtrace if not initialized
In the Windows implementation of gimp_backtrace_new(), return NULL
if the backend is not fully initialized.
2020-07-30 01:03:37 +03:00
Jehan 73b960aefb app: fix a build warning.
Fixes:
> warning: passing argument 1 of ‘GIMP_CONFIG’ discards ‘const’
> qualifier from pointer target type.
2020-07-20 15:41:22 +02:00
Jehan d3ef6cfb18 app: show playground if any of the experimental feature is enabled.
Basically if you enabled OpenCL or any of the experimental tools, it
will show the Playground in Preferences. Otherwise, say you enabled some
experimental feature months ago (e.g. with the CLI option) and you now
experience crashes or whatnot. And you forgot how to change it, and only
remembered that there was something in Preferences. It would make you
crazy to not find the tab again to disable the option.

This is even more important as OpenCL is moving from a normal option to
a playground option. So you might not even have ever seen the Playground
tab in Preferences and would not know how to disable OpenCL after you
enabled it originally in "System Resources" tab.

So now Playground is visible with any of these 3 conditions:
* If you use an unstable version.
* If you run GIMP with --show-playground option.
* If you previously enabled one of the playground options.
2020-07-17 13:28:43 +02:00
Jehan 74d0990456 app: fix Alpha to Selection for single selected layer.
By adding support for multiple selected layers, it seems I broke the
single selected layer case. Fixed now!
2020-07-06 23:15:12 +02:00
Jehan 86716ba8a4 app: fix gimp_image_merge_down() when merging multiple neighbour layers.
If the next visible layer below a selected layer is itself selected, we
want to create bigger merge list with all 3 layers merged at once (or
even more if the next-next is also selected, and so on).
2020-07-01 00:40:40 +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 dadae644bf app: fix selected layers in duplicated image.
This seems to have been broken since much longer, but it only made a
problem with recent changes. Since we were duplicating layer groups and
contents layers at once, the current code could not keep layer selection
other than at root level in a duplicated image.
Use the layer paths to make sure we select exactly the right copied
layers, since the path should not change in a fully duplicated image.
2020-06-27 18:07:51 +02:00
Ell c4a201eaf4 Issue #5208 - paint brush is broken when aspect ratio is set to negative
Fix horizontal downscaling of brush mipmap levels with odd width.
We'd previously fail to skip the last pixel of each input row,
which isn't included in the output when the width is odd, causing
subsequent output rows to be shifted to the right.
2020-06-12 17:30:28 +03:00
Ell 214936e8c6 app: use absolute offset for filter-tool split-preview guide position
In GimpDrawableFilter and GimpFilterTool, use an absolute offset
for the split-preview guide position, instead of storing it as a
fraction of the drawable's width/height.  The latter could
introduce rounding error, which would result in wrong coordinates
when converted back to an absolute offset.
2020-06-11 20:45:33 +03:00
qarmin be5d23bf98 Compare counter value instead its pointer address 2020-05-31 10:04:13 +00:00
Jehan 647ebffe7b app: GimpTransformTool multi-layer aware.
This implied a lot of other core changes, which also pushed me into
improving some of the edit actions and PDB calls to be multi-layer aware
in the same time.

Note that it is still work-in-progress, but I just had to commit
something in an acceptable intermediate state otherwise I was just going
crazy.

In particular now the various transform tools are multi-layer aware and
work simultaneously on all selected layers (and the linked layers if any
of the selected layers is linked too). Both preview and final transform
processing works.
In the limitations, preview doesn't work well (only one layer in the
preview) when there is a selection (though the actual transform works).

Also I am left to wonder how we should process this case of canvas
selection+transform on multi-layers. Indeed currently I am just creating
a floating selection (like we used to for the selection+transform case)
containing a transform result of the composited version of all selected
layers. This is a possible expected result, but another could be to get
several transformed layers (without composition). But then should the
"Floating Selection" concept allow for multiple Floating Selections?
Sooo many questions left to answer.
2020-05-28 14:28:01 +02:00
Jehan b8eef4e859 app: fix check for XCF 14.
I must obvioulsy check for selected layer number over 1, not 0. Right
now, all common XCF files ended as being version 14.
2020-05-26 16:57:27 +02:00
Jehan b05fc6950d app: create and use gimp_image_item_list_linked().
This function returns a new list of items from an input list. The output
list will optionally contains linked items if any of the input item is
linked so we don't have to rewrite the same duplicated code for every
feature where item links matter.

Moreover it also filters descendants if any of the input items is an
item group, hence avoiding to apply a transformation twice to a
descendant item.

Use this new function already in 2 places, hence skimming quite a bit of
redundant code.
2020-05-26 14:15:17 +02:00
Jehan 661f057603 app: add gimp_image_equal_selected_drawables().
This can be used in various places where we want to check whether a
previously saved list of drawables is still the same list of selected
drawables. It used to be easily done with an equality test with a single
active drawable, but not anymore with a list of selected drawables.
2020-05-26 14:15:17 +02:00
Ell 258c8454d5 app: implement GimpColorManaged for GimpImageProxy
In GimpImageProxy, implement GimpColorManaged by forwarding the
functions to the underlying GimpImage, and forwarding the signals
in the other direction.  This fixes color-managed view in the
Navigation dockable.
2020-05-22 16:35:56 +03:00
Ell d9f5558977 app: update core-enums.c 2020-05-22 16:35:56 +03:00
Jehan 5c221df99f app: layers-blend-space-* & layers-composite-space|mode-* multi-layer…
… aware.
2020-05-21 00:04:37 +02:00
Ell 09870d4b15 app: zero-out transparent pixels when converting to indexed
When converting an image to indexed mode, zero-out transparent
pixels instead of leaving junk in their indices, which might well
be out of range of the palette.
2020-05-20 21:16:52 +03: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
Ell a90f59d961 app: fix alignment of generic pixel buffers
Wherever we store arbitrary-format colors in an opaque buffer, use
double for the buffer, instead of char, so that it has a strict-
enough alignment to handle all our used pixel formats.
2020-05-20 08:53:41 +03:00
Jehan 5e960ad56b app: fix gimp_item_tree_get_insert_pos() with GIMP_IMAGE_ACTIVE_PARENT.
Don't check for NULL parent as it is a valid parent (for a root item).
Check instead just if we are the first item in the list.
2020-05-18 00:30:19 +02:00
Jehan a7c59277fb app: quick on-canvas copy-paste multi-layer aware. 2020-05-17 23:00:07 +02:00
Jehan 5498adf50a app, libgimp, pdb: color picker multi-layer aware.
Color picking on a single layer still works as it used to. On multiple
layer, it will now pick on the composited color, similarly to sample
merged if only selected layers were made visible.

The PDB/libgimp function gimp_image_pick_color() is also updated to work
on multiple drawables too, giving the same ability to plug-ins (the only
call to this function in core plug-ins have been updated).
2020-05-17 18:57:32 +02:00
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 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 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 8f22f12ee7 app: layers-lock-content and layers-lock-position multi-layer aware. 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 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 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 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 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 dbae0e436c app: new function gimp_item_is_ancestor(). 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 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 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 178f32f6a5 app: adds multi-selection support to "layers-delete" action. 2020-05-17 18:32:15 +02:00
Jehan 0593cf4c9e app: add concept of multi-selected layers in GimpImage.
Still the very base of the feature, mostly in test mode.
2020-05-17 18:32:15 +02:00
Jehan b487087429 app: add concept of selected items in GimpItemTree.
Instead of a single active item, we now have a list of selected items. I
keep the concept of "active" item (for now at least) when there is one
and only one item selected.

Also note that when inserting an item into the active parent's
container, it now requires all selected items to have the same hierarchy
(same parent). Same when adding on top of the selected items (in which
case, it means on top of the highest one).
2020-05-17 18:32:15 +02:00
Jehan b11e529316 app: fix a few warnings.
Fixes:
> warning: passing argument 1 of ‘gimp_list_get_sort_func’ from incompatible pointer type

Since commit f4c6d4bb79.
2020-05-14 17:01:13 +02:00
Niels De Graef 2afcca4e13 gimpcurve: Use g_object_notify_by_pspec
From commit 529aa743:

> `g_object_notify()` actually takes a global lock to look up the
> property by its name, which means there is a performance hit (albeit
> tiny) every time this function is called. For this reason, always try
> to use `g_object_notify_by_pspec()` instead.

While just _loading_ GIMP on my machine (ie during the splash screen)
`g_object_notify (curve, );` got called more than 6000 times already, so
it's not an unused path.

Note that it's also less easy to make an accidental typo when using
`g_object_notify_by_pspec()`, as the compiler will complain about the
enum value being incorrect.
2020-05-12 22:38:41 +02:00
Michael Natterer 97b714d428 Issue #3533 - Tool preset doesn't restore opacity and paint mode
There is no non-hackish way of fixing this without adding a new
"use-opacity-paint-mode" property to GimpToolPreset and a new toggle
in GimpToolPresetEditor. Restoring opacity and paint mode can now be
controlled explicitly, and defaults to TRUE.
2020-05-12 21:13:29 +02:00
Niels De Graef 7ac6f0a22e viewable: Use GET_PRIVATE() before precondition checks
`GET_PRIVATE()` expands to `gimp_viewable_get_instance_private()`, which
just returns an offset of the passed on pointer. As such, it's safe to
call this on any value (even NULL) and to put it at the top of the
function block, saving some lines.
2020-05-12 17:59:08 +02:00
Niels De Graef 88b9359efc viewable: Use g_object_notify_by_pspec()
From commit 529aa743:

> `g_object_notify()` actually takes a global lock to look up the
> property by its name, which means there is a performance hit (albeit
> tiny) every time this function is called. For this reason, always try
> to use `g_object_notify_by_pspec()` instead.

While just _loading_ GIMP on my machine (ie during the splash screen)
`g_object_notify (viewable, "icon-name");` got called more than 4000
times already, so it's not an unused path.

Note that it's also less easy to make an accidental typo when using
`g_object_notify_by_pspec()`, as the compiler will complain about the
enum value being incorrect.
2020-05-12 17:59:03 +02:00
Niels De Graef bd69747014 viewable: Get rid of unused "stock-id" property
The property was only foreseen for backwards compatibility, so let's get
rid of it as we have the opportunity.
2020-05-12 13:27:30 +02:00
Niels De Graef f4c6d4bb79 gimplist: Don't use sort_func field directly
Ideally, we expose as little fields of our struct as possible, so we
don't have to care too much about API/ABI stability.
2020-05-10 16:05:12 +00:00
Niels De Graef 7a8a300adc gimpconfig-iface: Use G_DECLARE_INTERFACE 2020-05-10 14:45:19 +00:00
luz.paz 36f620012d Fix typos
Found via codespell v1.17.0.dev0  
```
codespell -q 3 -S ./ChangeLog*,*.po,./.git,./NEWS* -L als,ang,ba,chello,daa,doubleclick,foto,hist,iff,inport,klass,mut,nd,ower,paeth,params,pard,pevent,sinc,thru,tim,uint
```
2020-05-04 08:55:48 -04:00
Niels De Graef db0493aa0d gir: Add more (out) annotations
This will change the API for some bindings, so we probably want to do it
before a release.
2020-05-03 17:57:23 +02:00
Niels De Graef 8d1ad63f3a Use %NULL instead of NULL in gtk-doc comments
This allows comments in bindings to other languages to use their
equivalent of `NULL`, e.g. `None` in python or `null` in Vala.
2020-05-03 17:40:14 +02:00
Niels De Graef 5f1598f63d gir: Add more (out) tags when appropriate
This makes a big difference for bindings, so make sure out-parameters
are properly annotated.
2020-05-03 17:35:01 +02:00
Øyvind Kolås 80664c8e6e app: do not snap white/black when making 2 color palette
For such needs there is a dedicated 1bit black/white palette in the
dialog.
2020-05-01 17:35:50 +02:00
Niels De Graef 85d9730936 Add some missing (nullable) annotations
Fixes https://gitlab.gnome.org/GNOME/gimp/-/issues/4750
2020-05-01 15:34:56 +02:00
Øyvind Kolås d4387987b5 app: when creating palette only snap to black/white when present
By only doing the snapping to white/black for whitest/blackest palette
entries when the original RGB data contained these colors we permit
choosing near white/black colors in the cases where this might be
a desirable result as the whitest/blackest colors.
2020-05-01 02:19:15 +02:00
Øyvind Kolås 9bb3ff42d7 app: make generated indexed palettes possibly contain pure black/white
The median-cut algorithm to derive a suitable palette for the image
computes each index to be used as the average of colors in a 3d box
in a color space, making the result value drift away from the extremes.
This makes it nigh impossible to achieve pure white or black, even
when the original image contained these colors, like in scans of
printed documents and technical drawings.

We counteract the drift by snapping the whitest color to white and the
blackest color to black if the resulting colors of median-cut are
already sufficiently close to white or black.
2020-04-30 21:21:16 +02:00
Ell 56693a8393 app: when copying GimpCurve, don't overwrite points from samples
In gimp_curve_config_copy(), make sure to copy the curve type
*before* the points, so that, when changing the type from FREE to
SMOOTH, we don't overwrite the copied points with interpolated
samples.
2020-04-14 18:01:59 +03:00
Ell 4932beb302 app: fix last commits 2020-04-08 01:04:29 +03:00
Ell 7b46a8be45 app: exclude GimpSettings::time property from comparison
As per last commit, explicitly exclude the GimpSettings::time
property from comparison.
2020-04-08 00:26:45 +03:00
Ell c5c807d191 libgimpconfig: add GIMP_CONFIG_PARAM_DONT_COMPARE flag
... which excludes a property from comparison in the default
implementation of GimpConfig::equal().
2020-04-08 00:10:42 +03:00
Ell c81cb59e4e app: apply common operation settings when reapplying a filter
Add a new gimp_drawable_apply_operation_with_config() function,
which takes an operation node together with a config object, and
applies the operation using the config options, including both the
operation-specific options, and the common GimpOperationSettings
options.

Use the function in gimp_gegl_procedure_execute(), so that
reapplying a filter takes the common operation settings used
originally into account.
2020-04-07 19:39:53 +03:00
Ell 8c619bf0b2 app: add gimp_gegl_node_has_key()
... which determines if a node's operation-class has a specific
key, and can be used instead of gimp_gegl_node_get_key() when only
existence is important, to avoid compiler warnings.

Update the rest of the code to use the new function.
2020-04-07 19:02:18 +03:00
Ell 9947093d02 app: use gimp_drawable_supports_alpha() in GimpDrawableFilter
... instead of GIMP_IS_LAYER()
2020-04-07 19:02:17 +03:00
Ell 9aee8744dc app: add gimp_drawable_filter_get_{drawable,operation,format}()
... which return the filter's drawable, operation, and output
format, respectively.
2020-04-07 19:02:16 +03:00
Ell 7ec033d896 app: add gimp_drawable_filter_set_preview()
... which allows enabling/disabling the filter's preview, without
destroying cached data.
2020-04-02 18:56:02 +03:00
Ell 616530e235 app: rename gimp_drawable_filter_set_preview() to _set_preview_split()
... in preparation for next commit.

Update GimpFilterTool accordingly.
2020-04-02 18:55:18 +03:00
Niels De Graef 878804fb01 Cleanup GObject signal marshallers
* Don't generate our own marshallers if they are available in GLib
  already
* Don't set the c_marshaller parameter in `g_signal_new()` if it's a
  default marshaller provided by GLib. See commit message of commit
  39e4aa3c57 on why this is the case.
2020-04-01 21:20:01 +00:00
woob 9a9e2e9a19 app: leave locked pixels alone when cropping
Cropping tools will no longer discard layer data that falls out of the
crop region if the layer's pixels are locked
2020-04-01 18:14:20 +00:00
Ell 6ed9b2bb7a Issue #4846 - Symmetry origin is wrong when painting on offset drawable
In gimp_symmetry_{mirror,mandala}_update_strokes(), adjust the
symmetry origin according to the drawable offset, so that it
remains fixed relative to the image regardless of the drawable
position.
2020-03-26 20:29:40 +02:00
Ell 83f935873a Issue #4858 - Duplicated image shows NULL in warning when closing it
In gimp_image_duplicate(), explicitly mark the new image as dirty,
so that its dirty time is set.  This avoids showing a NULL message
in place of the dirty time when closing the image.
2020-03-23 22:31:02 +02:00
Ell 64bf77aed8 app: render layer-group preview in chunks
In gimp_drawable_get_sub_preview_async(), when the drawable buffer
has a validate handler (i.e., when it's a group layer), use a chunk
iterator to validate the buffer in chunks, where each chunk is
validated in a separate invocation of the async function.  This
prevents validation from blocking the main thread for too long when
the buffer is not already fully validated.
2020-03-14 16:05:47 +02:00
Ell 919ddce773 app: speed up layer-group preview rendering
In gimp_drawable_get_sub_preview_async(), when the drawable buffer
has a validate handler (i.e., when the drawable is a group layer),
validate the requested area before calling gegl_buffer_get(), so
that the buffer is validated in a single step, instead of tile-by-
tile.
2020-03-14 13:54:58 +02:00
Ell faf6acfb67 app: add "chunked" parameter to gimp_tile_handler_validate_validate()
... which allows validating the area in chunks, instead of in a
single step.
2020-03-14 13:54:57 +02:00
Ell 30f509c84d app: allow waiting on idle asyncs
In gimp_idle_run_async(), connect to the async's "waiting" signal,
and run the async func in the context of the caller in response, to
avoid blocking indefinitely.
2020-03-14 13:54:57 +02:00
Ell fe82ee54e8 app: white-space fix in gimp-utils.c 2020-03-14 01:01:11 +02:00
Ell 10fe3009ed app: avoid duplication in gimp_drawable_get_sub_preview_async() 2020-03-14 00:57:15 +02:00
Ell fee159e6b4 Issue #4793 - Layer-group preview-update blocks UI when adding/removing layers
In gimp_drawable_get_sub_preview_async(), use
gimp_idle_run_async_full() to render the preview in a low-priority
idle source when the drawable uses a validate handler (i.e., when
it's a group layer), to avoid rendering the preview before the
projection is done rendering, causing a noticeable freeze.
2020-03-14 00:45:33 +02:00
Ell 6733b153cc app: add gimp_idle_run_async[_full]()
In gimp-utils, add new gimp_idle_run_async() and
gimp_idle_run_async_full() functions, having the same signature as
gimp_parallel_run_async[_full](), but running the async function in
an idle source on the main thread, instead of in a separate thread.

The 'priority' parameter of gimp_idle_run_async_full() specifies
the idle-source priority.
2020-03-14 00:45:32 +02:00
Ell f25a8934fa app: rename GimpParallelRunAsyncFunc to GimpRunAsyncFunc
... and move it to core-type.h, in preparation for next commit.
2020-03-14 00:43:43 +02:00
Ell aa9ae1c65c Issue #4634 - Pass-through groups bounding-box is not properly updated ...
... causing artifacts

In GimpGroupLayer, override GimpLayer::get_bounding_box() to return
the group's own calculated bounding box for pass-through groups,
instead of using the group graph's bounding box, as calculated by
the default implementation of GimpDrawable::get_bounding_box().
We don't currently update the group's bounding box in response to
all the events that may affect the graph's bounding box, which can
lead to artifacts, neither should we use the graph's bounding box
anyway, since it includes the backdrop's bounding box, as the
group's layers are composited against the background.

Note that we still use the graph's bounding box for non-pass-
through groups, since it takes attached filters into account,
which are applicable for normal groups, but not pass-through
groups.

Additionally, don't restrict the group's bounding when it has a
mask, since this is now handled by GimpLayer.
2020-02-21 22:55:34 +02:00
Ell 8c81c6e153 app: fix layer group effective mode for different mask modes
In gimp_group_layer_get_effective_mode(), don't take the mask into
account if GimpLayer::apply-mask is FALSE.
2020-02-21 22:55:33 +02:00
Ell 7f53cf9c55 app: fix layer bounding box for different mask modes
In gimp_layer_get_bounding_box(), return the mask bounding box when
show-mask is active, and otherwise delegate the actual layer
bounding box calculation to a new GimpLayer::get_bounding_box()
function, and intersect its result with the mask bounding box, if
necessary.  The default GimpLayer::get_bounding_box()
implementation simply chains up to
GimpDrawable::get_bounding_box(), but GimpGroupLayer will override
this function in the following commits.
2020-02-21 22:55:33 +02:00
Ell b2a1a7cb01 app: fix layer effective mode for different mask modes
In GimpLayer, update the effective mode, and excludes-backdrop,
when any of the mask-related properties change, and, when show-mask
is active, set the effective mode to NORMAL.
2020-02-21 22:54:16 +02:00
Ell ae6f6ba42a app: fix incorrect drawable format after applying a filter that resizes the drawable
In gimp_drawable_merge_filter(), fix the format of newly allocated
buffers when applying a filter that changes the size of the
drawable, and the requested format is either unspecified, or
matches the existing drawable format.  The new buffer would
previously be created with a "RGBA float" format in this case,
regardless of the image precision, resulting in a potential
mismatch between the drawable format and the image precision.

This cna lead to inconsistent buffer data when saved as XCF, which
is later rejected on load.  See issue #4643.
2020-02-21 12:02:55 +02:00
Ell 30e925065f app: fix gimp_brush_mipmap_get_memsize()
Don't include the main mask/pixmap buffer size -- it's already
counted in gimp_brush_get_memsize().
2020-02-13 16:56:33 +02:00
Ell f797f688ad app: reorganize #includes in gimpbrush-{mipmap,transform}.cc 2020-02-13 00:14:28 +02:00
Ell ee39f0ec13 app: use mipmaps when downscaling raster brushes
When downscaling raster brushes, we currently resample the original
brush with no fitlering (other than bilinear interpolation), which
results in very noticable aliasing when using heavily downscaled
big brushes.

This commit constructs a box-filtered mipmap hierarchy for the
original brush on-demand, and the closest mipmap is used as the
resampling source for downscaled brushes, significantly improving
the output quality.
2020-02-13 00:03:22 +02:00
Ell 2dddf59dbf app: add gimp_brush_transform_get_scale()
... which converts a (scale, aspect_ratio) pair to a (scale_x,
scale_y) pair.

Change gimp_brush_transform_matrix() to take (scale_x, scale_y)
parameters, instead of (scale, aspect_ratio), and change the rest
of the code accordingly.
2020-02-12 23:59:49 +02:00
Ell e0e1ad5e2a app: fix brush-transform resampling
In gimpbrush-transform.cc, resample the transformed brush at pixel
centers instead of edges, and fix the corresponding source
coordinates.
2020-02-12 23:59:48 +02:00
Ell 52cb2edd9e Issue #4605 - Invalid abr brush crashes GIMP
When loading ABR brushes, error out on negative scan-line lengths,
instead of trying to allocate a huge buffer.  This entire code
could use a whole lot more unsignedness, but this should cover the
crash.
2020-02-11 18:00:17 +02:00
Ell 782e209a33 app: in abr_rle_decode(), avoid freeing NULL scratch buffers
... gegl_scratch_free() doesn't generally accept NULL pointers.
2020-02-11 18:00:16 +02:00
Ell 07f95291a5 app: improve ABR brush loading speed
Improve the efficiency of decoding RLE data when loading ABR
brushes, by reading entire scanlines into a buffer all-at-once,
instead of reading the stream byte-by-byte.
2020-02-11 02:25:46 +02:00
Ell 893990afce Issue #4584 - Segfault when closing an image with a layer group ...
... containing a floating selection

When destroying a GimpGroupLayer, remove all the children signal
handlers before destroying the container, so that we don't attempt
to reallocate the group's projection in response to
"update-bounding-box" signals emitted during layer destruction,
which can happen for floating selections.
2020-02-07 23:37:21 +02:00
Ell 0891f1275a app: add gimp_container_remove_handlers_by_{func,data}()
... which remove all handlers matching the given callback/callback-
data.

temp
2020-02-07 23:37:21 +02:00
Ell db678ad212 app: in polynomial_odd_roots(), fix derivative array size 2020-02-07 00:56:07 +02:00
Ell 3a8725a409 app: add missing file to last commit 2020-02-05 01:19:18 +02:00
Ell d920569771 app: add support for offset buffers in GimpScanConvert
Ditto.
2020-02-03 21:21:09 +02:00
Ell 24534338e7 app: add support for offset buffers in gimp_channel_select_buffer() ...
... and gimp_gegl_mask_combine_buffer()

Allow the functions to work with buffers whose top-left corner is
not at (0, 0).
2020-02-03 21:21:08 +02:00
Ell 3cda972100 app: add a "Use tool groups" option to the toolbox preferences
Add a new Gimp::tool_item_ui_list, which is a GimpTreeProxy over
Gimp::tool_item_list.  This allows us to use either a hierarchical
or a flat tool list in the UI, by setting the "flat" property of
the new list.

Use Gimp::tool_item_ui_list in GimpToolPalette, so that the toolbox
layout is affected by this choice.

Add a "Use tool groups" toggle to the toolbox preferences, and bind
it to the "flat" property of Gimp::tool_item_ui_list.
2020-02-01 13:19:08 +02:00
Ell 2caa518b19 app: add GimpTreeProxy
Add a new GimpTreeProxy container class, which proxies a
GimpViewable tree.  The proxy has a dynamically-settable boolean
"flat" property, which controls if the tree hierarchy is preserved,
or if it's viewed as a flat list.
2020-02-01 13:15:25 +02:00
Ell c4cc015c43 app: add gimp_container_search()
Add a new GimpContainer::search() virtual function, and a
corresponding gimp_container_search() function, which works
similarly to gimp_container_foreach(), except that the callback
returns a boolean.  When the callback returns TRUE, the search is
stopped, and the current object is returned.

Implement GimpContainer::search() in GimpList.
2020-02-01 13:14:29 +02:00
Ell ee9661237e app: add GimpToolItem::shown property
Add a new read-only GimpToolItem::shown property, and a
corresponding GimpToolItem::shown-changed signal, which determines
if a tool item is visible throughtout the hierarchy, i.e., if it
and all its ancestors are visible.  This replaces
gimp_tool_item_is_visible().

Use the new property and signal in GimpToolPalette and
GimpToolEditor, to simplify the code, and in preparation for a flat
toolbox view.
2020-02-01 13:14:28 +02:00
Ell 30d833d00f app: use a weak pointer for tool-manager active group
In GimpToolManager, use a weak pointer for tracking the active tool
group, instead of taking a reference on it.  This avoids
erroneously extending the group's lifetime, which can cause
problems with the tool-item hierarchy.

In GimpToolGroup, make sure that newly-added tools don't already
have a parent.
2020-02-01 13:14:28 +02:00
Ell ffe4f8a068 app: add gimp_tool_info_get_action_name()
Move the logic for translating a tool identifier to a corresponding
action name to GimpToolInfo.  It's currently only used in
tools-actions.c, but the next commits will use it in tool buttons.
2020-01-30 02:51:56 +02:00
Ell 2255d62891 app: don't register action for GimpOperationTool
Allow creating GimpToolInfo objects with a NULL menu label, and do
that for GimpOperationTool.  The previous commit effectively
removed it from the Preferences tool editor, and this commit also
removes it from the action search.
2020-01-30 02:51:56 +02:00
Ell cd2adfbede app: add support for tool groups in toolrc
Add a new Gimp::tool_item_list list, in addition to
Gimp::tool_info_list.  The latter may contain arbitrary tool items,
including tool groups, and is intended for use in the UI (namely,
the toolbox and the preferences tool editor).

In gimp-tools, use Gimp::tool_item_list for representing the UI
tool order (while still using Gimp::tool_info_list as a flat list
of all GimpToolInfo objects), and add support for saving and
loading tool groups to/from toolrc.

Introduce file-version tracking in toolrc, and drop its contents on
version mismatch, or when new tools are introduced.  This is
slightly disruptive, but merging new changes with existing toolrc
files is non-trivial, and it doesn't happen very often.

Add support for a sysconf toolrc file, which is used if there's no
user toolrc file (i.e., on first use).  If neither file is found,
the hard-coded flat tool order is used.  This commit doesn't
provide a default toolrc file, but the next commits will.

Make the gimp-tools serialization and deserialization functions
public, for use in GimpToolEditor in the next commits.
2020-01-30 02:51:56 +02:00
Ell a63bf32310 app: don't merge similarly-named objects during GimpContainer deserialization ...
... if not using unique names

Add a new GimpContainer::get_unique_names() virtual function, and a
corresponding gimp_container_get_unique_names() function, which
determines if the container uses unique names for its objects.
Override get_unique_names() in GimpList, to return the corresponding
property.

In gimp_container_deserialize(), don't merge new objects with
existing objects sharing the same name if the container doesn't use
unique names.
2020-01-30 02:51:56 +02:00
Ell 49196140e2 app: add GimpToolGroup as a subclass of GimpToolItem
Add GimpToolGroup as a new subclass of GimpToolItem, representing a
collection of tools.  The end goal is to display tool groups using
a single button in the toolbox.

Tool groups are not recursive: they can only contain individual
tools, not other groups.  Each group has a single "active tool",
normally the most-recently-used tool of the group, which is
activated when clicking on the tool's button.
2020-01-30 02:51:54 +02:00
Ell 77111ba045 app: add GimpToolItem; derive GimpToolInfo from it
Add GimpToolItem as a common base class for toolbox items.
Derive GimpToolInfo from GimpToolItem, representing an individual
tool.  The next commits add support for tool groups, represented by
an alternative subclass of GimpToolItem.

Most of the tool-info properties remain in GimpToolInfo, however,
GimpToolItem takes care of tool-item visibility.
2020-01-30 02:50:15 +02:00
Elad Shahar ed6517f094 app: Fix Mandala Symmetry Kaleidoscope mode - brush transform and stroke order
Changed the reflection method to find the middle of the slice the
user is drawing on, and reflecting on that. This reflects the slice
in place, making it easier to rotate it to the intended location.
This fix preserves the order the dabs are drawn on the
slices, to be counterclockwise.

Fixed the brush transform, by setting the reflect output variable,
and calculating accordingly.
2020-01-22 01:17:23 +02:00
Ell b99a2631ef app: avoid deleting empty layer groups when downscaling image
When dowscaling an image (or a layer group), empty layer groups
can be discarded as a result of their new dimensions being too
small, since we're calculating their new dimensions according to
their fake 1x1 dimensions.  However, these dimensions are purely an
implementation detail and shouldn't affect the result, and neither
do we show a warning for them.

Instead, simply avoid discarding empty layer groups.
2020-01-21 20:15:58 +02:00
Ell 18870975b8 app: restrict whole-drawable updates to groups with filters
Restrict last commit's workaround to layer groups only (which is
the only relevant case ATM), since it negatively impacts the warp
tool, which does rely on the ability to perform (accurate) partial
updates with filters to improve performance.  It's only a temporary
hack anyway.
2020-01-20 00:38:04 +02:00
Ell 8be0e646bc app: always update full drawable region if it has filters
When a drawable has filters attached, they may influence the area
affected by drawable updates.  Currently, we ignore that, updating
the original region regardless.  This can lead to drawable updates
not affecting the correct regions.  This couldn't be triggered
until now, but since layer groups can now have a transform op
attached as a filter, updates to their sublayers -- which can
happen while the transform tool is active -- run into this problem.

Fix it for now by simply updating the full drawable region when the
drawable has filters.  This is a very conservative approach -- we
don't even bother checking if we're only dealing with point
filters, as this change only influences transformed groups right
now.  Ultimately, we need to rely on node invalidation to drive
updates, which takes this into account.
2020-01-19 21:06:24 +02:00
Ell 1e26ce8a60 app: don't emit GimpImage::linked-items-changed for non-attached items
In gimp_item_set_linked(), don't emit the
GimpImage::linked-items-changed signal if the item is not attached.
2020-01-19 21:06:23 +02:00
Ell 7d6737fe9a app: add GimpImage::linked-items-changed signal
Add a new GimpImage::linked-items-changed signal, which is emitted
whenever the set of linked items in an image changes.
2020-01-18 15:18:41 +02:00
Ell 203bc9d893 app: disable transform clipping for layer groups
Using any clipping mode other than ADJUST is currently broken for
layer groups, since each layer in the group is clipped
individually, instead of clipping being applied to the group as a
whole.  Ultimately, we should fix that, but for now, simply disable
clipping for layer groups, by overriding GimpItem::get_clip() to
always return ADJUST.
2020-01-18 11:13:27 +02:00
Ell 50b655de27 Issue #1975 - Color to alpha now requires an alpha-channel ...
... (used to add one automatically)

In GimpFilterTool and gimp_drawable_apply_operation(), use
gimp_drawable_filter_set_add_alpha() to add an alpha channel when
applying an operation that specifies "needs-alpha" to a drawable
that can have alpha.

Don't disable gegl:color-to-alpha (which has "needs-alpha") when
the drawable doesn't have an alpha channel, if one can be added.
2020-01-17 12:11:24 +02:00
Ell 5e1eba68e2 app: add GimpDrawable::supports_alpha() vfunc
Add a new GimpDrawable::supports_alpha() virtual function, and a
corresponding gimp_drawable_supports_alpha() function, which
determine if the drawable supports an alpha channel.  The default
implementation returns FALSE, and GimpLayer overrides it to return
TRUE.
2020-01-17 12:06:36 +02:00
Ell 0103fe2c19 app: silence warning in gimp_transform_resize_crop()
The crop-to-result and crop-with-aspect transform-boundary
algorithms seem to consistently fail in some cases, and spit out a
warning, which can be too verbose if it triggers the debug dialog.

Demote the warning to a g_printerr(), with an eye to just dropping
these algorithms altogether.
2020-01-17 00:29:42 +02:00
Ell b9a801f7d4 app: add gimp_drawable_filter_set_override_constraints()
In GimpDrawableFilter, add a
gimp_drawable_filter_set_override_constraints() function, which
allows bypassing certain constraints applied to the filter, based
on the drawable type and state.

Yes, this is a bit of a hack, added mostly as a quick-and-dirty way
to allow us to add filters to layer masks that affect their
bounding box, in preparation for composited transform previews.
2020-01-16 00:23:54 +02:00
Ell 1f81c31405 app: add gimp_drawable_filter_set_add_alpha()
Add an optional "format" parameter to gimp_drawable_merge_filter(),
which specifies the format to use for the output, possibly changing
the drawable's format.

In GimpDrawableFilter, add a gimp_drawable_filter_set_add_alpha()
function, which allows the filter to add an alpha channel to the
drawable when committed (by passing an appropriate format to
gimp_drawable_merge_filter()).
2020-01-16 00:23:52 +02:00
Ell cb5a63e260 app: calculate drawable bounding box according to graph by default
Change the default implementation of
GimpDrawable::get_bounding_box() to return the drawable source
node's bounding box, instead of the drawable's item bounds.  This
allows filters to affect the size of all drawables, including, in
particular, layer masks.

Change GimpLayer's implementation of get_bounding_box() to return
the intersection of the layer's own bounding box, and the layer
mask's bounding box (if it has one), and update the layer's
bounding box when the mask is enabled/disabled, or when its
bounding box changes.
2020-01-16 00:22:19 +02:00
Ell 7f84f10154 app: implement GimpPickable::flush in GimpGroupLayer
... by synchronously flushing the group's projection.  This is
necessary for pass-through groups, since their projection is
normally flushed asynchronously.
2020-01-15 22:03:51 +02:00
Elad Shahar 36dd48aea6 Issue #4484: Add reflection option for mandala symmetry 2020-01-11 23:54:40 +01:00
Ell 7b2e6b7595 app: clip transform-tools preview according to clipping mode
Add a "clip" property to GimpCanvasTransformPreview, specifying the
transform's clipping mode, and clip the preview accordingly.

In GimpTransformGridTool, sync the tool's clipping mode with the
preview's clipping mode.
2020-01-11 17:13:07 +02:00
Ell c93e5a2eae app: fix wrong fix to gimpbacktrace-windows.c
This fixes commit 468f3e84d8.
2020-01-07 22:18:43 +02:00