Commit Graph

1964 Commits

Author SHA1 Message Date
Povilas Kanapickas 51d1ab9bce libgimpwidgets: Introduce GIMP_ZOOM_PINCH
This zoom mode is handled pretty much the same as GIMP_ZOOM_SMOOTH
except that we do not apply adjustments for the scaling delta. Pinch
zooming is ultimately a different physical activity than smooth
scrolling and users likely expect different sensitivity.
2021-04-22 17:45:32 +00:00
Jehan 22586485aa libgimp, libgimpwidgets: fix def files.
Argh, I always forget. Sorry all Windows devs!
2021-04-20 18:14:42 +02:00
Jehan ca72c41fcd libgimp, libgimpwidgets: support of GimpRGB properties in…
… GimpProcedureDialog.

Technically I added:
- New gimp_prop_color_select_new() property widget to create a
  GimpColorButton for a given GimpRGB property.
- gimp_procedure_dialog_get_widget() now supports a GimpRGB property and
  will create a GimpColorArea by default.
- When the default doesn't suit you, a new function
  gimp_procedure_dialog_get_color_widget() allows to create either a
  GimpColorArea or a GimpColorButton (editable = TRUE), as well as
  choose the area type (small or large checks, as well as flat area,
  i.e. no alpha support).
2021-04-20 16:54:40 +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
luz paz 6457394069 Issue #6446: Typo fixes. 2021-02-24 12:33:03 +01:00
Jehan 579cfc064c libgimpwidgets: on HiPPI display, fix stroked eye when parent item…
… is invisible.
The GimpCellRendererToggle inconsistent state was not HiPPI-aware.
2021-02-21 16:52:25 +01:00
Jacob Boerema 1850f69dbf libgimpwidgets: fix Gtk warning about wrong state for GimpChainLine.
When GIMP_DEBUG=Gtk we can get a warning like
State 0 for GimpChainLine doesn't match state 128 set via
gtk_style_context_set_state () when moving the mouse over
a chain like the one in the Scale Image Dialog.

Let's remove this warning by setting the correct flags by
calling gtk_widget_get_state_flags.
2021-01-27 22:47:00 -05:00
Niels De Graef e8b6ba5c10 libgimpwidgets: Set transient_for on scrolledpreview
This makes sure that the navigation popup actually shows up on certain
window managers (like those based on Wayland).
2020-12-30 10:24:48 +01:00
Niels De Graef 434107731a libgimpwidgets: Use g_object_notify_by_pspec for zoommodel
`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:14:19 +01:00
Niels De Graef 76e380244b libgimpwidgets: Use g_object_notify_by_pspec for ruler
`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:14:19 +01:00
Jacob Boerema b3f3120e32 libgimpwidgets, app: silence warnings about State 0 for GimpRuler and GtkScrolledWindow doesn't match state 128 set via gtk_style_context_set_state ()
When run with GIMP_DEBUG=Gtk we get a lot of debug warnings for GimpRuler and once in a while for GtkScrolledWindow that State 0
doesn't match state 128 set via gtk_style_context_set_state (). This happens because we didn't enter the current state flags of
the widget but 0 and apparently Gtk isn't happy about that.

Let's fix this by using the actual state flags by calling gtk_widget_get_state_flags.
2020-12-28 14:05:09 -05:00
Niels De Graef df28349c17 GIR: Try to return more specific GtkWidget subclass
In GTK, a common scheme is to let a function creating a specific widget
to return a `GtkWidget *`, rather than the specific subtype, since you
often need to call API of GtkWidget, avoiding some useless casts.

For bindings however (and especially bindings to compiled languages),
this is a bit annoying, as you have to explicitly change the type of the
return value (downcast), which is not trivial (or at least desirable) in
each language.

