Remember zoom % and pan offset when opening another image, issue 2435

This commit is contained in:
DrSlony
2015-03-21 13:51:56 +01:00
parent f86fd06b11
commit 1ec6ff068b
10 changed files with 80 additions and 32 deletions

View File

@@ -884,6 +884,7 @@ PREFERENCES_MONITORICC;Monitor color profile
PREFERENCES_MULTITABDUALMON;Multiple Editor Tabs In Own Window Mode
PREFERENCES_MULTITAB;Multiple Editor Tabs Mode
PREFERENCES_NAVGUIDEBRUSH;Navigator guide color
PREFERENCES_NAVIGATIONFRAME;Navigation
PREFERENCES_NOISE;Noise Reduction
PREFERENCES_OUTDIRFOLDERHINT;Save images to the selected folder.
PREFERENCES_OUTDIRFOLDER;Save to folder
@@ -893,8 +894,9 @@ PREFERENCES_OUTDIR;Output Directory
PREFERENCES_OVERLAY_FILENAMES;Overlay filenames on thumbnails in the file browser
PREFERENCES_OVERLAY_FILENAMES_FILMSTRIP;Overlay filenames on thumbnails in the editor pannel
PREFERENCES_OVERWRITEOUTPUTFILE;Overwrite existing output files
PREFERENCES_PANFACTORFRAME;Pan Rate Amplification
PREFERENCES_PANFACTORLABEL;Factor
PREFERENCES_REMEMBERZOOMPAN;Remember zoom % and pan offset
PREFERENCES_REMEMBERZOOMPAN_TOOLTIP;Remember the zoom % and pan offset of the current image when opening a new image.\n\nThis option only works in "Single Editor Tab Mode" and when "Demosaicing method used for the preview at <100% zoom" is set to "As in PP3".
PREFERENCES_PANFACTORLABEL;Pan rate amplification
PREFERENCES_PARSEDEXTADDHINT;Add entered extension to the list.
PREFERENCES_PARSEDEXTADD;Add extension
PREFERENCES_PARSEDEXTDELHINT;Delete selected extension from the list.

View File

