summaryrefslogtreecommitdiff
path: root/plugingui
diff options
context:
space:
mode:
Diffstat (limited to 'plugingui')
-rw-r--r--plugingui/listboxbasic.cc13
1 files changed, 8 insertions, 5 deletions
diff --git a/plugingui/listboxbasic.cc b/plugingui/listboxbasic.cc
index 25cf00d..3d903a4 100644
--- a/plugingui/listboxbasic.cc
+++ b/plugingui/listboxbasic.cc
@@ -84,16 +84,13 @@ void GUI::ListBoxBasic::addItem(std::string name, std::string value)
void GUI::ListBoxBasic::addItems(std::vector<GUI::ListBoxBasic::Item> &is)
{
+ DEBUG(list, "addItems %d\n", is.size());
std::vector<GUI::ListBoxBasic::Item>::iterator i = is.begin();
while(i != is.end()) {
items.push_back(*i);
i++;
}
- int numitems = height() / (font.textHeight() + padding);
- scroll.setRange(numitems);
- scroll.setMaximum(items.size());
-
// sort
for(int x = 0; x < (int)items.size() - 1; x++) {
for(int y = 0; y < (int)items.size() - 1; y++) {
@@ -110,6 +107,10 @@ void GUI::ListBoxBasic::addItems(std::vector<GUI::ListBoxBasic::Item> &is)
}
if(selected == -1) setSelection((int)items.size() - 1);
+
+ int numitems = height() / (font.textHeight() + padding);
+ scroll.setRange(numitems);
+ scroll.setMaximum(items.size());
}
void GUI::ListBoxBasic::clear()
@@ -161,6 +162,7 @@ void GUI::ListBoxBasic::registerValueChangeHandler(void (*handler)(void *),
void GUI::ListBoxBasic::repaintEvent(GUI::RepaintEvent *e)
{
+ DEBUG(list, "repaint\n");
GUI::Painter p(this);
p.clear();
@@ -175,7 +177,8 @@ void GUI::ListBoxBasic::repaintEvent(GUI::RepaintEvent *e)
int yoffset = padding / 2;
int skip = scroll.value();
- for(int idx = skip; idx < (int)items.size(); idx++) {
+ int numitems = height() / (font.textHeight() + padding) + 1;
+ for(int idx = skip; idx < (int)items.size() && idx < skip + numitems; idx++) {
GUI::ListBoxBasic::Item *i = &items[idx];
if(idx == selected) {
p.setColour(GUI::Colour(183.0/255.0, 219.0/255.0 , 255.0/255.0, 0.5));