diff --git a/rtdata/themes/RawTherapee-GTK3-20_.css b/rtdata/themes/RawTherapee-GTK3-20_.css index f32455ca3..ba58e412f 100644 --- a/rtdata/themes/RawTherapee-GTK3-20_.css +++ b/rtdata/themes/RawTherapee-GTK3-20_.css @@ -325,14 +325,22 @@ scale:disabled trough { } /* Better on/off state separation for text toggle buttons, e.g. auto-levels or histogram matching. */ -button.text-button { +button.text-button.toggle { background-image: linear-gradient(to bottom, rgba(100,100,100,.3), rgba(30,30,30,.3)); } -button.text-button:checked { +button.text-button.toggle:hover { + background-image: linear-gradient(to bottom, rgba(128,128,128,.3), rgba(64,64,64,.3)); +} + +button.text-button.toggle:checked { background-image: linear-gradient(to bottom, rgba(30,30,30,.3), rgba(0,0,0,.4)); } +button.text-button.toggle:hover:checked { + background-image: linear-gradient(to bottom, rgba(48,48,48,.3), rgba(0,0,0,.3)); +} + separator { color: #363636; margin: 5px; diff --git a/rtdata/themes/RawTherapee-GTK3-_19.css b/rtdata/themes/RawTherapee-GTK3-_19.css index cfbec4355..a796b60a1 100644 --- a/rtdata/themes/RawTherapee-GTK3-_19.css +++ b/rtdata/themes/RawTherapee-GTK3-_19.css @@ -507,10 +507,19 @@ GtkNotebook { padding-right: 3px; } -GtkButton.text-button { +/* Better on/off state separation for text toggle buttons, e.g. auto-levels or histogram matching. */ +GtkToggleButton.button.text-button { background-image: linear-gradient(to bottom, rgba(100,100,100,.3), rgba(30,30,30,.3)); } -GtkButton.text-button:checked { +GtkToggleButton.button.text-button:hover { + background-image: linear-gradient(to bottom, rgba(128,128,128,.3), rgba(64,64,64,.3)); +} + +GtkToggleButton.button.text-button:checked { background-image: linear-gradient(to bottom, rgba(30,30,30,.3), rgba(0,0,0,.4)); } + +GtkToggleButton.button.text-button:hover:checked { + background-image: linear-gradient(to bottom, rgba(48,48,48,.3), rgba(0,0,0,.3)); +} diff --git a/rtengine/histmatching.cc b/rtengine/histmatching.cc index f0b49cddd..d63428738 100644 --- a/rtengine/histmatching.cc +++ b/rtengine/histmatching.cc @@ -169,7 +169,7 @@ void mappingToCurve(const std::vector &mapping, std::vector &curve) } // namespace -void RawImageSource::getAutoMatchedToneCurve(std::vector &outCurve) +void RawImageSource::getAutoMatchedToneCurve(const ColorManagementParams &cp, std::vector &outCurve) { BENCHFUN @@ -177,7 +177,18 @@ void RawImageSource::getAutoMatchedToneCurve(std::vector &outCurve) std::cout << "performing histogram matching for " << getFileName() << " on the embedded thumbnail" << std::endl; } - if (!histMatchingCache.empty()) { + const auto same_profile = + [](const ColorManagementParams &a, const ColorManagementParams &b) -> bool + { + return (a.input == b.input + && a.toneCurve == b.toneCurve + && a.applyLookTable == b.applyLookTable + && a.applyBaselineExposureOffset == b.applyBaselineExposureOffset + && a.applyHueSatMap == b.applyHueSatMap + && a.dcpIlluminant == b.dcpIlluminant); + }; + + if (!histMatchingCache.empty() && same_profile(histMatchingParams, cp)) { if (settings->verbose) { std::cout << "tone curve found in cache" << std::endl; } @@ -196,9 +207,12 @@ void RawImageSource::getAutoMatchedToneCurve(std::vector &outCurve) } ProcParams neutral; + neutral.icm = cp; neutral.raw.bayersensor.method = RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method::FAST); neutral.raw.xtranssensor.method = RAWParams::XTransSensor::getMethodString(RAWParams::XTransSensor::Method::FAST); neutral.icm.output = "sRGB"; + neutral.icm.gamma = "default"; + neutral.icm.freegamma = false; std::unique_ptr source; { @@ -211,6 +225,7 @@ void RawImageSource::getAutoMatchedToneCurve(std::vector &outCurve) std::cout << "histogram matching: no thumbnail found, generating a neutral curve" << std::endl; } histMatchingCache = outCurve; + histMatchingParams = cp; return; } skip = LIM(skip * fh / h, 6, 10); // adjust the skip factor -- the larger the thumbnail, the less we should skip to get a good match @@ -233,6 +248,7 @@ void RawImageSource::getAutoMatchedToneCurve(std::vector &outCurve) std::cout << "histogram matching: raw decoding failed, generating a neutral curve" << std::endl; } histMatchingCache = outCurve; + histMatchingParams = cp; return; } target.reset(thumb->processImage(neutral, sensor_type, fh / skip, TI_Nearest, getMetaData(), scale, false, true)); @@ -304,6 +320,7 @@ void RawImageSource::getAutoMatchedToneCurve(std::vector &outCurve) } histMatchingCache = outCurve; + histMatchingParams = cp; } } // namespace rtengine diff --git a/rtengine/imagesource.h b/rtengine/imagesource.h index 675243b65..af9eecc35 100644 --- a/rtengine/imagesource.h +++ b/rtengine/imagesource.h @@ -139,7 +139,7 @@ public: } // for RAW files, compute a tone curve using histogram matching on the embedded thumbnail - virtual void getAutoMatchedToneCurve(std::vector &outCurve) + virtual void getAutoMatchedToneCurve(const ColorManagementParams &cp, std::vector &outCurve) { outCurve = { 0.0 }; } diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index 79b3897d7..9cc909fb6 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -600,7 +600,7 @@ void ImProcCoordinator::updatePreviewImage(int todo, Crop* cropCall) } if (params.toneCurve.histmatching) { - imgsrc->getAutoMatchedToneCurve(params.toneCurve.curve); + imgsrc->getAutoMatchedToneCurve(params.icm, params.toneCurve.curve); if (params.toneCurve.autoexp) { params.toneCurve.expcomp = 0.0; diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index 5cf55d2e0..93cfff0bf 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -5809,7 +5809,7 @@ void ImProcFunctions::chromiLuminanceCurve (PipetteBuffer *pipetteBuffer, int pW float aprov1 = Chprov2 * sincosval.y; float bprov1 = Chprov2 * sincosval.x; - float fy = (Color::c1By116 * Lprov1 ) + Color::c1By116; + float fy = (Color::c1By116 * Lprov1 ) + Color::c16By116; float fx = (0.002f * aprov1) + fy; float fz = fy - (0.005f * bprov1); diff --git a/rtengine/rawimagesource.h b/rtengine/rawimagesource.h index 76737e948..f9bf7ce13 100644 --- a/rtengine/rawimagesource.h +++ b/rtengine/rawimagesource.h @@ -96,6 +96,7 @@ protected: float psBlueBrightness[4]; std::vector histMatchingCache; + ColorManagementParams histMatchingParams; void hphd_vertical(float** hpmap, int col_from, int col_to); void hphd_horizontal(float** hpmap, int row_from, int row_to); @@ -186,7 +187,7 @@ public: } void getAutoExpHistogram(LUTu & histogram, int& histcompr); void getRAWHistogram(LUTu & histRedRaw, LUTu & histGreenRaw, LUTu & histBlueRaw); - void getAutoMatchedToneCurve(std::vector &outCurve); + void getAutoMatchedToneCurve(const ColorManagementParams &cp, std::vector &outCurve); DCPProfile *getDCP(const ColorManagementParams &cmp, DCPProfile::ApplyState &as); void convertColorSpace(Imagefloat* image, const ColorManagementParams &cmp, const ColorTemp &wb); diff --git a/rtengine/refreshmap.cc b/rtengine/refreshmap.cc index 19751ae86..1e0408af0 100644 --- a/rtengine/refreshmap.cc +++ b/rtengine/refreshmap.cc @@ -74,7 +74,7 @@ int refreshmap[rtengine::NUMOFEVENTS] = { 0, // EvLDNEdgeTolerance: obsolete, 0, // EvCDNEnabled:obsolete, 0, // free entry - RGBCURVE, // EvDCPToneCurve, + RGBCURVE|M_AUTOEXP, // EvDCPToneCurve, ALLNORAW, // EvDCPIlluminant, RETINEX, // EvSHEnabled, RGBCURVE, // EvSHHighlights, @@ -419,8 +419,8 @@ int refreshmap[rtengine::NUMOFEVENTS] = { DIRPYREQUALIZER, // EvWavgreenlow DIRPYREQUALIZER, // EvWavbluelow DIRPYREQUALIZER, // EvWavNeutral - RGBCURVE, // EvDCPApplyLookTable, - RGBCURVE, // EvDCPApplyBaselineExposureOffset, + RGBCURVE|M_AUTOEXP, // EvDCPApplyLookTable, + RGBCURVE|M_AUTOEXP, // EvDCPApplyBaselineExposureOffset, ALLNORAW, // EvDCPApplyHueSatMap DIRPYREQUALIZER, // EvWavenacont DIRPYREQUALIZER, // EvWavenachrom diff --git a/rtengine/simpleprocess.cc b/rtengine/simpleprocess.cc index 3110d68a7..ed56b3989 100644 --- a/rtengine/simpleprocess.cc +++ b/rtengine/simpleprocess.cc @@ -749,7 +749,7 @@ private: } if (params.toneCurve.histmatching) { - imgsrc->getAutoMatchedToneCurve(params.toneCurve.curve); + imgsrc->getAutoMatchedToneCurve(params.icm, params.toneCurve.curve); if (params.toneCurve.autoexp) { params.toneCurve.expcomp = 0.0; diff --git a/rtgui/cropwindow.cc b/rtgui/cropwindow.cc index 001805362..6691fc997 100644 --- a/rtgui/cropwindow.cc +++ b/rtgui/cropwindow.cc @@ -2577,7 +2577,7 @@ void CropWindow::initialImageArrived () { for (auto listener : listeners) { - listener->initialImageArrived (this); + listener->initialImageArrived(); } } diff --git a/rtgui/cropwindow.h b/rtgui/cropwindow.h index c1d7c59cc..b1b419c33 100644 --- a/rtgui/cropwindow.h +++ b/rtgui/cropwindow.h @@ -40,7 +40,7 @@ public: virtual void cropPositionChanged (CropWindow*) {} virtual void cropWindowSizeChanged (CropWindow*) {} virtual void cropZoomChanged (CropWindow*) {} - virtual void initialImageArrived (CropWindow*) {} + virtual void initialImageArrived () {} }; class ImageArea; diff --git a/rtgui/editorpanel.cc b/rtgui/editorpanel.cc index 9c23053aa..7f5869a95 100644 --- a/rtgui/editorpanel.cc +++ b/rtgui/editorpanel.cc @@ -1068,7 +1068,6 @@ void EditorPanel::open (Thumbnail* tmb, rtengine::InitialImage* isrc) // since there was no resize event if (iareapanel->imageArea->mainCropWindow) { iareapanel->imageArea->mainCropWindow->cropHandler.newImage (ipc, false); - iareapanel->imageArea->mainCropWindow->initialImageArrived(); // In single tab mode, the image is not always updated between switches // normal redraw don't work, so this is the hard way @@ -1082,6 +1081,7 @@ void EditorPanel::open (Thumbnail* tmb, rtengine::InitialImage* isrc) } history->resetSnapShotNumber(); + navigator->setInvalid(ipc->getFullWidth(),ipc->getFullHeight()); } void EditorPanel::close () diff --git a/rtgui/imagearea.cc b/rtgui/imagearea.cc index 4c4f78a38..55444a916 100644 --- a/rtgui/imagearea.cc +++ b/rtgui/imagearea.cc @@ -25,7 +25,7 @@ #include "../rtengine/refreshmap.h" #include "options.h" -ImageArea::ImageArea (ImageAreaPanel* p) : parent(p), firstOpen(true), fullImageWidth(0), fullImageHeight(0) +ImageArea::ImageArea (ImageAreaPanel* p) : parent(p), fullImageWidth(0), fullImageHeight(0) { infotext = ""; @@ -633,33 +633,23 @@ void ImageArea::setZoom (double zoom) zoomPanel->refreshZoomLabel (); } -void ImageArea::initialImageArrived (CropWindow* cw) +void ImageArea::initialImageArrived () { if (mainCropWindow) { - if(firstOpen || options.prevdemo != PD_Sidecar || (!options.rememberZoomAndPan) ) { + int w, h; + mainCropWindow->cropHandler.getFullImageSize(w, h); + if(options.prevdemo != PD_Sidecar || !options.rememberZoomAndPan || w != fullImageWidth || h != fullImageHeight) { if (options.cropAutoFit || options.bgcolor != 0) { mainCropWindow->zoomFitCrop(); } else { mainCropWindow->zoomFit(); } - firstOpen = false; - mainCropWindow->cropHandler.getFullImageSize(fullImageWidth, fullImageHeight); - } else { - int w, h; - mainCropWindow->cropHandler.getFullImageSize(w, h); - - if(w != fullImageWidth || h != fullImageHeight) { - if (options.cropAutoFit) { - mainCropWindow->zoomFitCrop(); - } else { - mainCropWindow->zoomFit(); - } - } - - fullImageWidth = w; - fullImageHeight = h; + } else if ((options.cropAutoFit || options.bgcolor != 0) && mainCropWindow->cropHandler.cropParams.enabled) { + mainCropWindow->zoomFitCrop(); } + fullImageWidth = w; + fullImageHeight = h; } } diff --git a/rtgui/imagearea.h b/rtgui/imagearea.h index 91820beb1..65fc14cce 100644 --- a/rtgui/imagearea.h +++ b/rtgui/imagearea.h @@ -65,7 +65,6 @@ protected: void get_preferred_height_for_width_vfunc (int width, int &minimum_height, int &natural_height) const; void get_preferred_width_for_height_vfunc (int height, int &minimum_width, int &natural_width) const; - bool firstOpen; int fullImageWidth, fullImageHeight; public: CropWindow* mainCropWindow; @@ -148,7 +147,7 @@ public: void cropPositionChanged (CropWindow* cw); void cropWindowSizeChanged (CropWindow* cw); void cropZoomChanged (CropWindow* cw); - void initialImageArrived (CropWindow* cw) ; + void initialImageArrived (); // LockablePickerToolListener interface void switchPickerVisibility (bool isVisible); diff --git a/rtgui/navigator.h b/rtgui/navigator.h index 647df7a34..e6ca33559 100644 --- a/rtgui/navigator.h +++ b/rtgui/navigator.h @@ -46,7 +46,6 @@ protected: Gtk::Label *lH, *lS, *lV; Gtk::Label *lLAB_A, *lLAB_B, *lLAB_L; - void setInvalid (int fullWidth = -1, int fullHeight = -1); public: PreviewWindow* previewWindow; @@ -56,6 +55,7 @@ public: // pointermotionlistener interface // void pointerMoved (bool validPos, int x, int y, int r, int g, int b); void pointerMoved (bool validPos, Glib::ustring profile, Glib::ustring profileW, int x, int y, int r, int g, int b); + void setInvalid (int fullWidth = -1, int fullHeight = -1); void getRGBText (int r, int g, int b, Glib::ustring &sR, Glib::ustring &sG, Glib::ustring &sB); void getHSVText (float h, float s, float v, Glib::ustring &sH, Glib::ustring &sS, Glib::ustring &sV);