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