FastLED 3.9.15
Loading...
Searching...
No Matches

◆ FL_DISABLE_WARNING()

FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING ( float- equal)

Definition at line 6 of file ui.cpp.

8 {
9
10void UISlider::setValue(float value) {
11 float oldValue = mImpl.value();
12 if (value != oldValue) {
13 mImpl.setValue(value);
14 // Update the last frame value to keep state consistent
15 mLastFrameValue = value;
16 mLastFramevalueValid = true;
17 // Invoke callbacks to notify listeners (including JavaScript components)
18 mCallbacks.invoke(*this);
19 }
20}
21
22void UISlider::Listener::onBeginFrame() {
23 UISlider &owner = *mOwner;
24 if (!owner.mLastFramevalueValid) {
25 owner.mLastFrameValue = owner.value();
26 owner.mLastFramevalueValid = true;
27 return;
28 }
29 float value = owner.value();
30 if (value != owner.mLastFrameValue) {
31 owner.mCallbacks.invoke(*mOwner);
32 owner.mLastFrameValue = value;
33 }
34}
35
36void UIButton::Listener::onBeginFrame() {
37 bool clicked_this_frame = mOwner->clicked();
38
39 // Check the real button if one is attached
40 if (mOwner->mRealButton) {
41 if (mOwner->mRealButton->isPressed()) {
42 clicked_this_frame = true;
43 //mOwner->click(); // Update the UI button state
44 }
45 }
46
47 const bool clicked_changed = (clicked_this_frame != mClickedLastFrame);
48 mClickedLastFrame = clicked_this_frame;
49 if (clicked_changed) {
50 // FASTLED_WARN("Button: " << mOwner->name() << " clicked: " <<
51 // mOwner->clicked());
52 mOwner->mCallbacks.invoke(*mOwner);
53 }
54 // mOwner->mCallbacks.invoke(*mOwner);
55}
56
57void UICheckbox::Listener::onBeginFrame() {
58 UICheckbox &owner = *mOwner;
59 if (!owner.mLastFrameValueValid) {
60 owner.mLastFrameValue = owner.value();
61 owner.mLastFrameValueValid = true;
62 return;
63 }
64 bool value = owner.value();
65 if (value != owner.mLastFrameValue) {
66 owner.mCallbacks.invoke(owner);
67 owner.mLastFrameValue = value;
68 }
69}
70
71void UINumberField::Listener::onBeginFrame() {
72 UINumberField &owner = *mOwner;
73 if (!owner.mLastFrameValueValid) {
74 owner.mLastFrameValue = owner.value();
75 owner.mLastFrameValueValid = true;
76 return;
77 }
78 double value = owner.value();
79 if (value != owner.mLastFrameValue) {
80 owner.mCallbacks.invoke(owner);
81 owner.mLastFrameValue = value;
82 }
83}
84
85void UIDropdown::Listener::onBeginFrame() {
86 UIDropdown &owner = *mOwner;
87
88 // Check the next button if one is attached
89 bool shouldAdvance = false;
90 if (owner.mNextButton) {
91 if (owner.mNextButton->clicked()) {
92 shouldAdvance = true;
93 }
94 }
95
96 // If the next button was clicked, advance to the next option
97 if (shouldAdvance) {
98 owner.nextOption();
99 // The option change will be detected below and callbacks will be invoked
100 }
101
102 if (!owner.mLastFrameValueValid) {
103 owner.mLastFrameValue = owner.as_int();
104 owner.mLastFrameValueValid = true;
105 return;
106 }
107 int value = owner.as_int();
108 if (value != owner.mLastFrameValue) {
109 owner.mCallbacks.invoke(owner);
110 owner.mLastFrameValue = value;
111 }
112}
113
114} // end namespace fl

References fl::UISlider::mCallbacks, fl::UISlider::mImpl, fl::UISlider::mLastFrameValue, fl::UISlider::mLastFramevalueValid, fl::UISlider::Listener::mOwner, fl::UIButton::Listener::onBeginFrame(), fl::UICheckbox::Listener::onBeginFrame(), fl::UIDropdown::Listener::onBeginFrame(), fl::UINumberField::Listener::onBeginFrame(), fl::UISlider::Listener::onBeginFrame(), fl::UISliderImpl::setValue(), fl::UISlider::value, and fl::UISliderImpl::value().

+ Here is the call graph for this function: