Commit Graph

226 Commits

Author SHA1 Message Date
Jacob Boerema b130349935 app: fix incorrect order of parameters horizontally and vertically
There was one case where horizontally and vertically were mixed up in a
call to gimp_display_shell_scale_image_stops_to_fit.

The more usual order of parameters is first horizontal and then vertical.
So, let's fix the actual functions that have the illogical order
of vertically, horizontally instead of fixing the one call.

This brings it in line with the order in other functions and makes it less
likely we mistakenly mess up the parameters.

Besides that gimp_display_shell_scale_image_stops_to_fit also was not
declared as a local function, so we add that too.
2022-06-02 13:26:05 -04:00
woob eb58b277d2 app: Add drag-to-zoom speed preference
Adds the new configuration option "drag-zoom-speed" to adjust the rate
at which mouse movement can zoom the canvas, ranging from 25% to 300%
of the base rate and applying to both drag-to-zoom modes.
This option can be found in the preferences dialog as:
  Image Windows -> Zoom & Resize Behavior -> Drag-to-zoom speed
2022-04-05 12:31:11 +00:00
woob 4cffd91af4 app: Halve the rate of distance-based drag-to-zoom scaling
Reduces the rate from +/- 1% of the current scale per pixel, to 0.5% to
allow for more fine control while zooming.
2022-04-05 12:31:11 +00:00
woob 505a78e715 app: Add option to re-enable previous drag-to-zoom behavior
Adds a new configuration option "drag-zoom-mode" to choose whether to
zoom by distance of movement (newly added) or by duration of movement
(previous behavior) when zooming via dragging the mouse, defaulting to
distance.
This option can be found in the preferences dialog as:
  Image Windows -> Zoom & Resize Behavior -> Drag-to-zoom behavior
2022-04-05 12:31:11 +00:00
woob 8b1025919f app: Smoother zooming while dragging with the mouse
Changes the behavior of gimp_display_shell_scale_drag() to factor in 
the distance dragged, rather than just scaling a flat +/- 10% for each 
detected movement event. The factor by which to change the scaling is 
also altered from 10% at each movement event, to 1% compounded for 
each pixel of distance dragged.  
This makes zooming via Ctrl + Middle Click or Ctrl + Spacebar behave 
more consistently and less jittery versus the previous method, while 
offering more fine grained control.
2022-04-05 12:31:11 +00:00
Jehan f5ea8e9b2a app: fix leak of a GdkPoint and improve stable zoom centering logics.
This started as yet another report of leak by Massimo. But really the
leak of the GdkPoint created by the function
gimp_display_shell_push_zoom_focus_pointer_pos() is not only when
delta_y is 0. There are a few code paths in gimp_display_shell_scale()
when we would not pop this point. One of them is for instance when
window resizing in multi-window mode is allowed. There might be more
(but the code is convoluted enough not to be 100% sure if these are
possible with our specific case).

This specific function was initially created only to be used for unit
testing code (commit 7e3898da09), but it ended up being also used
internally (commit 792cd581a2). Since I see that the test for which
this code was initially created even seem broken right now (the assert
part for position check is commented out!), I even wonder if we should
keep it. We could indeed instead just add optional start_x|y arguments
to gimp_display_shell_scale(), which would be much cleaner. But I leave
it for now.

Instead I just make sure we clean the created GdkPoint after calling
gimp_display_shell_scale(). Also I get rid of the GQueue. It is clear in
the code that we are not expecting queuing interaction of several
positions. Worse right now, we could end up in weird cases where the
pushed points are not used when they should, then could end up being
used later in totally unrelated interactions (this would make the shell
position jump here and there). So let's just make it a single point.
Finally adding some appropriate comments in parts which are still a bit
wrong.
2021-08-20 20:51:29 +02:00
Povilas Kanapickas a8b258cd84 app: Implement canvas support for touchpad gesture zoom by pinch 2021-04-22 17:45:32 +00:00
Ell 2d6e80b8ed app: behave as if "show all" is disabled in scroll/zoom actions when keeping padding 2019-09-15 16:39:00 +03:00
Ell a1717a90a9 app: improve display scroll/zoom-related behavior in "show all" mode
In "show all" mode, the image is thought to be "infinite"; this
commit improves the overall scrolling/zooming behavior in this mode
according to this assumption.  In cases where a specific image size
is needed (e.g., for the scrollbar bounds, fit-image-in-window,
etc.), the image's full bounding box is used; however, in cases
where a center point is needed (e.g., for the zoomed-out scrollbar
bounds, center-image-in-window), the canvas center, rather than the
bounding-box center, is still used.
2019-09-04 20:47:25 +03:00
Ell 86dc451bce app, menus: add "show all" mode to GimpDisplayShell; "View -> Show All" toggle
Add a "show all" mode to GimpDisplayShell, controlled through a
corresponding "View -> Show All" menu item.  When enabled, the
entire image content is displayed, instead of cropping the image
to the canvas size.  More generally, the display behaves as if the
canvas were infinite.  The following commits improve the overall
behavior in this mode.

