fdo#44173: use a geometric progression for zooming

Zooming does now base on a geometric progression instead of an
arithmetic one.
Since the zoom factor is not only used in Draw but for all other
applications 1.2 seems like a good choice.
This commit is contained in:
Tim Hardeck 2012-01-13 18:22:46 +01:00 committed by Jan Holesovsky
parent 12eb7da661
commit 022ce7d362
6 changed files with 22 additions and 17 deletions

View file

@ -79,8 +79,7 @@
#include "sc.hrc"
#include "scabstdlg.hxx"
// fuer Rad-Maus
#define SC_DELTA_ZOOM 10
// for mouse wheel
#define MINZOOM_SLIDER 10
#define MAXZOOM_SLIDER 400
@ -449,9 +448,9 @@ sal_Bool ScPreviewShell::ScrollCommand( const CommandEvent& rCEvt )
long nOld = pPreview->GetZoom();
long nNew = nOld;
if ( pData->GetDelta() < 0 )
nNew = Max( (long) MINZOOM, (long)( nOld - SC_DELTA_ZOOM ) );
nNew = Max( (long) MINZOOM, (long)round( nOld / ZOOM_FACTOR ));
else
nNew = Min( (long) MAXZOOM, (long)( nOld + SC_DELTA_ZOOM ) );
nNew = Min( (long) MAXZOOM, (long)round( nOld * ZOOM_FACTOR ));
if ( nNew != nOld )
{

View file

@ -149,15 +149,14 @@
#include <string>
#include <algorithm>
#include <svx/zoom_def.hxx>
#define SPLIT_MARGIN 30
#define SC_ICONSIZE 36
#define SC_SCROLLBAR_MIN 30
#define SC_TABBAR_MIN 6
// fuer Rad-Maus
#define SC_DELTA_ZOOM 10
using namespace ::com::sun::star;
// STATIC DATA -----------------------------------------------------------
@ -1060,9 +1059,9 @@ bool ScTabView::ScrollCommand( const CommandEvent& rCEvt, ScSplitPos ePos )
long nOld = (long)(( rOldY.GetNumerator() * 100 ) / rOldY.GetDenominator());
long nNew = nOld;
if ( pData->GetDelta() < 0 )
nNew = Max( (long) MINZOOM, (long)( nOld - SC_DELTA_ZOOM ) );
nNew = Max( (long) MINZOOM, (long)round( nOld / ZOOM_FACTOR ));
else
nNew = Min( (long) MAXZOOM, (long)( nOld + SC_DELTA_ZOOM ) );
nNew = Min( (long) MAXZOOM, (long)round( nOld * ZOOM_FACTOR ));
if ( nNew != nOld )
{

View file

@ -82,6 +82,8 @@
#include <sfx2/request.hxx>
#include "SpellDialogChildWindow.hxx"
#include <svx/zoom_def.hxx>
#include "Window.hxx"
#include "fupoor.hxx"
@ -125,8 +127,6 @@ private:
namespace sd {
static const int DELTA_ZOOM = 10;
sal_Bool ViewShell::IsPageFlipMode(void) const
{
return this->ISA(DrawViewShell) && mpContentWindow.get() != NULL &&
@ -718,9 +718,9 @@ bool ViewShell::HandleScrollCommand(const CommandEvent& rCEvt, ::sd::Window* pWi
long nNewZoom;
if( pData->GetDelta() < 0L )
nNewZoom = Max( (long) pWin->GetMinZoom(), (long)(nOldZoom - DELTA_ZOOM) );
nNewZoom = Max( (long) pWin->GetMinZoom(), (long)round( nOldZoom / ZOOM_FACTOR ));
else
nNewZoom = Min( (long) pWin->GetMaxZoom(), (long)(nOldZoom + DELTA_ZOOM) );
nNewZoom = Min( (long) pWin->GetMaxZoom(), (long)round( nOldZoom * ZOOM_FACTOR ));
SetZoom( nNewZoom );
Invalidate( SID_ATTR_ZOOM );

View file

@ -8,4 +8,7 @@
#endif
// zoom factor for Calc, Writer, Draw and Impress
#define ZOOM_FACTOR 1.2
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View file

@ -36,6 +36,8 @@
#include <svx/dialmgr.hxx>
#include <svx/dialogs.hrc>
#include <svx/zoom_def.hxx>
#include <set>
// -----------------------------------------------------------------------
@ -357,11 +359,11 @@ sal_Bool SvxZoomSliderControl::MouseButtonDown( const MouseEvent & rEvt )
// click to - button
if ( nXDiff >= nButtonLeftOffset && nXDiff <= nButtonRightOffset )
mpImpl->mnCurrentZoom = mpImpl->mnCurrentZoom - 5;
mpImpl->mnCurrentZoom = round( mpImpl->mnCurrentZoom / ZOOM_FACTOR );
// click to + button
else if ( nXDiff >= aControlRect.GetWidth() - nSliderXOffset + nButtonLeftOffset &&
nXDiff <= aControlRect.GetWidth() - nSliderXOffset + nButtonRightOffset )
mpImpl->mnCurrentZoom = mpImpl->mnCurrentZoom + 5;
mpImpl->mnCurrentZoom = round( mpImpl->mnCurrentZoom * ZOOM_FACTOR );
// click to slider
else if( nXDiff >= nSliderXOffset && nXDiff <= aControlRect.GetWidth() - nSliderXOffset )
mpImpl->mnCurrentZoom = Offset2Zoom( nXDiff );

View file

@ -52,6 +52,8 @@
#include <IDocumentSettingAccess.hxx>
#include <svx/zoom_def.hxx>
//Das SetVisArea der DocShell darf nicht vom InnerResizePixel gerufen werden.
//Unsere Einstellungen muessen aber stattfinden.
#ifndef WB_RIGHT_ALIGNED
@ -1309,9 +1311,9 @@ sal_Bool SwView::HandleWheelCommands( const CommandEvent& rCEvt )
{
sal_uInt16 nFact = pWrtShell->GetViewOptions()->GetZoom();
if( 0L > pWData->GetDelta() )
nFact = static_cast< sal_uInt16 >(Max( 20, nFact - 10 ));
nFact = static_cast< sal_uInt16 >(Max( 20, (int)round( nFact / ZOOM_FACTOR )));
else
nFact = static_cast< sal_uInt16 >(Min( 600, nFact + 10 ));
nFact = static_cast< sal_uInt16 >(Min( 600, (int)round( nFact * ZOOM_FACTOR )));
SetZoom( SVX_ZOOM_PERCENT, nFact );
bOk = sal_True;