@@ -161,49 +161,49 @@ struct DropdownWindow : Window {
y -= item_height;
}
return false;
void DrawWidget(const Rect &r, int widget) const override
{
if (widget != WID_DM_ITEMS) return;
Colours colour = this->GetWidget<NWidgetCore>(widget)->colour;
Rect ir = r.Shrink(WidgetDimensions::scaled.fullbevel).Shrink(RectPadding::zero, WidgetDimensions::scaled.fullbevel);
int y = ir.top;
int pos = this->vscroll->GetPosition();
for (const auto &item : this->list) {
int item_height = item->Height();
/* Skip items that are scrolled up */
if (--pos >= 0) continue;
if (y + item_height - 1 <= ir.bottom) {
Rect full{ir.left, y, ir.right, y + item_height - 1};
bool selected = (this->selected_index == item->result);
bool selected = (this->selected_index == item->result) && item->Selectable();
if (selected) GfxFillRect(full, PC_BLACK);
item->Draw(full, full.Shrink(WidgetDimensions::scaled.dropdowntext, RectPadding::zero), selected, colour);
y += item_height;
void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override
int item;
if (this->GetDropDownItem(item)) {
this->click_delay = 4;
this->selected_index = item;
this->SetDirty();
/** Rate limit how fast scrolling happens. */
IntervalTimer<TimerWindow> scroll_interval = {std::chrono::milliseconds(30), [this](auto) {
if (this->scrolling == 0) return;
if (this->vscroll->UpdatePosition(this->scrolling)) this->SetDirty();
Status change: