do not initialize screens lazily as it doesn't make much sense
This commit is contained in:
@@ -93,6 +93,42 @@ void Action::ValidateScreenSize()
|
||||
}
|
||||
}
|
||||
|
||||
void Action::InitializeScreens()
|
||||
{
|
||||
myHelp = new Help;
|
||||
myPlaylist = new Playlist;
|
||||
myBrowser = new Browser;
|
||||
mySearcher = new SearchEngine;
|
||||
myLibrary = new MediaLibrary;
|
||||
myPlaylistEditor = new PlaylistEditor;
|
||||
myLyrics = new Lyrics;
|
||||
mySelectedItemsAdder = new SelectedItemsAdder;
|
||||
mySongInfo = new SongInfo;
|
||||
mySortPlaylistDialog = new SortPlaylistDialog;
|
||||
|
||||
# ifdef HAVE_CURL_CURL_H
|
||||
myLastfm = new Lastfm;
|
||||
# endif // HAVE_CURL_CURL_H
|
||||
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
myTinyTagEditor = new TinyTagEditor;
|
||||
myTagEditor = new TagEditor;
|
||||
# endif // HAVE_TAGLIB_H
|
||||
|
||||
# ifdef ENABLE_VISUALIZER
|
||||
myVisualizer = new Visualizer;
|
||||
# endif // ENABLE_VISUALIZER
|
||||
|
||||
# ifdef ENABLE_OUTPUTS
|
||||
myOutputs = new Outputs;
|
||||
# endif // ENABLE_OUTPUTS
|
||||
|
||||
# ifdef ENABLE_CLOCK
|
||||
myClock = new Clock;
|
||||
# endif // ENABLE_CLOCK
|
||||
|
||||
}
|
||||
|
||||
void Action::SetResizeFlags()
|
||||
{
|
||||
myHelp->hasToBeResized = 1;
|
||||
@@ -891,8 +927,6 @@ void SavePlaylist::Run()
|
||||
if (result == MPD_ERROR_SUCCESS)
|
||||
{
|
||||
Statusbar::msg("Playlist saved as \"%s\"", playlist_name.c_str());
|
||||
if (myPlaylistEditor->main()) // check if initialized
|
||||
myPlaylistEditor->Playlists->clear(); // make playlist's list update itself
|
||||
}
|
||||
else if (result == MPD_SERVER_ERROR_EXIST)
|
||||
{
|
||||
@@ -905,15 +939,12 @@ void SavePlaylist::Run()
|
||||
}
|
||||
else
|
||||
Statusbar::msg("Aborted");
|
||||
if (myPlaylistEditor->main()) // check if initialized
|
||||
myPlaylistEditor->Playlists->clear(); // make playlist's list update itself
|
||||
if (myScreen == myPlaylist)
|
||||
myPlaylist->EnableHighlighting();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (myBrowser->main()
|
||||
&& !myBrowser->isLocal()
|
||||
if (!myBrowser->isLocal()
|
||||
&& myBrowser->CurrentDir() == "/"
|
||||
&& !myBrowser->main()->empty())
|
||||
myBrowser->GetDirectory(myBrowser->CurrentDir());
|
||||
@@ -1522,10 +1553,8 @@ void EditPlaylistName::Run()
|
||||
{
|
||||
const char msg[] = "Playlist renamed to \"%ls\"";
|
||||
Statusbar::msg(msg, wideShorten(ToWString(new_name), COLS-const_strlen(msg)).c_str());
|
||||
if (myBrowser->main() && !myBrowser->isLocal())
|
||||
if (!myBrowser->isLocal())
|
||||
myBrowser->GetDirectory("/");
|
||||
if (myPlaylistEditor->main())
|
||||
myPlaylistEditor->Playlists->clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2145,7 +2174,7 @@ bool SetSelectedItemsPriority::canBeRun() const
|
||||
Statusbar::msg("Priorities are supported in MPD >= 0.17.0");
|
||||
return false;
|
||||
}
|
||||
return myScreen->activeWindow() == myPlaylist->main() && !myPlaylist->main()->empty();
|
||||
return myScreen == myPlaylist && !myPlaylist->main()->empty();
|
||||
}
|
||||
|
||||
void SetSelectedItemsPriority::Run()
|
||||
@@ -2260,7 +2289,7 @@ void NextScreen::Run()
|
||||
}
|
||||
else if (!Config.screens_seq.empty())
|
||||
{
|
||||
std::list<BasicScreen *>::const_iterator screen = std::find(Config.screens_seq.begin(), Config.screens_seq.end(), myScreen);
|
||||
auto screen = std::find(Config.screens_seq.begin(), Config.screens_seq.end(), myScreen);
|
||||
if (++screen == Config.screens_seq.end())
|
||||
Config.screens_seq.front()->switchTo();
|
||||
else
|
||||
@@ -2282,7 +2311,7 @@ void PreviousScreen::Run()
|
||||
}
|
||||
else if (!Config.screens_seq.empty())
|
||||
{
|
||||
std::list<BasicScreen *>::const_iterator screen = std::find(Config.screens_seq.begin(), Config.screens_seq.end(), myScreen);
|
||||
auto screen = std::find(Config.screens_seq.begin(), Config.screens_seq.end(), myScreen);
|
||||
if (screen == Config.screens_seq.begin())
|
||||
Config.screens_seq.back()->switchTo();
|
||||
else
|
||||
|
||||
@@ -73,6 +73,7 @@ struct Action
|
||||
}
|
||||
|
||||
static void ValidateScreenSize();
|
||||
static void InitializeScreens();
|
||||
static void SetResizeFlags();
|
||||
static void ResizeScreen(bool reload_main_window);
|
||||
static void SetWindowsDimensions();
|
||||
|
||||
@@ -49,7 +49,7 @@ using MPD::itDirectory;
|
||||
using MPD::itSong;
|
||||
using MPD::itPlaylist;
|
||||
|
||||
Browser *myBrowser = new Browser;
|
||||
Browser *myBrowser;
|
||||
|
||||
namespace {//
|
||||
|
||||
@@ -61,7 +61,7 @@ bool BrowserEntryMatcher(const Regex &rx, const MPD::Item &item, bool filter);
|
||||
|
||||
}
|
||||
|
||||
void Browser::init()
|
||||
Browser::Browser() : itsBrowseLocally(0), itsScrollBeginning(0), itsBrowsedDir("/")
|
||||
{
|
||||
w = new NC::Menu<MPD::Item>(0, MainStartY, COLS, MainHeight, Config.columns_in_browser && Config.titles_visibility ? Display::Columns(COLS) : "", Config.main_color, NC::brNone);
|
||||
w->setHighlightColor(Config.main_highlight_color);
|
||||
@@ -73,8 +73,6 @@ void Browser::init()
|
||||
|
||||
if (SupportedExtensions.empty())
|
||||
Mpd.GetSupportedExtensions(SupportedExtensions);
|
||||
|
||||
isInitialized = 1;
|
||||
}
|
||||
|
||||
void Browser::resize()
|
||||
@@ -99,9 +97,6 @@ void Browser::switchTo()
|
||||
# endif // !WIN32
|
||||
}
|
||||
|
||||
if (!isInitialized)
|
||||
init();
|
||||
|
||||
if (myLockedScreen)
|
||||
updateInactiveScreen(this);
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
struct Browser : public Screen< NC::Menu<MPD::Item> >, public Filterable, public HasSongs, public Searchable
|
||||
{
|
||||
Browser() : itsBrowseLocally(0), itsScrollBeginning(0), itsBrowsedDir("/") { }
|
||||
Browser();
|
||||
|
||||
// Screen< NC::Menu<MPD::Item> > implementation
|
||||
virtual void resize() OVERRIDE;
|
||||
@@ -80,7 +80,6 @@ struct Browser : public Screen< NC::Menu<MPD::Item> >, public Filterable, public
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void init() OVERRIDE;
|
||||
virtual bool isLockable() OVERRIDE { return true; }
|
||||
|
||||
private:
|
||||
|
||||
@@ -38,7 +38,7 @@ using Global::MainHeight;
|
||||
using Global::MainStartY;
|
||||
using Global::myScreen;
|
||||
|
||||
Clock *myClock = new Clock;
|
||||
Clock *myClock;
|
||||
|
||||
short Clock::disp[11] =
|
||||
{
|
||||
@@ -52,13 +52,12 @@ long Clock::older[6], Clock::next[6], Clock::newer[6], Clock::mask;
|
||||
size_t Clock::Width;
|
||||
const size_t Clock::Height = 8;
|
||||
|
||||
void Clock::init()
|
||||
Clock::Clock()
|
||||
{
|
||||
Width = Config.clock_display_seconds ? 60 : 40;
|
||||
|
||||
itsPane = new NC::Window(0, MainStartY, COLS, MainHeight, "", Config.main_color, NC::brNone);
|
||||
w = new NC::Window((COLS-Width)/2, (MainHeight-Height)/2+MainStartY, Width, Height-1, "", Config.main_color, NC::Border(Config.main_color));
|
||||
isInitialized = 1;
|
||||
}
|
||||
|
||||
void Clock::resize()
|
||||
@@ -82,9 +81,6 @@ void Clock::switchTo()
|
||||
if (myScreen == this)
|
||||
return;
|
||||
|
||||
if (!isInitialized)
|
||||
init();
|
||||
|
||||
if (myLockedScreen)
|
||||
updateInactiveScreen(this);
|
||||
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
|
||||
struct Clock : public Screen<NC::Window>
|
||||
{
|
||||
Clock();
|
||||
|
||||
virtual void resize() OVERRIDE;
|
||||
virtual void switchTo() OVERRIDE;
|
||||
|
||||
@@ -46,7 +48,6 @@ struct Clock : public Screen<NC::Window>
|
||||
virtual bool isMergable() OVERRIDE { return true; }
|
||||
|
||||
protected:
|
||||
virtual void init() OVERRIDE;
|
||||
virtual bool isLockable() OVERRIDE { return false; }
|
||||
|
||||
private:
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
using Global::MainHeight;
|
||||
using Global::MainStartY;
|
||||
|
||||
Help *myHelp = new Help;
|
||||
Help *myHelp;
|
||||
|
||||
namespace {//
|
||||
|
||||
@@ -95,12 +95,11 @@ std::string keyToString(const Key &key, bool *print_backspace)
|
||||
|
||||
}
|
||||
|
||||
void Help::init()
|
||||
Help::Help()
|
||||
{
|
||||
w = new NC::Scrollpad(0, MainStartY, COLS, MainHeight, "", Config.main_color, NC::brNone);
|
||||
GetKeybindings();
|
||||
w->flush();
|
||||
isInitialized = 1;
|
||||
}
|
||||
|
||||
void Help::resize()
|
||||
@@ -120,9 +119,6 @@ void Help::switchTo()
|
||||
if (myScreen == this)
|
||||
return;
|
||||
|
||||
if (!isInitialized)
|
||||
init();
|
||||
|
||||
if (myLockedScreen)
|
||||
updateInactiveScreen(this);
|
||||
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
|
||||
struct Help : public Screen<NC::Scrollpad>
|
||||
{
|
||||
Help();
|
||||
|
||||
virtual void resize() OVERRIDE;
|
||||
virtual void switchTo() OVERRIDE;
|
||||
|
||||
@@ -40,7 +42,6 @@ struct Help : public Screen<NC::Scrollpad>
|
||||
virtual bool isMergable() OVERRIDE { return true; }
|
||||
|
||||
protected:
|
||||
virtual void init() OVERRIDE;
|
||||
virtual bool isLockable() OVERRIDE { return true; }
|
||||
|
||||
private:
|
||||
|
||||
@@ -43,12 +43,11 @@
|
||||
using Global::MainHeight;
|
||||
using Global::MainStartY;
|
||||
|
||||
Lastfm *myLastfm = new Lastfm;
|
||||
Lastfm *myLastfm;
|
||||
|
||||
void Lastfm::init()
|
||||
Lastfm::Lastfm() : isReadyToTake(0), isDownloadInProgress(0)
|
||||
{
|
||||
w = new NC::Scrollpad(0, MainStartY, COLS, MainHeight, "", Config.main_color, NC::brNone);
|
||||
isInitialized = 1;
|
||||
}
|
||||
|
||||
void Lastfm::resize()
|
||||
@@ -90,9 +89,6 @@ void Lastfm::switchTo()
|
||||
if (myScreen == this)
|
||||
return myOldScreen->switchTo();
|
||||
|
||||
if (!isInitialized)
|
||||
init();
|
||||
|
||||
if (myLockedScreen)
|
||||
updateInactiveScreen(this);
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
struct Lastfm : public Screen<NC::Scrollpad>
|
||||
{
|
||||
Lastfm() : isReadyToTake(0), isDownloadInProgress(0) { }
|
||||
Lastfm();
|
||||
|
||||
// Screen<NC::Scrollpad>
|
||||
virtual void switchTo() OVERRIDE;
|
||||
@@ -56,7 +56,6 @@ struct Lastfm : public Screen<NC::Scrollpad>
|
||||
bool SetArtistInfoArgs(const std::string &artist, const std::string &lang = "");
|
||||
|
||||
protected:
|
||||
virtual void init() OVERRIDE;
|
||||
virtual bool isLockable() OVERRIDE { return false; }
|
||||
|
||||
private:
|
||||
|
||||
@@ -48,12 +48,15 @@ pthread_mutex_t Lyrics::itsDIBLock = PTHREAD_MUTEX_INITIALIZER;
|
||||
size_t Lyrics::itsWorkersNumber = 0;
|
||||
#endif // HAVE_CURL_CURL_H
|
||||
|
||||
Lyrics *myLyrics = new Lyrics;
|
||||
Lyrics *myLyrics;
|
||||
|
||||
void Lyrics::init()
|
||||
Lyrics::Lyrics() : ReloadNP(0),
|
||||
#ifdef HAVE_CURL_CURL_H
|
||||
isReadyToTake(0), isDownloadInProgress(0),
|
||||
#endif // HAVE_CURL_CURL_H
|
||||
itsScrollBegin(0)
|
||||
{
|
||||
w = new NC::Scrollpad(0, MainStartY, COLS, MainHeight, "", Config.main_color, NC::brNone);
|
||||
isInitialized = 1;
|
||||
}
|
||||
|
||||
void Lyrics::resize()
|
||||
@@ -99,9 +102,6 @@ void Lyrics::switchTo()
|
||||
if (myScreen == this)
|
||||
return myOldScreen->switchTo();
|
||||
|
||||
if (!isInitialized)
|
||||
init();
|
||||
|
||||
if (hasToBeResized)
|
||||
resize();
|
||||
|
||||
|
||||
@@ -30,11 +30,7 @@
|
||||
|
||||
struct Lyrics : public Screen<NC::Scrollpad>
|
||||
{
|
||||
Lyrics() : ReloadNP(0),
|
||||
# ifdef HAVE_CURL_CURL_H
|
||||
isReadyToTake(0), isDownloadInProgress(0),
|
||||
# endif // HAVE_CURL_CURL_H
|
||||
itsScrollBegin(0) { }
|
||||
Lyrics();
|
||||
|
||||
// Screen<NC::Scrollpad> implementation
|
||||
virtual void resize() OVERRIDE;
|
||||
@@ -63,7 +59,6 @@ struct Lyrics : public Screen<NC::Scrollpad>
|
||||
bool ReloadNP;
|
||||
|
||||
protected:
|
||||
virtual void init() OVERRIDE;
|
||||
virtual bool isLockable() OVERRIDE { return false; }
|
||||
|
||||
private:
|
||||
|
||||
@@ -42,7 +42,7 @@ using Global::MainHeight;
|
||||
using Global::MainStartY;
|
||||
using Global::myScreen;
|
||||
|
||||
MediaLibrary *myLibrary = new MediaLibrary;
|
||||
MediaLibrary *myLibrary;
|
||||
|
||||
namespace {//
|
||||
|
||||
@@ -112,7 +112,7 @@ public:
|
||||
|
||||
}
|
||||
|
||||
void MediaLibrary::init()
|
||||
MediaLibrary::MediaLibrary()
|
||||
{
|
||||
hasTwoColumns = 0;
|
||||
itsLeftColWidth = COLS/3-1;
|
||||
@@ -146,7 +146,6 @@ void MediaLibrary::init()
|
||||
Songs->setItemDisplayer(std::bind(Display::Songs, _1, this, Config.song_library_format));
|
||||
|
||||
w = Tags;
|
||||
isInitialized = 1;
|
||||
}
|
||||
|
||||
void MediaLibrary::resize()
|
||||
@@ -228,9 +227,6 @@ void MediaLibrary::switchTo()
|
||||
}
|
||||
}
|
||||
|
||||
if (!isInitialized)
|
||||
init();
|
||||
|
||||
if (myLockedScreen)
|
||||
updateInactiveScreen(this);
|
||||
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
|
||||
struct MediaLibrary : public Screen<NC::Window>, public Filterable, public HasColumns, public HasSongs, public Searchable
|
||||
{
|
||||
MediaLibrary();
|
||||
|
||||
virtual void switchTo() OVERRIDE;
|
||||
virtual void resize() OVERRIDE;
|
||||
|
||||
@@ -89,8 +91,7 @@ struct MediaLibrary : public Screen<NC::Window>, public Filterable, public HasCo
|
||||
NC::Menu<MPD::Song> *Songs;
|
||||
|
||||
protected:
|
||||
virtual void init();
|
||||
virtual bool isLockable() { return true; }
|
||||
virtual bool isLockable() OVERRIDE { return true; }
|
||||
|
||||
private:
|
||||
void AddToPlaylist(bool);
|
||||
|
||||
@@ -152,6 +152,7 @@ int main(int argc, char **argv)
|
||||
|
||||
Action::SetWindowsDimensions();
|
||||
Action::ValidateScreenSize();
|
||||
Action::InitializeScreens();
|
||||
|
||||
wHeader = new NC::Window(0, 0, COLS, Action::HeaderHeight, "", Config.header_color, NC::brNone);
|
||||
if (Config.header_visibility || Config.new_design)
|
||||
|
||||
@@ -33,9 +33,9 @@ using Global::MainHeight;
|
||||
using Global::MainStartY;
|
||||
using Global::myScreen;
|
||||
|
||||
Outputs *myOutputs = new Outputs;
|
||||
Outputs *myOutputs;
|
||||
|
||||
void Outputs::init()
|
||||
Outputs::Outputs()
|
||||
{
|
||||
w = new NC::Menu<MPD::Output>(0, MainStartY, COLS, MainHeight, "", Config.main_color, NC::brNone);
|
||||
w->cyclicScrolling(Config.use_cyclic_scrolling);
|
||||
@@ -43,7 +43,6 @@ void Outputs::init()
|
||||
w->setHighlightColor(Config.main_highlight_color);
|
||||
w->setItemDisplayer(Display::Outputs);
|
||||
|
||||
isInitialized = 1;
|
||||
FetchList();
|
||||
}
|
||||
|
||||
@@ -54,9 +53,6 @@ void Outputs::switchTo()
|
||||
if (myScreen == this)
|
||||
return;
|
||||
|
||||
if (!isInitialized)
|
||||
init();
|
||||
|
||||
if (myLockedScreen)
|
||||
updateInactiveScreen(this);
|
||||
|
||||
@@ -116,8 +112,6 @@ void Outputs::mouseButtonPressed(MEVENT me)
|
||||
|
||||
void Outputs::FetchList()
|
||||
{
|
||||
if (!isInitialized)
|
||||
return;
|
||||
w->clear();
|
||||
auto outputs = Mpd.GetOutputs();
|
||||
for (auto o = outputs.begin(); o != outputs.end(); ++o)
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
|
||||
struct Outputs : public Screen< NC::Menu<MPD::Output> >
|
||||
{
|
||||
Outputs();
|
||||
|
||||
// Screen< NC::Menu<MPD::Output> > implementation
|
||||
virtual void switchTo() OVERRIDE;
|
||||
virtual void resize() OVERRIDE;
|
||||
@@ -50,7 +52,6 @@ struct Outputs : public Screen< NC::Menu<MPD::Output> >
|
||||
void FetchList();
|
||||
|
||||
protected:
|
||||
virtual void init() OVERRIDE;
|
||||
virtual bool isLockable() OVERRIDE { return true; }
|
||||
};
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ using namespace std::placeholders;
|
||||
using Global::MainHeight;
|
||||
using Global::MainStartY;
|
||||
|
||||
Playlist *myPlaylist = new Playlist;
|
||||
Playlist *myPlaylist;
|
||||
|
||||
bool Playlist::ReloadTotalLength = 0;
|
||||
bool Playlist::ReloadRemaining = false;
|
||||
@@ -50,7 +50,7 @@ bool playlistEntryMatcher(const Regex &rx, const MPD::Song &s);
|
||||
|
||||
}
|
||||
|
||||
void Playlist::init()
|
||||
Playlist::Playlist() : itsTotalLength(0), itsRemainingTime(0), itsScrollBegin(0)
|
||||
{
|
||||
w = new NC::Menu<MPD::Song>(0, MainStartY, COLS, MainHeight, Config.columns_in_playlist && Config.titles_visibility ? Display::Columns(COLS) : "", Config.main_color, NC::brNone);
|
||||
w->cyclicScrolling(Config.use_cyclic_scrolling);
|
||||
@@ -62,8 +62,6 @@ void Playlist::init()
|
||||
w->setItemDisplayer(std::bind(Display::SongsInColumns, _1, this));
|
||||
else
|
||||
w->setItemDisplayer(std::bind(Display::Songs, _1, this, Config.song_list_format));
|
||||
|
||||
isInitialized = 1;
|
||||
}
|
||||
|
||||
void Playlist::switchTo()
|
||||
@@ -75,9 +73,6 @@ void Playlist::switchTo()
|
||||
if (myScreen == this)
|
||||
return;
|
||||
|
||||
if (!isInitialized)
|
||||
init();
|
||||
|
||||
itsScrollBegin = 0;
|
||||
|
||||
if (myLockedScreen)
|
||||
|
||||
@@ -29,8 +29,7 @@
|
||||
|
||||
struct Playlist : public Screen<NC::Menu<MPD::Song>>, public Filterable, public HasSongs, public Searchable
|
||||
{
|
||||
Playlist() : itsTotalLength(0), itsRemainingTime(0), itsScrollBegin(0) { }
|
||||
~Playlist() { }
|
||||
Playlist();
|
||||
|
||||
// Screen<NC::Menu<MPD::Song>> implementation
|
||||
virtual void switchTo() OVERRIDE;
|
||||
@@ -90,7 +89,6 @@ struct Playlist : public Screen<NC::Menu<MPD::Song>>, public Filterable, public
|
||||
static bool ReloadRemaining;
|
||||
|
||||
protected:
|
||||
virtual void init() OVERRIDE;
|
||||
virtual bool isLockable() OVERRIDE { return true; }
|
||||
|
||||
private:
|
||||
|
||||
@@ -40,7 +40,7 @@ using namespace std::placeholders;
|
||||
using Global::MainHeight;
|
||||
using Global::MainStartY;
|
||||
|
||||
PlaylistEditor *myPlaylistEditor = new PlaylistEditor;
|
||||
PlaylistEditor *myPlaylistEditor;
|
||||
|
||||
namespace {//
|
||||
|
||||
@@ -55,7 +55,7 @@ bool SongEntryMatcher(const Regex &rx, const MPD::Song &s);
|
||||
|
||||
}
|
||||
|
||||
void PlaylistEditor::init()
|
||||
PlaylistEditor::PlaylistEditor()
|
||||
{
|
||||
LeftColumnWidth = COLS/3-1;
|
||||
RightColumnStartX = LeftColumnWidth+1;
|
||||
@@ -81,7 +81,6 @@ void PlaylistEditor::init()
|
||||
Content->setItemDisplayer(std::bind(Display::Songs, _1, this, Config.song_list_format));
|
||||
|
||||
w = Playlists;
|
||||
isInitialized = 1;
|
||||
}
|
||||
|
||||
void PlaylistEditor::resize()
|
||||
@@ -123,9 +122,6 @@ void PlaylistEditor::switchTo()
|
||||
if (myScreen == this)
|
||||
return;
|
||||
|
||||
if (!isInitialized)
|
||||
init();
|
||||
|
||||
if (myLockedScreen)
|
||||
updateInactiveScreen(this);
|
||||
|
||||
@@ -509,8 +505,6 @@ void PlaylistEditor::nextColumn()
|
||||
|
||||
void PlaylistEditor::Locate(const std::string &name)
|
||||
{
|
||||
if (!isInitialized)
|
||||
init();
|
||||
update();
|
||||
for (size_t i = 0; i < Playlists->size(); ++i)
|
||||
{
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
|
||||
struct PlaylistEditor : public Screen<NC::Window>, public Filterable, public HasColumns, public HasSongs, public Searchable
|
||||
{
|
||||
PlaylistEditor();
|
||||
|
||||
virtual void switchTo() OVERRIDE;
|
||||
virtual void resize() OVERRIDE;
|
||||
|
||||
@@ -78,7 +80,6 @@ struct PlaylistEditor : public Screen<NC::Window>, public Filterable, public Has
|
||||
NC::Menu<MPD::Song> *Content;
|
||||
|
||||
protected:
|
||||
virtual void init() OVERRIDE;
|
||||
virtual bool isLockable() OVERRIDE { return true; }
|
||||
|
||||
private:
|
||||
|
||||
13
src/screen.h
13
src/screen.h
@@ -32,9 +32,7 @@ void scrollpadMouseButtonPressed(NC::Scrollpad *w, MEVENT me);
|
||||
/// basic class to be non-template to allow it.
|
||||
struct BasicScreen
|
||||
{
|
||||
/// Initializes all variables to zero
|
||||
BasicScreen() : hasToBeResized(0), isInitialized(0) { }
|
||||
|
||||
BasicScreen() : hasToBeResized(false) { }
|
||||
virtual ~BasicScreen() { }
|
||||
|
||||
/// @see Screen::activeWindow()
|
||||
@@ -93,12 +91,6 @@ struct BasicScreen
|
||||
static void unlock();
|
||||
|
||||
protected:
|
||||
/// Since screens initialization is lazy, we don't want to do
|
||||
/// this in the constructor. This function should be invoked
|
||||
/// only once and after that isInitialized flag has to be set
|
||||
/// to true to somehow avoid next attempt of initialization.
|
||||
virtual void init() = 0;
|
||||
|
||||
/// @return true if screen can be locked. Note that returning
|
||||
/// false here doesn't neccesarily mean that screen is also not
|
||||
/// mergable (eg. lyrics screen is not lockable since that wouldn't
|
||||
@@ -110,9 +102,6 @@ protected:
|
||||
/// automatically adjust locked screen's dimensions (if there is one set)
|
||||
/// if current screen is going to be subwindow.
|
||||
void getWindowResizeParams(size_t &x_offset, size_t &width, bool adjust_locked_screen = true);
|
||||
|
||||
/// Flag that inditates whether the screen is initialized or not
|
||||
bool isInitialized;
|
||||
};
|
||||
|
||||
void applyToVisibleWindows(void (BasicScreen::*f)());
|
||||
|
||||
@@ -38,7 +38,7 @@ using namespace std::placeholders;
|
||||
using Global::MainHeight;
|
||||
using Global::MainStartY;
|
||||
|
||||
SearchEngine *mySearcher = new SearchEngine;
|
||||
SearchEngine *mySearcher;
|
||||
|
||||
namespace {//
|
||||
|
||||
@@ -101,7 +101,7 @@ size_t SearchEngine::StaticOptions = 20;
|
||||
size_t SearchEngine::ResetButton = 16;
|
||||
size_t SearchEngine::SearchButton = 15;
|
||||
|
||||
void SearchEngine::init()
|
||||
SearchEngine::SearchEngine()
|
||||
{
|
||||
w = new NC::Menu<SEItem>(0, MainStartY, COLS, MainHeight, "", Config.main_color, NC::brNone);
|
||||
w->setHighlightColor(Config.main_highlight_color);
|
||||
@@ -111,7 +111,6 @@ void SearchEngine::init()
|
||||
w->setSelectedPrefix(Config.selected_item_prefix);
|
||||
w->setSelectedSuffix(Config.selected_item_suffix);
|
||||
SearchMode = &SearchModes[Config.search_engine_default_search_mode];
|
||||
isInitialized = 1;
|
||||
}
|
||||
|
||||
void SearchEngine::resize()
|
||||
@@ -135,9 +134,6 @@ void SearchEngine::switchTo()
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isInitialized)
|
||||
init();
|
||||
|
||||
if (myLockedScreen)
|
||||
updateInactiveScreen(this);
|
||||
|
||||
|
||||
@@ -75,6 +75,8 @@ struct SEItem
|
||||
|
||||
struct SearchEngine : public Screen< NC::Menu<SEItem> >, public Filterable, public HasSongs, public Searchable
|
||||
{
|
||||
SearchEngine();
|
||||
|
||||
// Screen< NC::Menu<SEItem> > implementation
|
||||
virtual void resize() OVERRIDE;
|
||||
virtual void switchTo() OVERRIDE;
|
||||
@@ -115,7 +117,6 @@ struct SearchEngine : public Screen< NC::Menu<SEItem> >, public Filterable, publ
|
||||
static size_t ResetButton;
|
||||
|
||||
protected:
|
||||
virtual void init() OVERRIDE;
|
||||
virtual bool isLockable() OVERRIDE { return true; }
|
||||
|
||||
private:
|
||||
|
||||
@@ -37,9 +37,9 @@ using Global::MainStartY;
|
||||
using Global::myScreen;
|
||||
using Global::myOldScreen;
|
||||
|
||||
SelectedItemsAdder *mySelectedItemsAdder = new SelectedItemsAdder;
|
||||
SelectedItemsAdder *mySelectedItemsAdder;
|
||||
|
||||
void SelectedItemsAdder::init()
|
||||
SelectedItemsAdder::SelectedItemsAdder() : itsPSWidth(35), itsPSHeight(11)
|
||||
{
|
||||
SetDimensions();
|
||||
itsPlaylistSelector = new NC::Menu<std::string>((COLS-itsWidth)/2, (MainHeight-itsHeight)/2+MainStartY, itsWidth, itsHeight, "Add selected item(s) to...", Config.main_color, Config.window_border);
|
||||
@@ -62,7 +62,6 @@ void SelectedItemsAdder::init()
|
||||
itsPositionSelector->addItem("Cancel");
|
||||
|
||||
w = itsPlaylistSelector;
|
||||
isInitialized = 1;
|
||||
}
|
||||
|
||||
void SelectedItemsAdder::switchTo()
|
||||
@@ -76,9 +75,6 @@ void SelectedItemsAdder::switchTo()
|
||||
if (!hs || !hs->allowsSelection())
|
||||
return;
|
||||
|
||||
if (!isInitialized)
|
||||
init();
|
||||
|
||||
// default to main window
|
||||
w = itsPlaylistSelector;
|
||||
|
||||
@@ -189,14 +185,6 @@ void SelectedItemsAdder::enterPressed()
|
||||
if (Mpd.CommitCommandsList())
|
||||
Statusbar::msg("Selected item(s) added to playlist \"%s\"", w->current().value().c_str());
|
||||
}
|
||||
if (pos != w->size()-1)
|
||||
{
|
||||
// refresh playlist's lists
|
||||
if (myBrowser->main() && !myBrowser->isLocal() && myBrowser->CurrentDir() == "/")
|
||||
myBrowser->GetDirectory("/");
|
||||
if (myPlaylistEditor->main())
|
||||
myPlaylistEditor->Playlists->clear(); // make playlist editor update itself
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
struct SelectedItemsAdder : public Screen< NC::Menu<std::string> >
|
||||
{
|
||||
SelectedItemsAdder() : itsPSWidth(35), itsPSHeight(11) { }
|
||||
SelectedItemsAdder();
|
||||
|
||||
// Screen< NC::Menu<std::string> > implementation
|
||||
virtual void switchTo() OVERRIDE;
|
||||
@@ -44,7 +44,6 @@ struct SelectedItemsAdder : public Screen< NC::Menu<std::string> >
|
||||
virtual bool isTabbable() OVERRIDE { return false; }
|
||||
|
||||
protected:
|
||||
virtual void init() OVERRIDE;
|
||||
virtual bool isLockable() OVERRIDE { return false; }
|
||||
|
||||
private:
|
||||
|
||||
@@ -32,15 +32,13 @@ using Global::myOldScreen;
|
||||
|
||||
ServerInfo *myServerInfo = new ServerInfo;
|
||||
|
||||
void ServerInfo::init()
|
||||
ServerInfo::ServerInfo()
|
||||
{
|
||||
SetDimensions();
|
||||
w = new NC::Scrollpad((COLS-itsWidth)/2, (MainHeight-itsHeight)/2+MainStartY, itsWidth, itsHeight, "MPD server info", Config.main_color, Config.window_border);
|
||||
|
||||
itsURLHandlers = Mpd.GetURLHandlers();
|
||||
itsTagTypes = Mpd.GetTagTypes();
|
||||
|
||||
isInitialized = 1;
|
||||
}
|
||||
|
||||
void ServerInfo::switchTo()
|
||||
@@ -53,9 +51,6 @@ void ServerInfo::switchTo()
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isInitialized)
|
||||
init();
|
||||
|
||||
// resize() can fall back to old screen, so we need it updated
|
||||
myOldScreen = myScreen;
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
|
||||
struct ServerInfo : public Screen<NC::Scrollpad>
|
||||
{
|
||||
ServerInfo();
|
||||
|
||||
// Screen<NC::Scrollpad> implementation
|
||||
virtual void switchTo() OVERRIDE;
|
||||
virtual void resize() OVERRIDE;
|
||||
@@ -40,7 +42,6 @@ struct ServerInfo : public Screen<NC::Scrollpad>
|
||||
virtual bool isTabbable() OVERRIDE { return false; }
|
||||
|
||||
protected:
|
||||
virtual void init() OVERRIDE;
|
||||
virtual bool isLockable() OVERRIDE { return false; }
|
||||
|
||||
private:
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace
|
||||
return NC::Border(stringToColor(border));
|
||||
}
|
||||
|
||||
BasicScreen *intToScreen(int n)
|
||||
ScreenRef intToScreen(int n)
|
||||
{
|
||||
switch (n)
|
||||
{
|
||||
@@ -120,7 +120,7 @@ namespace
|
||||
return myClock;
|
||||
# endif // ENABLE_CLOCK
|
||||
default:
|
||||
return 0;
|
||||
return ScreenRef();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -667,7 +667,7 @@ void Configuration::Read()
|
||||
++it;
|
||||
if (it == v.end())
|
||||
break;
|
||||
if (BasicScreen *screen = intToScreen(atoi(&*it)))
|
||||
if (auto screen = intToScreen(atoi(&*it)))
|
||||
screens_seq.push_back(screen);
|
||||
while (it != v.end() && isdigit(*it))
|
||||
++it;
|
||||
|
||||
@@ -45,6 +45,27 @@ struct Column
|
||||
bool display_empty_tag;
|
||||
};
|
||||
|
||||
// FIXME: temporary hack
|
||||
struct ScreenRef
|
||||
{
|
||||
ScreenRef() : m_ptr(0) { }
|
||||
template <typename ScreenT>
|
||||
ScreenRef(ScreenT *&ptr) : m_ptr(reinterpret_cast<BasicScreen **>(&ptr)) { }
|
||||
|
||||
BasicScreen &operator*() const { return **m_ptr; }
|
||||
BasicScreen *operator->() const { return *m_ptr; }
|
||||
|
||||
bool operator==(const ScreenRef &rhs) const { return m_ptr == rhs.m_ptr; }
|
||||
bool operator!=(const ScreenRef &rhs) const { return m_ptr != rhs.m_ptr; }
|
||||
bool operator==(const BasicScreen *rhs) const { return *m_ptr == rhs; }
|
||||
bool operator!=(const BasicScreen *rhs) const { return *m_ptr != rhs; }
|
||||
|
||||
operator bool() { return m_ptr != 0; }
|
||||
|
||||
private:
|
||||
BasicScreen **m_ptr;
|
||||
};
|
||||
|
||||
struct Configuration
|
||||
{
|
||||
Configuration();
|
||||
@@ -187,8 +208,8 @@ struct Configuration
|
||||
size_t now_playing_prefix_length;
|
||||
size_t now_playing_suffix_length;
|
||||
|
||||
BasicScreen *startup_screen;
|
||||
std::list<BasicScreen *> screens_seq;
|
||||
ScreenRef startup_screen;
|
||||
std::list<ScreenRef> screens_seq;
|
||||
|
||||
SortMode browser_sort_mode;
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
using Global::MainHeight;
|
||||
using Global::MainStartY;
|
||||
|
||||
SongInfo *mySongInfo = new SongInfo;
|
||||
SongInfo *mySongInfo;
|
||||
|
||||
const SongInfo::Metadata SongInfo::Tags[] =
|
||||
{
|
||||
@@ -47,13 +47,12 @@ const SongInfo::Metadata SongInfo::Tags[] =
|
||||
{ "Performer", &MPD::Song::getPerformer, &MPD::MutableSong::setPerformer },
|
||||
{ "Disc", &MPD::Song::getDisc, &MPD::MutableSong::setDisc },
|
||||
{ "Comment", &MPD::Song::getComment, &MPD::MutableSong::setComment },
|
||||
{ 0, 0, 0 }
|
||||
{ 0, 0, 0 }
|
||||
};
|
||||
|
||||
void SongInfo::init()
|
||||
SongInfo::SongInfo()
|
||||
{
|
||||
w = new NC::Scrollpad(0, MainStartY, COLS, MainHeight, "", Config.main_color, NC::brNone);
|
||||
isInitialized = 1;
|
||||
}
|
||||
|
||||
void SongInfo::resize()
|
||||
@@ -79,9 +78,6 @@ void SongInfo::switchTo()
|
||||
if (myScreen == this)
|
||||
return myOldScreen->switchTo();
|
||||
|
||||
if (!isInitialized)
|
||||
init();
|
||||
|
||||
if (myLockedScreen)
|
||||
updateInactiveScreen(this);
|
||||
|
||||
|
||||
@@ -33,6 +33,8 @@ struct SongInfo : public Screen<NC::Scrollpad>
|
||||
MPD::MutableSong::SetFunction Set;
|
||||
};
|
||||
|
||||
SongInfo();
|
||||
|
||||
// Screen<NC::Scrollpad> implementation
|
||||
virtual void switchTo() OVERRIDE;
|
||||
virtual void resize() OVERRIDE;
|
||||
@@ -51,7 +53,6 @@ struct SongInfo : public Screen<NC::Scrollpad>
|
||||
static const Metadata Tags[];
|
||||
|
||||
protected:
|
||||
virtual void init() OVERRIDE;
|
||||
virtual bool isLockable() OVERRIDE { return false; }
|
||||
|
||||
private:
|
||||
|
||||
@@ -29,9 +29,9 @@
|
||||
using Global::MainHeight;
|
||||
using Global::MainStartY;
|
||||
|
||||
SortPlaylistDialog *mySortPlaylistDialog = new SortPlaylistDialog;
|
||||
SortPlaylistDialog *mySortPlaylistDialog;
|
||||
|
||||
void SortPlaylistDialog::init()
|
||||
SortPlaylistDialog::SortPlaylistDialog()
|
||||
{
|
||||
setDimensions();
|
||||
|
||||
@@ -54,12 +54,10 @@ void SortPlaylistDialog::init()
|
||||
m_sort_options = w->size();
|
||||
m_sort_entry = std::make_pair("Sort", static_cast<MPD::Song::GetFunction>(0));
|
||||
m_cancel_entry = std::make_pair("Cancel", static_cast<MPD::Song::GetFunction>(0));
|
||||
|
||||
|
||||
w->addSeparator();
|
||||
w->addItem(m_sort_entry);
|
||||
w->addItem(m_cancel_entry);
|
||||
|
||||
isInitialized = true;
|
||||
}
|
||||
|
||||
void SortPlaylistDialog::switchTo()
|
||||
@@ -71,9 +69,6 @@ void SortPlaylistDialog::switchTo()
|
||||
|
||||
assert(myScreen != this);
|
||||
|
||||
if (!isInitialized)
|
||||
init();
|
||||
|
||||
if (hasToBeResized)
|
||||
resize();
|
||||
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
|
||||
struct SortPlaylistDialog : public Screen< NC::Menu< std::pair<std::string, MPD::Song::GetFunction> > >
|
||||
{
|
||||
SortPlaylistDialog();
|
||||
|
||||
virtual void switchTo() OVERRIDE;
|
||||
virtual void resize() OVERRIDE;
|
||||
|
||||
@@ -45,8 +47,7 @@ struct SortPlaylistDialog : public Screen< NC::Menu< std::pair<std::string, MPD:
|
||||
void moveSortOrderDown();
|
||||
|
||||
protected:
|
||||
virtual void init();
|
||||
virtual bool isLockable() { return false; }
|
||||
virtual bool isLockable() OVERRIDE { return false; }
|
||||
|
||||
private:
|
||||
void setDimensions();
|
||||
|
||||
@@ -176,12 +176,9 @@ void Status::Changes::playlist()
|
||||
|
||||
void Status::Changes::storedPlaylists()
|
||||
{
|
||||
if (myPlaylistEditor->main())
|
||||
{
|
||||
myPlaylistEditor->requestPlaylistsUpdate();
|
||||
myPlaylistEditor->requestContentsUpdate();
|
||||
}
|
||||
if (myBrowser->main() && myBrowser->CurrentDir() == "/")
|
||||
myPlaylistEditor->requestPlaylistsUpdate();
|
||||
myPlaylistEditor->requestContentsUpdate();
|
||||
if (myBrowser->CurrentDir() == "/")
|
||||
{
|
||||
myBrowser->GetDirectory("/");
|
||||
if (isVisible(myBrowser))
|
||||
@@ -191,26 +188,17 @@ void Status::Changes::storedPlaylists()
|
||||
|
||||
void Status::Changes::database()
|
||||
{
|
||||
if (myBrowser->main())
|
||||
{
|
||||
if (isVisible(myBrowser))
|
||||
myBrowser->GetDirectory(myBrowser->CurrentDir());
|
||||
else
|
||||
myBrowser->main()->clear();
|
||||
}
|
||||
if (isVisible(myBrowser))
|
||||
myBrowser->GetDirectory(myBrowser->CurrentDir());
|
||||
else
|
||||
myBrowser->main()->clear();
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
if (myTagEditor->main())
|
||||
{
|
||||
myTagEditor->Dirs->clear();
|
||||
}
|
||||
myTagEditor->Dirs->clear();
|
||||
# endif // HAVE_TAGLIB_H
|
||||
if (myLibrary->main())
|
||||
{
|
||||
if (myLibrary->Columns() == 2)
|
||||
myLibrary->Albums->clear();
|
||||
else
|
||||
myLibrary->Tags->clear();
|
||||
}
|
||||
if (myLibrary->Columns() == 2)
|
||||
myLibrary->Albums->clear();
|
||||
else
|
||||
myLibrary->Tags->clear();
|
||||
}
|
||||
|
||||
void Status::Changes::playerState()
|
||||
|
||||
@@ -44,7 +44,7 @@ using Global::myScreen;
|
||||
using Global::MainHeight;
|
||||
using Global::MainStartY;
|
||||
|
||||
TagEditor *myTagEditor = new TagEditor;
|
||||
TagEditor *myTagEditor;
|
||||
|
||||
namespace {//
|
||||
|
||||
@@ -84,7 +84,7 @@ bool SongEntryMatcher(const Regex &rx, const MPD::MutableSong &s);
|
||||
|
||||
}
|
||||
|
||||
void TagEditor::init()
|
||||
TagEditor::TagEditor() : FParser(0), FParserHelper(0), FParserLegend(0), FParserPreview(0), itsBrowsedDir("/")
|
||||
{
|
||||
PatternsFile = Config.ncmpcpp_directory + "patterns.list";
|
||||
SetDimensions(0, COLS);
|
||||
@@ -142,7 +142,6 @@ void TagEditor::init()
|
||||
FParserPreview = new NC::Scrollpad((COLS-FParserWidth)/2+FParserWidthOne, (MainHeight-FParserHeight)/2+MainStartY, FParserWidthTwo, FParserHeight, "Preview", Config.main_color, Config.window_border);
|
||||
|
||||
w = Dirs;
|
||||
isInitialized = 1;
|
||||
}
|
||||
|
||||
void TagEditor::SetDimensions(size_t x_offset, size_t width)
|
||||
@@ -200,9 +199,6 @@ void TagEditor::switchTo()
|
||||
if (myScreen == this)
|
||||
return;
|
||||
|
||||
if (!isInitialized)
|
||||
init();
|
||||
|
||||
if (myLockedScreen)
|
||||
updateInactiveScreen(this);
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
struct TagEditor : public Screen<NC::Window>, public Filterable, public HasColumns, public HasSongs, public Searchable
|
||||
{
|
||||
TagEditor() : FParser(0), FParserHelper(0), FParserLegend(0), FParserPreview(0), itsBrowsedDir("/") { }
|
||||
TagEditor();
|
||||
|
||||
virtual void resize() OVERRIDE;
|
||||
virtual void switchTo() OVERRIDE;
|
||||
@@ -87,8 +87,7 @@ struct TagEditor : public Screen<NC::Window>, public Filterable, public HasColum
|
||||
NC::Menu<MPD::MutableSong> *Tags;
|
||||
|
||||
protected:
|
||||
virtual void init();
|
||||
virtual bool isLockable() { return true; }
|
||||
virtual bool isLockable() OVERRIDE { return true; }
|
||||
|
||||
private:
|
||||
void SetDimensions(size_t, size_t);
|
||||
|
||||
@@ -43,16 +43,15 @@ using Global::MainHeight;
|
||||
using Global::MainStartY;
|
||||
using Global::myOldScreen;
|
||||
|
||||
TinyTagEditor *myTinyTagEditor = new TinyTagEditor;
|
||||
TinyTagEditor *myTinyTagEditor;
|
||||
|
||||
void TinyTagEditor::init()
|
||||
TinyTagEditor::TinyTagEditor()
|
||||
{
|
||||
w = new NC::Menu<NC::Buffer>(0, MainStartY, COLS, MainHeight, "", Config.main_color, NC::brNone);
|
||||
w->setHighlightColor(Config.main_highlight_color);
|
||||
w->cyclicScrolling(Config.use_cyclic_scrolling);
|
||||
w->centeredCursor(Config.centered_cursor);
|
||||
w->setItemDisplayer(Display::Default<NC::Buffer>);
|
||||
isInitialized = 1;
|
||||
}
|
||||
|
||||
void TinyTagEditor::resize()
|
||||
@@ -191,9 +190,6 @@ bool TinyTagEditor::getTags()
|
||||
std::string ext = itsEdited.getURI();
|
||||
ext = lowercase(ext.substr(ext.rfind(".")+1));
|
||||
|
||||
if (!isInitialized)
|
||||
init();
|
||||
|
||||
w->clear();
|
||||
w->reset();
|
||||
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
|
||||
struct TinyTagEditor : public Screen< NC::Menu<NC::Buffer> >
|
||||
{
|
||||
TinyTagEditor();
|
||||
|
||||
// Screen< NC::Menu<NC::Buffer> > implementation
|
||||
virtual void resize() OVERRIDE;
|
||||
virtual void switchTo() OVERRIDE;
|
||||
@@ -49,7 +51,6 @@ struct TinyTagEditor : public Screen< NC::Menu<NC::Buffer> >
|
||||
void SetEdited(const MPD::Song &);
|
||||
|
||||
protected:
|
||||
virtual void init() OVERRIDE;
|
||||
virtual bool isLockable() OVERRIDE { return true; }
|
||||
|
||||
private:
|
||||
|
||||
@@ -40,11 +40,11 @@
|
||||
using Global::MainStartY;
|
||||
using Global::MainHeight;
|
||||
|
||||
Visualizer *myVisualizer = new Visualizer;
|
||||
Visualizer *myVisualizer;
|
||||
|
||||
const int Visualizer::WindowTimeout = 1000/25; /* 25 fps */
|
||||
|
||||
void Visualizer::init()
|
||||
Visualizer::Visualizer()
|
||||
{
|
||||
w = new NC::Window(0, MainStartY, COLS, MainHeight, "", Config.visualizer_color, NC::brNone);
|
||||
|
||||
@@ -59,8 +59,6 @@ void Visualizer::init()
|
||||
# endif // HAVE_FFTW3_H
|
||||
|
||||
FindOutputID();
|
||||
|
||||
isInitialized = 1;
|
||||
}
|
||||
|
||||
void Visualizer::switchTo()
|
||||
@@ -71,9 +69,6 @@ void Visualizer::switchTo()
|
||||
if (myScreen == this)
|
||||
return;
|
||||
|
||||
if (!isInitialized)
|
||||
init();
|
||||
|
||||
if (myLockedScreen)
|
||||
updateInactiveScreen(this);
|
||||
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
|
||||
struct Visualizer : public Screen<NC::Window>
|
||||
{
|
||||
Visualizer();
|
||||
|
||||
virtual void switchTo() OVERRIDE;
|
||||
virtual void resize() OVERRIDE;
|
||||
|
||||
@@ -57,8 +59,7 @@ struct Visualizer : public Screen<NC::Window>
|
||||
static const int WindowTimeout;
|
||||
|
||||
protected:
|
||||
virtual void init();
|
||||
virtual bool isLockable() { return true; }
|
||||
virtual bool isLockable() OVERRIDE { return true; }
|
||||
|
||||
private:
|
||||
void DrawSoundWave(int16_t *, ssize_t, size_t, size_t);
|
||||
|
||||
Reference in New Issue
Block a user