Add a prefernces option to control the default "show all" state.
2019-09-04 20:47:21 +03:00
Niels De Graef 1dda60154c Use "Returns:" to annotate return values
To be able to annotate return values through GObject-introspection, you
need to make sure it is tagged with `Returns:` and not something else.
2019-08-03 07:53:47 +00:00
Michael Natterer 9aa6aa1f04 app: make display update much faster again
Introduce a render cache that keeps the result of scaling, color
management, display filters and shell mask (for tools like fuzzy
select).

Change gimpdisplayshell-render.[ch] to only render to the cache and
manage a cairo region of the cache's valid area. Call cache
invalidation functions form various places. Change the API of all
render functions to be in display coordinates.

Also get rid of gimpdisplayxfer.[ch] because we now have a
canvas-sized cairo surface which is a surface similar to the
destination surface.
2019-07-16 17:15:34 +02:00
Michael Natterer 5f700549e7 Change the license URL from http://www.gnu.org/licenses/ to https:// 2018-07-11 23:29:46 +02:00
Michael Natterer 792cd581a2 Issue #1531 - Zooming with mouse movement should keep track of original point
When Control-Button2-Zooming, remember the start point, pass it to
gimp_display_shell_scale_drag() and force gimp_display_shell_scale()
to zoom around that point by passing GIMP_ZOOM_FOCUS_POINTER and
faking the point using gimp_display_shell_push_zoom_focus_pointer_pos().
2018-06-04 11:42:02 +02:00
Jehan e5c08832cb Issue #1509 - GIMP master Git zoom in/out scrolling is reversed. 2018-05-26 22:41:54 +02:00
Michael Natterer d9e016bd37 app: undeprecate gimpdisplayshell-scale.c and fix "unused variable" warning 2018-05-23 23:44:19 +02:00
Michael Natterer 2dd2f1509b Enable and fix smooth scrolling and zooming
- Fix gimp_scroll_adjustment_values() for smooth scroll events
- Set GDK_SMOOTH_SCROLL_MASK on all widgets where we set GDK_SCROLL_MASK
- Add GIMP_ZOOM_SMOOTH to enum GimpZoomType
- Add "gdouble delta" to gimp_zoom_model_step()
- Change the meaning of the "scale" parameter to "scale or delta" in
  all functions that take GimpZoomType and a scale factor.
2018-05-20 21:06:34 +02:00
Michael Natterer c2763afd30 app: port gimp_display_shell_set_initial_scale() to the monitor's workarea 2018-05-20 21:06:33 +02:00
Michael Natterer ef2cf21f10 Bug 796252 - Mouse wheel zooming should center on cursor...
... _even at low zoom levels_

Pass GIMP_ZOOM_FOCUS_POINTER to gimp_display_shell_scale() when
wheel-scrolling, and change the scaling code to really honor
GIMP_ZOOM_FOCUS_POINTER and not apply magic image centering.

This keep the same point centered under the mouse for wheel-scrolling
and the zoom tool (== when the zooming is really triggered at a
certain mouse position).
2018-05-19 15:24:52 +02:00
Jehan 864e3df7a9 app: fix comment typos. 2017-11-14 04:45:13 +01:00
Michael Natterer b1ca8a161c app: allow to zoom with middle mouse button + control + drag up/down 2016-11-16 14:41:30 +01:00
Ell 26b978d2a8 app: avoid expensive rotated scale calculation when scale_x == scale_y
Ditto for the rulers' resolution calculation.
2016-08-09 22:28:21 +00:00
Ell 5bdb20c839 app: make rulers rotation aware
Place the rulers' origin at the top-left corner of the canvas
(screen space) bounding box, and set their scale to the image-
space scale along the screen-space horizontal/vertical directions
(in other words, measuring a distance using the rulers should
give the same results as the measure tool; note that rotation
comes into play here only when the horizontal and vertical
image or screen resolutions are different, since otherwise the
scale is direction invariant.)

Make scrollbar step match ruler step under the new behavior.
2016-08-09 21:31:07 +00:00
Ell 720b73ca86 app: fix a few canvas scroll/scale rounding inconsistencies
Apply rounding more consistently across some of the scroll/scale
functions, to avoid annoying one-pixel-off scrollbar size/position
issues.
2016-08-09 21:31:06 +00:00
Ell 168b935d43 app: make scale_{to_rectangle,fit_in,fill,shrink_wrap} rotation aware
Use the (screen space) bounding box of the rectangle/canvas for these
functions.
2016-07-21 21:24:06 +00:00
Ell bfba49d203 app: make scrollbar limits and scroll-offset clamping rotation aware
Limit the scrollbars by the (screen space) bounding box of the canvas.
Scroll offsets are clamped to 1.5 that.
2016-07-21 21:22:49 +00:00
Michael Natterer dd1809bc21 app: simplify gimp_display_shell_scale_get_zoom_focus()
The logic should be exactly as before, just less convoluted.
2016-01-14 23:57:40 +01:00
Michael Natterer 86cbc2f7a7 Bug 760402 - Zoom in (with "Resize window on zoom") displays wrong...
...several different zooms tiled together

