diff options
Diffstat (limited to 'src/ui/scrollwidget.c')
-rw-r--r-- | src/ui/scrollwidget.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/ui/scrollwidget.c b/src/ui/scrollwidget.c index 55ede426..32b57c69 100644 --- a/src/ui/scrollwidget.c +++ b/src/ui/scrollwidget.c | |||
@@ -48,6 +48,7 @@ struct Impl_ScrollWidget { | |||
48 | iClick click; | 48 | iClick click; |
49 | int startThumb; | 49 | int startThumb; |
50 | iAnim opacity; | 50 | iAnim opacity; |
51 | iBool fadeEnabled; | ||
51 | uint32_t fadeStart; | 52 | uint32_t fadeStart; |
52 | iBool willCheckFade; | 53 | iBool willCheckFade; |
53 | }; | 54 | }; |
@@ -76,6 +77,7 @@ void init_ScrollWidget(iScrollWidget *d) { | |||
76 | init_Click(&d->click, d, SDL_BUTTON_LEFT); | 77 | init_Click(&d->click, d, SDL_BUTTON_LEFT); |
77 | init_Anim(&d->opacity, minOpacity_()); | 78 | init_Anim(&d->opacity, minOpacity_()); |
78 | d->willCheckFade = iFalse; | 79 | d->willCheckFade = iFalse; |
80 | d->fadeEnabled = iTrue; | ||
79 | } | 81 | } |
80 | 82 | ||
81 | void deinit_ScrollWidget(iScrollWidget *d) { | 83 | void deinit_ScrollWidget(iScrollWidget *d) { |
@@ -108,7 +110,7 @@ static void unfade_ScrollWidget_(iScrollWidget *d, float opacity) { | |||
108 | setValue_Anim(&d->opacity, opacity, 66); | 110 | setValue_Anim(&d->opacity, opacity, 66); |
109 | addTicker_App(animateOpacity_ScrollWidget_, d); | 111 | addTicker_App(animateOpacity_ScrollWidget_, d); |
110 | } | 112 | } |
111 | if (!d->willCheckFade) { | 113 | if (!d->willCheckFade && d->fadeEnabled) { |
112 | d->willCheckFade = iTrue; | 114 | d->willCheckFade = iTrue; |
113 | /* TODO: This causes an inexplicable refresh issue on macOS: the drawing of one frame | 115 | /* TODO: This causes an inexplicable refresh issue on macOS: the drawing of one frame |
114 | takes 100ms for some reason (not the current frame but some time after). */ | 116 | takes 100ms for some reason (not the current frame but some time after). */ |
@@ -142,6 +144,11 @@ void setThumb_ScrollWidget(iScrollWidget *d, int thumb, int thumbSize) { | |||
142 | } | 144 | } |
143 | } | 145 | } |
144 | 146 | ||
147 | void setFadeEnabled_ScrollWidget(iScrollWidget *d, iBool fadeEnabled) { | ||
148 | d->fadeEnabled = fadeEnabled; | ||
149 | unfade_ScrollWidget_(d, 1.0f); | ||
150 | } | ||
151 | |||
145 | static iBool processEvent_ScrollWidget_(iScrollWidget *d, const SDL_Event *ev) { | 152 | static iBool processEvent_ScrollWidget_(iScrollWidget *d, const SDL_Event *ev) { |
146 | iWidget *w = as_Widget(d); | 153 | iWidget *w = as_Widget(d); |
147 | if (isMetricsChange_UserEvent(ev)) { | 154 | if (isMetricsChange_UserEvent(ev)) { |
@@ -156,7 +163,7 @@ static iBool processEvent_ScrollWidget_(iScrollWidget *d, const SDL_Event *ev) { | |||
156 | } | 163 | } |
157 | } | 164 | } |
158 | if (isCommand_UserEvent(ev, "scrollbar.fade")) { | 165 | if (isCommand_UserEvent(ev, "scrollbar.fade")) { |
159 | if (d->willCheckFade && SDL_GetTicks() > d->fadeStart) { | 166 | if (d->fadeEnabled && d->willCheckFade && SDL_GetTicks() > d->fadeStart) { |
160 | setValue_Anim(&d->opacity, minOpacity_(), 200); | 167 | setValue_Anim(&d->opacity, minOpacity_(), 200); |
161 | remove_Periodic(periodic_App(), d); | 168 | remove_Periodic(periodic_App(), d); |
162 | d->willCheckFade = iFalse; | 169 | d->willCheckFade = iFalse; |