use generic Scroll method
This commit is contained in:
@@ -24,7 +24,6 @@
|
||||
|
||||
#ifdef ENABLE_CLOCK
|
||||
|
||||
#include "display.h"
|
||||
#include "global.h"
|
||||
#include "playlist.h"
|
||||
#include "settings.h"
|
||||
@@ -136,7 +135,7 @@ void Clock::Update()
|
||||
{
|
||||
w->GotoXY(2*j+2, i);
|
||||
}
|
||||
if (Global::Config.clock_display_seconds || j < 18)
|
||||
if (Config.clock_display_seconds || j < 18)
|
||||
*w << " ";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ class Clock : public Screen<Window>
|
||||
virtual std::string Title();
|
||||
|
||||
virtual void Update();
|
||||
virtual void Scroll() { }
|
||||
|
||||
protected:
|
||||
static void Prepare();
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include "helpers.h"
|
||||
#include "playlist.h"
|
||||
|
||||
using Global::Config;
|
||||
using MPD::Song;
|
||||
using std::string;
|
||||
|
||||
|
||||
@@ -30,9 +30,6 @@
|
||||
|
||||
namespace Global
|
||||
{
|
||||
extern ncmpcpp_config Config;
|
||||
extern ncmpcpp_keys Key;
|
||||
|
||||
extern BasicScreen *myScreen;
|
||||
extern BasicScreen *myOldScreen;
|
||||
|
||||
|
||||
@@ -25,10 +25,10 @@
|
||||
#include "global.h"
|
||||
#include "helpers.h"
|
||||
#include "playlist.h"
|
||||
#include "status_checker.h"
|
||||
#include "tag_editor.h"
|
||||
|
||||
using namespace MPD;
|
||||
using Global::Config;
|
||||
using Global::Mpd;
|
||||
using Global::wFooter;
|
||||
using std::string;
|
||||
|
||||
@@ -60,9 +60,6 @@ using std::make_pair;
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
ncmpcpp_config Global::Config;
|
||||
ncmpcpp_keys Global::Key;
|
||||
|
||||
BasicScreen *Global::myScreen;
|
||||
BasicScreen *Global::myOldScreen;
|
||||
|
||||
@@ -311,83 +308,25 @@ int main(int argc, char *argv[])
|
||||
|
||||
// key mapping beginning
|
||||
|
||||
if (
|
||||
Keypressed(input, Key.Up)
|
||||
#ifdef ENABLE_CLOCK
|
||||
&& myScreen != myClock
|
||||
# endif // ENABLE_CLOCK
|
||||
)
|
||||
if (Keypressed(input, Key.Up))
|
||||
{
|
||||
if (!Config.fancy_scrolling
|
||||
&& (myScreen->Cmp() == myLibrary->Artists
|
||||
|| myScreen->Cmp() == myPlaylistEditor->List
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
|| myScreen->Cmp() == myTagEditor->LeftColumn
|
||||
# endif // HAVE_TAGLIB_H
|
||||
)
|
||||
)
|
||||
{
|
||||
myWindow->Main()->SetTimeout(50);
|
||||
while (Keypressed(input, Key.Up))
|
||||
{
|
||||
myWindow->Main()->Scroll(wUp);
|
||||
myWindow->Main()->Refresh();
|
||||
myWindow->Main()->ReadKey(input);
|
||||
myScreen->Scroll(wUp, Key.Up);
|
||||
}
|
||||
myWindow->Main()->SetTimeout(ncmpcpp_window_timeout);
|
||||
}
|
||||
else
|
||||
myWindow->Main()->Scroll(wUp);
|
||||
}
|
||||
else if (
|
||||
Keypressed(input, Key.Down)
|
||||
#ifdef ENABLE_CLOCK
|
||||
&& myScreen != myClock
|
||||
# endif // ENABLE_CLOCK
|
||||
)
|
||||
else if (Keypressed(input, Key.Down))
|
||||
{
|
||||
if (!Config.fancy_scrolling
|
||||
&& (myScreen->Cmp() == myLibrary->Artists
|
||||
|| myScreen->Cmp() == myPlaylistEditor->List
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
|| myScreen->Cmp() == myTagEditor->LeftColumn
|
||||
# endif // HAVE_TAGLIB_H
|
||||
)
|
||||
)
|
||||
{
|
||||
myWindow->Main()->SetTimeout(50);
|
||||
while (Keypressed(input, Key.Down))
|
||||
{
|
||||
myWindow->Main()->Scroll(wDown);
|
||||
myWindow->Main()->Refresh();
|
||||
myWindow->Main()->ReadKey(input);
|
||||
myScreen->Scroll(wDown, Key.Down);
|
||||
}
|
||||
myWindow->Main()->SetTimeout(ncmpcpp_window_timeout);
|
||||
}
|
||||
else
|
||||
myWindow->Main()->Scroll(wDown);
|
||||
}
|
||||
else if (
|
||||
Keypressed(input, Key.PageUp)
|
||||
#ifdef ENABLE_CLOCK
|
||||
&& myScreen != myClock
|
||||
# endif // ENABLE_CLOCK
|
||||
)
|
||||
else if (Keypressed(input, Key.PageUp))
|
||||
{
|
||||
myWindow->Main()->Scroll(wPageUp);
|
||||
myScreen->Scroll(wPageUp, Key.PageUp);
|
||||
}
|
||||
else if (
|
||||
Keypressed(input, Key.PageDown)
|
||||
#ifdef ENABLE_CLOCK
|
||||
&& myScreen != myClock
|
||||
# endif // ENABLE_CLOCK
|
||||
)
|
||||
else if (Keypressed(input, Key.PageDown))
|
||||
{
|
||||
myWindow->Main()->Scroll(wPageDown);
|
||||
myScreen->Scroll(wPageDown, Key.PageDown);
|
||||
}
|
||||
else if (Keypressed(input, Key.Home))
|
||||
{
|
||||
myWindow->Main()->Scroll(wHome);
|
||||
myScreen->Scroll(wHome);
|
||||
}
|
||||
else if (Keypressed(input, Key.End))
|
||||
{
|
||||
@@ -437,21 +376,7 @@ int main(int argc, char *argv[])
|
||||
wFooter->MoveTo(0, footer_start_y);
|
||||
wFooter->Resize(COLS, wFooter->GetHeight());
|
||||
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
if (myScreen == myLibrary)
|
||||
{
|
||||
myLibrary->Refresh();
|
||||
}
|
||||
else if (myScreen == myTagEditor)
|
||||
{
|
||||
myTagEditor->Refresh();
|
||||
}
|
||||
else
|
||||
# endif // HAVE_TAGLIB_H
|
||||
if (myScreen == myPlaylistEditor)
|
||||
{
|
||||
myPlaylistEditor->Refresh();
|
||||
}
|
||||
myScreen->Refresh();
|
||||
header_update_status = 1;
|
||||
PlayerState mpd_state = Mpd->GetState();
|
||||
StatusChanges changes;
|
||||
|
||||
23
src/screen.h
23
src/screen.h
@@ -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
|
||||
|
||||
|
||||
@@ -30,6 +30,9 @@ using std::string;
|
||||
const string config_file = config_dir + "config";
|
||||
const string keys_config_file = config_dir + "keys";
|
||||
|
||||
ncmpcpp_config Config;
|
||||
ncmpcpp_keys Key;
|
||||
|
||||
namespace
|
||||
{
|
||||
void GetKeys(string &line, int *key)
|
||||
|
||||
@@ -162,6 +162,9 @@ struct ncmpcpp_config
|
||||
int lyrics_db;
|
||||
};
|
||||
|
||||
extern ncmpcpp_config Config;
|
||||
extern ncmpcpp_keys Key;
|
||||
|
||||
void CreateConfigDir();
|
||||
void DefaultKeys(ncmpcpp_keys &);
|
||||
void DefaultConfiguration(ncmpcpp_config &);
|
||||
|
||||
Reference in New Issue
Block a user