Improved performance when paging through very long menu lists

This commit is contained in:
Klaus Schmidinger 2004-03-14 10:34:56 +01:00
parent 99f54a7780
commit 5f39e62ea1
3 changed files with 23 additions and 34 deletions

View File

@ -2714,7 +2714,7 @@ Video Disk Recorder Revision History
whether an event is currently running (see MANUAL under "The "Schedule" Menu" whether an event is currently running (see MANUAL under "The "Schedule" Menu"
for details). for details).
2004-03-13: Version 1.3.6 2004-03-14: Version 1.3.6
- Completed the Finnish OSD texts (thanks to Rolf Ahrenberg). - Completed the Finnish OSD texts (thanks to Rolf Ahrenberg).
- Fixed some descriptor handling in 'libsi' (thanks to Stéphane Esté-Gracias). - Fixed some descriptor handling in 'libsi' (thanks to Stéphane Esté-Gracias).
@ -2738,3 +2738,4 @@ Video Disk Recorder Revision History
This was also necessary to better display itemized texts. This was also necessary to better display itemized texts.
- Fixed detecting the running status in case an empty EPG event is broadcast (thanks - Fixed detecting the running status in case an empty EPG event is broadcast (thanks
to Michael Pennewiß for pointing this out). to Michael Pennewiß for pointing this out).
- Improved performance when paging through very long menu lists.

20
menu.c
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: menu.c 1.295 2004/03/07 09:40:34 kls Exp $ * $Id: menu.c 1.296 2004/03/14 10:31:13 kls Exp $
*/ */
#include "menu.h" #include "menu.h"
@ -1008,13 +1008,8 @@ public:
cMenuTimers::cMenuTimers(void) cMenuTimers::cMenuTimers(void)
:cOsdMenu(tr("Timers"), 2, CHNUMWIDTH, 10, 6, 6) :cOsdMenu(tr("Timers"), 2, CHNUMWIDTH, 10, 6, 6)
{ {
int i = 0; for (cTimer *timer = Timers.First(); timer; timer = Timers.Next(timer))
cTimer *timer; Add(new cMenuTimerItem(timer));
while ((timer = Timers.Get(i)) != NULL) {
Add(new cMenuTimerItem(timer));
i++;
}
if (Setup.SortTimers) if (Setup.SortTimers)
Sort(); Sort();
SetHelp(tr("Edit"), tr("New"), tr("Delete"), Setup.SortTimers ? tr("On/Off") : tr("Mark")); SetHelp(tr("Edit"), tr("New"), tr("Delete"), Setup.SortTimers ? tr("On/Off") : tr("Mark"));
@ -1493,13 +1488,8 @@ cMenuCommands::cMenuCommands(const char *Title, cCommands *Commands, const char
SetHasHotkeys(); SetHasHotkeys();
commands = Commands; commands = Commands;
parameters = Parameters ? strdup(Parameters) : NULL; parameters = Parameters ? strdup(Parameters) : NULL;
int i = 0; for (cCommand *command = commands->First(); command; command = commands->Next(command))
cCommand *command; Add(new cOsdItem(hk(command->Title())));
while ((command = commands->Get(i)) != NULL) {
Add(new cOsdItem(hk(command->Title())));
i++;
}
} }
cMenuCommands::~cMenuCommands() cMenuCommands::~cMenuCommands()

34
osd.c
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: osd.c 1.44 2004/03/05 15:27:48 kls Exp $ * $Id: osd.c 1.45 2004/03/14 10:33:20 kls Exp $
*/ */
#include "osd.h" #include "osd.h"
@ -429,14 +429,11 @@ void cOsdMenu::Display(void)
Interface->Help(helpRed, helpGreen, helpYellow, helpBlue); Interface->Help(helpRed, helpGreen, helpYellow, helpBlue);
int count = Count(); int count = Count();
if (count > 0) { if (count > 0) {
for (int i = 0; i < count; i++) { int ni = 0;
cOsdItem *item = Get(i); for (cOsdItem *item = First(); item; item = Next(item))
if (item) cStatus::MsgOsdItem(item->Text(), ni++);
cStatus::MsgOsdItem(item->Text(), i);
}
if (current < 0) if (current < 0)
current = 0; // just for safety - there HAS to be a current item! current = 0; // just for safety - there HAS to be a current item!
int n = 0;
if (current - first >= MAXOSDITEMS || current < first) { if (current - first >= MAXOSDITEMS || current < first) {
first = current - MAXOSDITEMS / 2; first = current - MAXOSDITEMS / 2;
if (first + MAXOSDITEMS > count) if (first + MAXOSDITEMS > count)
@ -444,15 +441,15 @@ void cOsdMenu::Display(void)
if (first < 0) if (first < 0)
first = 0; first = 0;
} }
for (int i = first; i < count; i++) { int i = first;
cOsdItem *item = Get(i); int n = 0;
if (item) { for (cOsdItem *item = Get(first); item; item = Next(item)) {
item->Display(i - first, i == current ? clrBlack : clrWhite, i == current ? clrCyan : clrBackground); item->Display(i - first, i == current ? clrBlack : clrWhite, i == current ? clrCyan : clrBackground);
if (i == current) if (i == current)
cStatus::MsgOsdCurrentItem(item->Text()); cStatus::MsgOsdCurrentItem(item->Text());
}
if (++n == MAXOSDITEMS) //TODO get this from Interface!!! if (++n == MAXOSDITEMS) //TODO get this from Interface!!!
break; break;
i++;
} }
} }
if (!isempty(status)) if (!isempty(status))
@ -562,12 +559,13 @@ void cOsdMenu::PageDown(void)
{ {
current += MAXOSDITEMS; current += MAXOSDITEMS;
first += MAXOSDITEMS; first += MAXOSDITEMS;
if (current > Count() - 1) { int count = Count();
current = Count() - 1; if (current > count - 1) {
first = max(0, Count() - MAXOSDITEMS); current = count - 1;
first = max(0, count - MAXOSDITEMS);
} }
if (SpecialItem(current)) { if (SpecialItem(current)) {
current += (current < Count() - 1) ? 1 : -1; current += (current < count - 1) ? 1 : -1;
first = max(first, current - MAXOSDITEMS); first = max(first, current - MAXOSDITEMS);
} }
Display(); Display();