Krita Source Code Documentation
Loading...
Searching...
No Matches
KisGammaExposureAction Class Reference

#include <kis_gamma_exposure_action.h>

+ Inheritance diagram for KisGammaExposureAction:

Classes

class  Private
 

Public Types

enum  Shortcuts {
  ExposureShortcut , GammaShortcut , AddExposure05Shortcut , RemoveExposure05Shortcut ,
  AddGamma05Shortcut , RemoveGamma05Shortcut , AddExposure02Shortcut , RemoveExposure02Shortcut ,
  AddGamma02Shortcut , RemoveGamma02Shortcut , ResetExposureAndGammaShortcut
}
 

Public Member Functions

void activate (int shortcut) override
 
void begin (int shortcut, QEvent *event=nullptr) override
 
void cursorMovedAbsolute (const QPointF &lastPos, const QPointF &pos) override
 
void deactivate (int shortcut) override
 
bool isShortcutRequired (int shortcut) const override
 
 KisGammaExposureAction ()
 
int priority () const override
 
 ~KisGammaExposureAction () override
 
- Public Member Functions inherited from KisAbstractInputAction
virtual bool canIgnoreModifiers () const
 
virtual QString description () const
 
virtual void end (QEvent *event)
 
virtual QString id () const
 
virtual KisInputActionGroup inputActionGroup (int shortcut) const
 
virtual void inputEvent (QEvent *event)
 
virtual bool isAvailable () const
 
 KisAbstractInputAction (const QString &id)
 
virtual QString name () const
 
virtual QHash< QString, int > shortcutIndexes () const
 
virtual bool supportsHiResInputEvents (int shortcut) const
 
virtual ~KisAbstractInputAction ()
 

Private Attributes

Private *const d {nullptr}
 

Additional Inherited Members

- Public Attributes inherited from KisAbstractInputAction
QString description
 
QString id
 
QHash< QString, int > indexes
 
QPointF lastCursorPosition
 
QString name
 
QPointF startCursorPosition
 
- Static Public Attributes inherited from KisAbstractInputAction
static KisInputManagerinputManager
 
- Protected Member Functions inherited from KisAbstractInputAction
virtual void cursorMoved (const QPointF &lastPos, const QPointF &pos)
 
QPoint eventPos (const QEvent *event)
 
QPointF eventPosF (const QEvent *event)
 
KisInputManagerinputManager () const
 
void setDescription (const QString &description)
 
void setName (const QString &name)
 
void setShortcutIndexes (const QHash< QString, int > &indexes)
 

Detailed Description

Definition at line 13 of file kis_gamma_exposure_action.h.

Member Enumeration Documentation

◆ Shortcuts

The different behaviours for this action.

Enumerator
ExposureShortcut 
GammaShortcut 
AddExposure05Shortcut 
RemoveExposure05Shortcut 
AddGamma05Shortcut 
RemoveGamma05Shortcut 
AddExposure02Shortcut 
RemoveExposure02Shortcut 
AddGamma02Shortcut 
RemoveGamma02Shortcut 
ResetExposureAndGammaShortcut 

Definition at line 19 of file kis_gamma_exposure_action.h.

Constructor & Destructor Documentation

◆ KisGammaExposureAction()

KisGammaExposureAction::KisGammaExposureAction ( )
explicit

Definition at line 58 of file kis_gamma_exposure_action.cpp.

