Codechange: migrate all Window-related timers to the new framework

This means we also say goodbye to GUITimers.
This commit is contained in:
Patric Stout
2023-04-13 17:18:27 +02:00
committed by Patric Stout
parent 5e1bcee39b
commit 1ba4dcc924
29 changed files with 259 additions and 336 deletions

View File

@@ -12,8 +12,9 @@
#include "../string_func.h"
#include "../strings_func.h"
#include "../window_func.h"
#include "../guitimer_func.h"
#include "../zoom_func.h"
#include "../timer/timer.h"
#include "../timer/timer_window.h"
#include "dropdown_type.h"
#include "dropdown_widget.h"
@@ -126,7 +127,6 @@ struct DropdownWindow : Window {
bool drag_mode;
bool instant_close; ///< Close the window when the mouse button is raised.
int scrolling; ///< If non-zero, auto-scroll the item list (one time).
GUITimer scrolling_timer; ///< Timer for auto-scroll of the item list.
Point position; ///< Position of the topleft corner of the window.
Scrollbar *vscroll;
@@ -183,7 +183,6 @@ struct DropdownWindow : Window {
this->click_delay = 0;
this->drag_mode = true;
this->instant_close = instant_close;
this->scrolling_timer = GUITimer(MILLISECONDS_PER_TICK);
}
void Close() override
@@ -278,22 +277,19 @@ struct DropdownWindow : Window {
}
}
void OnRealtimeTick(uint delta_ms) override
{
if (!this->scrolling_timer.Elapsed(delta_ms)) return;
this->scrolling_timer.SetInterval(MILLISECONDS_PER_TICK);
/** Rate limit how fast scrolling happens. */
IntervalTimer<TimerWindow> scroll_interval = {std::chrono::milliseconds(30), [this](auto) {
if (this->scrolling == 0) return;
if (this->scrolling != 0) {
int pos = this->vscroll->GetPosition();
int pos = this->vscroll->GetPosition();
this->vscroll->UpdatePosition(this->scrolling);
this->scrolling = 0;
this->vscroll->UpdatePosition(this->scrolling);
this->scrolling = 0;
if (pos != this->vscroll->GetPosition()) {
this->SetDirty();
}
if (pos != this->vscroll->GetPosition()) {
this->SetDirty();
}
}
}};
void OnMouseLoop() override
{