8 {
9
10void UISlider::setValue(float value) {
11 float oldValue = mImpl.value();
12 if (value != oldValue) {
13 mImpl.setValue(value);
14
15 mLastFrameValue = value;
16 mLastFramevalueValid = true;
17
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
40 if (mOwner->mRealButton) {
41 if (mOwner->mRealButton->isPressed()) {
42 clicked_this_frame = true;
43
44 }
45 }
46
47 const bool clicked_changed = (clicked_this_frame != mClickedLastFrame);
48 mClickedLastFrame = clicked_this_frame;
49 if (clicked_changed) {
50
51
52 mOwner->mCallbacks.invoke(*mOwner);
53 }
54
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
89 bool shouldAdvance = false;
90 if (owner.mNextButton) {
91 if (owner.mNextButton->clicked()) {
92 shouldAdvance = true;
93 }
94 }
95
96
97 if (shouldAdvance) {
98 owner.nextOption();
99
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}