CaptureMoment
0.1.0
Free and open-source non-destructive photo editor
Loading...
Searching...
No Matches
base_adjustment_model.cpp
Go to the documentation of this file.
1
8
#include "
models/operations/base_adjustment_model.h
"
9
10
#include <spdlog/spdlog.h>
11
#include <algorithm>
12
13
namespace
CaptureMoment::UI::Models::Operations
14
{
15
16
BaseAdjustmentModel::BaseAdjustmentModel
(QObject* parent)
17
:
OperationProvider
(parent), m_params{}
18
{
19
// Initialize the parameter structure's value.
20
m_params
.
value
= 0.0f;
// Default: no adjustment
21
spdlog::debug(
"BaseAdjustmentModel: Created with default value {}"
,
m_params
.
value
);
22
}
23
24
void
BaseAdjustmentModel::setValue
(
float
val)
25
{
26
// Clamp the incoming value to the allowed range [-1.0, 1.0] (or whatever minimum()/maximum() returns)
27
float
clamped_value { std::clamp(val,
minimum
(),
maximum
()) };
28
29
// Check if the value has actually changed to avoid unnecessary updates/signals.
30
if
(qFuzzyCompare(
m_params
.
value
, clamped_value)) {
31
return
;
// No change, exit early.
32
}
33
34
bool
was_active =
m_params
.
isActive
();
35
36
// Update the internal parameter structure.
37
m_params
.
value
= clamped_value;
38
39
bool
is_now_active {
isActive
() };
40
emit
valueChanged
(
m_params
.
value
);
// Emit inherited signal
41
42
if
(was_active != is_now_active) {
43
emit
isActiveChanged
();
// Emit inherited signal from OperationProvider
44
spdlog::debug(
"BaseAdjustmentModel::setValue: Activity state changed to {}"
, is_now_active);
45
}
46
}
47
48
}
// namespace CaptureMoment::UI::Models::Operations
base_adjustment_model.h
Generic Qt base class for single-value adjustment operations (e.g., Brightness, Contrast,...
CaptureMoment::UI::Models::Operations::BaseAdjustmentModel::BaseAdjustmentModel
BaseAdjustmentModel(QObject *parent=nullptr)
Constructs a BaseAdjustmentModel.
Definition
base_adjustment_model.cpp:16
CaptureMoment::UI::Models::Operations::BaseAdjustmentModel::isActive
bool isActive() const override
Checks if the adjustment operation is currently active. An operation is considered active if its inte...
Definition
base_adjustment_model.h:98
CaptureMoment::UI::Models::Operations::BaseAdjustmentModel::setValue
void setValue(float val)
Sets the adjustment value and triggers an update.
Definition
base_adjustment_model.cpp:24
CaptureMoment::UI::Models::Operations::BaseAdjustmentModel::valueChanged
void valueChanged(float value)
Signal emitted when the adjustment value changes. QML can connect to this signal to react to value up...
CaptureMoment::UI::Models::Operations::BaseAdjustmentModel::minimum
float minimum
Definition
base_adjustment_model.h:52
CaptureMoment::UI::Models::Operations::BaseAdjustmentModel::m_params
Domain::RelativeAdjustmentParams m_params
used for the value and activity state
Definition
base_adjustment_model.h:73
CaptureMoment::UI::Models::Operations::BaseAdjustmentModel::maximum
float maximum
Definition
base_adjustment_model.h:58
CaptureMoment::UI::Models::Operations::OperationProvider
Generic base class providing Qt signals/slots infrastructure for operation models.
Definition
operation_provider.h:35
CaptureMoment::UI::Models::Operations::OperationProvider::isActiveChanged
void isActiveChanged()
Signal emitted when the operation's activity state changes. This signal is emitted by the operation m...
CaptureMoment::UI::Models::Operations
Definition
base_adjustment_model.cpp:14
CaptureMoment::UI::Domain::RelativeAdjustmentParams::isActive
bool isActive() const
Checks if the parameter value indicates an active operation.
Definition
operation_parameters.h:53
CaptureMoment::UI::Domain::RelativeAdjustmentParams::value
float value
The adjustment value.
Definition
operation_parameters.h:38
CaptureMoment — footer