center cursor directly in Menu class

centering in Screen::Scroll is hacky and works
only for scrolling, not e.g. selecting.
This commit is contained in:
Andrzej Rybczak
2010-02-05 15:49:20 +01:00
parent e40ced8daf
commit bd64052f11
11 changed files with 33 additions and 17 deletions

View File

@@ -225,7 +225,6 @@ template <typename WindowType> void Screen<WindowType>::ReadKey(int &key)
template <typename WindowType> void Screen<WindowType>::Scroll(Where where, const int key[2])
{
List *list = Config.centered_cursor ? dynamic_cast<List *>(w) : 0;
if (!Config.fancy_scrolling && key)
{
int in = key[0];
@@ -234,38 +233,24 @@ template <typename WindowType> void Screen<WindowType>::Scroll(Where where, cons
{
TraceMpdStatus();
w->Scroll(where);
if (list)
list->Highlight(list->Choice());
w->Refresh();
w->ReadKey(in);
}
w->SetTimeout(ncmpcpp_window_timeout);
}
else
{
w->Scroll(where);
if (list)
list->Highlight(list->Choice());
}
}
template <typename WindowType> void Screen<WindowType>::MouseButtonPressed(MEVENT me)
{
List *list = Config.mouse_list_scroll_whole_page ? 0 : dynamic_cast<List *>(w);
if (me.bstate & BUTTON2_PRESSED)
{
if (list)
list->Highlight(list->Choice()+Config.lines_scrolled);
else
Scroll(wPageDown);
Scroll(wPageDown);
}
else if (me.bstate & BUTTON4_PRESSED)
{
if (list)
list->Highlight(list->Choice() > Config.lines_scrolled ? list->Choice()-Config.lines_scrolled : 0);
else
Scroll(wPageUp);
Scroll(wPageUp);
}
}