59 : KisAbstractInputAction("Exposure or Gamma")
60 , d(new Private(this))
61{
62 setName(i18n("Exposure and Gamma"));
63 setDescription(i18n("The <i>Exposure and Gamma</i> action changes the display mode of the canvas."));
64
65 QHash< QString, int > shortcuts;
66 shortcuts.insert(i18n("Exposure Mode"), ExposureShortcut);
67 shortcuts.insert(i18n("Gamma Mode"), GammaShortcut);
68
69 shortcuts.insert(i18n("Exposure +0.5"), AddExposure05Shortcut);
70 shortcuts.insert(i18n("Exposure -0.5"), RemoveExposure05Shortcut);
71 shortcuts.insert(i18n("Gamma +0.5"), AddGamma05Shortcut);
72 shortcuts.insert(i18n("Gamma -0.5"), RemoveGamma05Shortcut);
73
74 shortcuts.insert(i18n("Exposure +0.2"), AddExposure02Shortcut);
75 shortcuts.insert(i18n("Exposure -0.2"), RemoveExposure02Shortcut);
76 shortcuts.insert(i18n("Gamma +0.2"), AddGamma02Shortcut);
77 shortcuts.insert(i18n("Gamma -0.2"), RemoveGamma02Shortcut);
78
79 shortcuts.insert(i18n("Reset Exposure and Gamma"), ResetExposureAndGammaShortcut);
80 setShortcutIndexes(shortcuts);
81}
KisAbstractInputAction(const QString &id)
void setShortcutIndexes(const QHash< QString, int > &indexes)
void setName(const QString &name)
void setDescription(const QString &description)

References AddExposure02Shortcut, AddExposure05Shortcut, AddGamma02Shortcut, AddGamma05Shortcut, ExposureShortcut, GammaShortcut, RemoveExposure02Shortcut, RemoveExposure05Shortcut, RemoveGamma02Shortcut, RemoveGamma05Shortcut, ResetExposureAndGammaShortcut, KisAbstractInputAction::setDescription(), KisAbstractInputAction::setName(), and KisAbstractInputAction::setShortcutIndexes().

◆ ~KisGammaExposureAction()

KisGammaExposureAction::~KisGammaExposureAction ( )
override

Definition at line 83 of file kis_gamma_exposure_action.cpp.

84{
85 delete d;
86}

References d.

Member Function Documentation

◆ activate()

void KisGammaExposureAction::activate ( int shortcut)
overridevirtual

The method is called when the action is yet to be started, that is, e.g. the user has pressed all the modifiers for the action but hasn't started painting yet. This method is a right place to show the user what is going to happen, e.g. change the cursor.

Reimplemented from KisAbstractInputAction.

Definition at line 93 of file kis_gamma_exposure_action.cpp.

94{
95 if (shortcut == ExposureShortcut) {
96 QApplication::setOverrideCursor(KisCursor::changeExposureCursor());
97 } else /* if (shortcut == GammaShortcut) */ {
98 QApplication::setOverrideCursor(KisCursor::changeGammaCursor());
99 }
100}
static QCursor changeGammaCursor()
static QCursor changeExposureCursor()

References KisCursor::changeExposureCursor(), KisCursor::changeGammaCursor(), and ExposureShortcut.

◆ begin()

void KisGammaExposureAction::begin ( int shortcut,
QEvent * event = nullptr )
overridevirtual

Begin the action.

Parameters
shortcutThe index of the behaviour to trigger.
eventThe mouse event that has triggered this action. Is null for keyboard-activated actions.

Reimplemented from KisAbstractInputAction.

Definition at line 108 of file kis_gamma_exposure_action.cpp.

109{
110 KisAbstractInputAction::begin(shortcut, event);
111
113 inputManager()->canvas()->exposureGammaCorrectionInterface();
114
115 switch(shortcut) {
116 case ExposureShortcut:
117 d->baseExposure = interface->currentExposure();
118 d->mode = (Shortcuts)shortcut;
119 break;
120 case GammaShortcut:
121 d->baseGamma = interface->currentGamma();
122 d->mode = (Shortcuts)shortcut;
123 break;
124
126 d->addExposure(0.5);
127 break;
129 d->addExposure(-0.5);
130 break;
132 d->addGamma(0.5);
133 break;
135 d->addGamma(-0.5);
136 break;
137
139 d->addExposure(0.2);
140 break;
142 d->addExposure(-0.2);
143 break;
145 d->addGamma(0.2);
146 break;
148 d->addGamma(-0.2);
149 break;
150
153 inputManager()->canvas()->exposureGammaCorrectionInterface();
154 if (!interface->canChangeExposureAndGamma()) break;
155
156 interface->setCurrentGamma(1.0);
157 interface->setCurrentExposure(0.0);
158 break;
159 }
160 }
161}
static KisInputManager * inputManager
virtual void begin(int shortcut, QEvent *event)
KisCanvas2 * canvas

