diff --git a/rtdata/languages/default b/rtdata/languages/default index 92bbaa08f..25af81141 100644 --- a/rtdata/languages/default +++ b/rtdata/languages/default @@ -976,6 +976,12 @@ PREFERENCES_CLUTSCACHE;HaldCLUT Cache PREFERENCES_CLUTSCACHE_LABEL;Maximum number of cached CLUTs PREFERENCES_CLUTSDIR;HaldCLUT directory PREFERENCES_CMMBPC;Black point compensation +PREFERENCES_CROP;Crop editing +PREFERENCES_CROP_GUIDES;Guides shown when not editing the crop +PREFERENCES_CROP_GUIDES_NONE;None +PREFERENCES_CROP_GUIDES_FRAME;Frame +PREFERENCES_CROP_GUIDES_FULL;Original +PREFERENCES_CROP_AUTO_FIT;Automatically zoom to fit the crop area PREFERENCES_CURVEBBOXPOS;Position of curve copy & paste buttons PREFERENCES_CURVEBBOXPOS_ABOVE;Above PREFERENCES_CURVEBBOXPOS_BELOW;Below diff --git a/rtgui/cropwindow.cc b/rtgui/cropwindow.cc index b8bbfe4fc..001805362 100644 --- a/rtgui/cropwindow.cc +++ b/rtgui/cropwindow.cc @@ -312,8 +312,10 @@ void CropWindow::buttonPress (int button, int type, int bstate, int x, int y) screenCoordToImage (x, y, action_x, action_y); changeZoom (zoom11index, true, action_x, action_y); fitZoom = false; + } else if (options.cropAutoFit) { + zoomFitCrop(); } else { - zoomFitCrop (); + zoomFit(); } } else { zoom11 (); @@ -613,7 +615,7 @@ void CropWindow::buttonRelease (int button, int num, int bstate, int x, int y) needRedraw = true; - if (fitZoom) { + if (fitZoom && options.cropAutoFit) { zoomFitCrop(); } } else if (state == SCropWinMove) { @@ -727,7 +729,7 @@ void CropWindow::buttonRelease (int button, int num, int bstate, int x, int y) iarea->setToolHand (); needRedraw = true; - if (fitZoom) { + if (fitZoom && options.cropAutoFit) { zoomFitCrop(); } } @@ -1365,8 +1367,17 @@ void CropWindow::expose (Cairo::RefPtr cr) } } else { CropParams cropParams = cropHandler.cropParams; - if (state == SNormal && cropParams.guide != "None") { - cropParams.guide = "Frame"; + if (state == SNormal) { + switch (options.cropGuides) { + case Options::CROP_GUIDE_NONE: + cropParams.guide = "None"; + break; + case Options::CROP_GUIDE_FRAME: + cropParams.guide = "Frame"; + break; + default: + break; + } } bool useBgColor = (state == SNormal); @@ -2111,7 +2122,7 @@ void CropWindow::zoomFitCrop () centerY = cropHandler.cropParams.y + cropHandler.cropParams.h / 2; setCropAnchorPosition(centerX, centerY); changeZoom (cz, true, centerX, centerY); - fitZoom = true; //false; + fitZoom = options.cropAutoFit; } else { zoomFit(); } diff --git a/rtgui/filebrowserentry.cc b/rtgui/filebrowserentry.cc index c3adae3aa..cb3844687 100644 --- a/rtgui/filebrowserentry.cc +++ b/rtgui/filebrowserentry.cc @@ -168,6 +168,16 @@ void FileBrowserEntry::customBackBufferUpdate (Cairo::RefPtr c) drawCrop (c, prex, prey, prew, preh, 0, 0, scale, cropParams, true, false); } else { rtengine::procparams::CropParams cparams = thumbnail->getProcParams().crop; + switch (options.cropGuides) { + case Options::CROP_GUIDE_NONE: + cparams.guide = "None"; + break; + case Options::CROP_GUIDE_FRAME: + cparams.guide = "Frame"; + break; + default: + break; + } if (cparams.enabled && !thumbnail->isQuick()) { // Quick thumb have arbitrary sizes, so don't apply the crop drawCrop (c, prex, prey, prew, preh, 0, 0, scale, cparams, true, false); diff --git a/rtgui/imagearea.cc b/rtgui/imagearea.cc index e22da4dfb..0344e04b7 100644 --- a/rtgui/imagearea.cc +++ b/rtgui/imagearea.cc @@ -638,7 +638,11 @@ void ImageArea::initialImageArrived (CropWindow* cw) if (mainCropWindow) { if(firstOpen || options.prevdemo != PD_Sidecar || (!options.rememberZoomAndPan) ) { - mainCropWindow->zoomFitCrop (); + if (options.cropAutoFit) { + mainCropWindow->zoomFitCrop(); + } else { + mainCropWindow->zoomFit(); + } firstOpen = false; mainCropWindow->cropHandler.getFullImageSize(fullImageWidth, fullImageHeight); } else { @@ -646,7 +650,11 @@ void ImageArea::initialImageArrived (CropWindow* cw) mainCropWindow->cropHandler.getFullImageSize(w, h); if(w != fullImageWidth || h != fullImageHeight) { - mainCropWindow->zoomFitCrop (); + if (options.cropAutoFit) { + mainCropWindow->zoomFitCrop(); + } else { + mainCropWindow->zoomFit(); + } } fullImageWidth = w; diff --git a/rtgui/options.cc b/rtgui/options.cc index 127ea990f..449aa3809 100644 --- a/rtgui/options.cc +++ b/rtgui/options.cc @@ -614,6 +614,8 @@ void Options::setDefaults () gimpPluginShowInfoDialog = true; maxRecentFolders = 15; rtSettings.lensfunDbDirectory = ""; // set also in main.cc and main-cli.cc + cropGuides = CROP_GUIDE_FULL; + cropAutoFit = false; } Options* Options::copyFrom (Options* other) @@ -1386,6 +1388,12 @@ void Options::readFromFile (Glib::ustring fname) if (keyFile.has_key ("Crop Settings", "PPI")) { cropPPI = keyFile.get_integer ("Crop Settings", "PPI"); } + if (keyFile.has_key("Crop Settings", "GuidesMode")) { + cropGuides = CropGuidesMode(std::max(int(CROP_GUIDE_NONE), std::min(keyFile.get_integer("Crop Settings", "GuidesMode"), int(CROP_GUIDE_FULL)))); + } + if (keyFile.has_key("Crop Settings", "AutoFit")) { + cropAutoFit = keyFile.get_boolean("Crop Settings", "AutoFit"); + } } if (keyFile.has_group ("Color Management")) { @@ -2018,6 +2026,8 @@ void Options::saveToFile (Glib::ustring fname) //keyFile.set_integer_list ("GUI", "CurvePanelsExpanded", crvopen); keyFile.set_integer ("Crop Settings", "PPI", cropPPI); + keyFile.set_integer("Crop Settings", "GuidesMode", cropGuides); + keyFile.set_boolean("Crop Settings", "AutoFit", cropAutoFit); keyFile.set_string ("Color Management", "PrinterProfile", rtSettings.printerProfile); keyFile.set_integer ("Color Management", "PrinterIntent", rtSettings.printerIntent); diff --git a/rtgui/options.h b/rtgui/options.h index feeca7983..31d17ef9b 100644 --- a/rtgui/options.h +++ b/rtgui/options.h @@ -191,7 +191,6 @@ public: int showFilePanelState; // 0: normal, 1: maximized, 2: normal, 3: hidden bool showInfo; bool mainNBVertical; // main notebook vertical tabs? - int cropPPI; bool showClippedHighlights; bool showClippedShadows; int highlightThreshold; @@ -261,6 +260,12 @@ public: bool showFilmStripToolBar; + // cropping options + int cropPPI; + enum CropGuidesMode { CROP_GUIDE_NONE, CROP_GUIDE_FRAME, CROP_GUIDE_FULL }; + CropGuidesMode cropGuides; + bool cropAutoFit; + // Performance options Glib::ustring clutsDir; int rgbDenoiseThreadLimit; // maximum number of threads for the denoising tool ; 0 = use the maximum available diff --git a/rtgui/preferences.cc b/rtgui/preferences.cc index b53e884f5..2be5f3664 100644 --- a/rtgui/preferences.cc +++ b/rtgui/preferences.cc @@ -582,6 +582,22 @@ Gtk::Widget* Preferences::getProcParamsPanel () cdf->add(*dirgrid); mvbpp->pack_start (*cdf, Gtk::PACK_SHRINK, 4 ); + // Crop + Gtk::Frame *cropframe = Gtk::manage(new Gtk::Frame(M("PREFERENCES_CROP"))); + Gtk::VBox *cropvb = Gtk::manage(new Gtk::VBox()); + Gtk::HBox *crophb = Gtk::manage(new Gtk::HBox()); + cropGuides = Gtk::manage(new Gtk::ComboBoxText()); + cropGuides->append(M("PREFERENCES_CROP_GUIDES_NONE")); + cropGuides->append(M("PREFERENCES_CROP_GUIDES_FRAME")); + cropGuides->append(M("PREFERENCES_CROP_GUIDES_FULL")); + crophb->pack_start(*Gtk::manage(new Gtk::Label(M("PREFERENCES_CROP_GUIDES") + ": ")), Gtk::PACK_SHRINK, 4); + crophb->pack_start(*cropGuides); + cropvb->pack_start(*crophb); + cropAutoFit = Gtk::manage(new Gtk::CheckButton(M("PREFERENCES_CROP_AUTO_FIT"))); + cropvb->pack_start(*cropAutoFit); + cropframe->add(*cropvb); + mvbpp->pack_start(*cropframe, Gtk::PACK_SHRINK, 4); + return mvbpp; } @@ -1840,6 +1856,9 @@ void Preferences::storePreferences () moptions.sndLngEditProcDone = txtSndLngEditProcDone->get_text (); moptions.sndLngEditProcDoneSecs = spbSndLngEditProcDoneSecs->get_value (); #endif + + moptions.cropGuides = Options::CropGuidesMode(cropGuides->get_active_row_number()); + moptions.cropAutoFit = cropAutoFit->get_active(); } void Preferences::fillPreferences () @@ -2070,6 +2089,9 @@ void Preferences::fillPreferences () } } + cropGuides->set_active(moptions.cropGuides); + cropAutoFit->set_active(moptions.cropAutoFit); + addc.block (false); setc.block (false); cpfconn.block (false); diff --git a/rtgui/preferences.h b/rtgui/preferences.h index 7ce592457..cb0e6c709 100644 --- a/rtgui/preferences.h +++ b/rtgui/preferences.h @@ -204,6 +204,9 @@ class Preferences : public Gtk::Dialog, public ProfileStoreListener DynamicProfilePanel *dynProfilePanel; + Gtk::ComboBoxText *cropGuides; + Gtk::CheckButton *cropAutoFit; + Glib::ustring storedValueRaw; Glib::ustring storedValueImg; diff --git a/rtgui/previewwindow.cc b/rtgui/previewwindow.cc index cd4e0c75c..06ce3ad18 100644 --- a/rtgui/previewwindow.cc +++ b/rtgui/previewwindow.cc @@ -86,7 +86,18 @@ void PreviewWindow::updatePreviewImage () cc->fill(); if (previewHandler->getCropParams().enabled) { - drawCrop (cc, imgX, imgY, imgW, imgH, 0, 0, zoom, previewHandler->getCropParams(), true, false); + rtengine::CropParams cparams = previewHandler->getCropParams(); + switch (options.cropGuides) { + case Options::CROP_GUIDE_NONE: + cparams.guide = "None"; + break; + case Options::CROP_GUIDE_FRAME: + cparams.guide = "Frame"; + break; + default: + break; + } + drawCrop (cc, imgX, imgY, imgW, imgH, 0, 0, zoom, cparams, true, false); } } }