@@ -168,9 +168,9 @@ void CropWindow::getCropRectangle (int& x, int& y, int& w, int& h) {
cropHandler.cutRectToImgBounds (x, y, w, h);
}
void CropWindow::setCropPosition (int x, int y) {
void CropWindow::setCropPosition (int x, int y, bool update) {
cropHandler.setPosition (x, y);
cropHandler.setPosition (x, y, update);
for (std::list<CropWindowListener*>::iterator i=listeners.begin(); i!=listeners.end(); i++)
(*i)->cropPositionChanged (this);
}
@@ -1559,7 +1559,22 @@ void CropWindow::setZoom (double zoom) {
changeZoom (cz, false);
}
void CropWindow::zoomFit () {
double CropWindow::getZoomFitVal () {
double z = cropHandler.getFitZoom ();
int cz = MAXZOOMSTEPS;
if (z < zoomSteps[0].zoom)
cz = 0;
else
for (int i=0; i<MAXZOOMSTEPS; i++)
if (zoomSteps[i].zoom <= z && zoomSteps[i+1].zoom > z) {
cz = i;
break;
}
return zoomSteps[cz].zoom;
}
void CropWindow::zoomFit (bool skipZoomIfUnchanged) {
double z = cropHandler.getFitZoom ();
int cz = MAXZOOMSTEPS;
@@ -1572,7 +1587,7 @@ void CropWindow::zoomFit () {
break;
}
zoomVersion = exposeVersion;
changeZoom (cz);
changeZoom (cz, true, -1, -1, skipZoomIfUnchanged);
fitZoom = true;
}

View File

@@ -115,7 +115,7 @@ class CropWindow : public LWButtonListener, public CropHandlerListener, public E
int scaleValueToScreen (int value);
float scaleValueToScreen (float value);
double scaleValueToScreen (double value);
double getZoomFitVal ();
void setPosition (int x, int y);
void getPosition (int& x, int& y);
void setSize (int w, int h, bool norefresh=false);
@@ -129,7 +129,7 @@ class CropWindow : public LWButtonListener, public CropHandlerListener, public E
void zoomIn (bool toCursor=false, int cursorX=-1, int cursorY=-1);
void zoomOut (bool toCursor=false, int cursorX=-1, int cursorY=-1);
void zoom11 ();
void zoomFit ();
void zoomFit (bool skipZoomIfUnchanged=true);
void zoomFitCrop ();
double getZoom ();
bool isMinZoom ();
@@ -153,7 +153,7 @@ class CropWindow : public LWButtonListener, public CropHandlerListener, public E
// crop handling
void getCropRectangle (int& x, int& y, int& w, int& h);
void getCropPosition (int& x, int& y);
void setCropPosition (int x, int y);
void setCropPosition (int x, int y, bool update = true);
void getCropSize (int& w, int& h);
// listeners

View File

@@ -502,7 +502,10 @@ void EditorPanel::open (Thumbnail* tmb, rtengine::InitialImage* isrc) {
// In single tab mode, the image is not always updated between switches
// normal redraw don't work, so this is the hard way
if (!options.tabbedUI) iareapanel->imageArea->mainCropWindow->cropHandler.update();
// Disabled this with Issue 2435 because it seems to work fine now
// if (!options.tabbedUI && iareapanel->imageArea->mainCropWindow->getZoomFitVal() == 1.0) {
// iareapanel->imageArea->mainCropWindow->cropHandler.update();
// }
} else {
Gtk::Allocation alloc;
iareapanel->imageArea->on_resized(alloc);

View File

@@ -26,7 +26,7 @@
#include "../rtengine/refreshmap.h"
#include "options.h"
ImageArea::ImageArea (ImageAreaPanel* p) : parent(p) {
ImageArea::ImageArea (ImageAreaPanel* p) : parent(p), firstOpen(true) {
infotext = "";
cropgl = NULL;
@@ -520,8 +520,25 @@ void ImageArea::setZoom (double zoom) {
void ImageArea::initialImageArrived (CropWindow* cw) {
if (mainCropWindow)
mainCropWindow->zoomFit ();
if (mainCropWindow) {
if(firstOpen || options.prevdemo!=PD_Sidecar || (!options.rememberZoomAndPan) ) {
mainCropWindow->zoomFit (false);
firstOpen = false;
mainCropWindow->cropHandler.getFullImageSize(fullImageWidth,fullImageHeight);
} else {
int w,h;
mainCropWindow->cropHandler.getFullImageSize(w,h);
if(w == fullImageWidth && h == fullImageHeight) { // && mainCropWindow->getZoom() != mainCropWindow->getZoomFitVal()) {
int x,y;
mainCropWindow->getCropPosition(x,y);
mainCropWindow->setCropPosition(x,y, false);
} else {
mainCropWindow->zoomFit (false);
}
fullImageWidth = w;
fullImageHeight = h;
}
}
}
void ImageArea::syncBeforeAfterViews () {

View File

@@ -59,7 +59,8 @@ class ImageArea : public Gtk::DrawingArea, public CropWindowListener, public Edi
ImageAreaToolListener* listener;
CropWindow* getCropWindow (int x, int y);
bool firstOpen;
int fullImageWidth, fullImageHeight;
public:
CropWindow* mainCropWindow;
CropWindow* flawnOverWindow;

View File

@@ -288,6 +288,7 @@ void Options::setDefaults () {
historyPanelWidth = 330;
lastScale = 5;
panAccelFactor = 5;
rememberZoomAndPan = true;
lastCropSize = 1;
fbOnlyRaw = false;
fbShowDateTime = true;
@@ -805,6 +806,7 @@ if (keyFile.has_group ("GUI")) {
if (keyFile.has_key ("GUI", "HistoryPanelWidth")) historyPanelWidth = keyFile.get_integer ("GUI", "HistoryPanelWidth");
if (keyFile.has_key ("GUI", "LastPreviewScale")) lastScale = keyFile.get_integer ("GUI", "LastPreviewScale");
if (keyFile.has_key ("GUI", "PanAccelFactor")) panAccelFactor = keyFile.get_integer ("GUI", "PanAccelFactor");
if (keyFile.has_key ("GUI", "RememberZoomAndPan")) rememberZoomAndPan = keyFile.get_boolean ("GUI", "RememberZoomAndPan");
if (keyFile.has_key ("GUI", "LastCropSize")) lastCropSize = keyFile.get_integer ("GUI", "LastCropSize");
if (keyFile.has_key ("GUI", "ShowHistory")) showHistory = keyFile.get_boolean ("GUI", "ShowHistory");
if (keyFile.has_key ("GUI", "ShowFilePanelState")) showFilePanelState= keyFile.get_integer ("GUI", "ShowFilePanelState");
@@ -1130,6 +1132,7 @@ int Options::saveToFile (Glib::ustring fname) {
keyFile.set_integer ("GUI", "HistoryPanelWidth", historyPanelWidth);
keyFile.set_integer ("GUI", "LastPreviewScale", lastScale);
keyFile.set_integer ("GUI", "PanAccelFactor", panAccelFactor);
keyFile.set_boolean ("GUI", "RememberZoomAndPan", rememberZoomAndPan);
keyFile.set_integer ("GUI", "LastCropSize", lastCropSize);
keyFile.set_boolean ("GUI", "ShowHistory", showHistory);
keyFile.set_integer ("GUI", "ShowFilePanelState", showFilePanelState);

View File

@@ -195,6 +195,7 @@ class Options {
bool filmStripShowFileNames;
bool tabbedUI;
int previewSizeTab,previewSizeBrowser;
bool rememberZoomAndPan;
int multiDisplayMode; // 0=none, 1=Edit panels on other display
std::vector<double> cutOverlayBrush; // Red;Green;Blue;Alpha , all ranging 0..1
std::vector<double> navGuideBrush; // Red;Green;Blue;Alpha , all ranging 0..1

View File

@@ -901,7 +901,7 @@ Gtk::Widget* Preferences::getGeneralPanel () {
//-----
Gtk::HBox* hbcd = Gtk::manage( new Gtk::HBox () );
Gtk::HBox* hbcd = Gtk::manage( new Gtk::HBox (true) );
hbcd->set_spacing(4);
Gtk::Frame* frl = Gtk::manage( new Gtk::Frame (M("PREFERENCES_CLIPPINGIND")));
@@ -936,30 +936,33 @@ Gtk::Widget* Preferences::getGeneralPanel () {
frl->add (*vbrl);
hbcd->pack_start (*frl, true, true, 0);
//-----
Gtk::VBox* dfpfvb = Gtk::manage( new Gtk::VBox () );
dfpfvb->set_spacing (4);
//---
//-----
Gtk::Frame* pff = Gtk::manage( new Gtk::Frame (M("PREFERENCES_PANFACTORFRAME")) );
Gtk::Frame* navigationFrame = Gtk::manage( new Gtk::Frame (M("PREFERENCES_NAVIGATIONFRAME")) );
Gtk::VBox* navigationVBox = Gtk::manage( new Gtk::VBox () );
navigationVBox->set_border_width(4);
Gtk::HBox* pfhb = Gtk::manage( new Gtk::HBox () );
pfhb->set_border_width(4);
pfhb->set_spacing(4);
Gtk::Label* pfl = Gtk::manage( new Gtk::Label (M("PREFERENCES_PANFACTORLABEL") + ":", Gtk::ALIGN_LEFT));
Gtk::HBox* panFactorHBox = Gtk::manage( new Gtk::HBox () );
Gtk::Label* panFactorLabel = Gtk::manage( new Gtk::Label (M("PREFERENCES_PANFACTORLABEL") + ":", Gtk::ALIGN_LEFT));
panFactor = Gtk::manage( new Gtk::SpinButton () );
panFactor->set_digits (0);
panFactor->set_increments (1, 5);
panFactor->set_range (1, 10);
pfhb->pack_start (*pfl, Gtk::PACK_SHRINK, 0);
pfhb->pack_end (*panFactor, Gtk::PACK_SHRINK, 0);
pff->add (*pfhb);
panFactorHBox->pack_start (*panFactorLabel);
panFactorHBox->pack_end (*panFactor, Gtk::PACK_SHRINK);
dfpfvb->pack_start (*pff, true, true, 0);
hbcd->pack_start (*dfpfvb, Gtk::PACK_SHRINK, 4);
mvbsd->pack_start (*hbcd, Gtk::PACK_SHRINK, 4);
rememberZoomPanCheckbutton = Gtk::manage( new Gtk::CheckButton (M("PREFERENCES_REMEMBERZOOMPAN")) );
rememberZoomPanCheckbutton->set_tooltip_text(M("PREFERENCES_REMEMBERZOOMPAN_TOOLTIP"));
navigationVBox->pack_start (*panFactorHBox, Gtk::PACK_SHRINK);
navigationVBox->pack_start (*rememberZoomPanCheckbutton, Gtk::PACK_SHRINK);
navigationFrame->add (*navigationVBox);
hbcd->pack_start (*navigationFrame);
mvbsd->pack_start (*hbcd, Gtk::PACK_SHRINK, 0);
//-----
//-----
Gtk::Frame* fdg = Gtk::manage( new Gtk::Frame (M("PREFERENCES_EXTERNALEDITOR")) );
Gtk::VBox* dgvb = Gtk::manage( new Gtk::VBox () );
@@ -1297,6 +1300,7 @@ void Preferences::storePreferences () {
moptions.dateFormat = dateformat->get_text();
moptions.panAccelFactor = (int)panFactor->get_value();
moptions.rememberZoomAndPan = rememberZoomPanCheckbutton->get_active();
moptions.fbShowDateTime = showDateTime->get_active ();
moptions.fbShowBasicExif = showBasicExif->get_active ();
moptions.fbShowExpComp = showExpComp->get_active ();
@@ -1455,7 +1459,8 @@ void Preferences::fillPreferences () {
iprofiles->setActiveRowFromFullPath (moptions.defProfImg);
forImageComboChanged(); // update the tooltip
dateformat->set_text (moptions.dateFormat);
panFactor->set_value(moptions.panAccelFactor);
panFactor->set_value (moptions.panAccelFactor);
rememberZoomPanCheckbutton->set_active (moptions.rememberZoomAndPan);
#if !defined(__APPLE__) // monitor profile not supported on apple
if (safe_file_test (moptions.rtSettings.monitorProfile, Glib::FILE_TEST_EXISTS))
monProfile->set_filename (moptions.rtSettings.monitorProfile);

View File

@@ -90,6 +90,7 @@ class Preferences : public Gtk::Dialog, public ProfileStoreListener {
Gtk::SpinButton* shThresh;
Gtk::SpinButton* panFactor;
Gtk::CheckButton* rememberZoomPanCheckbutton;
Gtk::ComboBoxText* intent;
Gtk::ComboBoxText* view;