Luckily, we can use `(type ...)` annotation for this use case, leaving
the C API unchanged, while improving the experience for bindings.
2020-12-25 15:05:16 +01:00
Niels De Graef e34c051d78 gimpintcombobox: Add (array length) annotation
So that bindings can properly use the array constructor
2020-12-25 15:04:21 +01:00
Niels De Graef 73252da4f4 GIR: Add some missing (nullable) annotations 2020-12-25 15:02:09 +01:00
Jehan 91728164cd libgimpwidgets: allow prop labels on read-only properties.
When creating a label bound to a property, only make the binding
directional if the property is read-write.
This fixes WARNINGs and broken label in the GimpDeviceInfoEditor widget,
such as this one:
> The source object of type GimpDeviceInfo has no writable property called 'vendor-id'
2020-12-02 00:29:09 +01:00
Jehan b7d55fa066 libgimp, libgimpwidgets: fix gimp_prop_scale_entry_new() for integer…
… properties.
Also a forgotten fix in a call of this function in GimpProcedureDialog.
2020-11-26 00:28:14 +01:00
Jehan 2ea5dec56e libgimpwidgets: improved gimp_prop_scale_entry_new(), new function…
… gimp_label_spin_set_digits() and deleted gimp_prop_opacity_entry_new()

- The "digits" argument for the number of decimal places in
  gimp_prop_scale_entry_new() is now mostly useless since GimpLabelSpin
  (hence GimpScaleEntry too) got a nice estimation algorithm of sensible
  values.
- Add gimp_label_spin_set_digits() function to manually set the digits
  property when we don't like the estimated value.
- Also add a new "factor" argument to gimp_prop_scale_entry_new(). Its
  role is to allow a GimpScaleEntry showing a factored range, typically
  a [0, 100] range for some types of [0, 1] properties.
- Remove gimp_prop_opacity_entry_new() which was basically a
  special-case of gimp_prop_scale_entry_new() and which can now be
  easily reproduced by simply set factor=100.0.
- Update all usage of gimp_prop_scale_entry_new() in app/ and plug-ins/
  with updated arguments. It is interesting to note that all existing
  usage were either integers (digits=1) or when double, the estimated
  decimal places are the same as the ones which were manually set (hence
  showing the generic estimation is not too bad). So the new function
  gimp_label_spin_set_digits() was not even needed once in current code.
2020-11-25 02:32:22 +01:00
Jehan 8d5008d76f libgimp, libgimpbase, libgimpwidgets: new gimp_range_estimate_settings()
Similar code was used in 2 places basically (GimpLabelSpin and
GimpProcedureDialog) so just make it an utils function. It's good anyway
to have a generic function to estimate suitable increments and decimal
places depending on a range.

As a consequence also gimp_label_spin_new() now takes a gint digits
(instead of guint), with -1 meaning we want digits computed from the
range.
Similarly gimp_prop_scale_entry_new() docs adds the -1 meaning too.
2020-11-25 01:34:36 +01:00
Thomas Manni e1cdb9f54e app, icons: add Paint Select tool in the playground
A -quick done- first step towards the addition of a smart selection tool.
Require the gegl:paint-select workshop operation.
Still LOT of work to do (wip):
- fluctuations removal (GEGL side)
- multilevels pyramid approach + banded graphcut for instant result on large
   image (GEGL ? GIMP ?)
- Gaussian Mixtures for color models (GEGL side)
- drawable offsets (GIMP side)
- undo / redo (GIMP side)
- scribbles edition mode (GIMP side)
- dedicated icons
- ...
2020-11-24 12:10:40 +01:00
Jehan f9f516a99a libgimpwidgets: fix missing doc comments and annotations. 2020-11-20 11:36:11 +01:00
Jehan 9f03bdce30 libgimpwidgets: fix the def file. 2020-11-20 10:10:47 +01:00
Jehan bc3602a787 libgimpwidgets: new gimp_label_int_widget_get_widget() function. 2020-11-20 01:47:18 +01:00
Jehan 5fa38d5765 libgimp: bug fixes and design improvements for generated widgets. 2020-11-20 00:06:27 +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 74eb2b1f8a libgimp, libgimpwidgets: re-argh - fix the def files too.
Should fix distcheck and Windows builds.
2020-11-14 17:29:50 +01:00
Jehan e16f5bc1a1 libgimpwidgets: argh forgot to edit the autotools Makefile too! 2020-11-14 16:50:13 +01:00
Jehan 7b6f2e5c2b libgimp, libgimpwidgets, plug-ins: improved GimpProcedureDialog API.
- New GimpLabelIntWidget which is a label associated to any widget with
  an integer "value" property.
