Refine zoom.
This commit is contained in:
+1
-1
@@ -29,7 +29,7 @@ namespace glabels
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
LabelModel::LabelModel() : mModified(true)
|
||||
LabelModel::LabelModel() : mModified(true), mTmplate(0), mRotate(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
+8
-2
@@ -31,7 +31,7 @@ namespace
|
||||
const int nZoomLevels = 14;
|
||||
const double zoomLevels[nZoomLevels] = { 8, 6, 4, 3, 2, 1.5, 1, 0.75, 0.67, 0.50, 0.33, 0.25, 0.15, 0.10 };
|
||||
|
||||
const double ZOOM_TO_FIT_PAD = 16;
|
||||
const double ZOOM_TO_FIT_PAD = 16.0;
|
||||
|
||||
const QColor shadowColor( 64, 64, 64 );
|
||||
const double shadowOffsetPixels = 3;
|
||||
@@ -127,7 +127,7 @@ namespace glabels
|
||||
|
||||
void View::zoomToFit()
|
||||
{
|
||||
double x_scale = (72.0/physicalDpiY()) * ( width() - ZOOM_TO_FIT_PAD ) / mModel->w();
|
||||
double x_scale = (72.0/physicalDpiX()) * ( width() - ZOOM_TO_FIT_PAD ) / mModel->w();
|
||||
double y_scale = (72.0/physicalDpiY()) * ( height() - ZOOM_TO_FIT_PAD ) / mModel->h();
|
||||
double newZoom = min( x_scale, y_scale );
|
||||
|
||||
@@ -169,6 +169,12 @@ namespace glabels
|
||||
{
|
||||
zoomToFit();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Refresh to keep view location relative to window
|
||||
resetTransform();
|
||||
scale( mZoom*physicalDpiX()/72.0, mZoom*physicalDpiY()/72.0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user