From 0ac3bafbcad71033a2d503eb78a0955358251329 Mon Sep 17 00:00:00 2001 From: Alberto Griggio Date: Mon, 1 Jan 2018 22:48:16 +0100 Subject: [PATCH] some tweaks to the cropping GUI, inspired by recent comments on pixls.us --- rtgui/cropwindow.cc | 22 ++++++++++++++++++---- rtgui/imagearea.cc | 4 ++-- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/rtgui/cropwindow.cc b/rtgui/cropwindow.cc index f4510682e..b8bbfe4fc 100644 --- a/rtgui/cropwindow.cc +++ b/rtgui/cropwindow.cc @@ -313,7 +313,7 @@ void CropWindow::buttonPress (int button, int type, int bstate, int x, int y) changeZoom (zoom11index, true, action_x, action_y); fitZoom = false; } else { - zoomFit (); + zoomFitCrop (); } } else { zoom11 (); @@ -612,6 +612,10 @@ void CropWindow::buttonRelease (int button, int num, int bstate, int x, int y) } needRedraw = true; + + if (fitZoom) { + zoomFitCrop(); + } } else if (state == SCropWinMove) { if (iarea->showColorPickers () && !colorPickers.empty()) { needRedraw = true; @@ -722,6 +726,10 @@ void CropWindow::buttonRelease (int button, int num, int bstate, int x, int y) cropgl->cropManipReady (); iarea->setToolHand (); needRedraw = true; + + if (fitZoom) { + zoomFitCrop(); + } } if (decorated) { @@ -1356,6 +1364,12 @@ void CropWindow::expose (Cairo::RefPtr cr) drawObservedFrame (cr); } } else { + CropParams cropParams = cropHandler.cropParams; + if (state == SNormal && cropParams.guide != "None") { + cropParams.guide = "Frame"; + } + bool useBgColor = (state == SNormal); + if (cropHandler.cropPixbuf) { imgW = cropHandler.cropPixbuf->get_width (); imgH = cropHandler.cropPixbuf->get_height (); @@ -1772,7 +1786,7 @@ void CropWindow::expose (Cairo::RefPtr cr) if (cropHandler.cropParams.enabled) { int cropX, cropY; cropHandler.getPosition (cropX, cropY); - drawCrop (cr, x + imgAreaX + imgX, y + imgAreaY + imgY, imgW, imgH, cropX, cropY, zoomSteps[cropZoom].zoom, cropHandler.cropParams, (this == iarea->mainCropWindow), true, cropHandler.isFullDisplay ()); + drawCrop (cr, x + imgAreaX + imgX, y + imgAreaY + imgY, imgW, imgH, cropX, cropY, zoomSteps[cropZoom].zoom, cropParams, (this == iarea->mainCropWindow), useBgColor, cropHandler.isFullDisplay ()); } if (observedCropWin) { @@ -1853,7 +1867,7 @@ void CropWindow::expose (Cairo::RefPtr cr) cr->fill(); if (cropHandler.cropParams.enabled) { - drawCrop (cr, x + imgAreaX + imgX, y + imgAreaY + imgY, rough->get_width(), rough->get_height(), cropX, cropY, zoomSteps[cropZoom].zoom, cropHandler.cropParams, (this == iarea->mainCropWindow), true, cropHandler.isFullDisplay ()); + drawCrop (cr, x + imgAreaX + imgX, y + imgAreaY + imgY, rough->get_width(), rough->get_height(), cropX, cropY, zoomSteps[cropZoom].zoom, cropParams, (this == iarea->mainCropWindow), useBgColor, cropHandler.isFullDisplay ()); } if (observedCropWin) { @@ -2097,7 +2111,7 @@ void CropWindow::zoomFitCrop () centerY = cropHandler.cropParams.y + cropHandler.cropParams.h / 2; setCropAnchorPosition(centerX, centerY); changeZoom (cz, true, centerX, centerY); - fitZoom = false; + fitZoom = true; //false; } else { zoomFit(); } diff --git a/rtgui/imagearea.cc b/rtgui/imagearea.cc index c0d334482..e22da4dfb 100644 --- a/rtgui/imagearea.cc +++ b/rtgui/imagearea.cc @@ -638,7 +638,7 @@ void ImageArea::initialImageArrived (CropWindow* cw) if (mainCropWindow) { if(firstOpen || options.prevdemo != PD_Sidecar || (!options.rememberZoomAndPan) ) { - mainCropWindow->zoomFit (); + mainCropWindow->zoomFitCrop (); firstOpen = false; mainCropWindow->cropHandler.getFullImageSize(fullImageWidth, fullImageHeight); } else { @@ -646,7 +646,7 @@ void ImageArea::initialImageArrived (CropWindow* cw) mainCropWindow->cropHandler.getFullImageSize(w, h); if(w != fullImageWidth || h != fullImageHeight) { - mainCropWindow->zoomFit (); + mainCropWindow->zoomFitCrop (); } fullImageWidth = w;