From 5c94900026437ed108f29eb54cfe31f2ce0deba6 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Tue, 7 Nov 2017 15:42:47 +0100 Subject: OSD menus now try to keep the offset of the list cursor at a constant position on the screen, even if the list is modified while being displayed --- osdbase.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'osdbase.c') diff --git a/osdbase.c b/osdbase.c index ac8026ff..dea1d995 100644 --- a/osdbase.c +++ b/osdbase.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: osdbase.c 4.2 2017/04/03 12:30:52 kls Exp $ + * $Id: osdbase.c 4.3 2017/11/07 15:42:47 kls Exp $ */ #include "osdbase.h" @@ -92,6 +92,7 @@ cOsdMenu::cOsdMenu(const char *Title, int c0, int c1, int c2, int c3, int c4) SetTitle(Title); SetCols(c0, c1, c2, c3, c4); first = 0; + lastOffset = 0; current = marked = -1; subMenu = NULL; helpRed = helpGreen = helpYellow = helpBlue = NULL; @@ -253,7 +254,7 @@ void cOsdMenu::Display(void) } if (current < 0) current = 0; // just for safety - there HAS to be a current item! - first = min(first, max(0, count - displayMenuItems)); // in case the menu size has changed + first = max(0, min(first, max(0, count - displayMenuItems))); // in case the menu size has changed if (current - first >= displayMenuItems || current < first) { first = current - displayMenuItems / 2; if (first + displayMenuItems > count) @@ -281,6 +282,9 @@ void cOsdMenu::Display(void) void cOsdMenu::SetCurrent(cOsdItem *Item) { current = Item ? Item->Index() : -1; + if (current >= 0 && lastOffset > 0) + first = max(0, current - lastOffset); + lastOffset = 0; } void cOsdMenu::RefreshCurrent(void) @@ -326,6 +330,7 @@ void cOsdMenu::Clear(void) { if (marked >= 0) SetStatus(NULL); + lastOffset = (current > first) ? current - first : 0; first = 0; current = marked = -1; cList::Clear(); -- cgit v1.2.3