From 2004bbc3ef28ada3acca05f5d5fa9108121a6784 Mon Sep 17 00:00:00 2001 From: Daniel Lange Date: Mon, 11 Apr 2016 13:00:32 +0200 Subject: Imported Upstream version 1.0.2 --- Panel.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'Panel.c') diff --git a/Panel.c b/Panel.c index b090c52..d0f69bf 100644 --- a/Panel.c +++ b/Panel.c @@ -199,8 +199,10 @@ Object* Panel_remove(Panel* this, int i) { Object* Panel_getSelected(Panel* this) { assert (this != NULL); - - return Vector_get(this->items, this->selected); + if (Vector_size(this->items) > 0) + return Vector_get(this->items, this->selected); + else + return NULL; } void Panel_moveSelectedUp(Panel* this) { @@ -248,7 +250,11 @@ void Panel_draw(Panel* this, bool focus) { int scrollH = this->scrollH; int y = this->y; int x = this->x; int first = this->scrollV; - int last = MIN(itemCount, this->scrollV + MIN(itemCount, this->h)); + if (itemCount > this->h && first > itemCount - this->h) { + first = itemCount - this->h; + this->scrollV = first; + } + int last = MIN(itemCount, first + MIN(itemCount, this->h)); if (this->selected < first) { first = this->selected; this->scrollV = first; -- cgit v1.2.3