References KisGammaExposureAction::Private::addExposure(), AddExposure02Shortcut, AddExposure05Shortcut, KisGammaExposureAction::Private::addGamma(), AddGamma02Shortcut, AddGamma05Shortcut, KisGammaExposureAction::Private::baseExposure, KisGammaExposureAction::Private::baseGamma, KisAbstractInputAction::begin(), Private::canvas, d, ExposureShortcut, GammaShortcut, KisAbstractInputAction::inputManager, KisGammaExposureAction::Private::mode, RemoveExposure02Shortcut, RemoveExposure05Shortcut, RemoveGamma02Shortcut, RemoveGamma05Shortcut, and ResetExposureAndGammaShortcut.

◆ cursorMovedAbsolute()

void KisGammaExposureAction::cursorMovedAbsolute ( const QPointF & lastPos,
const QPointF & pos )
overridevirtual

Reimplemented from KisAbstractInputAction.

Definition at line 163 of file kis_gamma_exposure_action.cpp.

164{
165 QPointF diff = -(pos - startPos);
166
167 const int step = 200;
168
170 inputManager()->canvas()->exposureGammaCorrectionInterface();
171
172 if (!interface->canChangeExposureAndGamma()) return;
173
174
175 if (d->mode == ExposureShortcut) {
176 const qreal currentExposure = d->baseExposure + qreal(diff.y()) / step;
177 interface->setCurrentExposure(currentExposure);
178 } else if (d->mode == GammaShortcut) {
179 const qreal currentGamma = d->baseExposure + qreal(diff.y()) / step;
180 interface->setCurrentGamma(currentGamma);
181 }
182}

References KisGammaExposureAction::Private::baseExposure, Private::canvas, d, ExposureShortcut, GammaShortcut, KisAbstractInputAction::inputManager, and KisGammaExposureAction::Private::mode.

◆ deactivate()

void KisGammaExposureAction::deactivate ( int shortcut)
overridevirtual

The method is called when the action is not a candidate for the starting anymore. The action should revert everything that was done in activate() method.

See also
activate()

Reimplemented from KisAbstractInputAction.

Definition at line 102 of file kis_gamma_exposure_action.cpp.

103{
104 Q_UNUSED(shortcut);
105 QApplication::restoreOverrideCursor();
106}

◆ isShortcutRequired()

bool KisGammaExposureAction::isShortcutRequired ( int shortcut) const
overridevirtual

Return true when the specified shortcut is required for basic user interaction. This is used by the configuration system to prevent basic actions like painting from being removed.

Parameters
shortcutThe shortcut index to check.
Returns
True if the shortcut is required, false if not.

Reimplemented from KisAbstractInputAction.

Definition at line 184 of file kis_gamma_exposure_action.cpp.

185{
186 Q_UNUSED(shortcut);
187 return false;
188}

◆ priority()

int KisGammaExposureAction::priority ( ) const
overridevirtual

The priority for this action.

Priority determines how "important" the action is and is used to resolve conflicts when multiple actions can be activated.

Reimplemented from KisAbstractInputAction.

Definition at line 88 of file kis_gamma_exposure_action.cpp.

89{
90 return 5;
91}

Member Data Documentation

◆ d

Private* const KisGammaExposureAction::d {nullptr}
private

Definition at line 47 of file kis_gamma_exposure_action.h.

47{nullptr};

The documentation for this class was generated from the following files: