FastLED 3.9.15
Loading...
Searching...
No Matches
slider.cpp.hpp
Go to the documentation of this file.
1#include "fl/ui/slider.h"
3#include "fl/stl/noexcept.h"
4
7
8namespace fl {
9
10UISlider::UISlider(const char *name, float value, float min, float max, float step) FL_NOEXCEPT
11 : mImpl(name, value, min, max, step), mListener(this) {
12 mListener.addToEngineEventsOnce();
13}
14
16 float oldValue = mImpl.value();
17 mImpl.setValue(value);
18 // Read back post-clamp value; only fire callbacks if the observable value
19 // actually changed (avoids spurious notifications when caller passes an
20 // out-of-range value that clamps back to the current value).
21 float newValue = mImpl.value();
22 if (newValue != oldValue) {
23 mLastFrameValue = newValue;
24 mLastFrameValueValid = true;
25 // Invoke callbacks to notify listeners (including JavaScript components)
26 mCallbacks.invoke(*this);
27 }
28}
29
31 UISlider &owner = *mOwner;
32 if (!owner.mLastFrameValueValid) {
33 owner.mLastFrameValue = owner.value();
34 owner.mLastFrameValueValid = true;
35 return;
36 }
37 float value = owner.value();
38 if (value != owner.mLastFrameValue) {
39 owner.mCallbacks.invoke(*mOwner);
40 owner.mLastFrameValue = value;
41 }
42}
43
44} // namespace fl
45
FL_DISABLE_WARNING_PUSH U constexpr common_type_t< T, U > min(T a, U b) FL_NOEXCEPT
Memory functions are available in fl:: namespace via fl/stl/cstring.h Using declarations cannot work ...
Definition math.h:71
constexpr common_type_t< T, U > max(T a, U b) FL_NOEXCEPT
Definition math.h:75
void setValue(float value) FL_NOEXCEPT
constexpr int type_rank< T >::value
constexpr enable_if< is_fixed_point< T >::value, T >::type step(T edge, T x) FL_NOEXCEPT
Base definition for an LED controller.
Definition crgb.hpp:179
#define FL_DISABLE_WARNING(warning)
#define FL_DISABLE_WARNING_PUSH
#define FL_DISABLE_WARNING_POP
#define FL_NOEXCEPT
void onBeginFrame() FL_NOEXCEPT override