add ScreenType for screen's type identification
This commit is contained in:
@@ -30,6 +30,7 @@ ncmpcpp_SOURCES = \
|
||||
playlist_editor.cpp \
|
||||
regexes.cpp \
|
||||
screen.cpp \
|
||||
screen_type.cpp \
|
||||
scrollpad.cpp \
|
||||
search_engine.cpp \
|
||||
sel_items_adder.cpp \
|
||||
@@ -88,6 +89,7 @@ noinst_HEADERS = \
|
||||
regexes.h \
|
||||
screen.h \
|
||||
screen_switcher.h \
|
||||
screen_type.h \
|
||||
scrollpad.h \
|
||||
search_engine.h \
|
||||
sel_items_adder.h \
|
||||
|
||||
@@ -34,6 +34,7 @@ struct Browser: Screen<NC::Menu<MPD::Item>>, Filterable, HasSongs, Searchable, T
|
||||
virtual void switchTo() OVERRIDE;
|
||||
|
||||
virtual std::wstring title() OVERRIDE;
|
||||
virtual ScreenType type() OVERRIDE { return ScreenType::Browser; }
|
||||
|
||||
virtual void update() OVERRIDE { }
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ struct Clock: Screen<NC::Window>, Tabbable
|
||||
virtual void switchTo() OVERRIDE;
|
||||
|
||||
virtual std::wstring title() OVERRIDE;
|
||||
virtual ScreenType type() OVERRIDE { return ScreenType::Clock; }
|
||||
|
||||
virtual void update() OVERRIDE;
|
||||
virtual void scroll(NC::Where) OVERRIDE { }
|
||||
|
||||
@@ -33,6 +33,7 @@ struct Help: Screen<NC::Scrollpad>, Tabbable
|
||||
virtual void switchTo() OVERRIDE;
|
||||
|
||||
virtual std::wstring title() OVERRIDE;
|
||||
virtual ScreenType type() OVERRIDE { return ScreenType::Help; }
|
||||
|
||||
virtual void update() OVERRIDE { }
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ struct Lastfm: Screen<NC::Scrollpad>, Tabbable
|
||||
virtual void resize() OVERRIDE;
|
||||
|
||||
virtual std::wstring title() OVERRIDE;
|
||||
virtual ScreenType type() OVERRIDE { return ScreenType::Lastfm; }
|
||||
|
||||
virtual void update() OVERRIDE;
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ struct Lyrics: Screen<NC::Scrollpad>, Tabbable
|
||||
virtual void switchTo() OVERRIDE;
|
||||
|
||||
virtual std::wstring title() OVERRIDE;
|
||||
virtual ScreenType type() OVERRIDE { return ScreenType::Lyrics; }
|
||||
|
||||
virtual void update() OVERRIDE;
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ struct MediaLibrary: Screen<NC::Window *>, Filterable, HasColumns, HasSongs, Sea
|
||||
virtual void resize() OVERRIDE;
|
||||
|
||||
virtual std::wstring title() OVERRIDE;
|
||||
virtual ScreenType type() OVERRIDE { return ScreenType::MediaLibrary; }
|
||||
|
||||
virtual void refresh() OVERRIDE;
|
||||
virtual void update() OVERRIDE;
|
||||
|
||||
@@ -39,6 +39,7 @@ struct Outputs: Screen<NC::Menu<MPD::Output>>, Tabbable
|
||||
virtual void resize() OVERRIDE;
|
||||
|
||||
virtual std::wstring title() OVERRIDE;
|
||||
virtual ScreenType type() OVERRIDE { return ScreenType::Outputs; }
|
||||
|
||||
virtual void update() OVERRIDE { }
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ struct Playlist: Screen<NC::Menu<MPD::Song>>, Filterable, HasSongs, Searchable,
|
||||
virtual void resize() OVERRIDE;
|
||||
|
||||
virtual std::wstring title() OVERRIDE;
|
||||
virtual ScreenType type() OVERRIDE { return ScreenType::Playlist; }
|
||||
|
||||
virtual void update() OVERRIDE { }
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ struct PlaylistEditor: Screen<NC::Window *>, Filterable, HasColumns, HasSongs, S
|
||||
virtual void resize() OVERRIDE;
|
||||
|
||||
virtual std::wstring title() OVERRIDE;
|
||||
virtual ScreenType type() OVERRIDE { return ScreenType::PlaylistEditor; }
|
||||
|
||||
virtual void refresh() OVERRIDE;
|
||||
virtual void update() OVERRIDE;
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include "menu.h"
|
||||
#include "scrollpad.h"
|
||||
#include "screen_type.h"
|
||||
|
||||
void genericMouseButtonPressed(NC::Window &w, MEVENT me);
|
||||
void scrollpadMouseButtonPressed(NC::Scrollpad &w, MEVENT me);
|
||||
@@ -60,6 +61,9 @@ struct BaseScreen
|
||||
/// @return title of the screen
|
||||
virtual std::wstring title() = 0;
|
||||
|
||||
/// @return type of the screen
|
||||
virtual ScreenType type() = 0;
|
||||
|
||||
/// If the screen contantly has to update itself
|
||||
/// somehow, it should be called by this function.
|
||||
virtual void update() = 0;
|
||||
|
||||
70
src/screen_type.cpp
Normal file
70
src/screen_type.cpp
Normal file
@@ -0,0 +1,70 @@
|
||||
/***************************************************************************
|
||||
* 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. *
|
||||
***************************************************************************/
|
||||
|
||||
#include "screen_type.h"
|
||||
|
||||
ScreenType stringtoStarterScreenType(const std::string &s)
|
||||
{
|
||||
ScreenType result = ScreenType::Unknown;
|
||||
if (s == "browser")
|
||||
result = ScreenType::Browser;
|
||||
else if (s == "clock")
|
||||
result = ScreenType::Clock;
|
||||
else if (s == "help")
|
||||
result = ScreenType::Help;
|
||||
else if (s == "media_library")
|
||||
result = ScreenType::MediaLibrary;
|
||||
else if (s == "outputs")
|
||||
result = ScreenType::Outputs;
|
||||
else if (s == "playlist")
|
||||
result = ScreenType::Playlist;
|
||||
else if (s == "playlist_editor")
|
||||
result = ScreenType::PlaylistEditor;
|
||||
else if (s == "search_engine")
|
||||
result = ScreenType::SearchEngine;
|
||||
else if (s == "tag_editor")
|
||||
result = ScreenType::TagEditor;
|
||||
else if (s == "visualizer")
|
||||
result = ScreenType::Visualizer;
|
||||
return result;
|
||||
}
|
||||
|
||||
ScreenType stringToScreenType(const std::string &s)
|
||||
{
|
||||
ScreenType result = stringtoStarterScreenType(s);
|
||||
if (result == ScreenType::Unknown)
|
||||
{
|
||||
if (s == "last_fm")
|
||||
result = ScreenType::Lastfm;
|
||||
else if (s == "lyrics")
|
||||
result = ScreenType::Lyrics;
|
||||
else if (s == "selected_items_adder")
|
||||
result = ScreenType::SelectedItemsAdder;
|
||||
else if (s == "server_info")
|
||||
result = ScreenType::ServerInfo;
|
||||
else if (s == "song_info")
|
||||
result = ScreenType::SongInfo;
|
||||
else if (s == "sort_playlist_dialog")
|
||||
result = ScreenType::SortPlaylistDialog;
|
||||
else if (s == "tiny_tag_editor")
|
||||
result = ScreenType::TinyTagEditor;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
50
src/screen_type.h
Normal file
50
src/screen_type.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/***************************************************************************
|
||||
* 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 NCMPCPP_SCREEN_TYPE_H
|
||||
#define NCMPCPP_SCREEN_TYPE_H
|
||||
|
||||
#include <string>
|
||||
|
||||
enum class ScreenType {
|
||||
Browser,
|
||||
Clock,
|
||||
Help,
|
||||
Lastfm,
|
||||
Lyrics,
|
||||
MediaLibrary,
|
||||
Outputs,
|
||||
Playlist,
|
||||
PlaylistEditor,
|
||||
SearchEngine,
|
||||
SelectedItemsAdder,
|
||||
ServerInfo,
|
||||
SongInfo,
|
||||
SortPlaylistDialog,
|
||||
TagEditor,
|
||||
TinyTagEditor,
|
||||
Unknown,
|
||||
Visualizer,
|
||||
};
|
||||
|
||||
ScreenType stringtoStarterScreenType(const std::string &s);
|
||||
ScreenType stringToScreenType(const std::string &s);
|
||||
|
||||
#endif // NCMPCPP_SCREEN_TYPE_H
|
||||
@@ -82,6 +82,7 @@ struct SearchEngine: Screen<NC::Menu<SEItem>>, Filterable, HasSongs, Searchable,
|
||||
virtual void switchTo() OVERRIDE;
|
||||
|
||||
virtual std::wstring title() OVERRIDE;
|
||||
virtual ScreenType type() OVERRIDE { return ScreenType::SearchEngine; }
|
||||
|
||||
virtual void update() OVERRIDE { }
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ struct SelectedItemsAdder: Screen<NC::Menu<ExecItem<std::string, void()>> *>, Ta
|
||||
virtual void refresh() OVERRIDE;
|
||||
|
||||
virtual std::wstring title() OVERRIDE;
|
||||
virtual ScreenType type() OVERRIDE { return ScreenType::SelectedItemsAdder; }
|
||||
|
||||
virtual void update() OVERRIDE { }
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ struct ServerInfo: Screen<NC::Scrollpad>, Tabbable
|
||||
virtual void resize() OVERRIDE;
|
||||
|
||||
virtual std::wstring title() OVERRIDE;
|
||||
virtual ScreenType type() OVERRIDE { return ScreenType::ServerInfo; }
|
||||
|
||||
virtual void update() OVERRIDE;
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ struct SongInfo: Screen<NC::Scrollpad>, Tabbable
|
||||
virtual void resize() OVERRIDE;
|
||||
|
||||
virtual std::wstring title() OVERRIDE;
|
||||
virtual ScreenType type() OVERRIDE { return ScreenType::SongInfo; }
|
||||
|
||||
virtual void update() OVERRIDE { }
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ struct SortPlaylistDialog
|
||||
virtual void resize() OVERRIDE;
|
||||
|
||||
virtual std::wstring title() OVERRIDE;
|
||||
virtual ScreenType type() OVERRIDE { return ScreenType::SortPlaylistDialog; }
|
||||
|
||||
virtual void update() OVERRIDE { }
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ struct TagEditor: Screen<NC::Window *>, Filterable, HasColumns, HasSongs, Search
|
||||
virtual void switchTo() OVERRIDE;
|
||||
|
||||
virtual std::wstring title() OVERRIDE;
|
||||
virtual ScreenType type() OVERRIDE { return ScreenType::TagEditor; }
|
||||
|
||||
virtual void refresh() OVERRIDE;
|
||||
virtual void update() OVERRIDE;
|
||||
|
||||
@@ -38,6 +38,7 @@ struct TinyTagEditor: Screen<NC::Menu<NC::Buffer>>
|
||||
virtual void switchTo() OVERRIDE;
|
||||
|
||||
virtual std::wstring title() OVERRIDE;
|
||||
virtual ScreenType type() OVERRIDE { return ScreenType::TinyTagEditor; }
|
||||
|
||||
virtual void update() OVERRIDE { }
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ struct Visualizer: Screen<NC::Window>, Tabbable
|
||||
virtual void resize() OVERRIDE;
|
||||
|
||||
virtual std::wstring title() OVERRIDE;
|
||||
virtual ScreenType type() OVERRIDE { return ScreenType::Visualizer; }
|
||||
|
||||
virtual void update() OVERRIDE;
|
||||
virtual void scroll(NC::Where) OVERRIDE { }
|
||||
|
||||
Reference in New Issue
Block a user