split PressSpace action into modular pieces
This commit is contained in:
1
NEWS
1
NEWS
@@ -24,6 +24,7 @@ ncmpcpp-0.7 (????-??-??)
|
|||||||
* Support for Alt, Ctrl and Shift modifiers as well as Escape key was added.
|
* Support for Alt, Ctrl and Shift modifiers as well as Escape key was added.
|
||||||
* Action that updates the environment can now be used in bindings configuration file.
|
* Action that updates the environment can now be used in bindings configuration file.
|
||||||
* Searching in text fields now respects regular expression configuration.
|
* Searching in text fields now respects regular expression configuration.
|
||||||
|
* Monolithic 'press_space' action was split into 'add_item_to_playlist', 'toggle_lyrics_update_on_song_change' and 'toggle_visualization_type'.
|
||||||
|
|
||||||
ncmpcpp-0.6.4 (2015-05-02)
|
ncmpcpp-0.6.4 (2015-05-02)
|
||||||
|
|
||||||
|
|||||||
12
doc/bindings
12
doc/bindings
@@ -184,12 +184,18 @@
|
|||||||
#def_key "insert"
|
#def_key "insert"
|
||||||
# select_item
|
# select_item
|
||||||
#
|
#
|
||||||
#def_key "space"
|
|
||||||
# press_space
|
|
||||||
#
|
|
||||||
#def_key "enter"
|
#def_key "enter"
|
||||||
# press_enter
|
# press_enter
|
||||||
#
|
#
|
||||||
|
#def_key "space"
|
||||||
|
# add_item_to_playlist
|
||||||
|
#
|
||||||
|
#def_key "space"
|
||||||
|
# toggle_lyrics_update_on_song_change
|
||||||
|
#
|
||||||
|
#def_key "space"
|
||||||
|
# toggle_visualization_type
|
||||||
|
#
|
||||||
#def_key "delete"
|
#def_key "delete"
|
||||||
# delete_playlist_items
|
# delete_playlist_items
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -377,10 +377,6 @@
|
|||||||
##
|
##
|
||||||
#lastfm_preferred_language = en
|
#lastfm_preferred_language = en
|
||||||
#
|
#
|
||||||
## Available values: add_remove, always_add.
|
|
||||||
##
|
|
||||||
#space_add_mode = always_add
|
|
||||||
#
|
|
||||||
#show_hidden_files_in_local_browser = no
|
#show_hidden_files_in_local_browser = no
|
||||||
#
|
#
|
||||||
##
|
##
|
||||||
|
|||||||
@@ -245,9 +245,6 @@ If set to yes, it will be possible to physically delete files and directories fr
|
|||||||
.B lastfm_preferred_language = ISO 639 alpha-2 language code
|
.B lastfm_preferred_language = ISO 639 alpha-2 language code
|
||||||
If set, ncmpcpp will try to get info from last.fm in language you set and if it fails, it will fall back to english. Otherwise it will use english the first time.
|
If set, ncmpcpp will try to get info from last.fm in language you set and if it fails, it will fall back to english. Otherwise it will use english the first time.
|
||||||
.TP
|
.TP
|
||||||
.B space_add_mode = add_remove/always_add
|
|
||||||
If set to add_remove, pressing space on item which is already in playlist will remove it, otherwise add it again.
|
|
||||||
.TP
|
|
||||||
.B show_hidden_files_in_local_browser = yes/no
|
.B show_hidden_files_in_local_browser = yes/no
|
||||||
Trigger for displaying in local browser files and directories that begin with '.'
|
Trigger for displaying in local browser files and directories that begin with '.'
|
||||||
.TP
|
.TP
|
||||||
|
|||||||
@@ -512,11 +512,6 @@ void PressEnter::run()
|
|||||||
myScreen->enterPressed();
|
myScreen->enterPressed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PressSpace::run()
|
|
||||||
{
|
|
||||||
myScreen->spacePressed();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PreviousColumn::canBeRun()
|
bool PreviousColumn::canBeRun()
|
||||||
{
|
{
|
||||||
auto hc = hasColumns(myScreen);
|
auto hc = hasColumns(myScreen);
|
||||||
@@ -593,6 +588,23 @@ void VolumeDown::run()
|
|||||||
Mpd.SetVolume(volume);
|
Mpd.SetVolume(volume);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AddItemToPlaylist::canBeRun()
|
||||||
|
{
|
||||||
|
if (m_hs != static_cast<void *>(myScreen))
|
||||||
|
m_hs = dynamic_cast<HasSongs *>(myScreen);
|
||||||
|
return m_hs != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddItemToPlaylist::run()
|
||||||
|
{
|
||||||
|
bool success = m_hs->addItemToPlaylist();
|
||||||
|
if (success)
|
||||||
|
{
|
||||||
|
myScreen->scroll(NC::Scroll::Down);
|
||||||
|
listsChangeFinisher();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool DeletePlaylistItems::canBeRun()
|
bool DeletePlaylistItems::canBeRun()
|
||||||
{
|
{
|
||||||
return (myScreen == myPlaylist && !myPlaylist->main().empty())
|
return (myScreen == myPlaylist && !myPlaylist->main().empty())
|
||||||
@@ -1060,6 +1072,19 @@ void ToggleSeparatorsBetweenAlbums::run()
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ToggleLyricsUpdateOnSongChange::canBeRun()
|
||||||
|
{
|
||||||
|
return myScreen == myLyrics;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToggleLyricsUpdateOnSongChange::run()
|
||||||
|
{
|
||||||
|
Config.now_playing_lyrics = !Config.now_playing_lyrics;
|
||||||
|
Statusbar::printf("Update lyrics if song changes: %1%",
|
||||||
|
Config.now_playing_lyrics ? "on" : "off"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef HAVE_CURL_CURL_H
|
#ifndef HAVE_CURL_CURL_H
|
||||||
bool ToggleLyricsFetcher::canBeRun()
|
bool ToggleLyricsFetcher::canBeRun()
|
||||||
{
|
{
|
||||||
@@ -2121,6 +2146,22 @@ void SetSelectedItemsPriority::run()
|
|||||||
myPlaylist->SetSelectedItemsPriority(prio);
|
myPlaylist->SetSelectedItemsPriority(prio);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ToggleVisualizationType::canBeRun()
|
||||||
|
{
|
||||||
|
# ifdef ENABLE_VISUALIZER
|
||||||
|
return myScreen == myVisualizer;
|
||||||
|
# else
|
||||||
|
return false;
|
||||||
|
# endif // ENABLE_VISUALIZER
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToggleVisualizationType::run()
|
||||||
|
{
|
||||||
|
# ifdef ENABLE_VISUALIZER
|
||||||
|
myVisualizer->ToggleVisualizationType();
|
||||||
|
# endif // ENABLE_VISUALIZER
|
||||||
|
}
|
||||||
|
|
||||||
bool SetVisualizerSampleMultiplier::canBeRun()
|
bool SetVisualizerSampleMultiplier::canBeRun()
|
||||||
{
|
{
|
||||||
# ifdef ENABLE_VISUALIZER
|
# ifdef ENABLE_VISUALIZER
|
||||||
@@ -2472,7 +2513,6 @@ void populateActions()
|
|||||||
insert_action(new Actions::ToggleInterface());
|
insert_action(new Actions::ToggleInterface());
|
||||||
insert_action(new Actions::JumpToParentDirectory());
|
insert_action(new Actions::JumpToParentDirectory());
|
||||||
insert_action(new Actions::PressEnter());
|
insert_action(new Actions::PressEnter());
|
||||||
insert_action(new Actions::PressSpace());
|
|
||||||
insert_action(new Actions::SelectItem());
|
insert_action(new Actions::SelectItem());
|
||||||
insert_action(new Actions::PreviousColumn());
|
insert_action(new Actions::PreviousColumn());
|
||||||
insert_action(new Actions::NextColumn());
|
insert_action(new Actions::NextColumn());
|
||||||
@@ -2480,6 +2520,7 @@ void populateActions()
|
|||||||
insert_action(new Actions::SlaveScreen());
|
insert_action(new Actions::SlaveScreen());
|
||||||
insert_action(new Actions::VolumeUp());
|
insert_action(new Actions::VolumeUp());
|
||||||
insert_action(new Actions::VolumeDown());
|
insert_action(new Actions::VolumeDown());
|
||||||
|
insert_action(new Actions::AddItemToPlaylist());
|
||||||
insert_action(new Actions::DeletePlaylistItems());
|
insert_action(new Actions::DeletePlaylistItems());
|
||||||
insert_action(new Actions::DeleteStoredPlaylist());
|
insert_action(new Actions::DeleteStoredPlaylist());
|
||||||
insert_action(new Actions::DeleteBrowserItems());
|
insert_action(new Actions::DeleteBrowserItems());
|
||||||
@@ -2500,6 +2541,7 @@ void populateActions()
|
|||||||
insert_action(new Actions::SeekBackward());
|
insert_action(new Actions::SeekBackward());
|
||||||
insert_action(new Actions::ToggleDisplayMode());
|
insert_action(new Actions::ToggleDisplayMode());
|
||||||
insert_action(new Actions::ToggleSeparatorsBetweenAlbums());
|
insert_action(new Actions::ToggleSeparatorsBetweenAlbums());
|
||||||
|
insert_action(new Actions::ToggleLyricsUpdateOnSongChange());
|
||||||
insert_action(new Actions::ToggleLyricsFetcher());
|
insert_action(new Actions::ToggleLyricsFetcher());
|
||||||
insert_action(new Actions::ToggleFetchingLyricsInBackground());
|
insert_action(new Actions::ToggleFetchingLyricsInBackground());
|
||||||
insert_action(new Actions::TogglePlayingSongCentering());
|
insert_action(new Actions::TogglePlayingSongCentering());
|
||||||
@@ -2553,6 +2595,7 @@ void populateActions()
|
|||||||
insert_action(new Actions::ToggleMediaLibrarySortMode());
|
insert_action(new Actions::ToggleMediaLibrarySortMode());
|
||||||
insert_action(new Actions::RefetchLyrics());
|
insert_action(new Actions::RefetchLyrics());
|
||||||
insert_action(new Actions::SetSelectedItemsPriority());
|
insert_action(new Actions::SetSelectedItemsPriority());
|
||||||
|
insert_action(new Actions::ToggleVisualizationType());
|
||||||
insert_action(new Actions::SetVisualizerSampleMultiplier());
|
insert_action(new Actions::SetVisualizerSampleMultiplier());
|
||||||
insert_action(new Actions::ShowSongInfo());
|
insert_action(new Actions::ShowSongInfo());
|
||||||
insert_action(new Actions::ShowArtistInfo());
|
insert_action(new Actions::ShowArtistInfo());
|
||||||
|
|||||||
@@ -37,15 +37,15 @@ enum class Type
|
|||||||
MacroUtility = 0,
|
MacroUtility = 0,
|
||||||
Dummy, UpdateEnvironment, MouseEvent, ScrollUp, ScrollDown, ScrollUpArtist, ScrollUpAlbum,
|
Dummy, UpdateEnvironment, MouseEvent, ScrollUp, ScrollDown, ScrollUpArtist, ScrollUpAlbum,
|
||||||
ScrollDownArtist, ScrollDownAlbum, PageUp, PageDown, MoveHome, MoveEnd,
|
ScrollDownArtist, ScrollDownAlbum, PageUp, PageDown, MoveHome, MoveEnd,
|
||||||
ToggleInterface, JumpToParentDirectory, PressEnter, PressSpace, PreviousColumn,
|
ToggleInterface, JumpToParentDirectory, PressEnter, PreviousColumn,
|
||||||
NextColumn, MasterScreen, SlaveScreen, VolumeUp, VolumeDown, DeletePlaylistItems,
|
NextColumn, MasterScreen, SlaveScreen, VolumeUp, VolumeDown, AddItemToPlaylist,
|
||||||
DeleteStoredPlaylist, DeleteBrowserItems, ReplaySong, Previous, Next, Pause,
|
DeletePlaylistItems, DeleteStoredPlaylist, DeleteBrowserItems, ReplaySong, Previous,
|
||||||
Stop, ExecuteCommand, SavePlaylist, MoveSortOrderUp, MoveSortOrderDown,
|
Next, Pause, Stop, ExecuteCommand, SavePlaylist, MoveSortOrderUp, MoveSortOrderDown,
|
||||||
MoveSelectedItemsUp, MoveSelectedItemsDown, MoveSelectedItemsTo, Add,
|
MoveSelectedItemsUp, MoveSelectedItemsDown, MoveSelectedItemsTo, Add,
|
||||||
SeekForward, SeekBackward, ToggleDisplayMode, ToggleSeparatorsBetweenAlbums,
|
SeekForward, SeekBackward, ToggleDisplayMode, ToggleSeparatorsBetweenAlbums,
|
||||||
ToggleLyricsFetcher, ToggleFetchingLyricsInBackground, TogglePlayingSongCentering,
|
ToggleLyricsUpdateOnSongChange, ToggleLyricsFetcher, ToggleFetchingLyricsInBackground,
|
||||||
UpdateDatabase, JumpToPlayingSong, ToggleRepeat, Shuffle, ToggleRandom,
|
TogglePlayingSongCentering, UpdateDatabase, JumpToPlayingSong, ToggleRepeat, Shuffle,
|
||||||
StartSearching, SaveTagChanges, ToggleSingle, ToggleConsume, ToggleCrossfade,
|
ToggleRandom, StartSearching, SaveTagChanges, ToggleSingle, ToggleConsume, ToggleCrossfade,
|
||||||
SetCrossfade, SetVolume, EditSong, EditLibraryTag, EditLibraryAlbum, EditDirectoryName,
|
SetCrossfade, SetVolume, EditSong, EditLibraryTag, EditLibraryAlbum, EditDirectoryName,
|
||||||
EditPlaylistName, EditLyrics, JumpToBrowser, JumpToMediaLibrary,
|
EditPlaylistName, EditLyrics, JumpToBrowser, JumpToMediaLibrary,
|
||||||
JumpToPlaylistEditor, ToggleScreenLock, JumpToTagEditor, JumpToPositionInSong,
|
JumpToPlaylistEditor, ToggleScreenLock, JumpToTagEditor, JumpToPositionInSong,
|
||||||
@@ -56,7 +56,7 @@ enum class Type
|
|||||||
ToggleAddMode, ToggleMouse, ToggleBitrateVisibility,
|
ToggleAddMode, ToggleMouse, ToggleBitrateVisibility,
|
||||||
AddRandomItems, ToggleBrowserSortMode, ToggleLibraryTagType,
|
AddRandomItems, ToggleBrowserSortMode, ToggleLibraryTagType,
|
||||||
ToggleMediaLibrarySortMode, RefetchLyrics,
|
ToggleMediaLibrarySortMode, RefetchLyrics,
|
||||||
SetSelectedItemsPriority, SetVisualizerSampleMultiplier,
|
SetSelectedItemsPriority, ToggleVisualizationType, SetVisualizerSampleMultiplier,
|
||||||
ShowSongInfo, ShowArtistInfo, ShowLyrics, Quit, NextScreen, PreviousScreen,
|
ShowSongInfo, ShowArtistInfo, ShowLyrics, Quit, NextScreen, PreviousScreen,
|
||||||
ShowHelp, ShowPlaylist, ShowBrowser, ChangeBrowseMode, ShowSearchEngine,
|
ShowHelp, ShowPlaylist, ShowBrowser, ChangeBrowseMode, ShowSearchEngine,
|
||||||
ResetSearchEngine, ShowMediaLibrary, ToggleMediaLibraryColumnsMode,
|
ResetSearchEngine, ShowMediaLibrary, ToggleMediaLibraryColumnsMode,
|
||||||
@@ -272,14 +272,6 @@ private:
|
|||||||
virtual void run() OVERRIDE;
|
virtual void run() OVERRIDE;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PressSpace: BaseAction
|
|
||||||
{
|
|
||||||
PressSpace(): BaseAction(Type::PressSpace, "press_space") { }
|
|
||||||
|
|
||||||
private:
|
|
||||||
virtual void run() OVERRIDE;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct PreviousColumn: BaseAction
|
struct PreviousColumn: BaseAction
|
||||||
{
|
{
|
||||||
PreviousColumn(): BaseAction(Type::PreviousColumn, "previous_column") { }
|
PreviousColumn(): BaseAction(Type::PreviousColumn, "previous_column") { }
|
||||||
@@ -332,6 +324,17 @@ private:
|
|||||||
virtual void run() OVERRIDE;
|
virtual void run() OVERRIDE;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct AddItemToPlaylist: BaseAction
|
||||||
|
{
|
||||||
|
AddItemToPlaylist(): BaseAction(Type::AddItemToPlaylist, "add_item_to_playlist") { }
|
||||||
|
|
||||||
|
private:
|
||||||
|
virtual bool canBeRun() OVERRIDE;
|
||||||
|
virtual void run() OVERRIDE;
|
||||||
|
|
||||||
|
HasSongs *m_hs;
|
||||||
|
};
|
||||||
|
|
||||||
struct DeletePlaylistItems: BaseAction
|
struct DeletePlaylistItems: BaseAction
|
||||||
{
|
{
|
||||||
DeletePlaylistItems(): BaseAction(Type::DeletePlaylistItems, "delete_playlist_items") { }
|
DeletePlaylistItems(): BaseAction(Type::DeletePlaylistItems, "delete_playlist_items") { }
|
||||||
@@ -506,6 +509,16 @@ private:
|
|||||||
virtual void run() OVERRIDE;
|
virtual void run() OVERRIDE;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ToggleLyricsUpdateOnSongChange: BaseAction
|
||||||
|
{
|
||||||
|
ToggleLyricsUpdateOnSongChange()
|
||||||
|
: BaseAction(Type::ToggleLyricsUpdateOnSongChange, "toggle_lyrics_update_on_song_change") { }
|
||||||
|
|
||||||
|
private:
|
||||||
|
virtual bool canBeRun() OVERRIDE;
|
||||||
|
virtual void run() OVERRIDE;
|
||||||
|
};
|
||||||
|
|
||||||
struct ToggleLyricsFetcher: BaseAction
|
struct ToggleLyricsFetcher: BaseAction
|
||||||
{
|
{
|
||||||
ToggleLyricsFetcher(): BaseAction(Type::ToggleLyricsFetcher, "toggle_lyrics_fetcher") { }
|
ToggleLyricsFetcher(): BaseAction(Type::ToggleLyricsFetcher, "toggle_lyrics_fetcher") { }
|
||||||
@@ -998,6 +1011,17 @@ private:
|
|||||||
virtual void run() OVERRIDE;
|
virtual void run() OVERRIDE;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ToggleVisualizationType: BaseAction
|
||||||
|
{
|
||||||
|
ToggleVisualizationType()
|
||||||
|
: BaseAction(Type::ToggleVisualizationType, "toggle_visualization_type") { }
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
virtual bool canBeRun() OVERRIDE;
|
||||||
|
virtual void run() OVERRIDE;
|
||||||
|
};
|
||||||
|
|
||||||
struct SetVisualizerSampleMultiplier: BaseAction
|
struct SetVisualizerSampleMultiplier: BaseAction
|
||||||
{
|
{
|
||||||
SetVisualizerSampleMultiplier()
|
SetVisualizerSampleMultiplier()
|
||||||
|
|||||||
@@ -472,10 +472,14 @@ void BindingsConfiguration::generateDefaults()
|
|||||||
bind(k, Actions::Type::MoveEnd);
|
bind(k, Actions::Type::MoveEnd);
|
||||||
if (notBound(k = stringToKey("insert")))
|
if (notBound(k = stringToKey("insert")))
|
||||||
bind(k, Actions::Type::SelectItem);
|
bind(k, Actions::Type::SelectItem);
|
||||||
if (notBound(k = stringToKey("space")))
|
|
||||||
bind(k, Actions::Type::PressSpace);
|
|
||||||
if (notBound(k = stringToKey("enter")))
|
if (notBound(k = stringToKey("enter")))
|
||||||
bind(k, Actions::Type::PressEnter);
|
bind(k, Actions::Type::PressEnter);
|
||||||
|
if (notBound(k = stringToKey("space")))
|
||||||
|
{
|
||||||
|
bind(k, Actions::Type::AddItemToPlaylist);
|
||||||
|
bind(k, Actions::Type::ToggleLyricsUpdateOnSongChange);
|
||||||
|
bind(k, Actions::Type::ToggleVisualizationType);
|
||||||
|
}
|
||||||
if (notBound(k = stringToKey("delete")))
|
if (notBound(k = stringToKey("delete")))
|
||||||
{
|
{
|
||||||
bind(k, Actions::Type::DeletePlaylistItems);
|
bind(k, Actions::Type::DeletePlaylistItems);
|
||||||
|
|||||||
@@ -243,46 +243,6 @@ void Browser::enterPressed()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Browser::spacePressed()
|
|
||||||
{
|
|
||||||
if (w.empty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
const MPD::Item &item = w.current()->value();
|
|
||||||
// ignore parent directory
|
|
||||||
if (isParentDirectory(item))
|
|
||||||
return;
|
|
||||||
|
|
||||||
switch (item.type())
|
|
||||||
{
|
|
||||||
case MPD::Item::Type::Directory:
|
|
||||||
{
|
|
||||||
bool success = true;
|
|
||||||
if (m_local_browser)
|
|
||||||
{
|
|
||||||
std::vector<MPD::Song> songs;
|
|
||||||
getLocalDirectoryRecursively(songs, item.directory().path());
|
|
||||||
success = addSongsToPlaylist(songs.begin(), songs.end(), false, -1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
Mpd.Add(item.directory().path());
|
|
||||||
Statusbar::printf("Directory \"%1%\" added%2%",
|
|
||||||
item.directory().path(), withErrors(success)
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case MPD::Item::Type::Song:
|
|
||||||
addSongToPlaylist(item.song(), false);
|
|
||||||
break;
|
|
||||||
case MPD::Item::Type::Playlist:
|
|
||||||
Mpd.LoadPlaylist(item.playlist().path());
|
|
||||||
Statusbar::printf("Playlist \"%1%\" loaded", item.playlist().path());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
w.scroll(NC::Scroll::Down);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Browser::mouseButtonPressed(MEVENT me)
|
void Browser::mouseButtonPressed(MEVENT me)
|
||||||
{
|
{
|
||||||
if (w.empty() || !w.hasCoords(me.x, me.y) || size_t(me.y) >= w.size())
|
if (w.empty() || !w.hasCoords(me.x, me.y) || size_t(me.y) >= w.size())
|
||||||
@@ -299,22 +259,12 @@ void Browser::mouseButtonPressed(MEVENT me)
|
|||||||
drawHeader();
|
drawHeader();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
addItemToPlaylist();
|
||||||
size_t pos = w.choice();
|
|
||||||
spacePressed();
|
|
||||||
if (pos < w.size()-1)
|
|
||||||
w.scroll(NC::Scroll::Up);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case MPD::Item::Type::Playlist:
|
case MPD::Item::Type::Playlist:
|
||||||
case MPD::Item::Type::Song:
|
case MPD::Item::Type::Song:
|
||||||
if (me.bstate & BUTTON1_PRESSED)
|
if (me.bstate & BUTTON1_PRESSED)
|
||||||
{
|
addItemToPlaylist();
|
||||||
size_t pos = w.choice();
|
|
||||||
spacePressed();
|
|
||||||
if (pos < w.size()-1)
|
|
||||||
w.scroll(NC::Scroll::Up);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
enterPressed();
|
enterPressed();
|
||||||
break;
|
break;
|
||||||
@@ -351,6 +301,46 @@ bool Browser::find(SearchDirection direction, bool wrap, bool skip_current)
|
|||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
|
|
||||||
|
bool Browser::addItemToPlaylist()
|
||||||
|
{
|
||||||
|
bool result = false;
|
||||||
|
if (w.empty())
|
||||||
|
return result;
|
||||||
|
|
||||||
|
const MPD::Item &item = w.current()->value();
|
||||||
|
// ignore parent directory
|
||||||
|
if (isParentDirectory(item))
|
||||||
|
return result;
|
||||||
|
|
||||||
|
switch (item.type())
|
||||||
|
{
|
||||||
|
case MPD::Item::Type::Directory:
|
||||||
|
{
|
||||||
|
if (m_local_browser)
|
||||||
|
{
|
||||||
|
std::vector<MPD::Song> songs;
|
||||||
|
getLocalDirectoryRecursively(songs, item.directory().path());
|
||||||
|
result = addSongsToPlaylist(songs.begin(), songs.end(), false, -1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Mpd.Add(item.directory().path());
|
||||||
|
Statusbar::printf("Directory \"%1%\" added%2%",
|
||||||
|
item.directory().path(), withErrors(result)
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MPD::Item::Type::Song:
|
||||||
|
result = addSongToPlaylist(item.song(), false);
|
||||||
|
break;
|
||||||
|
case MPD::Item::Type::Playlist:
|
||||||
|
Mpd.LoadPlaylist(item.playlist().path());
|
||||||
|
Statusbar::printf("Playlist \"%1%\" loaded", item.playlist().path());
|
||||||
|
result = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<MPD::Song> Browser::getSelectedSongs()
|
std::vector<MPD::Song> Browser::getSelectedSongs()
|
||||||
{
|
{
|
||||||
std::vector<MPD::Song> songs;
|
std::vector<MPD::Song> songs;
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ struct Browser: Screen<BrowserWindow>, HasSongs, Searchable, Tabbable
|
|||||||
virtual void update() OVERRIDE;
|
virtual void update() OVERRIDE;
|
||||||
|
|
||||||
virtual void enterPressed() OVERRIDE;
|
virtual void enterPressed() OVERRIDE;
|
||||||
virtual void spacePressed() OVERRIDE;
|
|
||||||
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
||||||
|
|
||||||
virtual bool isLockable() OVERRIDE { return true; }
|
virtual bool isLockable() OVERRIDE { return true; }
|
||||||
@@ -70,6 +69,7 @@ struct Browser: Screen<BrowserWindow>, HasSongs, Searchable, Tabbable
|
|||||||
virtual bool find(SearchDirection direction, bool wrap, bool skip_current) OVERRIDE;
|
virtual bool find(SearchDirection direction, bool wrap, bool skip_current) OVERRIDE;
|
||||||
|
|
||||||
// HasSongs implementation
|
// HasSongs implementation
|
||||||
|
virtual bool addItemToPlaylist() OVERRIDE;
|
||||||
virtual std::vector<MPD::Song> getSelectedSongs() OVERRIDE;
|
virtual std::vector<MPD::Song> getSelectedSongs() OVERRIDE;
|
||||||
|
|
||||||
// private members
|
// private members
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ struct Clock: Screen<NC::Window>, Tabbable
|
|||||||
virtual void scroll(NC::Scroll) OVERRIDE { }
|
virtual void scroll(NC::Scroll) OVERRIDE { }
|
||||||
|
|
||||||
virtual void enterPressed() OVERRIDE { }
|
virtual void enterPressed() OVERRIDE { }
|
||||||
virtual void spacePressed() OVERRIDE { }
|
|
||||||
virtual void mouseButtonPressed(MEVENT) OVERRIDE { }
|
virtual void mouseButtonPressed(MEVENT) OVERRIDE { }
|
||||||
|
|
||||||
virtual bool isLockable() OVERRIDE { return false; }
|
virtual bool isLockable() OVERRIDE { return false; }
|
||||||
|
|||||||
12
src/help.cpp
12
src/help.cpp
@@ -246,7 +246,7 @@ void write_bindings(NC::Scrollpad &w)
|
|||||||
|
|
||||||
key_section(w, "Browser");
|
key_section(w, "Browser");
|
||||||
key(w, Type::PressEnter, "Enter directory/Add item to playlist and play it");
|
key(w, Type::PressEnter, "Enter directory/Add item to playlist and play it");
|
||||||
key(w, Type::PressSpace, "Add item to playlist");
|
key(w, Type::AddItemToPlaylist, "Add item to playlist");
|
||||||
# ifdef HAVE_TAGLIB_H
|
# ifdef HAVE_TAGLIB_H
|
||||||
key(w, Type::EditSong, "Edit song");
|
key(w, Type::EditSong, "Edit song");
|
||||||
# endif // HAVE_TAGLIB_H
|
# endif // HAVE_TAGLIB_H
|
||||||
@@ -261,7 +261,7 @@ void write_bindings(NC::Scrollpad &w)
|
|||||||
|
|
||||||
key_section(w, "Search engine");
|
key_section(w, "Search engine");
|
||||||
key(w, Type::PressEnter, "Add item to playlist and play it/change option");
|
key(w, Type::PressEnter, "Add item to playlist and play it/change option");
|
||||||
key(w, Type::PressSpace, "Add item to playlist");
|
key(w, Type::AddItemToPlaylist, "Add item to playlist");
|
||||||
# ifdef HAVE_TAGLIB_H
|
# ifdef HAVE_TAGLIB_H
|
||||||
key(w, Type::EditSong, "Edit song");
|
key(w, Type::EditSong, "Edit song");
|
||||||
# endif // HAVE_TAGLIB_H
|
# endif // HAVE_TAGLIB_H
|
||||||
@@ -273,7 +273,7 @@ void write_bindings(NC::Scrollpad &w)
|
|||||||
key(w, Type::PreviousColumn, "Previous column");
|
key(w, Type::PreviousColumn, "Previous column");
|
||||||
key(w, Type::NextColumn, "Next column");
|
key(w, Type::NextColumn, "Next column");
|
||||||
key(w, Type::PressEnter, "Add item to playlist and play it");
|
key(w, Type::PressEnter, "Add item to playlist and play it");
|
||||||
key(w, Type::PressSpace, "Add item to playlist");
|
key(w, Type::AddItemToPlaylist, "Add item to playlist");
|
||||||
# ifdef HAVE_TAGLIB_H
|
# ifdef HAVE_TAGLIB_H
|
||||||
key(w, Type::EditSong, "Edit song");
|
key(w, Type::EditSong, "Edit song");
|
||||||
# endif // HAVE_TAGLIB_H
|
# endif // HAVE_TAGLIB_H
|
||||||
@@ -285,7 +285,7 @@ void write_bindings(NC::Scrollpad &w)
|
|||||||
key(w, Type::PreviousColumn, "Previous column");
|
key(w, Type::PreviousColumn, "Previous column");
|
||||||
key(w, Type::NextColumn, "Next column");
|
key(w, Type::NextColumn, "Next column");
|
||||||
key(w, Type::PressEnter, "Add item to playlist and play it");
|
key(w, Type::PressEnter, "Add item to playlist and play it");
|
||||||
key(w, Type::PressSpace, "Add item to playlist");
|
key(w, Type::AddItemToPlaylist, "Add item to playlist");
|
||||||
# ifdef HAVE_TAGLIB_H
|
# ifdef HAVE_TAGLIB_H
|
||||||
key(w, Type::EditSong, "Edit song");
|
key(w, Type::EditSong, "Edit song");
|
||||||
# endif // HAVE_TAGLIB_H
|
# endif // HAVE_TAGLIB_H
|
||||||
@@ -298,7 +298,7 @@ void write_bindings(NC::Scrollpad &w)
|
|||||||
key(w, Type::CropPlaylist, "Clear playlist except selected items");
|
key(w, Type::CropPlaylist, "Clear playlist except selected items");
|
||||||
|
|
||||||
key_section(w, "Lyrics");
|
key_section(w, "Lyrics");
|
||||||
key(w, Type::PressSpace, "Toggle reloading lyrics upon song change");
|
key(w, Type::ToggleLyricsUpdateOnSongChange, "Toggle lyrics update on song change");
|
||||||
key(w, Type::EditLyrics, "Open lyrics in external editor");
|
key(w, Type::EditLyrics, "Open lyrics in external editor");
|
||||||
key(w, Type::RefetchLyrics, "Refetch lyrics");
|
key(w, Type::RefetchLyrics, "Refetch lyrics");
|
||||||
|
|
||||||
@@ -322,7 +322,7 @@ void write_bindings(NC::Scrollpad &w)
|
|||||||
|
|
||||||
# if defined(ENABLE_VISUALIZER) && defined(HAVE_FFTW3_H)
|
# if defined(ENABLE_VISUALIZER) && defined(HAVE_FFTW3_H)
|
||||||
key_section(w, "Music visualizer");
|
key_section(w, "Music visualizer");
|
||||||
key(w, Type::PressSpace, "Toggle visualization type");
|
key(w, Type::ToggleVisualizationType, "Toggle visualization type");
|
||||||
key(w, Type::SetVisualizerSampleMultiplier, "Set visualizer sample multiplier");
|
key(w, Type::SetVisualizerSampleMultiplier, "Set visualizer sample multiplier");
|
||||||
# endif // ENABLE_VISUALIZER && HAVE_FFTW3_H
|
# endif // ENABLE_VISUALIZER && HAVE_FFTW3_H
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ struct Help: Screen<NC::Scrollpad>, Tabbable
|
|||||||
virtual void update() OVERRIDE { }
|
virtual void update() OVERRIDE { }
|
||||||
|
|
||||||
virtual void enterPressed() OVERRIDE { }
|
virtual void enterPressed() OVERRIDE { }
|
||||||
virtual void spacePressed() OVERRIDE { }
|
|
||||||
|
|
||||||
virtual bool isLockable() OVERRIDE { return true; }
|
virtual bool isLockable() OVERRIDE { return true; }
|
||||||
virtual bool isMergable() OVERRIDE { return true; }
|
virtual bool isMergable() OVERRIDE { return true; }
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
#include "playlist.h"
|
#include "playlist.h"
|
||||||
#include "statusbar.h"
|
#include "statusbar.h"
|
||||||
|
#include "utility/functional.h"
|
||||||
|
|
||||||
const MPD::Song *currentSong(const BaseScreen *screen)
|
const MPD::Song *currentSong(const BaseScreen *screen)
|
||||||
{
|
{
|
||||||
@@ -88,41 +89,36 @@ bool addSongsToPlaylist(VectorSongIterator first, VectorSongIterator last, bool
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void removeSongFromPlaylist(const SongMenu &playlist, const MPD::Song &s)
|
||||||
|
{
|
||||||
|
Mpd.StartCommandsList();
|
||||||
|
for (auto &item : reverse_iteration(playlist))
|
||||||
|
if (item.value() == s)
|
||||||
|
Mpd.Delete(item.value().getPosition());
|
||||||
|
Mpd.CommitCommandsList();
|
||||||
|
}
|
||||||
|
|
||||||
bool addSongToPlaylist(const MPD::Song &s, bool play, int position)
|
bool addSongToPlaylist(const MPD::Song &s, bool play, int position)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
if (Config.space_add_mode == SpaceAddMode::AddRemove && myPlaylist->checkForSong(s))
|
if (Config.space_add_mode == SpaceAddMode::AddRemove
|
||||||
|
&& !play
|
||||||
|
&& myPlaylist->checkForSong(s)
|
||||||
|
)
|
||||||
{
|
{
|
||||||
auto &w = myPlaylist->main();
|
result = true;
|
||||||
if (play)
|
removeSongFromPlaylist(myPlaylist->main(), s);
|
||||||
{
|
return result;
|
||||||
auto song = std::find(w.beginV(), w.endV(), s);
|
|
||||||
assert(song != w.endV());
|
|
||||||
Mpd.PlayID(song->getID());
|
|
||||||
result = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Mpd.StartCommandsList();
|
|
||||||
for (auto it = w.rbeginV(); it != w.rendV(); ++it)
|
|
||||||
if (*it == s)
|
|
||||||
Mpd.Delete(it->getPosition());
|
|
||||||
Mpd.CommitCommandsList();
|
|
||||||
// we return false in this case
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
int id = Mpd.AddSong(s, position);
|
||||||
|
if (id >= 0)
|
||||||
{
|
{
|
||||||
int id = Mpd.AddSong(s, position);
|
Statusbar::printf("Added to playlist: %s",
|
||||||
if (id >= 0)
|
Format::stringify<char>(Config.song_status_format, &s)
|
||||||
{
|
);
|
||||||
Statusbar::printf("Added to playlist: %s",
|
if (play)
|
||||||
Format::stringify<char>(Config.song_status_format, &s)
|
Mpd.PlayID(id);
|
||||||
);
|
result = true;
|
||||||
if (play)
|
|
||||||
Mpd.PlayID(id);
|
|
||||||
result = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ struct Searchable
|
|||||||
|
|
||||||
struct HasSongs
|
struct HasSongs
|
||||||
{
|
{
|
||||||
|
virtual bool addItemToPlaylist() = 0;
|
||||||
virtual std::vector<MPD::Song> getSelectedSongs() = 0;
|
virtual std::vector<MPD::Song> getSelectedSongs() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ struct Lastfm: Screen<NC::Scrollpad>, Tabbable
|
|||||||
virtual void update() OVERRIDE;
|
virtual void update() OVERRIDE;
|
||||||
|
|
||||||
virtual void enterPressed() OVERRIDE { }
|
virtual void enterPressed() OVERRIDE { }
|
||||||
virtual void spacePressed() OVERRIDE { }
|
|
||||||
|
|
||||||
virtual bool isLockable() OVERRIDE { return false; }
|
virtual bool isLockable() OVERRIDE { return false; }
|
||||||
virtual bool isMergable() OVERRIDE { return true; }
|
virtual bool isMergable() OVERRIDE { return true; }
|
||||||
|
|||||||
@@ -137,14 +137,6 @@ std::wstring Lyrics::title()
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lyrics::spacePressed()
|
|
||||||
{
|
|
||||||
Config.now_playing_lyrics = !Config.now_playing_lyrics;
|
|
||||||
Statusbar::printf("Reload lyrics if song changes: %1%",
|
|
||||||
Config.now_playing_lyrics ? "on" : "off"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef HAVE_CURL_CURL_H
|
#ifdef HAVE_CURL_CURL_H
|
||||||
void Lyrics::DownloadInBackground(const MPD::Song &s)
|
void Lyrics::DownloadInBackground(const MPD::Song &s)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ struct Lyrics: Screen<NC::Scrollpad>, Tabbable
|
|||||||
virtual void update() OVERRIDE;
|
virtual void update() OVERRIDE;
|
||||||
|
|
||||||
virtual void enterPressed() OVERRIDE { }
|
virtual void enterPressed() OVERRIDE { }
|
||||||
virtual void spacePressed() OVERRIDE;
|
|
||||||
|
|
||||||
virtual bool isLockable() OVERRIDE { return false; }
|
virtual bool isLockable() OVERRIDE { return false; }
|
||||||
virtual bool isMergable() OVERRIDE { return true; }
|
virtual bool isMergable() OVERRIDE { return true; }
|
||||||
@@ -54,7 +53,7 @@ struct Lyrics: Screen<NC::Scrollpad>, Tabbable
|
|||||||
|
|
||||||
# ifdef HAVE_CURL_CURL_H
|
# ifdef HAVE_CURL_CURL_H
|
||||||
void Refetch();
|
void Refetch();
|
||||||
|
|
||||||
static void ToggleFetcher();
|
static void ToggleFetcher();
|
||||||
static void DownloadInBackground(const MPD::Song &s);
|
static void DownloadInBackground(const MPD::Song &s);
|
||||||
# endif // HAVE_CURL_CURL_H
|
# endif // HAVE_CURL_CURL_H
|
||||||
|
|||||||
@@ -451,12 +451,7 @@ int MediaLibrary::windowTimeout()
|
|||||||
|
|
||||||
void MediaLibrary::enterPressed()
|
void MediaLibrary::enterPressed()
|
||||||
{
|
{
|
||||||
AddToPlaylist(true);
|
addItemToPlaylist(true);
|
||||||
}
|
|
||||||
|
|
||||||
void MediaLibrary::spacePressed()
|
|
||||||
{
|
|
||||||
AddToPlaylist(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MediaLibrary::mouseButtonPressed(MEVENT me)
|
void MediaLibrary::mouseButtonPressed(MEVENT me)
|
||||||
@@ -491,12 +486,7 @@ void MediaLibrary::mouseButtonPressed(MEVENT me)
|
|||||||
{
|
{
|
||||||
Tags.Goto(me.y);
|
Tags.Goto(me.y);
|
||||||
if (me.bstate & BUTTON3_PRESSED)
|
if (me.bstate & BUTTON3_PRESSED)
|
||||||
{
|
addItemToPlaylist();
|
||||||
size_t pos = Tags.choice();
|
|
||||||
spacePressed();
|
|
||||||
if (pos < Tags.size()-1)
|
|
||||||
Tags.scroll(NC::Scroll::Up);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Screen<WindowType>::mouseButtonPressed(me);
|
Screen<WindowType>::mouseButtonPressed(me);
|
||||||
@@ -519,12 +509,7 @@ void MediaLibrary::mouseButtonPressed(MEVENT me)
|
|||||||
{
|
{
|
||||||
Albums.Goto(me.y);
|
Albums.Goto(me.y);
|
||||||
if (me.bstate & BUTTON3_PRESSED)
|
if (me.bstate & BUTTON3_PRESSED)
|
||||||
{
|
addItemToPlaylist();
|
||||||
size_t pos = Albums.choice();
|
|
||||||
spacePressed();
|
|
||||||
if (pos < Albums.size()-1)
|
|
||||||
Albums.scroll(NC::Scroll::Up);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Screen<WindowType>::mouseButtonPressed(me);
|
Screen<WindowType>::mouseButtonPressed(me);
|
||||||
@@ -538,12 +523,7 @@ void MediaLibrary::mouseButtonPressed(MEVENT me)
|
|||||||
{
|
{
|
||||||
Songs.Goto(me.y);
|
Songs.Goto(me.y);
|
||||||
if (me.bstate & BUTTON1_PRESSED)
|
if (me.bstate & BUTTON1_PRESSED)
|
||||||
{
|
addItemToPlaylist();
|
||||||
size_t pos = Songs.choice();
|
|
||||||
spacePressed();
|
|
||||||
if (pos < Songs.size()-1)
|
|
||||||
Songs.scroll(NC::Scroll::Up);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
enterPressed();
|
enterPressed();
|
||||||
}
|
}
|
||||||
@@ -608,6 +588,11 @@ bool MediaLibrary::find(SearchDirection direction, bool wrap, bool skip_current)
|
|||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
|
|
||||||
|
bool MediaLibrary::addItemToPlaylist()
|
||||||
|
{
|
||||||
|
return addItemToPlaylist(false);
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<MPD::Song> MediaLibrary::getSelectedSongs()
|
std::vector<MPD::Song> MediaLibrary::getSelectedSongs()
|
||||||
{
|
{
|
||||||
std::vector<MPD::Song> result;
|
std::vector<MPD::Song> result;
|
||||||
@@ -923,10 +908,11 @@ void MediaLibrary::LocateSong(const MPD::Song &s)
|
|||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MediaLibrary::AddToPlaylist(bool add_n_play)
|
bool MediaLibrary::addItemToPlaylist(bool play)
|
||||||
{
|
{
|
||||||
|
bool result = false;
|
||||||
if (isActiveWindow(Songs) && !Songs.empty())
|
if (isActiveWindow(Songs) && !Songs.empty())
|
||||||
addSongToPlaylist(Songs.current()->value(), add_n_play);
|
result = addSongToPlaylist(Songs.current()->value(), play);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((!Tags.empty() && isActiveWindow(Tags))
|
if ((!Tags.empty() && isActiveWindow(Tags))
|
||||||
@@ -938,11 +924,11 @@ void MediaLibrary::AddToPlaylist(bool add_n_play)
|
|||||||
std::make_move_iterator(Mpd.CommitSearchSongs()),
|
std::make_move_iterator(Mpd.CommitSearchSongs()),
|
||||||
std::make_move_iterator(MPD::SongIterator())
|
std::make_move_iterator(MPD::SongIterator())
|
||||||
);
|
);
|
||||||
bool success = addSongsToPlaylist(list.begin(), list.end(), add_n_play, -1);
|
result = addSongsToPlaylist(list.begin(), list.end(), play, -1);
|
||||||
std::string tag_type = boost::locale::to_lower(
|
std::string tag_type = boost::locale::to_lower(
|
||||||
tagTypeToString(Config.media_lib_primary_tag));
|
tagTypeToString(Config.media_lib_primary_tag));
|
||||||
Statusbar::printf("Songs with %1% \"%2%\" added%3%",
|
Statusbar::printf("Songs with %1% \"%2%\" added%3%",
|
||||||
tag_type, Tags.current()->value().tag(), withErrors(success)
|
tag_type, Tags.current()->value().tag(), withErrors(result)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if (isActiveWindow(Albums))
|
else if (isActiveWindow(Albums))
|
||||||
@@ -951,24 +937,13 @@ void MediaLibrary::AddToPlaylist(bool add_n_play)
|
|||||||
std::make_move_iterator(getSongsFromAlbum(Albums.current()->value())),
|
std::make_move_iterator(getSongsFromAlbum(Albums.current()->value())),
|
||||||
std::make_move_iterator(MPD::SongIterator())
|
std::make_move_iterator(MPD::SongIterator())
|
||||||
);
|
);
|
||||||
bool success = addSongsToPlaylist(list.begin(), list.end(), add_n_play, -1);
|
result = addSongsToPlaylist(list.begin(), list.end(), play, -1);
|
||||||
Statusbar::printf("Songs from album \"%1%\" added%2%",
|
Statusbar::printf("Songs from album \"%1%\" added%2%",
|
||||||
Albums.current()->value().entry().album(), withErrors(success)
|
Albums.current()->value().entry().album(), withErrors(result)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
if (!add_n_play)
|
|
||||||
{
|
|
||||||
w->scroll(NC::Scroll::Down);
|
|
||||||
if (isActiveWindow(Tags))
|
|
||||||
{
|
|
||||||
Albums.clear();
|
|
||||||
Songs.clear();
|
|
||||||
}
|
|
||||||
else if (isActiveWindow(Albums))
|
|
||||||
Songs.clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ struct MediaLibrary: Screen<NC::Window *>, HasColumns, HasSongs, Searchable, Tab
|
|||||||
virtual int windowTimeout() OVERRIDE;
|
virtual int windowTimeout() OVERRIDE;
|
||||||
|
|
||||||
virtual void enterPressed() OVERRIDE;
|
virtual void enterPressed() OVERRIDE;
|
||||||
virtual void spacePressed() OVERRIDE;
|
|
||||||
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
||||||
|
|
||||||
virtual bool isLockable() OVERRIDE { return true; }
|
virtual bool isLockable() OVERRIDE { return true; }
|
||||||
@@ -57,6 +56,7 @@ struct MediaLibrary: Screen<NC::Window *>, HasColumns, HasSongs, Searchable, Tab
|
|||||||
virtual bool find(SearchDirection direction, bool wrap, bool skip_current) OVERRIDE;
|
virtual bool find(SearchDirection direction, bool wrap, bool skip_current) OVERRIDE;
|
||||||
|
|
||||||
// HasSongs implementation
|
// HasSongs implementation
|
||||||
|
virtual bool addItemToPlaylist() OVERRIDE;
|
||||||
virtual std::vector<MPD::Song> getSelectedSongs() OVERRIDE;
|
virtual std::vector<MPD::Song> getSelectedSongs() OVERRIDE;
|
||||||
|
|
||||||
// HasColumns implementation
|
// HasColumns implementation
|
||||||
@@ -133,7 +133,7 @@ struct MediaLibrary: Screen<NC::Window *>, HasColumns, HasSongs, Searchable, Tab
|
|||||||
SongMenu Songs;
|
SongMenu Songs;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void AddToPlaylist(bool);
|
bool addItemToPlaylist(bool play);
|
||||||
|
|
||||||
bool m_tags_update_request;
|
bool m_tags_update_request;
|
||||||
bool m_albums_update_request;
|
bool m_albums_update_request;
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ struct Outputs: Screen<NC::Menu<MPD::Output>>, Tabbable
|
|||||||
virtual void update() OVERRIDE { }
|
virtual void update() OVERRIDE { }
|
||||||
|
|
||||||
virtual void enterPressed() OVERRIDE;
|
virtual void enterPressed() OVERRIDE;
|
||||||
virtual void spacePressed() OVERRIDE { }
|
|
||||||
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
||||||
|
|
||||||
virtual bool isLockable() OVERRIDE { return true; }
|
virtual bool isLockable() OVERRIDE { return true; }
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ struct Playlist: Screen<SongMenu>, HasSongs, Searchable, Tabbable
|
|||||||
virtual void update() OVERRIDE;
|
virtual void update() OVERRIDE;
|
||||||
|
|
||||||
virtual void enterPressed() OVERRIDE;
|
virtual void enterPressed() OVERRIDE;
|
||||||
virtual void spacePressed() OVERRIDE { }
|
|
||||||
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
||||||
|
|
||||||
virtual bool isLockable() OVERRIDE { return true; }
|
virtual bool isLockable() OVERRIDE { return true; }
|
||||||
@@ -57,6 +56,7 @@ struct Playlist: Screen<SongMenu>, HasSongs, Searchable, Tabbable
|
|||||||
virtual bool find(SearchDirection direction, bool wrap, bool skip_current) OVERRIDE;
|
virtual bool find(SearchDirection direction, bool wrap, bool skip_current) OVERRIDE;
|
||||||
|
|
||||||
// HasSongs implementation
|
// HasSongs implementation
|
||||||
|
virtual bool addItemToPlaylist() OVERRIDE { return false; };
|
||||||
virtual std::vector<MPD::Song> getSelectedSongs() OVERRIDE;
|
virtual std::vector<MPD::Song> getSelectedSongs() OVERRIDE;
|
||||||
|
|
||||||
// private members
|
// private members
|
||||||
|
|||||||
@@ -225,34 +225,9 @@ int PlaylistEditor::windowTimeout()
|
|||||||
return Screen<WindowType>::windowTimeout();
|
return Screen<WindowType>::windowTimeout();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlaylistEditor::AddToPlaylist(bool add_n_play)
|
|
||||||
{
|
|
||||||
if (isActiveWindow(Playlists) && !Playlists.empty())
|
|
||||||
{
|
|
||||||
std::vector<MPD::Song> list(
|
|
||||||
std::make_move_iterator(Mpd.GetPlaylistContent(Playlists.current()->value().path())),
|
|
||||||
std::make_move_iterator(MPD::SongIterator())
|
|
||||||
);
|
|
||||||
bool success = addSongsToPlaylist(list.begin(), list.end(), add_n_play, -1);
|
|
||||||
Statusbar::printf("Playlist \"%1%\" loaded%2%",
|
|
||||||
Playlists.current()->value().path(), withErrors(success)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else if (isActiveWindow(Content) && !Content.empty())
|
|
||||||
addSongToPlaylist(Content.current()->value(), add_n_play);
|
|
||||||
|
|
||||||
if (!add_n_play)
|
|
||||||
w->scroll(NC::Scroll::Down);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlaylistEditor::enterPressed()
|
void PlaylistEditor::enterPressed()
|
||||||
{
|
{
|
||||||
AddToPlaylist(true);
|
addItemToPlaylist(true);
|
||||||
}
|
|
||||||
|
|
||||||
void PlaylistEditor::spacePressed()
|
|
||||||
{
|
|
||||||
AddToPlaylist(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlaylistEditor::mouseButtonPressed(MEVENT me)
|
void PlaylistEditor::mouseButtonPressed(MEVENT me)
|
||||||
@@ -270,12 +245,7 @@ void PlaylistEditor::mouseButtonPressed(MEVENT me)
|
|||||||
{
|
{
|
||||||
Playlists.Goto(me.y);
|
Playlists.Goto(me.y);
|
||||||
if (me.bstate & BUTTON3_PRESSED)
|
if (me.bstate & BUTTON3_PRESSED)
|
||||||
{
|
addItemToPlaylist();
|
||||||
size_t pos = Playlists.choice();
|
|
||||||
spacePressed();
|
|
||||||
if (pos < Playlists.size()-1)
|
|
||||||
Playlists.scroll(NC::Scroll::Up);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Screen<WindowType>::mouseButtonPressed(me);
|
Screen<WindowType>::mouseButtonPressed(me);
|
||||||
@@ -294,12 +264,7 @@ void PlaylistEditor::mouseButtonPressed(MEVENT me)
|
|||||||
{
|
{
|
||||||
Content.Goto(me.y);
|
Content.Goto(me.y);
|
||||||
if (me.bstate & BUTTON1_PRESSED)
|
if (me.bstate & BUTTON1_PRESSED)
|
||||||
{
|
addItemToPlaylist();
|
||||||
size_t pos = Content.choice();
|
|
||||||
spacePressed();
|
|
||||||
if (pos < Content.size()-1)
|
|
||||||
Content.scroll(NC::Scroll::Up);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
enterPressed();
|
enterPressed();
|
||||||
}
|
}
|
||||||
@@ -353,6 +318,11 @@ bool PlaylistEditor::find(SearchDirection direction, bool wrap, bool skip_curren
|
|||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
|
|
||||||
|
bool PlaylistEditor::addItemToPlaylist()
|
||||||
|
{
|
||||||
|
return addItemToPlaylist(false);
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<MPD::Song> PlaylistEditor::getSelectedSongs()
|
std::vector<MPD::Song> PlaylistEditor::getSelectedSongs()
|
||||||
{
|
{
|
||||||
std::vector<MPD::Song> result;
|
std::vector<MPD::Song> result;
|
||||||
@@ -450,6 +420,25 @@ void PlaylistEditor::Locate(const MPD::Playlist &playlist)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PlaylistEditor::addItemToPlaylist(bool play)
|
||||||
|
{
|
||||||
|
bool result = false;
|
||||||
|
if (isActiveWindow(Playlists) && !Playlists.empty())
|
||||||
|
{
|
||||||
|
std::vector<MPD::Song> list(
|
||||||
|
std::make_move_iterator(Mpd.GetPlaylistContent(Playlists.current()->value().path())),
|
||||||
|
std::make_move_iterator(MPD::SongIterator())
|
||||||
|
);
|
||||||
|
result = addSongsToPlaylist(list.begin(), list.end(), play, -1);
|
||||||
|
Statusbar::printf("Playlist \"%1%\" loaded%2%",
|
||||||
|
Playlists.current()->value().path(), withErrors(result)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if (isActiveWindow(Content) && !Content.empty())
|
||||||
|
result = addSongToPlaylist(Content.current()->value(), play);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
std::string SongToString(const MPD::Song &s)
|
std::string SongToString(const MPD::Song &s)
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ struct PlaylistEditor: Screen<NC::Window *>, HasColumns, HasSongs, Searchable, T
|
|||||||
virtual int windowTimeout() OVERRIDE;
|
virtual int windowTimeout() OVERRIDE;
|
||||||
|
|
||||||
virtual void enterPressed() OVERRIDE;
|
virtual void enterPressed() OVERRIDE;
|
||||||
virtual void spacePressed() OVERRIDE;
|
|
||||||
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
||||||
|
|
||||||
virtual bool isLockable() OVERRIDE { return true; }
|
virtual bool isLockable() OVERRIDE { return true; }
|
||||||
@@ -57,6 +56,7 @@ struct PlaylistEditor: Screen<NC::Window *>, HasColumns, HasSongs, Searchable, T
|
|||||||
virtual bool find(SearchDirection direction, bool wrap, bool skip_current) OVERRIDE;
|
virtual bool find(SearchDirection direction, bool wrap, bool skip_current) OVERRIDE;
|
||||||
|
|
||||||
// HasSongs implementation
|
// HasSongs implementation
|
||||||
|
virtual bool addItemToPlaylist() OVERRIDE;
|
||||||
virtual std::vector<MPD::Song> getSelectedSongs() OVERRIDE;
|
virtual std::vector<MPD::Song> getSelectedSongs() OVERRIDE;
|
||||||
|
|
||||||
// HasColumns implementation
|
// HasColumns implementation
|
||||||
@@ -78,7 +78,7 @@ struct PlaylistEditor: Screen<NC::Window *>, HasColumns, HasSongs, Searchable, T
|
|||||||
SongMenu Content;
|
SongMenu Content;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void AddToPlaylist(bool);
|
bool addItemToPlaylist(bool play);
|
||||||
|
|
||||||
bool m_playlists_update_requested;
|
bool m_playlists_update_requested;
|
||||||
bool m_content_update_requested;
|
bool m_content_update_requested;
|
||||||
|
|||||||
@@ -76,9 +76,6 @@ struct BaseScreen
|
|||||||
/// Invoked after Enter was pressed
|
/// Invoked after Enter was pressed
|
||||||
virtual void enterPressed() = 0;
|
virtual void enterPressed() = 0;
|
||||||
|
|
||||||
/// Invoked after Space was pressed
|
|
||||||
virtual void spacePressed() = 0;
|
|
||||||
|
|
||||||
/// @see Screen::mouseButtonPressed()
|
/// @see Screen::mouseButtonPressed()
|
||||||
virtual void mouseButtonPressed(MEVENT me) = 0;
|
virtual void mouseButtonPressed(MEVENT me) = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -268,15 +268,6 @@ void SearchEngine::enterPressed()
|
|||||||
addSongToPlaylist(w.current()->value().song(), true);
|
addSongToPlaylist(w.current()->value().song(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchEngine::spacePressed()
|
|
||||||
{
|
|
||||||
if (w.current()->value().isSong())
|
|
||||||
{
|
|
||||||
addSongToPlaylist(w.current()->value().song(), false);
|
|
||||||
w.scroll(NC::Scroll::Down);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SearchEngine::mouseButtonPressed(MEVENT me)
|
void SearchEngine::mouseButtonPressed(MEVENT me)
|
||||||
{
|
{
|
||||||
if (w.empty() || !w.hasCoords(me.x, me.y) || size_t(me.y) >= w.size())
|
if (w.empty() || !w.hasCoords(me.x, me.y) || size_t(me.y) >= w.size())
|
||||||
@@ -291,12 +282,7 @@ void SearchEngine::mouseButtonPressed(MEVENT me)
|
|||||||
else if (w.choice() >= StaticOptions)
|
else if (w.choice() >= StaticOptions)
|
||||||
{
|
{
|
||||||
if (me.bstate & BUTTON1_PRESSED)
|
if (me.bstate & BUTTON1_PRESSED)
|
||||||
{
|
addItemToPlaylist();
|
||||||
size_t pos = w.choice();
|
|
||||||
spacePressed();
|
|
||||||
if (pos < w.size()-1)
|
|
||||||
w.scroll(NC::Scroll::Up);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
enterPressed();
|
enterPressed();
|
||||||
}
|
}
|
||||||
@@ -332,6 +318,14 @@ bool SearchEngine::find(SearchDirection direction, bool wrap, bool skip_current)
|
|||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
|
|
||||||
|
bool SearchEngine::addItemToPlaylist()
|
||||||
|
{
|
||||||
|
bool result = false;
|
||||||
|
if (!w.empty() && w.current()->value().isSong())
|
||||||
|
result = addSongToPlaylist(w.current()->value().song(), false);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<MPD::Song> SearchEngine::getSelectedSongs()
|
std::vector<MPD::Song> SearchEngine::getSelectedSongs()
|
||||||
{
|
{
|
||||||
std::vector<MPD::Song> result;
|
std::vector<MPD::Song> result;
|
||||||
|
|||||||
@@ -105,7 +105,6 @@ struct SearchEngine: Screen<SearchEngineWindow>, HasSongs, Searchable, Tabbable
|
|||||||
virtual void update() OVERRIDE { }
|
virtual void update() OVERRIDE { }
|
||||||
|
|
||||||
virtual void enterPressed() OVERRIDE;
|
virtual void enterPressed() OVERRIDE;
|
||||||
virtual void spacePressed() OVERRIDE;
|
|
||||||
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
||||||
|
|
||||||
virtual bool isLockable() OVERRIDE { return true; }
|
virtual bool isLockable() OVERRIDE { return true; }
|
||||||
@@ -118,6 +117,7 @@ struct SearchEngine: Screen<SearchEngineWindow>, HasSongs, Searchable, Tabbable
|
|||||||
virtual bool find(SearchDirection direction, bool wrap, bool skip_current) OVERRIDE;
|
virtual bool find(SearchDirection direction, bool wrap, bool skip_current) OVERRIDE;
|
||||||
|
|
||||||
// HasSongs implementation
|
// HasSongs implementation
|
||||||
|
virtual bool addItemToPlaylist() OVERRIDE;
|
||||||
virtual std::vector<MPD::Song> getSelectedSongs() OVERRIDE;
|
virtual std::vector<MPD::Song> getSelectedSongs() OVERRIDE;
|
||||||
|
|
||||||
// private members
|
// private members
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ struct SelectedItemsAdder: Screen<NC::Menu<RunnableItem<std::string, void()>> *>
|
|||||||
virtual void update() OVERRIDE { }
|
virtual void update() OVERRIDE { }
|
||||||
|
|
||||||
virtual void enterPressed() OVERRIDE;
|
virtual void enterPressed() OVERRIDE;
|
||||||
virtual void spacePressed() OVERRIDE { }
|
|
||||||
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
||||||
|
|
||||||
virtual bool isLockable() OVERRIDE { return false; }
|
virtual bool isLockable() OVERRIDE { return false; }
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ struct ServerInfo: Screen<NC::Scrollpad>, Tabbable
|
|||||||
virtual void update() OVERRIDE;
|
virtual void update() OVERRIDE;
|
||||||
|
|
||||||
virtual void enterPressed() OVERRIDE { }
|
virtual void enterPressed() OVERRIDE { }
|
||||||
virtual void spacePressed() OVERRIDE { }
|
|
||||||
|
|
||||||
virtual bool isLockable() OVERRIDE { return false; }
|
virtual bool isLockable() OVERRIDE { return false; }
|
||||||
virtual bool isMergable() OVERRIDE { return false; }
|
virtual bool isMergable() OVERRIDE { return false; }
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ struct SongInfo: Screen<NC::Scrollpad>, Tabbable
|
|||||||
virtual void update() OVERRIDE { }
|
virtual void update() OVERRIDE { }
|
||||||
|
|
||||||
virtual void enterPressed() OVERRIDE { }
|
virtual void enterPressed() OVERRIDE { }
|
||||||
virtual void spacePressed() OVERRIDE { }
|
|
||||||
|
|
||||||
virtual bool isLockable() OVERRIDE { return false; }
|
virtual bool isLockable() OVERRIDE { return false; }
|
||||||
virtual bool isMergable() OVERRIDE { return true; }
|
virtual bool isMergable() OVERRIDE { return true; }
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ struct SortPlaylistDialog
|
|||||||
virtual void update() OVERRIDE { }
|
virtual void update() OVERRIDE { }
|
||||||
|
|
||||||
virtual void enterPressed() OVERRIDE;
|
virtual void enterPressed() OVERRIDE;
|
||||||
virtual void spacePressed() OVERRIDE { }
|
|
||||||
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
||||||
|
|
||||||
virtual bool isLockable() OVERRIDE { return false; }
|
virtual bool isLockable() OVERRIDE { return false; }
|
||||||
|
|||||||
@@ -714,8 +714,6 @@ void TagEditor::mouseButtonPressed(MEVENT me)
|
|||||||
Dirs->Goto(me.y);
|
Dirs->Goto(me.y);
|
||||||
if (me.bstate & BUTTON1_PRESSED)
|
if (me.bstate & BUTTON1_PRESSED)
|
||||||
enterPressed();
|
enterPressed();
|
||||||
else
|
|
||||||
spacePressed();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Screen<WindowType>::mouseButtonPressed(me);
|
Screen<WindowType>::mouseButtonPressed(me);
|
||||||
@@ -806,6 +804,14 @@ bool TagEditor::find(SearchDirection direction, bool wrap, bool skip_current)
|
|||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
|
|
||||||
|
bool TagEditor::addItemToPlaylist()
|
||||||
|
{
|
||||||
|
bool result = false;
|
||||||
|
if (w == Tags && !Tags->empty())
|
||||||
|
result = addSongToPlaylist(*Tags->currentV(), false);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<MPD::Song> TagEditor::getSelectedSongs()
|
std::vector<MPD::Song> TagEditor::getSelectedSongs()
|
||||||
{
|
{
|
||||||
std::vector<MPD::Song> result;
|
std::vector<MPD::Song> result;
|
||||||
|
|||||||
@@ -63,7 +63,6 @@ struct TagEditor: Screen<NC::Window *>, HasColumns, HasSongs, Searchable, Tabbab
|
|||||||
virtual void update() OVERRIDE;
|
virtual void update() OVERRIDE;
|
||||||
|
|
||||||
virtual void enterPressed() OVERRIDE;
|
virtual void enterPressed() OVERRIDE;
|
||||||
virtual void spacePressed() OVERRIDE { }
|
|
||||||
virtual void mouseButtonPressed(MEVENT) OVERRIDE;
|
virtual void mouseButtonPressed(MEVENT) OVERRIDE;
|
||||||
|
|
||||||
virtual bool isLockable() OVERRIDE { return true; }
|
virtual bool isLockable() OVERRIDE { return true; }
|
||||||
@@ -76,6 +75,7 @@ struct TagEditor: Screen<NC::Window *>, HasColumns, HasSongs, Searchable, Tabbab
|
|||||||
virtual bool find(SearchDirection direction, bool wrap, bool skip_current) OVERRIDE;
|
virtual bool find(SearchDirection direction, bool wrap, bool skip_current) OVERRIDE;
|
||||||
|
|
||||||
// HasSongs implementation
|
// HasSongs implementation
|
||||||
|
virtual bool addItemToPlaylist() OVERRIDE;
|
||||||
virtual std::vector<MPD::Song> getSelectedSongs() OVERRIDE;
|
virtual std::vector<MPD::Song> getSelectedSongs() OVERRIDE;
|
||||||
|
|
||||||
// HasColumns implementation
|
// HasColumns implementation
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ struct TinyTagEditor: Screen<NC::Menu<NC::Buffer>>
|
|||||||
virtual void update() OVERRIDE { }
|
virtual void update() OVERRIDE { }
|
||||||
|
|
||||||
virtual void enterPressed() OVERRIDE;
|
virtual void enterPressed() OVERRIDE;
|
||||||
virtual void spacePressed() OVERRIDE { }
|
|
||||||
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
||||||
|
|
||||||
virtual bool isLockable() OVERRIDE { return false; }
|
virtual bool isLockable() OVERRIDE { return false; }
|
||||||
|
|||||||
@@ -24,6 +24,36 @@
|
|||||||
#include <boost/locale/encoding_utf.hpp>
|
#include <boost/locale/encoding_utf.hpp>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
template <typename BaseT>
|
||||||
|
struct reversed_iteration
|
||||||
|
{
|
||||||
|
reversed_iteration(BaseT &base_)
|
||||||
|
: base(base_) { }
|
||||||
|
|
||||||
|
BaseT &base;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename BaseT>
|
||||||
|
reversed_iteration<BaseT> reverse_iteration(BaseT &base_) {
|
||||||
|
return reversed_iteration<BaseT>(base_);
|
||||||
|
}
|
||||||
|
template <typename BaseT>
|
||||||
|
auto begin(reversed_iteration<BaseT> &rev) -> decltype(rev.base.rbegin()) {
|
||||||
|
return rev.base.rbegin();
|
||||||
|
}
|
||||||
|
template <typename BaseT>
|
||||||
|
auto begin(reversed_iteration<const BaseT> &rev) -> decltype(rev.base.rbegin()) {
|
||||||
|
return rev.base.rbegin();
|
||||||
|
}
|
||||||
|
template <typename BaseT>
|
||||||
|
auto end(reversed_iteration<BaseT> &rev) -> decltype(rev.base.rend()) {
|
||||||
|
return rev.base.rend();
|
||||||
|
}
|
||||||
|
template <typename BaseT>
|
||||||
|
auto end(reversed_iteration<const BaseT> &rev) -> decltype(rev.base.rend()) {
|
||||||
|
return rev.base.rend();
|
||||||
|
}
|
||||||
|
|
||||||
template <typename ValueT>
|
template <typename ValueT>
|
||||||
struct pointer_extractor
|
struct pointer_extractor
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -187,32 +187,6 @@ int Visualizer::windowTimeout()
|
|||||||
return Screen<WindowType>::windowTimeout();
|
return Screen<WindowType>::windowTimeout();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Visualizer::spacePressed()
|
|
||||||
{
|
|
||||||
switch (Config.visualizer_type)
|
|
||||||
{
|
|
||||||
case VisualizerType::Wave:
|
|
||||||
Config.visualizer_type = VisualizerType::WaveFilled;
|
|
||||||
break;
|
|
||||||
case VisualizerType::WaveFilled:
|
|
||||||
# ifdef HAVE_FFTW3_H
|
|
||||||
Config.visualizer_type = VisualizerType::Spectrum;
|
|
||||||
# else
|
|
||||||
Config.visualizer_type = VisualizerType::Ellipse;
|
|
||||||
# endif // HAVE_FFTW3_H
|
|
||||||
break;
|
|
||||||
# ifdef HAVE_FFTW3_H
|
|
||||||
case VisualizerType::Spectrum:
|
|
||||||
Config.visualizer_type = VisualizerType::Ellipse;
|
|
||||||
break;
|
|
||||||
# endif // HAVE_FFTW3_H
|
|
||||||
case VisualizerType::Ellipse:
|
|
||||||
Config.visualizer_type = VisualizerType::Wave;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
Statusbar::printf("Visualization type: %1%", Config.visualizer_type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
|
|
||||||
void Visualizer::DrawSoundWave(int16_t *buf, ssize_t samples, size_t y_offset, size_t height)
|
void Visualizer::DrawSoundWave(int16_t *buf, ssize_t samples, size_t y_offset, size_t height)
|
||||||
@@ -443,6 +417,32 @@ void Visualizer::DrawFrequencySpectrumStereo(int16_t *buf_left, int16_t *buf_rig
|
|||||||
|
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
|
|
||||||
|
void Visualizer::ToggleVisualizationType()
|
||||||
|
{
|
||||||
|
switch (Config.visualizer_type)
|
||||||
|
{
|
||||||
|
case VisualizerType::Wave:
|
||||||
|
Config.visualizer_type = VisualizerType::WaveFilled;
|
||||||
|
break;
|
||||||
|
case VisualizerType::WaveFilled:
|
||||||
|
# ifdef HAVE_FFTW3_H
|
||||||
|
Config.visualizer_type = VisualizerType::Spectrum;
|
||||||
|
# else
|
||||||
|
Config.visualizer_type = VisualizerType::Ellipse;
|
||||||
|
# endif // HAVE_FFTW3_H
|
||||||
|
break;
|
||||||
|
# ifdef HAVE_FFTW3_H
|
||||||
|
case VisualizerType::Spectrum:
|
||||||
|
Config.visualizer_type = VisualizerType::Ellipse;
|
||||||
|
break;
|
||||||
|
# endif // HAVE_FFTW3_H
|
||||||
|
case VisualizerType::Ellipse:
|
||||||
|
Config.visualizer_type = VisualizerType::Wave;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Statusbar::printf("Visualization type: %1%", Config.visualizer_type);
|
||||||
|
}
|
||||||
|
|
||||||
void Visualizer::SetFD()
|
void Visualizer::SetFD()
|
||||||
{
|
{
|
||||||
if (m_fifo < 0 && (m_fifo = open(Config.visualizer_fifo_path.c_str(), O_RDONLY | O_NONBLOCK)) < 0)
|
if (m_fifo < 0 && (m_fifo = open(Config.visualizer_fifo_path.c_str(), O_RDONLY | O_NONBLOCK)) < 0)
|
||||||
|
|||||||
@@ -50,13 +50,13 @@ struct Visualizer: Screen<NC::Window>, Tabbable
|
|||||||
virtual int windowTimeout() OVERRIDE;
|
virtual int windowTimeout() OVERRIDE;
|
||||||
|
|
||||||
virtual void enterPressed() OVERRIDE { }
|
virtual void enterPressed() OVERRIDE { }
|
||||||
virtual void spacePressed() OVERRIDE;
|
|
||||||
virtual void mouseButtonPressed(MEVENT) OVERRIDE { }
|
virtual void mouseButtonPressed(MEVENT) OVERRIDE { }
|
||||||
|
|
||||||
virtual bool isLockable() OVERRIDE { return true; }
|
virtual bool isLockable() OVERRIDE { return true; }
|
||||||
virtual bool isMergable() OVERRIDE { return true; }
|
virtual bool isMergable() OVERRIDE { return true; }
|
||||||
|
|
||||||
// private members
|
// private members
|
||||||
|
void ToggleVisualizationType();
|
||||||
void SetFD();
|
void SetFD();
|
||||||
void ResetFD();
|
void ResetFD();
|
||||||
void FindOutputID();
|
void FindOutputID();
|
||||||
|
|||||||
Reference in New Issue
Block a user