Commit graph

37 commits

Author SHA1 Message Date
Bruno Lopes
d254c5684c app, libgimp*, plug-ins: Use strtok_s on Windows to fix CRT_INSECURE_DEPRECATE 2026-03-31 16:27:25 -03:00
balooii
8bdb5cbfd7 app: Fix duplicating vector layers 2026-03-26 11:52:24 -03:00
balooii balooii
a2c5d70c92 core, path: Fix image transforms with vector layers
(Modified by CmykStudent from balooii's original merge request)
When performing image-level operations (resize, crop, scale, flip,
rotate, arbitrary transform), paths referenced by non-rasterized vector
layers were being transformed twice:

1. Via the vector layer's overrides, which explicitly transforms
   the referenced path to keep it in sync
2. Via the image-level queue that processes all paths independently

This patch adds a check for whether the layer has been rasterized.
If so, we bypass the vector layer's transform so the path is not
transformed a second time.
2026-03-25 20:29:17 -04:00
Alx Sa
7f39ea1fa9 path: Conditionally scale imported paths
The Path Import dialog has an option to choose whether
the imported paths scale to match the dimensions of the
image or not. While this variable guards scaling the paths
themselves, it did not prevent the viewbox from being scaled
Thus, the paths always appeared to be scaled.

This patch adds a check for the scale parameter in parse_svg_viewbox ()
and conditionally scales the viewbox based on user input.
2026-03-22 01:51:21 +00:00
Alx Sa
ff647fccb0 path, core: Create gimp_vector_layer_set ()
Currently to change vector layer properties,
you need to grab the VectorLayerOptions
and then grab its FillOptions or the
StrokeOptions to make changes.
To make this process more self-contained,
this patch creates a gimp_vector_layer_set ()
function that operates in the same manner
as gimp_text_layer_set (). 
This patch adds properties for Fill -
Stroke properties will be added in a
follow-up commit.
This also adds
automatic tracking for Undoing/Redoing
vector property settings.
A demonstration of its use in DnD colors
and patterns onto the layer dock is
included.
2026-03-17 19:32:51 +00:00
Alx Sa
81cdda873d path: Don't transform rasterized vector layers...
...as vectors
Resolves #15997

For vector layers, we transform either the path
or the layer pixels depending on whether it is
rasterized or not. However, the check for this had
not been updated to account for the new
GimpRasterizable interface, so it did not work
properly.

This patch updates the check to use
gimp_item_is_vector_layer () instead of just
checking if the path exists, as this function
also verifies it hasn't been rasterized yet.
2026-03-15 01:40:32 +00:00
Alx Sa
90273fe90a path: Add gimp_vector_layer_convert ()
When we copy and paste a vector layer,
we need to reattach its path to the
(potentially) new image. Similar to what
we did for NDE filters in 8db97f4e,
we convert the existing path if necessary
before continuing with the gimp_item_convert ()
process. This prevents several CRITICALs,
for instance when copying a group that
contains vector layers rather than the
vector layers directly.
2026-02-26 03:20:05 +00:00
Alx Sa
d35893890d path: Unescape imported path information
When we export paths in GIMP, we escape the <title>
text to ensure it matches the SVG specification.
On import, we were not unescaping the text. This resulted
in changed path names when copying and pasting within
GIMP itself.
This patch adds a call to g_uri_unescape_string () to convert
the escaped text back to its original format.
2026-02-15 00:17:57 +00:00
Alx Sa
0da5e56a7b app/path: Add <title> to SVG import/export
In 84ff512c, we made the SVG id attribute
conform to SVG standards by using a
generic ID. However, we also relied on
that field to rename the path when copying
and pasting in GIMP. As a result, the path
name was lost.
This patch adds a <title> element inside the
<path> element, per David Gowers.
This allows us to retain the original
path name when copying and pasting
paths within GIMP itself, as this also adds
a check to see if there's a title element and
uses that as the path name.
2026-01-08 03:01:52 +00:00
Alx Sa
52bf4bb6ee path: Update path import code from C-based librsvg
GIMP's path import code is largely copied
from an earlier version of rsvg. Therefore,
it does not include updates that made
number processing more robust
(such as properly parsing 'c1.5.2' as '1.5, 0.2'
for curve coordinates)

Per the suggestion by @federico, this patch
updates our code using rsvg-path.c from 
the last version of the C-based librsvg
(updated November 3rd, 2016).

Our original code also broke if there was any
spaces after the last item in the SVG transform
attribute. This patch adds a call to
g_strstrip () to trim any unnecessary spaces
either before or after the transform string
to prevent this issue.
2025-11-25 23:27:52 +00:00
Alx Sa
84ff512cfa path: Use generic ID for path export
Resolves #13570
The SVG specification prohibits certain characters
from being used as part of a path id attribute, such as
whitespace and hyphens. Rather than try to filter the
path name selected by the user, this patch switches to
an auto-incrementing "path%d" format to ensure any
exported path can be read by strict parsers. This also
matches how we implemented ids in the SVG export
plug-in.
2025-11-22 17:49:33 +00:00
Jehan
2edd6ccb95 app, pdb: do not push undos on rasterizables when loading a XCF.
Fixing:

> GIMP-CRITICAL: gimp_image_undo_push_rasterizable: assertion 'gimp_item_is_attached (GIMP_ITEM (rasterizable))' failed

… when loading the XCF from #14131.
2025-10-23 01:16:58 +02:00
Jehan
1235bf00bd app: factorize auto-rename code into GimpRasterizable.
Rasterizable objects are all created from some side data and can be
renamed automatically based on this data (from the link file for link
layers; from the path for vector layers; from the text for text layers).

So let's share code.
2025-10-22 22:29:19 +02:00
Jehan
435963324a app: one more file with Windows newline fixed with dos2unix. 2025-10-22 19:33:58 +02:00
Jehan
1a73a4ddc6 app: edit vector layer with path tool as default edit action.
- Getting rid of the dedicated vector layer options dialog (with fill
  and stroke settings) which appeared when double-clicking on a vector
  layer. This is a duplicated with the Path tool options.
- Double-clicking a vector layer instead will simply start the Path tool
  (same as double-clicking a text layer starts the Text tool).
- The path choice settings only is missing from the Path tool options.
  Instead of moving it there, I move it to the generic layer options
  dialog. I don't think it's the kind of setting you really change often
  (most of the time, you likely just make a new vector layer).
- Offsets are ignored too and hidden for vector layers.
- Also making sure that the path changes shows live when editing the
  setting in dialog, but it is properly reverted if canceling the
  attributes edition.
- Also make sure the undo step changes the path back.
2025-10-22 19:33:58 +02:00
Jehan
c5cdea4842 app: copy the rasterization state for all 3 types implementing GimpRasterizable. 2025-10-14 22:06:04 +02:00
Jehan
172d4356c5 app, libgimp, pdb: convert several files newlines with dos2unix. 2025-10-13 18:00:10 +02:00
Jehan
d593cb3230 app, pdb, po: new GimpRasterizable interface.
Share the whole rasterize logic of the text, link and vector layer into
an interface. I didn't write it as an abstract parent class, because we
might have more rasterizable items in the future, which may not be
layers (e.g. there were discussions of vector masks).
2025-10-13 15:37:11 +02:00
Jehan
4752246f8a app: minor coding style cleanup. 2025-10-11 00:04:45 +02:00
Jehan
1e88cfd70f app: make the "Create New Layer" option work properly.
It will duplicate the current path, create a new vector layer based on
it and will let one start editing it.
2025-10-10 23:40:54 +02:00
Jehan
0725b023cd app: add "Confirm Path Editing" dialog on Path tool similar to the…
… "Confirm Text Editing" one on Text tool.

When selecting a rasterized vector layer, this will suggest to edit it
anyway (hence losing any modification since rasterization), create a new
layer based off the same path, or cancel.
2025-10-10 23:34:37 +02:00
Jehan
7c7f7b4898 app, libgimpwidgets: add 2 new icon macros.
New libgimpwidgets icon macros: GIMP_ICON_LAYER_LINK_LAYER and
GIMP_ICON_LAYER_VECTOR_LAYER. Note that the actual icons still need to
be done so I use temporary actual icon designs for now.

Also adding some TODOs for these.

Fix run warning:

> WARNING: icon theme has no icon 'gimp-vector-layer'.
2025-10-10 23:34:37 +02:00
Jehan
94568edb64 app: fix Windows-style line breaks with dos2unix. 2025-10-09 21:03:59 +02:00
Jehan
ac46ece4e3 app: make it possible to retrieve discarded vector layers too. 2025-10-09 21:03:59 +02:00
Bruno Lopes
f09007507f
Declare gexiv2 dependency on many targets (due to gimpmetadata.h)
Our build files were relying 'sysroot' to find gexiv2.h but this is
not possible with Apple Clang om which sysroot points to macOS SDK.
So, exotic environments like Homebrew were failing. Let's fix this.
2025-10-03 18:31:53 -03:00
luzpaz
155e951fa6 app: Fix description typo
This patch fixes a minor typo in a user-facing description within app/path/gimpvectorlayer.c  
This was found via codespell.
2025-09-24 17:24:28 +00:00
Alx Sa
bc7cc0b698 path: Update SVG tag when exporting paths
Per Martin Owens of Inkscape and Jonathan Watt,
one of the SVG specification editors
(https://jwatt.org/svg/authoring/#doctype-declaration),
we should not export the DTD with the GimpPath SVG.
This patch also adds an explicit SVG version to the
<svg> tag.
2025-09-15 17:28:33 +00:00
Alx Sa
602300ec8e pdb, app, libgimp, libgimpconfig: Stroke/Fill Vector Layer PDB
This patch adds additional API for setting the stroke/fill
properties of vector layers. You can now set/get color, stroke
width and stroke style via the PDB. Pattern get/set API is not
yet implemented.

This patch also updates a missing parameter check for GimpVectorLayer
in gimp_config_param_spec_duplicate (), and adds additional API
in /app to make it easier to safely retrieve GimpVectorLayerOptions.
2025-09-15 14:14:46 +00:00
Jehan
2821dbab58 app: add generic support for less destructive transform tools.
This commit will make all transform tools run on a link layer cumulate
their transform matrix on top of the previous transform steps. It means
that as long as you don't edit the pixels another way (e.g. with a paint
tool), all your transformations will apply as a single transformation.

For instance it means that applying several transform tool steps on a
monitored link layer will be less destructive than applying the exact
same transformations on the exact same "normal" layer contents.
Even scaling an image to 1x1 then back to a big size will work very
fine!

Note nevertheless the following limitations in current implementation:

* The link layer with transformations will still show as a standard link
  layer. Nothing says it has transformation applied on it right now.
* To drop transformations applied on a link layer, you have to discard
  the link info, then monitor the link again. A specific action in the
  contextual menu could be worth it.
* This should work with all transform tools (scale, rotation, unified,
  perspective, 3D, even Warp…) but it won't work for the Flip tool, nor
  will it work for the Transform actions. I will need to implement
  GimpItem's rotate(), flip() and resize() methods next.
* The layer mask would still be destructively transformed (I have not
  made any tests with layer masks yet, but this should be done next
  too).
* I think that the "scaled-only" property is now meaningless. It is now
  being replaced by the presence of the GimpMatrix3. Nevertheless I have
  still not removed this property.
* The load/save code has not been redone yet to include all these
  changes.

The kind of caveats we'd have to know about (and which are not planned
for change, because it's just how it is):

* Any intermediate interpolation methods are dropped when cumulating
  transform steps. Only the last interpolation is stored. This is
  because anyway the interpolation is only there as the best algorithm
  where we visually see the less quality loss. Applying several
  transformations as a single matrix will always be visually better than
  applying several matrices (whatever the intermediate interpolation
  methods chosen).
* This only works with the "Adjust" clipping method (basically no
  clipping) because 2 transform steps with clipping won't produce the
  same result as the multiplied matrix with clipping. It means that
  applying a transform with clipping will downgrade your link layer to
  being a normal layer.
  The only issue I have with this is how to best convey that clipping is
  a major setting setting here, which disables our less-destructive
  abilities. Right now, people will just have to "know" it.
* Vector link layers in particular will have 2 levels of
  non/less-destructivity transforms. In particular any scaling (both
  through "Scale Image", "Scale Layers" and transform tools — since I
  added code to detect a matrix doing only scaling and optionally
  translation) done **first** will be completely non-destructive since
  we will simply reload the original vector source at the right
  dimensions. Any other kind of transforms will be appended through the
  cumulative matrix, as raster link layers. This also includes scaling
  done **after** other transforms, since we cannot easily move the
  scaling first (matrix multiplication is not commutative). This second
  level of scaling will therefore be *less* destructive, but still
  destructive.
  It is possible eventually to improve the whole thing if we add some
  day the ability to request loading a vector image with a transform
  matrix (it will then be up to each vector format plug-in to support
  this feature or not).

Note: it could be argued that this whole implementation could in fact be
moved over to base layers, since it would allow also less-destructivity
when applying multiple transformations in a row. We would only merge
results once we edit pixels more directly.
But I think that it's not a bad idea to experiment with this new code in
the link layer. Eventually I may likely move this to the parent
GimpLayer if no blocking issues are found.
2025-08-27 11:34:04 +02:00
Alx Sa
4b67eb9cd0 paths, tools: Prevent CRITICAL when discarding empty vector layer
Resolves #14705
The path tool prevents creating a vector layer from an empty path.
However, the menu option "Path to Vector Layers" does not have this check.
This patch updates the check to constrain it to just one path.
Additionally, it adds a check for the path being NULL before trying to use
it in g_set_object ().
2025-08-19 00:10:22 -04:00
Michael Natterer
c2195a24ca app: redo preview backgrounds completely
While there is a style "background color", the idea of a "widget
background color" is completely bogus, the widget background can be a
gradient or whatever.

- Get rid of "background" in GimpViewable's preview API, only leave the
  "foreground color" there for things like brushes or fonts.
- In GimpViewRenderer, add the background types to be used to class and
  instance, so each renderer type can choose what it needs.
- Render all previews to alpha surfaces, and do the background
  for all renderers generically in gimp_view_renderer_real_draw(),
  then render the preview surface on top of it.
2025-08-18 14:05:54 +02:00
Jehan
ada86282de app: reimplement saving/loading of vector layers and bump to XCF 24.
We now have a proper PROP_VECTOR_LAYER property in the XCF which will
store the various data relevant to vector layers.
This also fixes saving this new type of layers at all, since it was
broken in MR !773.
2025-08-16 23:44:09 -04:00
Jehan
9f17f97198 app: small cleanup in GimpVectorLayer.
- Some coding style bugs.
- Factorize setting vector layer options into
  gimp_vector_layer_set_vector_options(), making sure all code paths to
  update the options do the same thing.
- Ceil the vector layer size since stroke width is a double. C rounds
  towards zero, which means we may still have too small buffer.
2025-08-17 02:20:19 +00:00
Alx Sa
a1cd2a2588 path, tools, pdb: UX updates to vector layers
This patch improves vector layer UX based on feedback.
In summary:
* Makes vector layer editable from the Path tool
* Adds initial PDB for creating vector layers in scripts
* Size vector layers to the path size, rather than image
* Transform tools utilize the path for resizing
* Path tool automatically selects vector layer path
2025-08-17 02:20:19 +00:00
Michael Natterer
df497b5ca6 app: move "default_name" from GimpItemClass to GimpViewableClass and
set default names for a lot of stuff. To be used by GimpRow soon.
2025-07-16 17:22:11 +02:00
Michael Natterer
246f9d284f app, pdb, libgimp: use "#pragma once" instead of:
#ifndef __FOO_H__
 #define __FOO_H__

 /* declarations  */

 #endif /* __FOO_H__ */

And some cleanups while I saw the headers.
This is far from finished...
2025-07-13 03:21:37 +02:00
Michael Natterer
69f84942fa app: rename app/vectors/ to app/path/ 2025-07-07 15:44:15 +02:00