diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2017-11-07 15:42:47 +0100 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2017-11-07 15:42:47 +0100 |
commit | 5c94900026437ed108f29eb54cfe31f2ce0deba6 (patch) | |
tree | c8ad4901d92dfcc3f7b93980d2e733103650d085 /osdbase.c | |
parent | e02a0a8c888923dd145ffff70f639c6c9601cef3 (diff) | |
download | vdr-5c94900026437ed108f29eb54cfe31f2ce0deba6.tar.gz vdr-5c94900026437ed108f29eb54cfe31f2ce0deba6.tar.bz2 |
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
Diffstat (limited to 'osdbase.c')
-rw-r--r-- | osdbase.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -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<cOsdItem>::Clear(); |