Skip to content

Commit

Permalink
GUI2/Listbox: fully show any partially-obscured items when selected
Browse files Browse the repository at this point in the history
  • Loading branch information
Vultraz committed Nov 3, 2017
1 parent feccf66 commit 9902b07
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/gui/widgets/listbox.cpp
Expand Up @@ -33,6 +33,7 @@
#include "gui/widgets/viewport.hpp"
#include "gui/widgets/widget_helpers.hpp"
#include "gui/widgets/window.hpp"
#include "sdl/rect.hpp"
#include "utils/functional.hpp"

#include <boost/optional.hpp>
Expand Down Expand Up @@ -301,11 +302,19 @@ void listbox::list_item_clicked(widget& caller)
#endif

fire(event::NOTIFY_MODIFIED, *this, nullptr);
return;
break;
}
}

assert(false);
const SDL_Rect& visible = content_visible_area();
SDL_Rect rect = generator_->item(generator_->get_selected_item()).get_rectangle();

if(sdl::rects_overlap(visible, rect)) {
rect.x = visible.x;
rect.w = visible.w;

show_content_rect(rect);
}
}

void listbox::set_self_active(const bool /*active*/)
Expand Down

0 comments on commit 9902b07

Please sign in to comment.