use generic Scroll method

This commit is contained in:
Andrzej Rybczak
2009-02-15 20:05:28 +01:00
parent e6bd98e0a7
commit c547fbe03b
9 changed files with 42 additions and 92 deletions

View File

@@ -24,6 +24,8 @@
#include "window.h"
#include "menu.h"
#include "mpdpp.h"
#include "helpers.h"
#include "status_checker.h"
class BasicScreen
{
@@ -41,6 +43,7 @@ class BasicScreen
virtual void Update() { }
virtual void Refresh() = 0;
virtual void Scroll(Where, const int * = 0) = 0;
virtual void EnterPressed() { }
virtual void SpacePressed() { }
@@ -62,6 +65,7 @@ template <class WindowType> class Screen : public BasicScreen
WindowType *&Main();
virtual void Refresh();
virtual void Scroll(Where where, const int *);
protected:
WindowType *w;
@@ -83,5 +87,24 @@ template <class WindowType> void Screen<WindowType>::Refresh()
w->Display();
}
template <class WindowType> void Screen<WindowType>::Scroll(Where where, const int *key)
{
if (!Config.fancy_scrolling && key)
{
int in = key[0];
w->SetTimeout(ncmpcpp_window_timeout/10);
while (Keypressed(in, key))
{
TraceMpdStatus();
w->Scroll(where);
w->Refresh();
w->ReadKey(in);
}
w->SetTimeout(ncmpcpp_window_timeout);
}
else
w->Scroll(where);
}
#endif