From 8d7498b82cdcfe8d647d7aae0adddc762fa8f3ce Mon Sep 17 00:00:00 2001 From: alberth Date: Sat, 19 Sep 2009 13:08:37 +0000 Subject: (svn r17575) -Codechange: Adding a new combined button+dropdown widget. --- src/widgets/dropdown.cpp | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp index 0b010305c..94c3b2b73 100644 --- a/src/widgets/dropdown.cpp +++ b/src/widgets/dropdown.cpp @@ -103,7 +103,16 @@ struct DropdownWindow : Window { { Window *w2 = FindWindowById(this->parent_wnd_class, this->parent_wnd_num); if (w2 != NULL) { - w2->RaiseWidget(this->parent_button); + if (w2->nested_array != NULL) { + NWidgetCore *nwi2 = w2->GetWidget(this->parent_button); + if (nwi2->type == NWID_BUTTON_DRPDOWN) { + nwi2->disp_flags &= ~ND_DROPDOWN_ACTIVE; + } else { + w2->RaiseWidget(this->parent_button); + } + } else { + w2->RaiseWidget(this->parent_button); + } w2->SetWidgetDirty(this->parent_button); } @@ -251,20 +260,23 @@ void ShowDropDownList(Window *w, DropDownList *list, int selected, int button, u DeleteWindowById(WC_DROPDOWN_MENU, 0); - w->LowerWidget(button); - w->SetWidgetDirty(button); - /* Our parent's button widget is used to determine where to place the drop * down list window. */ Rect wi_rect; Colours wi_colour; if (w->nested_array != NULL) { - const NWidgetCore *nwi = w->GetWidget(button); + NWidgetCore *nwi = w->GetWidget(button); wi_rect.left = nwi->pos_x; wi_rect.right = nwi->pos_x + nwi->current_x - 1; wi_rect.top = nwi->pos_y; wi_rect.bottom = nwi->pos_y + nwi->current_y - 1; wi_colour = nwi->colour; + + if (nwi->type == NWID_BUTTON_DRPDOWN) { + nwi->disp_flags |= ND_DROPDOWN_ACTIVE; + } else { + w->LowerWidget(button); + } } else { const Widget *wi = &w->widget[button]; wi_rect.left = wi->left; @@ -272,7 +284,10 @@ void ShowDropDownList(Window *w, DropDownList *list, int selected, int button, u wi_rect.top = wi->top; wi_rect.bottom = wi->bottom; wi_colour = wi->colour; + + w->LowerWidget(button); } + w->SetWidgetDirty(button); /* The preferred position is just below the dropdown calling widget */ int top = w->top + wi_rect.bottom + 1; -- cgit v1.2.3-70-g09d2