In gimp_display_shell_scale() don't shortcut things in the case where
we resize the window, but call gimp_display_shell_scale_resize() like
all other scaling functions do in the end.
2016-01-10 20:32:17 +01:00
Michael Natterer 83fbd31f12 app: disable "Resize windows on zoom/resize" in single-window mode
They only make sense if the image is by itself in multi-window mode.
2016-01-10 20:09:28 +01:00
Michael Natterer 117800063e app: pause/resume the shell in gimp_display_shell_scale_to()
around calls to scale() and scroll().
2016-01-05 20:24:18 +01:00
Michael Natterer 9391cd390f app: reorder an rename stuff in gimpdisplayshell-scale.[ch]
Rename gimp_display_shell_scale_handle_zoom_revert() to
gimp_display_shell_scale_save_revert_values() because the old name was
completely unclear.
2016-01-05 19:20:23 +01:00
Michael Natterer c80f0136ba app: make gimp_display_shell_calculate_scale_x_and_y() private 2016-01-05 18:52:03 +01:00
Michael Natterer 095eea6532 app: move gimp_display_shell_scale_changed() to gimpdisplayshell-scale.[ch]
and rename it to gimp_display_shell_scale_update().
2016-01-05 18:48:22 +01:00
Michael Natterer b0ce294f8f app: make gimp_display_shell_scale_get_image_size_for_scale() private 2016-01-05 18:36:37 +01:00
Michael Natterer d64ca7222e app make gimp_display_shell_get_screen_resolution() private 2016-01-05 18:30:15 +01:00
Michael Natterer 2f26016a47 app: move the code to update scrollbars and rulers to their own files
so they are gone from the "scale" and "scroll" namespaces because they
belong to neither and both. And because the files are way too large.
2016-01-05 18:05:38 +01:00
Michael Natterer 211d05d1d7 Bug 759288 - Unfocused Zoom In/Out in Rotated Canvas View
gimp_display_shell_scale_to(): calculate the point that should not
move with GimpDisplayShell's untransform/transform functions before
and after scaling, then scroll to the right point. Just using the
scale functions doesn't work any longer when a rotation is
active. Other functions are affected too, but this most important
issue can be fixed by fixing just this function.
2016-01-05 14:01:57 +01:00
Michael Natterer 5bc9ad947a app: fix gimp_display_shell_scale_to_rectangle() to also do only scrolling
which means: also scroll to the rectangle if the scale doesn't change.
2015-10-18 15:18:23 +02:00
Michael Natterer ded7c8f585 app: add gimp_display_shell_scale_to_rectangle()
and move the magnify tool's rectangle zoom logic to the new function.
2015-10-18 14:59:30 +02:00
Michael Natterer b7f471b1a3 app: change some integers in gimpdisplayshell-scale.c to gdouble
which does not have any effect by itself, but is needed for fixing
viewport calculation for rotated canvases.
2015-10-18 14:40:19 +02:00
Michael Natterer b4a2cf9432 app: remove useless real_new_scale variable from gimp_display_shell_scale() 2013-04-21 03:14:36 +02:00
Michael Natterer c3b53b8b66 app: move the "get scaled image size" functions from shell-draw to -scale 2013-04-18 19:06:17 +02:00
Michael Natterer afddcce4e5 app: remove gimp_display_shell_update_scrollbars_and_rulers()
and move its two statements to its two callers.
2013-04-18 18:45:55 +02:00
Ville Skyttä 6b0d1038cc Bug 692641 - Various spelling fixes 2013-01-27 18:59:02 +01:00
Michael Natterer c35ff719a7 app/libgimp*: remove stuff found by -Wunused-but-set-variable 2011-05-01 23:23:19 +02:00
Michael Natterer ddc63de6d6 app: remove "gboolean use_offsets" from gimpdisplayshell-transform.[ch] 2010-09-23 19:24:04 +02:00
Martin Nordholts 6ad46f651a Bug 610587 - Zooming with zoom tool pans away from the cursor
Update lower and upper value of adjustments *before* we set the new
value, otherwise it will be erroneously clamped sometimes.
2010-06-19 08:09:34 +02:00
Martin Nordholts 7e3898da09 app/tests: Add keyboard zoom focus regression test
Add keyboard zoom focus regression test. We also need a new display
shell utility function
gimp_display_shell_push_zoom_focus_pointer_pos() for that.
2010-06-18 20:57:59 +02:00
Martin Nordholts 5da660a14d app: Make zoom focus with keyboard work again
Make zoom focus with keyboard work again, it broke when
GimpDisplayShell stopped being a GtkWindow and thus the source of key
events.
2010-06-12 15:37:21 +02:00
Michael Natterer 8671860945 app: move "image" member of GimpDisplay to the private struct 2010-02-28 16:15:59 +01:00