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
9
10#include <spdlog/spdlog.h>
11#include <algorithm>
12
14{
15
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
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
Generic Qt base class for single-value adjustment operations (e.g., Brightness, Contrast,...
BaseAdjustmentModel(QObject *parent=nullptr)
Constructs a BaseAdjustmentModel.
bool isActive() const override
Checks if the adjustment operation is currently active. An operation is considered active if its inte...
void setValue(float val)
Sets the adjustment value and triggers an update.
void valueChanged(float value)
Signal emitted when the adjustment value changes. QML can connect to this signal to react to value up...
Domain::RelativeAdjustmentParams m_params
used for the value and activity state
Generic base class providing Qt signals/slots infrastructure for operation models.
void isActiveChanged()
Signal emitted when the operation's activity state changes. This signal is emitted by the operation m...
bool isActive() const
Checks if the parameter value indicates an active operation.
CaptureMoment — footer