- New gimp_procedure_dialog_get_int_combo() which creates a labeled
  combo box from an integer property of the GimpProcedureConfig.
- Renamed gimp_procedure_dialog_populate*() with
  gimp_procedure_dialog_fill*(). Naming is hard! I hesitated using
  _pack() as well (similarly to GtkBox API).
- New gimp_procedure_dialog_fill_flowbox*() functions to create a
  GtkFlowBox filled with property widgets (or other container widgets as
  we can pack them one in another). This is an alternative way to build
  your GUI with sane defaults, with list of property names.
2020-11-13 21:27:56 +01:00
Jehan 735a071c4e libgimpwidgets: align gimpproswitch label to the left. 2020-11-13 12:36:45 +01:00
Jehan e85dd77ad1 libgimpwidgets: fix GimpChainButton init().
So the minor fix on commit 3e35fe4d80 was not so minor after all, and I
should have looked more in details into its contents.

GET_PRIVATE() macro uses the `priv` pointer value hence had to be called
after gimp_chain_button_get_instance_private(). Thus the order was
important; the initialization and assignment values were actually
different. Simply let's get rid of the previous initialization of
`private` (make it declaration-only) to avoid cppcheck to (wrongfully)
complain about double variable assignment to the same value.
2020-11-07 18:14:58 +01:00
Rafał Mikrut 3e35fe4d80 Cppcheck fixes 2020-11-05 19:42:14 +00:00
Jehan fb7a46c6a2 libgimpwidgets: fix gimpwidgets.def file.
Forgot to add/remove changed functions! Again!

Also I fixed a function which is supposed to be static in
GimpScaleEntry.
2020-11-05 19:23:35 +01:00
Jehan d95f417719 app, libgimpwidgets, modules, plug-ins: code changes after GimpScaleEntry…
… reclassing as GimpLabelSpin subclass.
2020-11-05 18:06:52 +01:00
Jehan 079d8fd7f2 libgimpwidgets: make GimpScaleEntry a child class of GimpLabelSpin. 2020-11-05 18:06:52 +01:00
Jehan 4ea2b430be libgimpwidgets: new GimpLabeled class and GimpLabelSpin subclass.
There is currently no property widget which just creates a
GimpSpinButton with a label. Just as the GimpScaleEntry was needed, this
one is as well.
I am creating a GimpLabeled abstract class which will represent various
widgets with a label. While this may seem a bit over-engineered for such
a basic feature, this will actually bring some consistency and a common
parent. In particular this can be used to get the GtkLabel with a common
interface to add them all in a common GtkSizeGroup when generating
dialogs automatically, hence make dialogs with properly aligned labels
and edition widgets.
2020-11-05 18:06:52 +01:00
Jehan 0d98969a47 libgimpwidgets, plug-ins: rename gimp_scale_entry_set_range() to…
… gimp_scale_entry_set_bounds().
I realized that this function may look like the set() opposite for
gimp_scale_entry_get_range(), which it is not at all. The get_range() is
for getting back the GtkRange widget packed in the GimpScaleEntry,
whereas the set_range() is to change the minimum and maximum allowed
values.

I had recently renamed the former, and could just rename it back into
gimp_scale_entry_get_scale() as it was, but since the class we rely on
is actually called GtkRange (GtkScale is a subclass), I think it could
be misleading. So in the end, let's rather rename the function setting
the widget minimum and maximum as gimp_scale_entry_set_bounds() instead.
Hopefully this is even more understandable. Naming is hard!
2020-11-01 03:00:09 +01:00
Jehan b3c0ba061b app, libgimpwidgets, modules, plug-ins: finishing GimpScaleEntry port.
Renaming the temporary function gimp_scale_entry_new2() into
gimp_scale_entry_new() now that the original code is entirely gone. This
is now a fully-fledged widget with a nice and proper introspectable API.
2020-11-01 02:46:20 +01:00
Jehan 77d2a93a52 libgimpwidgets, plug-ins: remove legacy gimp_color_scale_entry_new().
Former gimp_color_scale_entry_new() is finally replaced by the
GimpColorScaleEntry implementation.
Both places which used it (GimpColorScales and compose plug-in) now use
the new widget.

