FastLED 3.9.15
Loading...
Searching...
No Matches
ui.cpp
Go to the documentation of this file.
1
2
3#include "fl/ui.h"
4#include <stdint.h>
5
6#pragma GCC diagnostic push
7#pragma GCC diagnostic ignored "-Wfloat-equal"
8
9namespace fl {
10
12
13 if (value != Super::value()) {
14 Super::setValue(value);
15 }
16}
17
19 UISlider &owner = *mOwner;
20 if (!owner.mLastFramevalueValid) {
21 owner.mLastFrameValue = owner.value();
22 owner.mLastFramevalueValid = true;
23 return;
24 }
25 float value = owner.value();
26 if (value != owner.mLastFrameValue) {
27 owner.mCallbacks.invoke(*mOwner);
28 owner.mLastFrameValue = value;
29 }
30}
31
33 bool clicked_this_frame = mOwner->clicked();
34
35 // Check the real button if one is attached
36 if (mOwner->mRealButton) {
37 if (mOwner->mRealButton->isPressed()) {
38 clicked_this_frame = true;
39 //mOwner->click(); // Update the UI button state
40 }
41 }
42
43 const bool clicked_changed = (clicked_this_frame != mClickedLastFrame);
44 mClickedLastFrame = clicked_this_frame;
45 if (clicked_changed) {
46 // FASTLED_WARN("Button: " << mOwner->name() << " clicked: " <<
47 // mOwner->clicked());
48 mOwner->mCallbacks.invoke(*mOwner);
49 }
50 // mOwner->mCallbacks.invoke(*mOwner);
51}
52
54 UICheckbox &owner = *mOwner;
55 if (!owner.mLastFrameValueValid) {
56 owner.mLastFrameValue = owner.value();
57 owner.mLastFrameValueValid = true;
58 return;
59 }
60 bool value = owner.value();
61 if (value != owner.mLastFrameValue) {
62 owner.mCallbacks.invoke(owner);
63 owner.mLastFrameValue = value;
64 }
65}
66
68 UINumberField &owner = *mOwner;
69 if (!owner.mLastFrameValueValid) {
70 owner.mLastFrameValue = owner.value();
71 owner.mLastFrameValueValid = true;
72 return;
73 }
74 double value = owner.value();
75 if (value != owner.mLastFrameValue) {
76 owner.mCallbacks.invoke(owner);
77 owner.mLastFrameValue = value;
78 }
79}
80
81} // end namespace fl
82
83#pragma GCC diagnostic pop
bool mLastFrameValue
Definition ui.h:239
FunctionList< UICheckbox & > mCallbacks
Definition ui.h:238
bool mLastFrameValueValid
Definition ui.h:240
UICheckbox(const char *name, bool value=false)
Definition ui.h:194
bool value() const
Definition ui_impl.h:132
double value() const
Definition ui.h:252
FunctionList< UINumberField & > mCallbacks
Definition ui.h:300
UINumberField(const char *name, double value, double min=0, double max=100)
Definition ui.h:248
bool mLastFrameValueValid
Definition ui.h:299
double mLastFrameValue
Definition ui.h:298
bool mLastFramevalueValid
Definition ui.h:99
UISlider(const char *name, float value=128.0f, float min=1, float max=255, float step=-1.f)
Definition ui.h:30
float mLastFrameValue
Definition ui.h:98
void setValue(float value)
Definition ui.cpp:11
FunctionList< UISlider & > mCallbacks
Definition ui.h:97
float value() const
Definition ui.h:33
Implements a simple red square effect for 2D LED grids.
Definition crgb.h:16
bool mClickedLastFrame
Definition ui.h:181
UIButton * mOwner
Definition ui.h:179
void onBeginFrame() override
Definition ui.cpp:32
UICheckbox * mOwner
Definition ui.h:232
void onBeginFrame() override
Definition ui.cpp:53
UINumberField * mOwner
Definition ui.h:293
void onBeginFrame() override
Definition ui.cpp:67
void onBeginFrame() override
Definition ui.cpp:18
UISlider * mOwner
Definition ui.h:92