rawTherapee/rtgui/lockablecolorpicker.h
Lawrence37 e438e0e604
Some more cherry-picking for 5.10 (#6937)
* Local adjustments - Show additional settings - link with complexity  (#6899)

* Change hishow -additional seeting - with complexity

* Modify windows.yml and appimage.yml

* Fixed bug in duplicate spot

* Remove pre-dev builds

* Update camconst.json white levels for 1DxII

* Fix warnings: conversion to double/float, unused variables, register keyword

* Fix crash when opening image in editor

Do not access uninitialized raw image data. The raw data is requested
when the demosaic mode is set to None and the cursor is moved over the
image in the editor. It can occur before the raw data is loaded.

* Fix sRGB working profile crash

The sRGB working profile cannot be found under some conditions because
the profile name is stored as a Glib::ustring and the same strings may
not be equal when using different locales. Use std::string whenever
comparing profile names.

---------

Co-authored-by: Desmis <jdesmis@gmail.com>
Co-authored-by: CarVac <airplaniac2002@gmail.com>
Co-authored-by: Alexander Gruzintsev <0v3rt1r3d@gmail.com>
2024-02-04 15:43:33 -08:00

105 lines
2.9 KiB
C++

/*
* This file is part of RawTherapee.
*
* Copyright (c) 2004-2010 Gabor Horvath <hgabor@rawtherapee.com>
*
* RawTherapee is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* RawTherapee is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with RawTherapee. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include "guiutils.h"
#include "../rtengine/coord.h"
class CropWindow;
namespace rtengine
{
namespace procparams
{
struct ColorManagementParams;
}
}
class LockablePickerToolListener
{
public:
virtual ~LockablePickerToolListener () = default;
/// Callback on Color Picker's visibility switch
virtual void switchPickerVisibility(bool isVisible) = 0;
};
class LockableColorPicker final : BackBuffer
{
public:
enum class Size {
S5=5,
S10=10,
S15=15,
S20=20,
S25=25,
S30=30
};
enum class Validity {
INSIDE,
CROSSING,
OUTSIDE
};
private:
enum class ColorPickerType {
RGB,
HSV,
LAB
};
CropWindow* cropWindow; // the color picker is displayed in a single cropWindow, the one that the user has clicked in
ColorPickerType displayedValues;
rtengine::Coord position; // Coordinate in image space
rtengine::Coord anchorOffset;
Size size;
rtengine::procparams::ColorManagementParams *color_management_params;
Validity validity;
float r, g, b; // red green blue in [0;1] range
float rpreview, gpreview, bpreview;
float hue, sat, val; // hue saturation value in [0;1] range
float L, a, bb; // L*a*b value in [0;1] range
void updateBackBuffer ();
public:
LockableColorPicker (CropWindow* cropWindow, rtengine::procparams::ColorManagementParams *color_management_params);
void draw (const Cairo::RefPtr<Cairo::Context> &cr);
// Used to update the RGB color, the HSV values will be updated accordingly
void setPosition (const rtengine::Coord &newPos);
void setRGB (const float R, const float G, const float B, const float previewR, const float previewG, const float previewB);
void getImagePosition (rtengine::Coord &imgPos) const;
void getScreenPosition (rtengine::Coord &screenPos) const;
Size getSize () const;
bool isOver (int x, int y);
void setValidity (Validity isValid);
void setSize (Size newSize);
void rollDisplayedValues ();
bool incSize ();
bool decSize ();
bool cycleRGB ();
bool cycleHSV ();
};