Also making "upper" and "lower" properties of GimpScaleEntry into
construction properties, and create the main GtkAjustment at init, so
that we are sure that lower and upper bounds are properly set before we
set the value (when setting all properties at once, we cannot ensure
that these limit properties are set before the "value" one).
2020-11-01 02:23:03 +01:00
Jehan 1cdfb0bd3f libgimpwidgets: use G_DECLARE_* macros on Gimp*ScaleEntry classes.
I updated GimpScaleEntry and GimpColorScaleEntry header to use
respectively the macros G_DECLARE_DERIVABLE_TYPE and
G_DECLARE_FINAL_TYPE.

Though having the `priv` structure directly in the object data is
extremely comfortable for developing (hence we don't want to use this
macro on core code as it makes coding a bit more bothersome), it is true
that it does not make for a very pretty public interface (showing a
`priv` member which nobody can actually use, and a private type which
has no associated functions). So it might be a good idea to use these
macros at least on libgimp side.

I am still not sure though if it is a good idea so we could say it's an
experiment. At least the docs says that using G_DECLARE_FINAL_TYPE does
not affect ABI stability as it can later be changed into a
G_DECLARE_DERIVABLE_TYPE because the class structure stays private. So
at least that's one good point.

P.S.: also reordering gimpwidgets.def.
2020-11-01 00:47:43 +01:00
Jehan f27d172750 libgimpwidgets: new GimpColorScaleEntry class.
Similarly to GimpScaleEntry, this is meant to replace usage of
gimp_color_scale_entry_new() by having a proper widget. This is a child
class of GimpScaleEntry which simply replaces the GtkScale by a
GimpColorScale by adding a GimpScaleEntry class method to create the
scale widget (only restriction: it must be a GtkRange subtype).

This also triggers me to rename gimp_scale_entry_get_scale() into
gimp_scale_entry_get_range() (as well as the 2 plug-ins already using
this function).
2020-11-01 00:08:20 +01:00
Jehan aa0b70ea38 libgimpwidgets: get rid of old gimp_scale_entry_new().
Also do a few minor fixes in GimpScaleEntry implementation.
2020-11-01 00:08:20 +01:00
Jehan 10dfaead68 libgimpwidgets, plug-ins: continue GimpScaleEntry port to real widget.
I got rid of gimp_scale_entry_set_sensitive(), as we can now use the
generic gtk_widget_set_sensitive(), and I ported the 2 plug-ins using
this function.
I also created gimp_scale_entry_set_value() to set the value (nicer than
setting object properties).
2020-10-30 21:30:16 +01:00
Jehan ad8b417871 libgimpwidgets: better algorithm for GimpScaleEntry default increments.
For very small ranges, just dividing by 10 and 100 is not very good. You
could end up with weird step values. It is often better to use 10^(-x)
values just below your range.
I.e for a 0.5 range, a step of 0.1 and page of 0.01 are probably fine
(better than 0.05 and 0.005).

Of course as usual these are default values only and setting custom
increments is possible through available API.

Also fixing a small bug in gimp_scale_entry_set_increments() added in
commit 0f05825a29.
2020-10-30 17:41:24 +01:00
Jehan 99193230b3 libgimpwidgets: fix def files.
And consequentely the distcheck as well as Windows builds.
2020-10-30 13:04:30 +01:00
Jehan 0f05825a29 app, libgimpwidgets, plug-ins: default increments for GimpScaleEntry.
Instead of setting always manually the step and page increments when
creating a GimpScaleEntry, let's just generate some common cases
automatically. Indeed the increments are rarely something you want to
care about. The algorithm used is:
- For a range under 1.0, use a hundredth and a tenth (typically a [0,
  1.0] range will step-increment of 0.01 and page-increment of 0.1).
- For small ranges (under 40), step-increment by 1, page-increment by 2.
- For bigger ranges, step-increment by 1, page-increment by 10.

For use cases when you absolutely want specific increment values, I add
the gimp_scale_entry_set_increments() function. It is much better to
have a small and understandable constructor call followed by
configuration calls (only when needed) rather than a constructor with a
crazy amount of parameters. Hence gimp_scale_entry_new() went from 17
arguments (absolutely unreadable calls) to now 5.
2020-10-30 12:33:46 +01:00
Jehan 1e81bdabb0 app, libgimpwidgets: improve GimpScaleEntry API.
* Add a gimp_scale_entry_get_value() because if we don't do a property
  widget, getting the value of the widget easily is a main point.
