abstract shared parts of switchTo methods away
This commit is contained in:
@@ -87,6 +87,7 @@ noinst_HEADERS = \
|
||||
regex_filter.h \
|
||||
regexes.h \
|
||||
screen.h \
|
||||
screen_switcher.h \
|
||||
scrollpad.h \
|
||||
search_engine.h \
|
||||
sel_items_adder.h \
|
||||
|
||||
@@ -2284,15 +2284,10 @@ void Quit::Run()
|
||||
|
||||
void NextScreen::Run()
|
||||
{
|
||||
using Global::myOldScreen;
|
||||
using Global::myPrevScreen;
|
||||
|
||||
if (Config.screen_switcher_previous)
|
||||
{
|
||||
if (myScreen->isTabbable())
|
||||
myPrevScreen->switchTo();
|
||||
else
|
||||
myOldScreen->switchTo();
|
||||
if (auto tababble = dynamic_cast<Tabbable *>(myScreen))
|
||||
tababble->switchToPreviousScreen();
|
||||
}
|
||||
else if (!Config.screens_seq.empty())
|
||||
{
|
||||
@@ -2306,15 +2301,10 @@ void NextScreen::Run()
|
||||
|
||||
void PreviousScreen::Run()
|
||||
{
|
||||
using Global::myOldScreen;
|
||||
using Global::myPrevScreen;
|
||||
|
||||
if (Config.screen_switcher_previous)
|
||||
{
|
||||
if (myScreen->isTabbable())
|
||||
myPrevScreen->switchTo();
|
||||
else
|
||||
myOldScreen->switchTo();
|
||||
if (auto tababble = dynamic_cast<Tabbable *>(myScreen))
|
||||
tababble->switchToPreviousScreen();
|
||||
}
|
||||
else if (!Config.screens_seq.empty())
|
||||
{
|
||||
@@ -2326,24 +2316,27 @@ void PreviousScreen::Run()
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_TAGLIB_H
|
||||
bool ShowHelp::canBeRun() const
|
||||
{
|
||||
return myScreen != myTinyTagEditor;
|
||||
}
|
||||
return myScreen != myHelp
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
&& myScreen != myTinyTagEditor
|
||||
# endif // HAVE_TAGLIB_H
|
||||
;
|
||||
}
|
||||
|
||||
void ShowHelp::Run()
|
||||
{
|
||||
myHelp->switchTo();
|
||||
}
|
||||
|
||||
#ifdef HAVE_TAGLIB_H
|
||||
bool ShowPlaylist::canBeRun() const
|
||||
{
|
||||
return myScreen != myTinyTagEditor;
|
||||
}
|
||||
return myScreen != myPlaylist
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
&& myScreen != myTinyTagEditor;
|
||||
# endif // HAVE_TAGLIB_H
|
||||
}
|
||||
|
||||
void ShowPlaylist::Run()
|
||||
{
|
||||
@@ -2386,12 +2379,13 @@ void ShowMediaLibrary::Run()
|
||||
myLibrary->switchTo();
|
||||
}
|
||||
|
||||
#ifdef HAVE_TAGLIB_H
|
||||
bool ShowPlaylistEditor::canBeRun() const
|
||||
{
|
||||
return myScreen != myTinyTagEditor;
|
||||
}
|
||||
return myScreen != myPlaylistEditor
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
&& myScreen != myTinyTagEditor;
|
||||
# endif // HAVE_TAGLIB_H
|
||||
}
|
||||
|
||||
void ShowPlaylistEditor::Run()
|
||||
{
|
||||
@@ -2401,7 +2395,8 @@ void ShowPlaylistEditor::Run()
|
||||
bool ShowTagEditor::canBeRun() const
|
||||
{
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
return myScreen != myTinyTagEditor;
|
||||
return myScreen != myTagEditor
|
||||
&& myScreen != myTinyTagEditor;
|
||||
# else
|
||||
return false;
|
||||
# endif // HAVE_TAGLIB_H
|
||||
@@ -2418,11 +2413,11 @@ void ShowTagEditor::Run()
|
||||
bool ShowOutputs::canBeRun() const
|
||||
{
|
||||
# ifdef ENABLE_OUTPUTS
|
||||
return myScreen != myOutputs
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
return myScreen != myTinyTagEditor;
|
||||
# else
|
||||
return true;
|
||||
&& myScreen != myTinyTagEditor
|
||||
# endif // HAVE_TAGLIB_H
|
||||
;
|
||||
# else
|
||||
return false;
|
||||
# endif // ENABLE_OUTPUTS
|
||||
@@ -2437,15 +2432,15 @@ void ShowOutputs::Run()
|
||||
|
||||
bool ShowVisualizer::canBeRun() const
|
||||
{
|
||||
# ifdef ENABLE_OUTPUTS
|
||||
# ifdef ENABLE_VISUALIZER
|
||||
return myScreen != myVisualizer
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
return myScreen != myTinyTagEditor;
|
||||
# else
|
||||
return true;
|
||||
&& myScreen != myTinyTagEditor
|
||||
# endif // HAVE_TAGLIB_H
|
||||
;
|
||||
# else
|
||||
return false;
|
||||
# endif // ENABLE_OUTPUTS
|
||||
# endif // ENABLE_VISUALIZER
|
||||
}
|
||||
|
||||
void ShowVisualizer::Run()
|
||||
@@ -2458,11 +2453,11 @@ void ShowVisualizer::Run()
|
||||
bool ShowClock::canBeRun() const
|
||||
{
|
||||
# ifdef ENABLE_CLOCK
|
||||
return myScreen != myClock
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
return myScreen != myTinyTagEditor;
|
||||
# else
|
||||
return true;
|
||||
&& myScreen != myTinyTagEditor
|
||||
# endif // HAVE_TAGLIB_H
|
||||
;
|
||||
# else
|
||||
return false;
|
||||
# endif // ENABLE_CLOCK
|
||||
|
||||
@@ -979,9 +979,7 @@ struct ShowHelp : public Action
|
||||
ShowHelp() : Action(aShowHelp, "show_help") { }
|
||||
|
||||
protected:
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
virtual bool canBeRun() const;
|
||||
# endif // HAVE_TAGLIB_H
|
||||
virtual void Run();
|
||||
};
|
||||
|
||||
@@ -990,9 +988,7 @@ struct ShowPlaylist : public Action
|
||||
ShowPlaylist() : Action(aShowPlaylist, "show_playlist") { }
|
||||
|
||||
protected:
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
virtual bool canBeRun() const;
|
||||
# endif // HAVE_TAGLIB_H
|
||||
virtual void Run();
|
||||
};
|
||||
|
||||
@@ -1034,9 +1030,7 @@ struct ShowPlaylistEditor : public Action
|
||||
ShowPlaylistEditor() : Action(aShowPlaylistEditor, "show_playlist_editor") { }
|
||||
|
||||
protected:
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
virtual bool canBeRun() const;
|
||||
# endif // HAVE_TAGLIB_H
|
||||
virtual void Run();
|
||||
};
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include "utility/comparators.h"
|
||||
#include "title.h"
|
||||
#include "tags.h"
|
||||
#include "screen_switcher.h"
|
||||
|
||||
using namespace std::placeholders;
|
||||
|
||||
@@ -87,35 +88,27 @@ void Browser::resize()
|
||||
|
||||
void Browser::switchTo()
|
||||
{
|
||||
using Global::myLockedScreen;
|
||||
using Global::myInactiveScreen;
|
||||
|
||||
if (myScreen == this)
|
||||
{
|
||||
# ifndef WIN32
|
||||
myBrowser->ChangeBrowseMode();
|
||||
ChangeBrowseMode();
|
||||
# endif // !WIN32
|
||||
}
|
||||
|
||||
if (myLockedScreen)
|
||||
updateInactiveScreen(this);
|
||||
|
||||
if (hasToBeResized || myLockedScreen)
|
||||
resize();
|
||||
else
|
||||
{
|
||||
SwitchTo::execute(this);
|
||||
|
||||
if (isLocal() && Config.browser_sort_mode == smMTime) // local browser doesn't support sorting by mtime
|
||||
Config.browser_sort_mode = smName;
|
||||
|
||||
if (w.empty())
|
||||
myBrowser->GetDirectory(itsBrowsedDir);
|
||||
GetDirectory(itsBrowsedDir);
|
||||
else
|
||||
markSongsInPlaylist(getProxySongList());
|
||||
|
||||
if (myScreen != this && myScreen->isTabbable())
|
||||
Global::myPrevScreen = myScreen;
|
||||
myScreen = this;
|
||||
drawHeader();
|
||||
}
|
||||
}
|
||||
|
||||
std::wstring Browser::title()
|
||||
{
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "mpdpp.h"
|
||||
#include "screen.h"
|
||||
|
||||
struct Browser : public Screen<NC::Menu<MPD::Item>>, public Filterable, public HasSongs, public Searchable
|
||||
struct Browser: Screen<NC::Menu<MPD::Item>>, Filterable, HasSongs, Searchable, Tabbable
|
||||
{
|
||||
Browser();
|
||||
|
||||
@@ -41,7 +41,6 @@ struct Browser : public Screen<NC::Menu<MPD::Item>>, public Filterable, public H
|
||||
virtual void spacePressed() OVERRIDE;
|
||||
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
||||
|
||||
virtual bool isTabbable() OVERRIDE { return true; }
|
||||
virtual bool isMergable() OVERRIDE { return true; }
|
||||
|
||||
// Filterable implementation
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "status.h"
|
||||
#include "statusbar.h"
|
||||
#include "title.h"
|
||||
#include "screen_switcher.h"
|
||||
|
||||
using Global::MainHeight;
|
||||
using Global::MainStartY;
|
||||
@@ -76,30 +77,13 @@ void Clock::resize()
|
||||
|
||||
void Clock::switchTo()
|
||||
{
|
||||
using Global::myLockedScreen;
|
||||
|
||||
if (myScreen == this)
|
||||
return;
|
||||
|
||||
if (myLockedScreen)
|
||||
updateInactiveScreen(this);
|
||||
|
||||
size_t x_offset, width;
|
||||
getWindowResizeParams(x_offset, width, false);
|
||||
if (Width > width || Height > MainHeight)
|
||||
{
|
||||
Statusbar::msg("Screen is too small to display clock");
|
||||
if (myLockedScreen)
|
||||
updateInactiveScreen(myLockedScreen);
|
||||
return;
|
||||
}
|
||||
|
||||
if (hasToBeResized || myLockedScreen)
|
||||
resize();
|
||||
|
||||
if (myScreen != this && myScreen->isTabbable())
|
||||
Global::myPrevScreen = myScreen;
|
||||
myScreen = this;
|
||||
else
|
||||
{
|
||||
SwitchTo::execute(this);
|
||||
drawHeader();
|
||||
Prepare();
|
||||
m_pane.refresh();
|
||||
@@ -107,6 +91,7 @@ void Clock::switchTo()
|
||||
w.clear();
|
||||
w.display();
|
||||
}
|
||||
}
|
||||
|
||||
std::wstring Clock::title()
|
||||
{
|
||||
|
||||
@@ -25,10 +25,11 @@
|
||||
|
||||
#ifdef ENABLE_CLOCK
|
||||
|
||||
#include "window.h"
|
||||
#include "interfaces.h"
|
||||
#include "screen.h"
|
||||
#include "window.h"
|
||||
|
||||
struct Clock : public Screen<NC::Window>
|
||||
struct Clock: Screen<NC::Window>, Tabbable
|
||||
{
|
||||
Clock();
|
||||
|
||||
@@ -44,7 +45,6 @@ struct Clock : public Screen<NC::Window>
|
||||
virtual void spacePressed() OVERRIDE { }
|
||||
virtual void mouseButtonPressed(MEVENT) OVERRIDE { }
|
||||
|
||||
virtual bool isTabbable() OVERRIDE { return true; }
|
||||
virtual bool isMergable() OVERRIDE { return true; }
|
||||
|
||||
protected:
|
||||
|
||||
@@ -23,8 +23,6 @@
|
||||
namespace Global {//
|
||||
|
||||
BasicScreen *myScreen;
|
||||
BasicScreen *myOldScreen;
|
||||
BasicScreen *myPrevScreen;
|
||||
BasicScreen *myLockedScreen;
|
||||
BasicScreen *myInactiveScreen;
|
||||
|
||||
|
||||
@@ -31,12 +31,6 @@ namespace Global {//
|
||||
// currently active screen (displayed in main window)
|
||||
extern BasicScreen *myScreen;
|
||||
|
||||
// for info, lyrics, popups to remember which screen return to
|
||||
extern BasicScreen *myOldScreen;
|
||||
|
||||
// "real" screen switching (browser, search, etc.)
|
||||
extern BasicScreen *myPrevScreen;
|
||||
|
||||
// points at the screen that was locked (or is null if no screen is locked)
|
||||
extern BasicScreen *myLockedScreen;
|
||||
|
||||
|
||||
17
src/help.cpp
17
src/help.cpp
@@ -27,6 +27,7 @@
|
||||
#include "status.h"
|
||||
#include "utility/wide_string.h"
|
||||
#include "title.h"
|
||||
#include "screen_switcher.h"
|
||||
|
||||
using Global::MainHeight;
|
||||
using Global::MainStartY;
|
||||
@@ -113,21 +114,7 @@ void Help::resize()
|
||||
|
||||
void Help::switchTo()
|
||||
{
|
||||
using Global::myScreen;
|
||||
using Global::myLockedScreen;
|
||||
|
||||
if (myScreen == this)
|
||||
return;
|
||||
|
||||
if (myLockedScreen)
|
||||
updateInactiveScreen(this);
|
||||
|
||||
if (hasToBeResized || myLockedScreen)
|
||||
resize();
|
||||
|
||||
if (myScreen != this && myScreen->isTabbable())
|
||||
Global::myPrevScreen = myScreen;
|
||||
myScreen = this;
|
||||
SwitchTo::execute(this);
|
||||
drawHeader();
|
||||
}
|
||||
|
||||
|
||||
@@ -22,9 +22,10 @@
|
||||
#define _HELP_H
|
||||
|
||||
#include "actions.h"
|
||||
#include "interfaces.h"
|
||||
#include "screen.h"
|
||||
|
||||
struct Help : public Screen<NC::Scrollpad>
|
||||
struct Help: Screen<NC::Scrollpad>, Tabbable
|
||||
{
|
||||
Help();
|
||||
|
||||
@@ -38,7 +39,6 @@ struct Help : public Screen<NC::Scrollpad>
|
||||
virtual void enterPressed() OVERRIDE { }
|
||||
virtual void spacePressed() OVERRIDE { }
|
||||
|
||||
virtual bool isTabbable() OVERRIDE { return true; }
|
||||
virtual bool isMergable() OVERRIDE { return true; }
|
||||
|
||||
protected:
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include <string>
|
||||
#include "gcc.h"
|
||||
#include "screen.h"
|
||||
#include "song.h"
|
||||
#include "proxy_song_list.h"
|
||||
|
||||
@@ -59,4 +60,23 @@ struct HasColumns
|
||||
virtual void nextColumn() = 0;
|
||||
};
|
||||
|
||||
struct Tabbable
|
||||
{
|
||||
Tabbable() : m_previous_screen(0) { }
|
||||
|
||||
void switchToPreviousScreen() const {
|
||||
if (m_previous_screen)
|
||||
m_previous_screen->switchTo();
|
||||
}
|
||||
void setPreviousScreen(BasicScreen *screen) {
|
||||
m_previous_screen = screen;
|
||||
}
|
||||
BasicScreen *previousScreen() const {
|
||||
return m_previous_screen;
|
||||
}
|
||||
|
||||
private:
|
||||
BasicScreen *m_previous_screen;
|
||||
};
|
||||
|
||||
#endif // _INTERFACES_H
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include "global.h"
|
||||
#include "statusbar.h"
|
||||
#include "title.h"
|
||||
#include "screen_switcher.h"
|
||||
|
||||
using Global::MainHeight;
|
||||
using Global::MainStartY;
|
||||
@@ -83,28 +84,18 @@ void Lastfm::Take()
|
||||
void Lastfm::switchTo()
|
||||
{
|
||||
using Global::myScreen;
|
||||
using Global::myOldScreen;
|
||||
using Global::myLockedScreen;
|
||||
|
||||
if (myScreen == this)
|
||||
return myOldScreen->switchTo();
|
||||
|
||||
if (myLockedScreen)
|
||||
updateInactiveScreen(this);
|
||||
|
||||
if (hasToBeResized || myLockedScreen)
|
||||
resize();
|
||||
|
||||
if (myScreen != this)
|
||||
{
|
||||
SwitchTo::execute(this);
|
||||
// get an old info if it waits
|
||||
if (isReadyToTake)
|
||||
Take();
|
||||
|
||||
Load();
|
||||
|
||||
myOldScreen = myScreen;
|
||||
myScreen = this;
|
||||
drawHeader();
|
||||
}
|
||||
else
|
||||
switchToPreviousScreen();
|
||||
}
|
||||
|
||||
void Lastfm::Load()
|
||||
{
|
||||
|
||||
@@ -28,10 +28,11 @@
|
||||
#include <memory>
|
||||
#include <pthread.h>
|
||||
|
||||
#include "interfaces.h"
|
||||
#include "lastfm_service.h"
|
||||
#include "screen.h"
|
||||
|
||||
struct Lastfm : public Screen<NC::Scrollpad>
|
||||
struct Lastfm: Screen<NC::Scrollpad>, Tabbable
|
||||
{
|
||||
Lastfm();
|
||||
|
||||
@@ -46,7 +47,6 @@ struct Lastfm : public Screen<NC::Scrollpad>
|
||||
virtual void spacePressed() OVERRIDE { }
|
||||
|
||||
virtual bool isMergable() OVERRIDE { return true; }
|
||||
virtual bool isTabbable() OVERRIDE { return false; }
|
||||
|
||||
// private members
|
||||
void Refetch();
|
||||
|
||||
@@ -35,11 +35,10 @@
|
||||
#include "song.h"
|
||||
#include "statusbar.h"
|
||||
#include "title.h"
|
||||
#include "screen_switcher.h"
|
||||
|
||||
using Global::MainHeight;
|
||||
using Global::MainStartY;
|
||||
using Global::myScreen;
|
||||
using Global::myOldScreen;
|
||||
|
||||
#ifdef HAVE_CURL_CURL_H
|
||||
LyricsFetcher **Lyrics::itsFetcher = 0;
|
||||
@@ -96,17 +95,9 @@ void Lyrics::update()
|
||||
|
||||
void Lyrics::switchTo()
|
||||
{
|
||||
using Global::myLockedScreen;
|
||||
using Global::myInactiveScreen;
|
||||
|
||||
if (myScreen == this)
|
||||
return myOldScreen->switchTo();
|
||||
|
||||
if (hasToBeResized)
|
||||
resize();
|
||||
|
||||
itsScrollBegin = 0;
|
||||
|
||||
using Global::myScreen;
|
||||
if (myScreen != this)
|
||||
{
|
||||
# ifdef HAVE_CURL_CURL_H
|
||||
// take lyrics if they were downloaded
|
||||
if (isReadyToTake)
|
||||
@@ -125,28 +116,17 @@ void Lyrics::switchTo()
|
||||
|
||||
if (!s->getArtist().empty() && !s->getTitle().empty())
|
||||
{
|
||||
myOldScreen = myScreen;
|
||||
myScreen = this;
|
||||
|
||||
SwitchTo::execute(this);
|
||||
itsScrollBegin = 0;
|
||||
itsSong = *s;
|
||||
Load();
|
||||
|
||||
drawHeader();
|
||||
}
|
||||
else
|
||||
{
|
||||
Statusbar::msg("Song must have both artist and title tag set");
|
||||
return;
|
||||
}
|
||||
|
||||
// if we resize for locked screen, we have to do that in the end since
|
||||
// fetching lyrics may fail (eg. if tags are missing) and we don't want
|
||||
// to adjust screen size then.
|
||||
if (myLockedScreen) // BUG
|
||||
{
|
||||
updateInactiveScreen(this);
|
||||
resize();
|
||||
}
|
||||
else
|
||||
switchToPreviousScreen();
|
||||
}
|
||||
|
||||
std::wstring Lyrics::title()
|
||||
@@ -366,8 +346,7 @@ void Lyrics::Load()
|
||||
|
||||
void Lyrics::Edit()
|
||||
{
|
||||
if (myScreen != this)
|
||||
return;
|
||||
assert(Global::myScreen == this);
|
||||
|
||||
if (Config.external_editor.empty())
|
||||
{
|
||||
|
||||
@@ -24,11 +24,12 @@
|
||||
#include <pthread.h>
|
||||
#include <queue>
|
||||
|
||||
#include "mpdpp.h"
|
||||
#include "screen.h"
|
||||
#include "interfaces.h"
|
||||
#include "lyrics_fetcher.h"
|
||||
#include "screen.h"
|
||||
#include "song.h"
|
||||
|
||||
struct Lyrics : public Screen<NC::Scrollpad>
|
||||
struct Lyrics: Screen<NC::Scrollpad>, Tabbable
|
||||
{
|
||||
Lyrics();
|
||||
|
||||
@@ -44,7 +45,6 @@ struct Lyrics : public Screen<NC::Scrollpad>
|
||||
virtual void spacePressed() OVERRIDE;
|
||||
|
||||
virtual bool isMergable() OVERRIDE { return true; }
|
||||
virtual bool isTabbable() OVERRIDE { return false; }
|
||||
|
||||
// private members
|
||||
void Edit();
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include "utility/comparators.h"
|
||||
#include "utility/type_conversions.h"
|
||||
#include "title.h"
|
||||
#include "screen_switcher.h"
|
||||
|
||||
using namespace std::placeholders;
|
||||
|
||||
@@ -197,16 +198,11 @@ void MediaLibrary::refresh()
|
||||
|
||||
void MediaLibrary::switchTo()
|
||||
{
|
||||
using Global::myLockedScreen;
|
||||
|
||||
if (myScreen == this)
|
||||
{
|
||||
if (Config.media_library_disable_two_column_mode)
|
||||
return;
|
||||
else
|
||||
if (!Config.media_library_disable_two_column_mode)
|
||||
{
|
||||
hasTwoColumns = !hasTwoColumns;
|
||||
hasToBeResized = 1;
|
||||
Tags.clear();
|
||||
Albums.clear();
|
||||
Albums.reset();
|
||||
@@ -225,22 +221,18 @@ void MediaLibrary::switchTo()
|
||||
}
|
||||
else
|
||||
Albums.setTitle(Config.titles_visibility ? "Albums" : "");
|
||||
}
|
||||
}
|
||||
|
||||
if (myLockedScreen)
|
||||
updateInactiveScreen(this);
|
||||
|
||||
if (hasToBeResized || myLockedScreen)
|
||||
resize();
|
||||
|
||||
if (myScreen != this && myScreen->isTabbable())
|
||||
Global::myPrevScreen = myScreen;
|
||||
myScreen = this;
|
||||
drawHeader();
|
||||
markSongsInPlaylist(songsProxyList());
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SwitchTo::execute(this);
|
||||
markSongsInPlaylist(songsProxyList());
|
||||
drawHeader();
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
|
||||
std::wstring MediaLibrary::title()
|
||||
{
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "interfaces.h"
|
||||
#include "screen.h"
|
||||
|
||||
struct MediaLibrary : public Screen<NC::Window *>, public Filterable, public HasColumns, public HasSongs, public Searchable
|
||||
struct MediaLibrary: Screen<NC::Window *>, Filterable, HasColumns, HasSongs, Searchable, Tabbable
|
||||
{
|
||||
MediaLibrary();
|
||||
|
||||
@@ -40,7 +40,6 @@ struct MediaLibrary : public Screen<NC::Window *>, public Filterable, public Has
|
||||
virtual void spacePressed() OVERRIDE;
|
||||
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
||||
|
||||
virtual bool isTabbable() OVERRIDE { return true; }
|
||||
virtual bool isMergable() OVERRIDE { return true; }
|
||||
|
||||
// Filterable implementation
|
||||
|
||||
@@ -79,8 +79,6 @@ namespace
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
using Global::myScreen;
|
||||
using Global::myOldScreen;
|
||||
using Global::myPrevScreen;
|
||||
using Global::myLockedScreen;
|
||||
using Global::myInactiveScreen;
|
||||
|
||||
@@ -165,11 +163,6 @@ int main(int argc, char **argv)
|
||||
wFooter->addFDCallback(Mpd.GetFD(), Statusbar::Helpers::mpd);
|
||||
wFooter->createHistory();
|
||||
|
||||
// initialize screens to browser as default previous screen
|
||||
myScreen = myBrowser;
|
||||
myPrevScreen = myBrowser;
|
||||
myOldScreen = myBrowser;
|
||||
|
||||
// initialize global timer
|
||||
gettimeofday(&Timer, 0);
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "status.h"
|
||||
#include "statusbar.h"
|
||||
#include "title.h"
|
||||
#include "screen_switcher.h"
|
||||
|
||||
using Global::MainHeight;
|
||||
using Global::MainStartY;
|
||||
@@ -47,21 +48,7 @@ Outputs::Outputs()
|
||||
|
||||
void Outputs::switchTo()
|
||||
{
|
||||
using Global::myLockedScreen;
|
||||
|
||||
if (myScreen == this)
|
||||
return;
|
||||
|
||||
if (myLockedScreen)
|
||||
updateInactiveScreen(this);
|
||||
|
||||
if (hasToBeResized || myLockedScreen)
|
||||
resize();
|
||||
|
||||
if (myScreen != this && myScreen->isTabbable())
|
||||
Global::myPrevScreen = myScreen;
|
||||
myScreen = this;
|
||||
w.Window::clear();
|
||||
SwitchTo::execute(this);
|
||||
drawHeader();
|
||||
}
|
||||
|
||||
|
||||
@@ -25,11 +25,12 @@
|
||||
|
||||
#ifdef ENABLE_OUTPUTS
|
||||
|
||||
#include "interfaces.h"
|
||||
#include "menu.h"
|
||||
#include "mpdpp.h"
|
||||
#include "screen.h"
|
||||
|
||||
struct Outputs : public Screen<NC::Menu<MPD::Output>>
|
||||
struct Outputs: Screen<NC::Menu<MPD::Output>>, Tabbable
|
||||
{
|
||||
Outputs();
|
||||
|
||||
@@ -45,7 +46,6 @@ struct Outputs : public Screen<NC::Menu<MPD::Output>>
|
||||
virtual void spacePressed() OVERRIDE { }
|
||||
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
||||
|
||||
virtual bool isTabbable() OVERRIDE { return true; }
|
||||
virtual bool isMergable() OVERRIDE { return true; }
|
||||
|
||||
// private members
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "menu.h"
|
||||
#include "playlist.h"
|
||||
#include "regex_filter.h"
|
||||
#include "screen_switcher.h"
|
||||
#include "song.h"
|
||||
#include "status.h"
|
||||
#include "statusbar.h"
|
||||
@@ -66,24 +67,8 @@ Playlist::Playlist() : itsTotalLength(0), itsRemainingTime(0), itsScrollBegin(0)
|
||||
|
||||
void Playlist::switchTo()
|
||||
{
|
||||
using Global::myScreen;
|
||||
using Global::myLockedScreen;
|
||||
using Global::myInactiveScreen;
|
||||
|
||||
if (myScreen == this)
|
||||
return;
|
||||
|
||||
SwitchTo::execute(this);
|
||||
itsScrollBegin = 0;
|
||||
|
||||
if (myLockedScreen)
|
||||
updateInactiveScreen(this);
|
||||
|
||||
if (hasToBeResized || myLockedScreen)
|
||||
resize();
|
||||
|
||||
if (myScreen != this && myScreen->isTabbable())
|
||||
Global::myPrevScreen = myScreen;
|
||||
myScreen = this;
|
||||
EnableHighlighting();
|
||||
drawHeader();
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include "screen.h"
|
||||
#include "song.h"
|
||||
|
||||
struct Playlist : public Screen<NC::Menu<MPD::Song>>, public Filterable, public HasSongs, public Searchable
|
||||
struct Playlist: Screen<NC::Menu<MPD::Song>>, Filterable, HasSongs, Searchable, Tabbable
|
||||
{
|
||||
Playlist();
|
||||
|
||||
@@ -43,7 +43,6 @@ struct Playlist : public Screen<NC::Menu<MPD::Song>>, public Filterable, public
|
||||
virtual void spacePressed() OVERRIDE;
|
||||
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
||||
|
||||
virtual bool isTabbable() OVERRIDE { return true; }
|
||||
virtual bool isMergable() OVERRIDE { return true; }
|
||||
|
||||
// Filterable implementation
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "tag_editor.h"
|
||||
#include "utility/comparators.h"
|
||||
#include "title.h"
|
||||
#include "screen_switcher.h"
|
||||
|
||||
using namespace std::placeholders;
|
||||
|
||||
@@ -116,23 +117,9 @@ void PlaylistEditor::refresh()
|
||||
|
||||
void PlaylistEditor::switchTo()
|
||||
{
|
||||
using Global::myScreen;
|
||||
using Global::myLockedScreen;
|
||||
|
||||
if (myScreen == this)
|
||||
return;
|
||||
|
||||
if (myLockedScreen)
|
||||
updateInactiveScreen(this);
|
||||
|
||||
if (hasToBeResized || myLockedScreen)
|
||||
resize();
|
||||
|
||||
if (myScreen != this && myScreen->isTabbable())
|
||||
Global::myPrevScreen = myScreen;
|
||||
myScreen = this;
|
||||
drawHeader();
|
||||
SwitchTo::execute(this);
|
||||
markSongsInPlaylist(contentProxyList());
|
||||
drawHeader();
|
||||
refresh();
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "interfaces.h"
|
||||
#include "screen.h"
|
||||
|
||||
struct PlaylistEditor : public Screen<NC::Window *>, public Filterable, public HasColumns, public HasSongs, public Searchable
|
||||
struct PlaylistEditor: Screen<NC::Window *>, Filterable, HasColumns, HasSongs, Searchable, Tabbable
|
||||
{
|
||||
PlaylistEditor();
|
||||
|
||||
@@ -40,7 +40,6 @@ struct PlaylistEditor : public Screen<NC::Window *>, public Filterable, public H
|
||||
virtual void spacePressed() OVERRIDE;
|
||||
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
||||
|
||||
virtual bool isTabbable() OVERRIDE { return true; }
|
||||
virtual bool isMergable() OVERRIDE { return true; }
|
||||
|
||||
// Filterable implementation
|
||||
|
||||
@@ -117,6 +117,7 @@ void BasicScreen::unlock()
|
||||
{
|
||||
if (myInactiveScreen && myInactiveScreen != myLockedScreen)
|
||||
myScreen = myInactiveScreen;
|
||||
if (myScreen != myLockedScreen)
|
||||
myLockedScreen->switchTo();
|
||||
myLockedScreen = 0;
|
||||
myInactiveScreen = 0;
|
||||
|
||||
@@ -73,10 +73,6 @@ struct BasicScreen
|
||||
/// @see Screen::mouseButtonPressed()
|
||||
virtual void mouseButtonPressed(MEVENT me) = 0;
|
||||
|
||||
/// When this is overwritten with a function returning true, the
|
||||
/// screen will be used in tab switching.
|
||||
virtual bool isTabbable() = 0;
|
||||
|
||||
/// @return true if screen is mergable, ie. can be "proper" subwindow
|
||||
/// if one of the screens is locked. Screens that somehow resemble popups
|
||||
/// will want to return false here.
|
||||
|
||||
60
src/screen_switcher.h
Normal file
60
src/screen_switcher.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008-2012 by Andrzej Rybczak *
|
||||
* electricityispower@gmail.com *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef _SCREEN_SWITCHER_H
|
||||
#define _SCREEN_SWITCHER_H
|
||||
|
||||
#include "global.h"
|
||||
|
||||
class SwitchTo
|
||||
{
|
||||
template <bool ToBeExecuted, typename ScreenT> struct TabbableAction_ {
|
||||
static void execute(ScreenT *) { }
|
||||
};
|
||||
template <typename ScreenT> struct TabbableAction_<true, ScreenT> {
|
||||
static void execute(ScreenT *screen) {
|
||||
using Global::myScreen;
|
||||
// it has to work only if both current and previous screens are Tabbable
|
||||
if (dynamic_cast<Tabbable *>(myScreen))
|
||||
screen->setPreviousScreen(myScreen);
|
||||
}
|
||||
};
|
||||
|
||||
public:
|
||||
template <typename ScreenT>
|
||||
static void execute(ScreenT *screen)
|
||||
{
|
||||
using Global::myScreen;
|
||||
using Global::myLockedScreen;
|
||||
|
||||
const bool isScreenMergable = screen->isMergable() && myLockedScreen;
|
||||
const bool isScreenTabbable = std::is_base_of<Tabbable, ScreenT>::value;
|
||||
|
||||
assert(myScreen != screen);
|
||||
if (isScreenMergable)
|
||||
updateInactiveScreen(screen);
|
||||
if (screen->hasToBeResized || isScreenMergable)
|
||||
screen->resize();
|
||||
TabbableAction_<isScreenTabbable, ScreenT>::execute(screen);
|
||||
myScreen = screen;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // _SCREEN_SWITCHER_H
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "statusbar.h"
|
||||
#include "utility/comparators.h"
|
||||
#include "title.h"
|
||||
#include "screen_switcher.h"
|
||||
|
||||
using namespace std::placeholders;
|
||||
|
||||
@@ -125,29 +126,16 @@ void SearchEngine::resize()
|
||||
|
||||
void SearchEngine::switchTo()
|
||||
{
|
||||
using Global::myScreen;
|
||||
using Global::myLockedScreen;
|
||||
|
||||
if (myScreen == this)
|
||||
if (Global::myScreen != this)
|
||||
{
|
||||
reset();
|
||||
return;
|
||||
}
|
||||
|
||||
if (myLockedScreen)
|
||||
updateInactiveScreen(this);
|
||||
|
||||
if (hasToBeResized || myLockedScreen)
|
||||
resize();
|
||||
|
||||
SwitchTo::execute(this);
|
||||
if (w.empty())
|
||||
Prepare();
|
||||
|
||||
if (myScreen != this && myScreen->isTabbable())
|
||||
Global::myPrevScreen = myScreen;
|
||||
myScreen = this;
|
||||
drawHeader();
|
||||
markSongsInPlaylist(getProxySongList());
|
||||
drawHeader();
|
||||
}
|
||||
else
|
||||
reset();
|
||||
}
|
||||
|
||||
std::wstring SearchEngine::title()
|
||||
|
||||
@@ -73,7 +73,7 @@ struct SEItem
|
||||
MPD::Song itsSong;
|
||||
};
|
||||
|
||||
struct SearchEngine : public Screen<NC::Menu<SEItem>>, public Filterable, public HasSongs, public Searchable
|
||||
struct SearchEngine: Screen<NC::Menu<SEItem>>, Filterable, HasSongs, Searchable, Tabbable
|
||||
{
|
||||
SearchEngine();
|
||||
|
||||
@@ -89,7 +89,6 @@ struct SearchEngine : public Screen<NC::Menu<SEItem>>, public Filterable, public
|
||||
virtual void spacePressed() OVERRIDE;
|
||||
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
||||
|
||||
virtual bool isTabbable() OVERRIDE { return true; }
|
||||
virtual bool isMergable() OVERRIDE { return true; }
|
||||
|
||||
// Filterable implementation
|
||||
@@ -111,7 +110,6 @@ struct SearchEngine : public Screen<NC::Menu<SEItem>>, public Filterable, public
|
||||
virtual MPD::SongList getSelectedSongs() OVERRIDE;
|
||||
|
||||
// private members
|
||||
|
||||
static size_t StaticOptions;
|
||||
static size_t SearchButton;
|
||||
static size_t ResetButton;
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "settings.h"
|
||||
#include "statusbar.h"
|
||||
#include "utility/comparators.h"
|
||||
#include "screen_switcher.h"
|
||||
|
||||
SelectedItemsAdder *mySelectedItemsAdder;
|
||||
|
||||
@@ -103,7 +104,6 @@ void SelectedItemsAdder::switchTo()
|
||||
{
|
||||
using Global::myScreen;
|
||||
|
||||
assert(myScreen != this);
|
||||
auto hs = hasSongs(myScreen);
|
||||
if (!hs || !hs->allowsSelection())
|
||||
return;
|
||||
@@ -115,15 +115,10 @@ void SelectedItemsAdder::switchTo()
|
||||
Statusbar::msg("List of selected items is empty");
|
||||
return;
|
||||
}
|
||||
|
||||
if (hasToBeResized)
|
||||
resize();
|
||||
|
||||
populatePlaylistSelector(myScreen);
|
||||
|
||||
SwitchTo::execute(this);
|
||||
// default to main window
|
||||
w = &m_playlist_selector;
|
||||
myScreen = this;
|
||||
}
|
||||
|
||||
void SelectedItemsAdder::resize()
|
||||
@@ -141,10 +136,10 @@ void SelectedItemsAdder::resize()
|
||||
(COLS-m_position_selector_width)/2,
|
||||
MainStartY+(MainHeight-m_position_selector_height)/2
|
||||
);
|
||||
if (m_old_screen && m_old_screen->hasToBeResized) // resize background window
|
||||
if (previousScreen() && previousScreen()->hasToBeResized) // resize background window
|
||||
{
|
||||
m_old_screen->resize();
|
||||
m_old_screen->refresh();
|
||||
previousScreen()->resize();
|
||||
previousScreen()->refresh();
|
||||
}
|
||||
hasToBeResized = 0;
|
||||
}
|
||||
@@ -162,7 +157,7 @@ void SelectedItemsAdder::refresh()
|
||||
|
||||
std::wstring SelectedItemsAdder::title()
|
||||
{
|
||||
return m_old_screen->title();
|
||||
return previousScreen()->title();
|
||||
}
|
||||
|
||||
void SelectedItemsAdder::enterPressed()
|
||||
@@ -187,7 +182,6 @@ void SelectedItemsAdder::mouseButtonPressed(MEVENT me)
|
||||
void SelectedItemsAdder::populatePlaylistSelector(BasicScreen *old_screen)
|
||||
{
|
||||
typedef SelectedItemsAdder Self;
|
||||
m_old_screen = old_screen;
|
||||
m_playlist_selector.reset();
|
||||
m_playlist_selector.clear();
|
||||
if (old_screen != myPlaylist)
|
||||
@@ -245,7 +239,7 @@ void SelectedItemsAdder::addToExistingPlaylist(const std::string &playlist) cons
|
||||
if (Mpd.CommitCommandsList())
|
||||
{
|
||||
Statusbar::msg("Selected item(s) added to playlist \"%s\"", playlist.c_str());
|
||||
m_old_screen->switchTo();
|
||||
switchToPreviousScreen();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -301,7 +295,7 @@ void SelectedItemsAdder::addAfterHighlightedSong() const
|
||||
void SelectedItemsAdder::cancel()
|
||||
{
|
||||
if (isActiveWindow(m_playlist_selector))
|
||||
m_old_screen->switchTo();
|
||||
switchToPreviousScreen();
|
||||
else if (isActiveWindow(m_position_selector))
|
||||
w = &m_playlist_selector;
|
||||
}
|
||||
@@ -309,7 +303,7 @@ void SelectedItemsAdder::cancel()
|
||||
void SelectedItemsAdder::exitSuccessfully() const
|
||||
{
|
||||
Statusbar::msg("Selected items added");
|
||||
m_old_screen->switchTo();
|
||||
switchToPreviousScreen();
|
||||
}
|
||||
|
||||
void SelectedItemsAdder::setDimensions()
|
||||
|
||||
@@ -22,10 +22,11 @@
|
||||
#define _SEL_ITEMS_ADDER_H
|
||||
|
||||
#include "exec_item.h"
|
||||
#include "interfaces.h"
|
||||
#include "screen.h"
|
||||
#include "song.h"
|
||||
|
||||
struct SelectedItemsAdder : public Screen<NC::Menu<ExecItem<std::string, void()>> *>
|
||||
struct SelectedItemsAdder: Screen<NC::Menu<ExecItem<std::string, void()>> *>, Tabbable
|
||||
{
|
||||
typedef typename std::remove_pointer<WindowType>::type Component;
|
||||
|
||||
@@ -44,7 +45,6 @@ struct SelectedItemsAdder : public Screen<NC::Menu<ExecItem<std::string, void()>
|
||||
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
||||
|
||||
virtual bool isMergable() OVERRIDE { return false; }
|
||||
virtual bool isTabbable() OVERRIDE { return false; }
|
||||
|
||||
protected:
|
||||
virtual bool isLockable() OVERRIDE { return false; }
|
||||
@@ -65,8 +65,6 @@ private:
|
||||
|
||||
void setDimensions();
|
||||
|
||||
BasicScreen *m_old_screen;
|
||||
|
||||
size_t m_playlist_selector_width;
|
||||
size_t m_playlist_selector_height;
|
||||
|
||||
|
||||
@@ -25,10 +25,10 @@
|
||||
#include "helpers.h"
|
||||
#include "server_info.h"
|
||||
#include "statusbar.h"
|
||||
#include "screen_switcher.h"
|
||||
|
||||
using Global::MainHeight;
|
||||
using Global::MainStartY;
|
||||
using Global::myOldScreen;
|
||||
|
||||
ServerInfo *myServerInfo;
|
||||
|
||||
@@ -43,41 +43,28 @@ ServerInfo::ServerInfo()
|
||||
void ServerInfo::switchTo()
|
||||
{
|
||||
using Global::myScreen;
|
||||
|
||||
if (myScreen == this)
|
||||
{
|
||||
myOldScreen->switchTo();
|
||||
return;
|
||||
}
|
||||
|
||||
// resize() can fall back to old screen, so we need it updated
|
||||
myOldScreen = myScreen;
|
||||
|
||||
if (hasToBeResized)
|
||||
resize();
|
||||
|
||||
myScreen = this;
|
||||
//w.Window::clear();
|
||||
if (myScreen != this)
|
||||
SwitchTo::execute(this);
|
||||
else
|
||||
switchToPreviousScreen();
|
||||
}
|
||||
|
||||
void ServerInfo::resize()
|
||||
{
|
||||
SetDimensions();
|
||||
if (itsHeight < 5) // screen too low to display this window
|
||||
return myOldScreen->switchTo();
|
||||
w.resize(itsWidth, itsHeight);
|
||||
w.moveTo((COLS-itsWidth)/2, (MainHeight-itsHeight)/2+MainStartY);
|
||||
if (myOldScreen && myOldScreen->hasToBeResized) // resize background window
|
||||
if (previousScreen() && previousScreen()->hasToBeResized) // resize background window
|
||||
{
|
||||
myOldScreen->resize();
|
||||
myOldScreen->refresh();
|
||||
previousScreen()->resize();
|
||||
previousScreen()->refresh();
|
||||
}
|
||||
hasToBeResized = 0;
|
||||
}
|
||||
|
||||
std::wstring ServerInfo::title()
|
||||
{
|
||||
return myOldScreen->title();
|
||||
return previousScreen()->title();
|
||||
}
|
||||
|
||||
void ServerInfo::update()
|
||||
|
||||
@@ -21,9 +21,10 @@
|
||||
#ifndef _SERVER_INFO
|
||||
#define _SERVER_INFO
|
||||
|
||||
#include "interfaces.h"
|
||||
#include "screen.h"
|
||||
|
||||
struct ServerInfo : public Screen<NC::Scrollpad>
|
||||
struct ServerInfo: Screen<NC::Scrollpad>, Tabbable
|
||||
{
|
||||
ServerInfo();
|
||||
|
||||
@@ -39,7 +40,6 @@ struct ServerInfo : public Screen<NC::Scrollpad>
|
||||
virtual void spacePressed() OVERRIDE { }
|
||||
|
||||
virtual bool isMergable() OVERRIDE { return false; }
|
||||
virtual bool isTabbable() OVERRIDE { return false; }
|
||||
|
||||
protected:
|
||||
virtual bool isLockable() OVERRIDE { return false; }
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "song_info.h"
|
||||
#include "tag_editor.h"
|
||||
#include "title.h"
|
||||
#include "screen_switcher.h"
|
||||
|
||||
#ifdef HAVE_TAGLIB_H
|
||||
# include "fileref.h"
|
||||
@@ -71,35 +72,24 @@ std::wstring SongInfo::title()
|
||||
void SongInfo::switchTo()
|
||||
{
|
||||
using Global::myScreen;
|
||||
using Global::myOldScreen;
|
||||
using Global::myLockedScreen;
|
||||
|
||||
if (myScreen == this)
|
||||
return myOldScreen->switchTo();
|
||||
|
||||
if (myLockedScreen)
|
||||
updateInactiveScreen(this);
|
||||
|
||||
if (myScreen != this)
|
||||
{
|
||||
auto s = currentSong(myScreen);
|
||||
if (!s)
|
||||
return;
|
||||
|
||||
if (hasToBeResized || myLockedScreen)
|
||||
resize();
|
||||
|
||||
myOldScreen = myScreen;
|
||||
myScreen = this;
|
||||
|
||||
SwitchTo::execute(this);
|
||||
w.clear();
|
||||
w.reset();
|
||||
PrepareSong(*s);
|
||||
w.flush();
|
||||
|
||||
// redraw header after we're done with the file, since reading it from disk
|
||||
// takes a bit of time and having header updated before content of a window
|
||||
// is displayed doesn't look nice.
|
||||
drawHeader();
|
||||
}
|
||||
else
|
||||
switchToPreviousScreen();
|
||||
}
|
||||
|
||||
void SongInfo::PrepareSong(MPD::Song &s)
|
||||
{
|
||||
|
||||
@@ -21,10 +21,11 @@
|
||||
#ifndef _SONG_INFO_H
|
||||
#define _SONG_INFO_H
|
||||
|
||||
#include "screen.h"
|
||||
#include "interfaces.h"
|
||||
#include "mutable_song.h"
|
||||
#include "screen.h"
|
||||
|
||||
struct SongInfo : public Screen<NC::Scrollpad>
|
||||
struct SongInfo: Screen<NC::Scrollpad>, Tabbable
|
||||
{
|
||||
struct Metadata
|
||||
{
|
||||
@@ -47,7 +48,6 @@ struct SongInfo : public Screen<NC::Scrollpad>
|
||||
virtual void spacePressed() OVERRIDE { }
|
||||
|
||||
virtual bool isMergable() OVERRIDE { return true; }
|
||||
virtual bool isTabbable() OVERRIDE { return false; }
|
||||
|
||||
// private members
|
||||
static const Metadata Tags[];
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "sort_playlist.h"
|
||||
#include "statusbar.h"
|
||||
#include "utility/comparators.h"
|
||||
#include "screen_switcher.h"
|
||||
|
||||
using Global::MainHeight;
|
||||
using Global::MainStartY;
|
||||
@@ -62,19 +63,7 @@ SortPlaylistDialog::SortPlaylistDialog()
|
||||
|
||||
void SortPlaylistDialog::switchTo()
|
||||
{
|
||||
using Global::myScreen;
|
||||
using Global::myOldScreen;
|
||||
using Global::myLockedScreen;
|
||||
using Global::myInactiveScreen;
|
||||
|
||||
assert(myScreen != this);
|
||||
|
||||
if (hasToBeResized)
|
||||
resize();
|
||||
|
||||
myOldScreen = myScreen;
|
||||
myScreen = this;
|
||||
|
||||
SwitchTo::execute(this);
|
||||
w.reset();
|
||||
refresh();
|
||||
}
|
||||
@@ -90,7 +79,7 @@ void SortPlaylistDialog::resize()
|
||||
|
||||
std::wstring SortPlaylistDialog::title()
|
||||
{
|
||||
return Global::myOldScreen->title();
|
||||
return previousScreen()->title();
|
||||
}
|
||||
|
||||
void SortPlaylistDialog::enterPressed()
|
||||
@@ -154,11 +143,11 @@ void SortPlaylistDialog::enterPressed()
|
||||
if (Mpd.CommitCommandsList())
|
||||
Statusbar::msg("Playlist sorted");
|
||||
|
||||
Global::myOldScreen->switchTo();
|
||||
switchToPreviousScreen();
|
||||
}
|
||||
else if (*option == m_cancel_entry)
|
||||
{
|
||||
Global::myOldScreen->switchTo();
|
||||
switchToPreviousScreen();
|
||||
}
|
||||
else
|
||||
Statusbar::msg("Move tag types up and down to adjust sort order");
|
||||
|
||||
@@ -21,10 +21,11 @@
|
||||
#ifndef _SORT_PLAYLIST
|
||||
#define _SORT_PLAYLIST
|
||||
|
||||
#include "interfaces.h"
|
||||
#include "screen.h"
|
||||
#include "song.h"
|
||||
|
||||
struct SortPlaylistDialog : public Screen<NC::Menu<std::pair<std::string, MPD::Song::GetFunction>>>
|
||||
struct SortPlaylistDialog: Screen<NC::Menu<std::pair<std::string, MPD::Song::GetFunction>>>, Tabbable
|
||||
{
|
||||
SortPlaylistDialog();
|
||||
|
||||
@@ -39,7 +40,6 @@ struct SortPlaylistDialog : public Screen<NC::Menu<std::pair<std::string, MPD::S
|
||||
virtual void spacePressed() OVERRIDE { }
|
||||
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
||||
|
||||
virtual bool isTabbable() OVERRIDE { return false; }
|
||||
virtual bool isMergable() OVERRIDE { return false; }
|
||||
|
||||
// private members
|
||||
|
||||
@@ -290,7 +290,7 @@ void Status::Changes::songID()
|
||||
if (Config.autocenter_mode && !myPlaylist->main().isFiltered())
|
||||
myPlaylist->main().highlight(Mpd.GetCurrentlyPlayingSongPos());
|
||||
|
||||
if (Config.now_playing_lyrics && isVisible(myLyrics) && Global::myOldScreen == myPlaylist)
|
||||
if (Config.now_playing_lyrics && isVisible(myLyrics) && myLyrics->previousScreen() == myPlaylist)
|
||||
myLyrics->ReloadNP = 1;
|
||||
|
||||
elapsedTime();
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "utility/comparators.h"
|
||||
#include "title.h"
|
||||
#include "tags.h"
|
||||
#include "screen_switcher.h"
|
||||
|
||||
using namespace std::placeholders;
|
||||
|
||||
@@ -194,20 +195,7 @@ std::wstring TagEditor::title()
|
||||
|
||||
void TagEditor::switchTo()
|
||||
{
|
||||
using Global::myLockedScreen;
|
||||
|
||||
if (myScreen == this)
|
||||
return;
|
||||
|
||||
if (myLockedScreen)
|
||||
updateInactiveScreen(this);
|
||||
|
||||
if (hasToBeResized || myLockedScreen)
|
||||
resize();
|
||||
|
||||
if (myScreen != this && myScreen->isTabbable())
|
||||
Global::myPrevScreen = myScreen;
|
||||
myScreen = this;
|
||||
SwitchTo::execute(this);
|
||||
drawHeader();
|
||||
refresh();
|
||||
}
|
||||
|
||||
@@ -28,12 +28,11 @@
|
||||
#include <list>
|
||||
|
||||
#include "interfaces.h"
|
||||
#include "mpdpp.h"
|
||||
#include "mutable_song.h"
|
||||
#include "regex_filter.h"
|
||||
#include "screen.h"
|
||||
|
||||
struct TagEditor : public Screen<NC::Window *>, public Filterable, public HasColumns, public HasSongs, public Searchable
|
||||
struct TagEditor: Screen<NC::Window *>, Filterable, HasColumns, HasSongs, Searchable, Tabbable
|
||||
{
|
||||
TagEditor();
|
||||
|
||||
@@ -49,7 +48,6 @@ struct TagEditor : public Screen<NC::Window *>, public Filterable, public HasCol
|
||||
virtual void spacePressed() OVERRIDE;
|
||||
virtual void mouseButtonPressed(MEVENT) OVERRIDE;
|
||||
|
||||
virtual bool isTabbable() OVERRIDE { return true; }
|
||||
virtual bool isMergable() OVERRIDE { return true; }
|
||||
|
||||
// Filterable implementation
|
||||
|
||||
@@ -33,9 +33,6 @@
|
||||
#include <textidentificationframe.h>
|
||||
#include <xiphcomment.h>
|
||||
|
||||
#include "browser.h"
|
||||
#include "playlist.h"
|
||||
|
||||
#include "global.h"
|
||||
#include "settings.h"
|
||||
#include "utility/numeric_conversions.h"
|
||||
@@ -253,7 +250,8 @@ bool write(MPD::MutableSong &s)
|
||||
new_name += s.getDirectory() + "/" + s.getNewURI();
|
||||
if (std::rename(old_name.c_str(), new_name.c_str()) == 0 && !s.isFromDatabase())
|
||||
{
|
||||
if (Global::myOldScreen == myPlaylist)
|
||||
// FIXME
|
||||
/*if (myTinyTagEditor == myPlaylist)
|
||||
{
|
||||
// if we rename local file, it won't get updated
|
||||
// so just remove it from playlist and add again
|
||||
@@ -269,7 +267,7 @@ bool write(MPD::MutableSong &s)
|
||||
Mpd.CommitCommandsList();
|
||||
}
|
||||
else // only myBrowser->main()
|
||||
myBrowser->GetDirectory(myBrowser->CurrentDir());
|
||||
myBrowser->GetDirectory(myBrowser->CurrentDir());*/
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -38,10 +38,10 @@
|
||||
#include "tag_editor.h"
|
||||
#include "title.h"
|
||||
#include "tags.h"
|
||||
#include "screen_switcher.h"
|
||||
|
||||
using Global::MainHeight;
|
||||
using Global::MainStartY;
|
||||
using Global::myOldScreen;
|
||||
|
||||
TinyTagEditor *myTinyTagEditor;
|
||||
|
||||
@@ -66,22 +66,14 @@ void TinyTagEditor::resize()
|
||||
void TinyTagEditor::switchTo()
|
||||
{
|
||||
using Global::myScreen;
|
||||
using Global::myLockedScreen;
|
||||
|
||||
if (itsEdited.isStream())
|
||||
{
|
||||
Statusbar::msg("Streams can't be edited");
|
||||
}
|
||||
else if (getTags())
|
||||
{
|
||||
if (myLockedScreen)
|
||||
updateInactiveScreen(this);
|
||||
|
||||
if (hasToBeResized || myLockedScreen)
|
||||
resize();
|
||||
|
||||
myOldScreen = myScreen;
|
||||
myScreen = this;
|
||||
m_previous_screen = myScreen;
|
||||
SwitchTo::execute(this);
|
||||
drawHeader();
|
||||
}
|
||||
else
|
||||
@@ -139,9 +131,9 @@ void TinyTagEditor::enterPressed()
|
||||
Mpd.UpdateDirectory(itsEdited.getDirectory());
|
||||
else
|
||||
{
|
||||
if (myOldScreen == myPlaylist)
|
||||
if (m_previous_screen == myPlaylist)
|
||||
myPlaylist->main().current().value() = itsEdited;
|
||||
else if (myOldScreen == myBrowser)
|
||||
else if (m_previous_screen == myBrowser)
|
||||
myBrowser->GetDirectory(myBrowser->CurrentDir());
|
||||
}
|
||||
}
|
||||
@@ -149,7 +141,7 @@ void TinyTagEditor::enterPressed()
|
||||
Statusbar::msg("Error while writing tags");
|
||||
}
|
||||
if (option > 21)
|
||||
myOldScreen->switchTo();
|
||||
m_previous_screen->switchTo();
|
||||
}
|
||||
|
||||
void TinyTagEditor::mouseButtonPressed(MEVENT me)
|
||||
|
||||
@@ -25,10 +25,11 @@
|
||||
|
||||
#ifdef HAVE_TAGLIB_H
|
||||
|
||||
#include "interfaces.h"
|
||||
#include "mutable_song.h"
|
||||
#include "screen.h"
|
||||
|
||||
struct TinyTagEditor : public Screen<NC::Menu<NC::Buffer>>
|
||||
struct TinyTagEditor: Screen<NC::Menu<NC::Buffer>>
|
||||
{
|
||||
TinyTagEditor();
|
||||
|
||||
@@ -45,17 +46,17 @@ struct TinyTagEditor : public Screen<NC::Menu<NC::Buffer>>
|
||||
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
||||
|
||||
virtual bool isMergable() OVERRIDE { return true; }
|
||||
virtual bool isTabbable() OVERRIDE { return false; }
|
||||
|
||||
// private members
|
||||
void SetEdited(const MPD::Song &);
|
||||
|
||||
protected:
|
||||
virtual bool isLockable() OVERRIDE { return true; }
|
||||
virtual bool isLockable() OVERRIDE { return false; }
|
||||
|
||||
private:
|
||||
bool getTags();
|
||||
MPD::MutableSong itsEdited;
|
||||
BasicScreen *m_previous_screen;
|
||||
};
|
||||
|
||||
extern TinyTagEditor *myTinyTagEditor;
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include "status.h"
|
||||
#include "statusbar.h"
|
||||
#include "title.h"
|
||||
#include "screen_switcher.h"
|
||||
|
||||
using Global::MainStartY;
|
||||
using Global::MainHeight;
|
||||
@@ -62,31 +63,13 @@ Visualizer::Visualizer()
|
||||
|
||||
void Visualizer::switchTo()
|
||||
{
|
||||
using Global::myScreen;
|
||||
using Global::myLockedScreen;
|
||||
|
||||
if (myScreen == this)
|
||||
return;
|
||||
|
||||
if (myLockedScreen)
|
||||
updateInactiveScreen(this);
|
||||
|
||||
if (hasToBeResized || myLockedScreen)
|
||||
resize();
|
||||
|
||||
if (myScreen != this && myScreen->isTabbable())
|
||||
Global::myPrevScreen = myScreen;
|
||||
myScreen = this;
|
||||
drawHeader();
|
||||
SwitchTo::execute(this);
|
||||
w.clear();
|
||||
|
||||
SetFD();
|
||||
|
||||
m_timer.tv_sec = 0;
|
||||
m_timer.tv_usec = 0;
|
||||
|
||||
m_timer = { 0, 0 };
|
||||
if (m_fifo >= 0)
|
||||
Global::wFooter->setTimeout(WindowTimeout);
|
||||
drawHeader();
|
||||
}
|
||||
|
||||
void Visualizer::resize()
|
||||
|
||||
@@ -25,14 +25,15 @@
|
||||
|
||||
#ifdef ENABLE_VISUALIZER
|
||||
|
||||
#include "window.h"
|
||||
#include "interfaces.h"
|
||||
#include "screen.h"
|
||||
#include "window.h"
|
||||
|
||||
#ifdef HAVE_FFTW3_H
|
||||
# include <fftw3.h>
|
||||
#endif
|
||||
|
||||
struct Visualizer : public Screen<NC::Window>
|
||||
struct Visualizer: Screen<NC::Window>, Tabbable
|
||||
{
|
||||
Visualizer();
|
||||
|
||||
@@ -48,7 +49,6 @@ struct Visualizer : public Screen<NC::Window>
|
||||
virtual void spacePressed() OVERRIDE;
|
||||
virtual void mouseButtonPressed(MEVENT) OVERRIDE { }
|
||||
|
||||
virtual bool isTabbable() OVERRIDE { return true; }
|
||||
virtual bool isMergable() OVERRIDE { return true; }
|
||||
|
||||
// private members
|
||||
|
||||
Reference in New Issue
Block a user