After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 540210 - Improved zoom behavior when using ctrl+mouse wheel button
Improved zoom behavior when using ctrl+mouse wheel button
Status: RESOLVED FIXED
Product: dia
Classification: Other
Component: general
0.96.x
Other Linux
: Normal enhancement
: 0.97.2
Assigned To: Dia maintainers
Dia maintainers
Depends on:
Blocks:
 
 
Reported: 2008-06-25 20:23 UTC by Ithai Levi
Modified: 2011-01-07 12:08 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Ithai Levi 2008-06-25 20:23:57 UTC
When using the mouse wheel button to zoom in and out, it may be more intuitive to maintain the drawing zoom center-point based on the cursor position. This can help orientation and prevent the drawing from "jumping" around while zooming in and out.

To do this I suggest the following implementation for ddisplay_zoom in display.c:

void
ddisplay_zoom(DDisplay *ddisp, Point *point, real magnify)
{
  Rectangle *visible;
  real width, height;
  // %%
  // cursor position ratios
  real rx,ry; 
  // %%

  visible = &ddisp->visible;

  // %%
  // ithai - calculate cursor position ratios
  rx = (point->x-visible->left)/(visible->right - visible->left);
  ry = (point->y-visible->top)/(visible->bottom - visible->top);
  // %%

  width = (visible->right - visible->left)/magnify;
  height = (visible->bottom - visible->top)/magnify;

  if ((ddisp->zoom_factor <= DDISPLAY_MIN_ZOOM) && (magnify<=1.0))
    return;
  if ((ddisp->zoom_factor >= DDISPLAY_MAX_ZOOM) && (magnify>=1.0))
    return;

  ddisp->zoom_factor *= magnify;

  // %%
  // ithai - set new origin based on the calculated ratios before zooming
  ddisplay_set_origo(ddisp, point->x-(width*rx),point->y-(height*ry));
  // %%
  
  ddisplay_update_scrollbars(ddisp);
  ddisplay_add_update_all(ddisp);
  ddisplay_flush(ddisp);

  update_zoom_status (ddisp);
}

This works better for me. Tested okay with v0.96+svn.
Comment 1 Hans Breuer 2008-07-25 13:05:51 UTC
thanks for the suggestion, just commited:

2008-07-25  Hans Breuer  <hans@breuer.org>

	* app/display.c(ddisplay_zoom) : improved zoom behavior when using 
	ctrl+mouse wheel around the cursor position, based on code by 
	Ithai Levi, bug #540210 

 
Comment 2 Hans Breuer 2008-07-26 10:12:21 UTC
sorry, I was too fast, see:

2008-07-26  Hans Breuer  <hans@breuer.org>

	* app/display.c(ddisplay_zoom) : reverted changes from bug #540210,
	it broke the other use cases, mainly zoom all (ctrl^e)
	
Comment 3 Hans Breuer 2009-01-18 08:26:15 UTC
without an updated patch this is not goind to be part of 0.97
Comment 4 Starcom 2009-05-06 09:27:30 UTC
I think it would be possible to add a setting or a key combination to chose between these two zoom mode (zoom around the mouse cursor or zoom around the center of the view) but also around selected objects or a selected area like in some drawing softwares.
Comment 5 Hans Breuer 2010-08-04 14:56:47 UTC
The easy fix just applied is implmenting it in a new function just used for wheel zooming. See: http://git.gnome.org/browse/dia/commit/?id=dc4fccba65a30dec1c81b4506a0f44fb880ceaa4
Comment 6 Hans Breuer 2011-01-07 12:08:49 UTC
Cherry-picked to dia-0-97 branch.