* Move gimp_scale_entry_(set|get)_logarithmic() to the new class API.
* Internally edit the GtkSpinButton width depending on min/max values,
  place digits, and possible value sign.
* Emit a "value-changed" signal (similarly to other widgets with a
  value), for cases when just binding the "value" property is not
  enough.
* Finally use the new API in palette-import-dialog.
2020-10-30 11:02:20 +01:00
Jehan 5238958e55 libgimpwidgets: make GimpScaleEntry into its own widget.
Instead of the gimp_scale_entry_new() which creates several bound yet
independant widgets, and in the same time pack them into an existing
grid and return a GtkAdjustment (while heavily relying on GObject data
to link widgets), let's have a proper custom widget with its own clean
API.
This also simplifies the gimp_prop_scale_entry_new() property widget
variant.

First advantage is that we don't force the usage of a grid to use this
widget (there are a few pieces of code which create a GtkGrid with only
this inside just to be able to use this feature).

Second thing is that I am creating a much simpler API.
gimp_scale_entry_new() had 17 parameters! How crazy is that? So I
removed all the grid packing related parameters. Also I moved the spin
button/scale unconstraining parameters into their separate function,
because the constrained behavior is the most common use case, so it's
stupid to add 3 permanent dummy parameters for most calls. Instead the
few times where we'll want different ranges for the spin button and the
scale, we'll call the separate API gimp_scale_entry_set_range().

Thirdly the tooltip can be set directly with gimp_help_set_help_data()
since this is now its own widget. No need to have dedicated logics
anymore, better stay generic. Similarly no need of a custom function to
switch sensitivitivy (instead of generic gtk_widget_set_sensitive()).

Fourth thing is that we should not use macros for the public API, but
proper functions, because macros are not properly introspected for
binding.

For future improvements, maybe we could even make this widget implement
GtkOrientable interface, in order to be able to use it vertically.

Note: right now, I created a separate gimp_scale_entry_new2() and only
modified the property widget API to use this new code. Eventually I will
remove fully the old gimp_scale_entry_new() function (and the new code
will replace it).
2020-10-30 11:02:20 +01:00
Jehan 82ee478920 libgimpwidgets: store GimpFileEntry private data in appropriate struct.
There was a /* FIXME MOVE TO PRIVATE */ and anyway it makes sense to not
leave such data in the public API.

I note that the whole widget declaration is between #ifndef
GIMP_DISABLE_DEPRECATED macros so maybe we should just delete it
altogether for GIMP 3, but it might still have a usage. Maybe it could
also be interesting to experiment with the file portal on such widget
for plug-in usage? Let's see.
2020-10-30 11:02:20 +01:00
Lloyd Konneker 2920a13609 Issue #5809: missing dependency on libm for libgimpwidgets/test-eevl 2020-10-24 18:24:14 +02:00
Jehan b326b68b32 libgimpwidgets: GtkComboBox "active" property must trigger…
… GimpIntComboBox "value" property.
For this, I connect to the "changed" signal, which is equivalent anyway.
Otherwise the link was not bidirectionnal, so selecting a new item in
the combo list was not actually changing the internal value, hence the
binding set by gimp_prop_int_combo_box_new() was not complete either.
Not sure how I missed that. Hopefully not missing anything else!
2020-09-29 17:02:21 +02:00
Jehan db71a8ffc7 libgimpwidgets: add a "value" property to GimpIntComboBox…
… and have gimp_prop_int_combo_box_new() bind to "value" instead of
"active".

The "active" property is defined by GtkComboBox and is the index of the
combo box, not its values, whereas with gimp_prop_int_combo_box_new(),
we want to bind an int property to the combobox value. Therefore the
commit 0828a371c2 was only properly working when we were creating a
combo box with values starting at 0 and incremented by 1.

By adding a "value" property to GimpIntComboBox, I allow binding any
property to the int value rather than the index.

See also !265 where the issue was raised as it affected our HEIF
plug-in.
2020-09-18 15:26:32 +02:00