diff options
author | Andrzej Rybczak <electricityispower@gmail.com> | 2012-10-05 21:25:22 +0200 |
---|---|---|
committer | Andrzej Rybczak <electricityispower@gmail.com> | 2012-10-05 21:25:22 +0200 |
commit | 1eb000371416ad1defec39cdcc3a711833a7b7c7 (patch) | |
tree | d0af59bab42537b45492eca0a08930af87f25a34 | |
parent | 044464962c9ccbf9ff017379e67724ce58553b60 (diff) |
window: rename Where to Scroll and make it enum class
-rw-r--r-- | src/actions.cpp | 12 | ||||
-rw-r--r-- | src/browser.cpp | 8 | ||||
-rw-r--r-- | src/clock.h | 2 | ||||
-rw-r--r-- | src/helpers.h | 4 | ||||
-rw-r--r-- | src/media_library.cpp | 14 | ||||
-rw-r--r-- | src/menu.h | 40 | ||||
-rw-r--r-- | src/playlist.cpp | 2 | ||||
-rw-r--r-- | src/playlist_editor.cpp | 10 | ||||
-rw-r--r-- | src/screen.cpp | 12 | ||||
-rw-r--r-- | src/screen.h | 4 | ||||
-rw-r--r-- | src/scrollpad.cpp | 14 | ||||
-rw-r--r-- | src/scrollpad.h | 2 | ||||
-rw-r--r-- | src/search_engine.cpp | 10 | ||||
-rw-r--r-- | src/sel_items_adder.cpp | 2 | ||||
-rw-r--r-- | src/sort_playlist.cpp | 4 | ||||
-rw-r--r-- | src/tag_editor.cpp | 6 | ||||
-rw-r--r-- | src/visualizer.h | 2 | ||||
-rw-r--r-- | src/window.cpp | 10 | ||||
-rw-r--r-- | src/window.h | 4 |
19 files changed, 81 insertions, 81 deletions
diff --git a/src/actions.cpp b/src/actions.cpp index fb89c39c..9fc1f6a3 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -527,13 +527,13 @@ void MouseEvent::Run() void ScrollUp::Run() { - myScreen->scroll(NC::wUp); + myScreen->scroll(NC::Scroll::Up); ListsChangeFinisher(); } void ScrollDown::Run() { - myScreen->scroll(NC::wDown); + myScreen->scroll(NC::Scroll::Down); ListsChangeFinisher(); } @@ -631,25 +631,25 @@ void ScrollDownAlbum::Run() void PageUp::Run() { - myScreen->scroll(NC::wPageUp); + myScreen->scroll(NC::Scroll::PageUp); ListsChangeFinisher(); } void PageDown::Run() { - myScreen->scroll(NC::wPageDown); + myScreen->scroll(NC::Scroll::PageDown); ListsChangeFinisher(); } void MoveHome::Run() { - myScreen->scroll(NC::wHome); + myScreen->scroll(NC::Scroll::Home); ListsChangeFinisher(); } void MoveEnd::Run() { - myScreen->scroll(NC::wEnd); + myScreen->scroll(NC::Scroll::End); ListsChangeFinisher(); } diff --git a/src/browser.cpp b/src/browser.cpp index 6cc17881..56990b75 100644 --- a/src/browser.cpp +++ b/src/browser.cpp @@ -153,7 +153,7 @@ void Browser::spacePressed() { i = w.choice(); w.at(i).setSelected(!w.at(i).isSelected()); - w.scroll(NC::wDown); + w.scroll(NC::Scroll::Down); return; } @@ -198,7 +198,7 @@ void Browser::spacePressed() break; } } - w.scroll(NC::wDown); + w.scroll(NC::Scroll::Down); } void Browser::mouseButtonPressed(MEVENT me) @@ -221,7 +221,7 @@ void Browser::mouseButtonPressed(MEVENT me) size_t pos = w.choice(); spacePressed(); if (pos < w.size()-1) - w.scroll(NC::wUp); + w.scroll(NC::Scroll::Up); } break; case itPlaylist: @@ -231,7 +231,7 @@ void Browser::mouseButtonPressed(MEVENT me) size_t pos = w.choice(); spacePressed(); if (pos < w.size()-1) - w.scroll(NC::wUp); + w.scroll(NC::Scroll::Up); } else enterPressed(); diff --git a/src/clock.h b/src/clock.h index a2fe43fe..71676fbc 100644 --- a/src/clock.h +++ b/src/clock.h @@ -40,7 +40,7 @@ struct Clock: Screen<NC::Window>, Tabbable virtual ScreenType type() OVERRIDE { return ScreenType::Clock; } virtual void update() OVERRIDE; - virtual void scroll(NC::Where) OVERRIDE { } + virtual void scroll(NC::Scroll) OVERRIDE { } virtual void enterPressed() OVERRIDE { } virtual void spacePressed() OVERRIDE { } diff --git a/src/helpers.h b/src/helpers.h index dafe2e09..1e2c7b5d 100644 --- a/src/helpers.h +++ b/src/helpers.h @@ -167,7 +167,7 @@ void moveSelectedItemsUp(NC::Menu<MPD::Song> &m, F swap_fun) // if we move only one item, do not select it. however, if single item // was selected prior to move, it'll deselect it. oh well. list[0]->setSelected(false); - m.scroll(NC::wUp); + m.scroll(NC::Scroll::Up); } } } @@ -201,7 +201,7 @@ void moveSelectedItemsDown(NC::Menu<MPD::Song> &m, F swap_fun) // if we move only one item, do not select it. however, if single item // was selected prior to move, it'll deselect it. oh well. list[0]->setSelected(false); - m.scroll(NC::wDown); + m.scroll(NC::Scroll::Down); } } } diff --git a/src/media_library.cpp b/src/media_library.cpp index 00a45934..ffea08d5 100644 --- a/src/media_library.cpp +++ b/src/media_library.cpp @@ -418,7 +418,7 @@ void MediaLibrary::spacePressed() { size_t idx = Tags.choice(); Tags[idx].setSelected(!Tags[idx].isSelected()); - Tags.scroll(NC::wDown); + Tags.scroll(NC::Scroll::Down); Albums.clear(); Songs.clear(); } @@ -428,7 +428,7 @@ void MediaLibrary::spacePressed() { size_t idx = Albums.choice(); Albums[idx].setSelected(!Albums[idx].isSelected()); - Albums.scroll(NC::wDown); + Albums.scroll(NC::Scroll::Down); Songs.clear(); } } @@ -436,7 +436,7 @@ void MediaLibrary::spacePressed() { size_t idx = Songs.choice(); Songs[idx].setSelected(!Songs[idx].isSelected()); - Songs.scroll(NC::wDown); + Songs.scroll(NC::Scroll::Down); } } else @@ -479,7 +479,7 @@ void MediaLibrary::mouseButtonPressed(MEVENT me) size_t pos = Tags.choice(); spacePressed(); if (pos < Tags.size()-1) - Tags.scroll(NC::wUp); + Tags.scroll(NC::Scroll::Up); } } else @@ -507,7 +507,7 @@ void MediaLibrary::mouseButtonPressed(MEVENT me) size_t pos = Albums.choice(); spacePressed(); if (pos < Albums.size()-1) - Albums.scroll(NC::wUp); + Albums.scroll(NC::Scroll::Up); } } else @@ -526,7 +526,7 @@ void MediaLibrary::mouseButtonPressed(MEVENT me) size_t pos = Songs.choice(); spacePressed(); if (pos < Songs.size()-1) - Songs.scroll(NC::wUp); + Songs.scroll(NC::Scroll::Up); } else enterPressed(); @@ -981,7 +981,7 @@ void MediaLibrary::AddToPlaylist(bool add_n_play) if (!add_n_play) { - w->scroll(NC::wDown); + w->scroll(NC::Scroll::Down); if (isActiveWindow(Tags)) { Albums.clear(); @@ -284,7 +284,7 @@ public: /// Scrolls by given amount of lines /// @param where indicated where exactly one wants to go /// @see Window::scroll() - virtual void scroll(Where where) OVERRIDE; + virtual void scroll(Scroll where) OVERRIDE; /// Cleares all options, used filters etc. It doesn't reset highlighted position though. /// @see reset() @@ -609,9 +609,9 @@ template <typename T> void Menu<T>::refresh() if (!isHighlightable(m_highlight)) { - scroll(wUp); + scroll(Scroll::Up); if (!isHighlightable(m_highlight)) - scroll(wDown); + scroll(Scroll::Down); } size_t line = 0; @@ -655,7 +655,7 @@ template <typename T> void Menu<T>::refresh() Window::refresh(); } -template <typename T> void Menu<T>::scroll(Where where) +template <typename T> void Menu<T>::scroll(Scroll where) { if (m_options_ptr->empty()) return; @@ -664,42 +664,42 @@ template <typename T> void Menu<T>::scroll(Where where) size_t max_visible_highlight = m_beginning+m_height-1; switch (where) { - case wUp: + case Scroll::Up: { if (m_highlight <= m_beginning && m_highlight > 0) --m_beginning; if (m_highlight == 0) { if (m_cyclic_scroll_enabled) - return scroll(wEnd); + return scroll(Scroll::End); break; } else --m_highlight; if (!isHighlightable(m_highlight)) - scroll(m_highlight == 0 && !m_cyclic_scroll_enabled ? wDown : wUp); + scroll(m_highlight == 0 && !m_cyclic_scroll_enabled ? Scroll::Down : Scroll::Up); break; } - case wDown: + case Scroll::Down: { if (m_highlight >= max_visible_highlight && m_highlight < max_highlight) ++m_beginning; if (m_highlight == max_highlight) { if (m_cyclic_scroll_enabled) - return scroll(wHome); + return scroll(Scroll::Home); break; } else ++m_highlight; if (!isHighlightable(m_highlight)) - scroll(m_highlight == max_highlight && !m_cyclic_scroll_enabled ? wUp : wDown); + scroll(m_highlight == max_highlight && !m_cyclic_scroll_enabled ? Scroll::Up : Scroll::Down); break; } - case wPageUp: + case Scroll::PageUp: { if (m_cyclic_scroll_enabled && m_highlight == 0) - return scroll(wEnd); + return scroll(Scroll::End); if (m_highlight < m_height) m_highlight = 0; else @@ -709,35 +709,35 @@ template <typename T> void Menu<T>::scroll(Where where) else m_beginning -= m_height; if (!isHighlightable(m_highlight)) - scroll(m_highlight == 0 && !m_cyclic_scroll_enabled ? wDown : wUp); + scroll(m_highlight == 0 && !m_cyclic_scroll_enabled ? Scroll::Down : Scroll::Up); break; } - case wPageDown: + case Scroll::PageDown: { if (m_cyclic_scroll_enabled && m_highlight == max_highlight) - return scroll(wHome); + return scroll(Scroll::Home); m_highlight += m_height; m_beginning += m_height; m_beginning = std::min(m_beginning, max_beginning); m_highlight = std::min(m_highlight, max_highlight); if (!isHighlightable(m_highlight)) - scroll(m_highlight == max_highlight && !m_cyclic_scroll_enabled ? wUp : wDown); + scroll(m_highlight == max_highlight && !m_cyclic_scroll_enabled ? Scroll::Up : Scroll::Down); break; } - case wHome: + case Scroll::Home: { m_highlight = 0; m_beginning = 0; if (!isHighlightable(m_highlight)) - scroll(wDown); + scroll(Scroll::Down); break; } - case wEnd: + case Scroll::End: { m_highlight = max_highlight; m_beginning = max_beginning; if (!isHighlightable(m_highlight)) - scroll(wUp); + scroll(Scroll::Up); break; } } diff --git a/src/playlist.cpp b/src/playlist.cpp index 1ee4a531..092d91a9 100644 --- a/src/playlist.cpp +++ b/src/playlist.cpp @@ -108,7 +108,7 @@ void Playlist::spacePressed() if (!w.empty()) { w.current().setSelected(!w.current().isSelected()); - w.scroll(NC::wDown); + w.scroll(NC::Scroll::Down); } } diff --git a/src/playlist_editor.cpp b/src/playlist_editor.cpp index ff6d6e5f..ff9ff170 100644 --- a/src/playlist_editor.cpp +++ b/src/playlist_editor.cpp @@ -232,7 +232,7 @@ void PlaylistEditor::AddToPlaylist(bool add_n_play) addSongToPlaylist(Content.current().value(), add_n_play); if (!add_n_play) - w->scroll(NC::wDown); + w->scroll(NC::Scroll::Down); } void PlaylistEditor::enterPressed() @@ -249,7 +249,7 @@ void PlaylistEditor::spacePressed() if (!Playlists.empty()) { Playlists.current().setSelected(!Playlists.current().isSelected()); - Playlists.scroll(NC::wDown); + Playlists.scroll(NC::Scroll::Down); } } else if (isActiveWindow(Content)) @@ -257,7 +257,7 @@ void PlaylistEditor::spacePressed() if (!Content.empty()) { Content.current().setSelected(!Content.current().isSelected()); - Content.scroll(NC::wDown); + Content.scroll(NC::Scroll::Down); } } } @@ -284,7 +284,7 @@ void PlaylistEditor::mouseButtonPressed(MEVENT me) size_t pos = Playlists.choice(); spacePressed(); if (pos < Playlists.size()-1) - Playlists.scroll(NC::wUp); + Playlists.scroll(NC::Scroll::Up); } } else @@ -308,7 +308,7 @@ void PlaylistEditor::mouseButtonPressed(MEVENT me) size_t pos = Content.choice(); spacePressed(); if (pos < Content.size()-1) - Content.scroll(NC::wUp); + Content.scroll(NC::Scroll::Up); } else enterPressed(); diff --git a/src/screen.cpp b/src/screen.cpp index c9b250ee..24869e6a 100644 --- a/src/screen.cpp +++ b/src/screen.cpp @@ -45,18 +45,18 @@ void genericMouseButtonPressed(NC::Window &w, MEVENT me) if (me.bstate & BUTTON2_PRESSED) { if (Config.mouse_list_scroll_whole_page) - w.scroll(NC::wPageDown); + w.scroll(NC::Scroll::PageDown); else for (size_t i = 0; i < Config.lines_scrolled; ++i) - w.scroll(NC::wDown); + w.scroll(NC::Scroll::Down); } else if (me.bstate & BUTTON4_PRESSED) { if (Config.mouse_list_scroll_whole_page) - w.scroll(NC::wPageUp); + w.scroll(NC::Scroll::PageUp); else for (size_t i = 0; i < Config.lines_scrolled; ++i) - w.scroll(NC::wUp); + w.scroll(NC::Scroll::Up); } } @@ -65,12 +65,12 @@ void scrollpadMouseButtonPressed(NC::Scrollpad &w, MEVENT me) if (me.bstate & BUTTON2_PRESSED) { for (size_t i = 0; i < Config.lines_scrolled; ++i) - w.scroll(NC::wDown); + w.scroll(NC::Scroll::Down); } else if (me.bstate & BUTTON4_PRESSED) { for (size_t i = 0; i < Config.lines_scrolled; ++i) - w.scroll(NC::wUp); + w.scroll(NC::Scroll::Up); } } diff --git a/src/screen.h b/src/screen.h index f2561dd6..453ce526 100644 --- a/src/screen.h +++ b/src/screen.h @@ -49,7 +49,7 @@ struct BaseScreen virtual void refreshWindow() = 0; /// @see Screen::scroll() - virtual void scroll(NC::Where where) = 0; + virtual void scroll(NC::Scroll where) = 0; /// Method used for switching to screen virtual void switchTo() = 0; @@ -168,7 +168,7 @@ public: /// if fancy scrolling feature is disabled, enters the /// loop that holds main loop until user releases the key /// @param where indicates where one wants to scroll - virtual void scroll(NC::Where where) OVERRIDE { + virtual void scroll(NC::Scroll where) OVERRIDE { Accessor::apply(w).scroll(where); } diff --git a/src/scrollpad.cpp b/src/scrollpad.cpp index d05f8b06..4424199e 100644 --- a/src/scrollpad.cpp +++ b/src/scrollpad.cpp @@ -130,25 +130,25 @@ void Scrollpad::resize(size_t new_width, size_t new_height) flush(); } -void Scrollpad::scroll(Where where) +void Scrollpad::scroll(Scroll where) { assert(m_real_height >= m_height); size_t max_beginning = m_real_height - m_height; switch (where) { - case wUp: + case Scroll::Up: { if (m_beginning > 0) --m_beginning; break; } - case wDown: + case Scroll::Down: { if (m_beginning < max_beginning) ++m_beginning; break; } - case wPageUp: + case Scroll::PageUp: { if (m_beginning > m_height) m_beginning -= m_height; @@ -156,17 +156,17 @@ void Scrollpad::scroll(Where where) m_beginning = 0; break; } - case wPageDown: + case Scroll::PageDown: { m_beginning = std::min(m_beginning + m_height, max_beginning); break; } - case wHome: + case Scroll::Home: { m_beginning = 0; break; } - case wEnd: + case Scroll::End: { m_beginning = max_beginning; break; diff --git a/src/scrollpad.h b/src/scrollpad.h index e31e7d05..c4cd3fba 100644 --- a/src/scrollpad.h +++ b/src/scrollpad.h @@ -83,7 +83,7 @@ struct Scrollpad: public Window /// @param where indicates where exactly one wants to go /// @see Window::scroll() /// - virtual void scroll(Where where) OVERRIDE; + virtual void scroll(Scroll where) OVERRIDE; /// Resizes the window /// @param new_width new window's width diff --git a/src/search_engine.cpp b/src/search_engine.cpp index 4689b451..fbfbbb9c 100644 --- a/src/search_engine.cpp +++ b/src/search_engine.cpp @@ -189,8 +189,8 @@ void SearchEngine::enterPressed() if (Config.block_search_constraints_change) for (size_t i = 0; i < StaticOptions-4; ++i) w.at(i).setInactive(true); - w.scroll(NC::wDown); - w.scroll(NC::wDown); + w.scroll(NC::Scroll::Down); + w.scroll(NC::Scroll::Down); } else Statusbar::msg("No results found"); @@ -214,12 +214,12 @@ void SearchEngine::spacePressed() if (Config.space_selects) { w.current().setSelected(!w.current().isSelected()); - w.scroll(NC::wDown); + w.scroll(NC::Scroll::Down); return; } addSongToPlaylist(w.current().value().song(), false); - w.scroll(NC::wDown); + w.scroll(NC::Scroll::Down); } void SearchEngine::mouseButtonPressed(MEVENT me) @@ -240,7 +240,7 @@ void SearchEngine::mouseButtonPressed(MEVENT me) size_t pos = w.choice(); spacePressed(); if (pos < w.size()-1) - w.scroll(NC::wUp); + w.scroll(NC::Scroll::Up); } else enterPressed(); diff --git a/src/sel_items_adder.cpp b/src/sel_items_adder.cpp index 4b998584..57368d1a 100644 --- a/src/sel_items_adder.cpp +++ b/src/sel_items_adder.cpp @@ -68,7 +68,7 @@ SelectedItemsAdder::SelectedItemsAdder() MainStartY+(MainHeight-m_position_selector_height)/2, m_position_selector_width, m_position_selector_height, - "Where?", + "Scroll?", Config.main_color, Config.window_border ); diff --git a/src/sort_playlist.cpp b/src/sort_playlist.cpp index 0e555921..d0981343 100644 --- a/src/sort_playlist.cpp +++ b/src/sort_playlist.cpp @@ -133,7 +133,7 @@ void SortPlaylistDialog::moveSortOrderDown() if ((cur+1)->item().second) { std::iter_swap(cur, cur+1); - w.scroll(NC::wDown); + w.scroll(NC::Scroll::Down); } } @@ -143,7 +143,7 @@ void SortPlaylistDialog::moveSortOrderUp() if (cur > w.beginV() && cur->item().second) { std::iter_swap(cur, cur-1); - w.scroll(NC::wUp); + w.scroll(NC::Scroll::Up); } } diff --git a/src/tag_editor.cpp b/src/tag_editor.cpp index e0fbd647..4b82e9ed 100644 --- a/src/tag_editor.cpp +++ b/src/tag_editor.cpp @@ -507,7 +507,7 @@ void TagEditor::enterPressed() Statusbar::unlock(); if (new_tag != Tags->current().value().getTags(get, Config.tags_separator)) Tags->current().value().setTags(set, new_tag, Config.tags_separator); - Tags->scroll(NC::wDown); + Tags->scroll(NC::Scroll::Down); } } else @@ -532,7 +532,7 @@ void TagEditor::enterPressed() Statusbar::unlock(); if (!new_name.empty() && new_name != old_name) s.setNewURI(new_name + extension); - Tags->scroll(NC::wDown); + Tags->scroll(NC::Scroll::Down); } } else if (id == 16) // capitalize first letters @@ -591,7 +591,7 @@ void TagEditor::spacePressed() if (w == Tags && !Tags->empty()) { Tags->current().setSelected(!Tags->current().isSelected()); - w->scroll(NC::wDown); + w->scroll(NC::Scroll::Down); } } diff --git a/src/visualizer.h b/src/visualizer.h index 7d61470c..33372d71 100644 --- a/src/visualizer.h +++ b/src/visualizer.h @@ -44,7 +44,7 @@ struct Visualizer: Screen<NC::Window>, Tabbable virtual ScreenType type() OVERRIDE { return ScreenType::Visualizer; } virtual void update() OVERRIDE; - virtual void scroll(NC::Where) OVERRIDE { } + virtual void scroll(NC::Scroll) OVERRIDE { } virtual void enterPressed() OVERRIDE { } virtual void spacePressed() OVERRIDE; diff --git a/src/window.cpp b/src/window.cpp index 0d1ae3d1..9d0ac6cf 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -795,22 +795,22 @@ int Window::getTimeout() const return m_window_timeout; } -void Window::scroll(Where where) +void Window::scroll(Scroll where) { idlok(m_window, 1); scrollok(m_window, 1); switch (where) { - case wUp: + case Scroll::Up: wscrl(m_window, 1); break; - case wDown: + case Scroll::Down: wscrl(m_window, -1); break; - case wPageUp: + case Scroll::PageUp: wscrl(m_window, m_width); break; - case wPageDown: + case Scroll::PageDown: wscrl(m_window, -m_width); break; default: diff --git a/src/window.h b/src/window.h index a433f7a8..fb73d8a2 100644 --- a/src/window.h +++ b/src/window.h @@ -127,7 +127,7 @@ enum Format { enum Border { brNone, brBlack, brRed, brGreen, brYellow, brBlue, brMagenta, brCyan, brWhite }; /// This indicates how much the window has to be scrolled -enum Where { wUp, wDown, wPageUp, wPageDown, wHome, wEnd }; +enum class Scroll { Up, Down, PageUp, PageDown, Home, End }; /// Helper function that is invoked each time one will want /// to obtain string from Window::getString() function @@ -334,7 +334,7 @@ struct Window /// Scrolls the window by amount of lines given in its parameter /// @param where indicates how many lines it has to scroll - virtual void scroll(Where where); + virtual void scroll(Scroll where); /// Applies function of compatible prototype to internal WINDOW pointer /// The mostly used function in this case seem to be wclrtoeol(), which |