add support for scrolling the list with mouse wheel by given number of lines

This commit is contained in:
Andrzej Rybczak
2009-11-11 00:31:03 +01:00
parent c6e26e121f
commit 35a182d79e
6 changed files with 30 additions and 2 deletions

View File

@@ -284,6 +284,8 @@
# #
#mouse_support = "yes" #mouse_support = "yes"
# #
#mouse_list_scroll_whole_page = "yes"
#
#empty_tag_marker = "<empty>" #empty_tag_marker = "<empty>"
# #
#enable_window_title = "yes" #enable_window_title = "yes"

View File

@@ -153,6 +153,9 @@ If enabled, content of other columns will be updated immediately while scrolling
.B cyclic_scrolling = yes/no .B cyclic_scrolling = yes/no
If enabled, cyclic scrolling is used (e.g. if you press down arrow being at the end of list, it'll take you to the beginning) If enabled, cyclic scrolling is used (e.g. if you press down arrow being at the end of list, it'll take you to the beginning)
.TP .TP
.B mouse_list_scroll_whole_page = yes/no
If enabled, mouse wheel will scroll the whole page of item list at a time, otherwise the number of lines specified by lines_scrolled variable.
.TP
.B lines_scrolled = NUMBER .B lines_scrolled = NUMBER
Number of lines that are scrolled with mouse wheel. Number of lines that are scrolled with mouse wheel.
.TP .TP

View File

@@ -52,6 +52,15 @@ namespace NCurses
/// ///
virtual void GetSelected(std::vector<size_t> &v) const = 0; virtual void GetSelected(std::vector<size_t> &v) const = 0;
/// Highlights given position
/// @param pos position to be highlighted
///
virtual void Highlight(size_t pos) = 0;
/// @return currently highlighted position
///
virtual size_t Choice() const = 0;
/// @see Menu::Empty() /// @see Menu::Empty()
/// ///
virtual bool Empty() const = 0; virtual bool Empty() const = 0;

View File

@@ -239,12 +239,20 @@ template <typename WindowType> void Screen<WindowType>::Scroll(Where where, cons
template <typename WindowType> void Screen<WindowType>::MouseButtonPressed(MEVENT me) template <typename WindowType> void Screen<WindowType>::MouseButtonPressed(MEVENT me)
{ {
List *list = Config.mouse_list_scroll_whole_page ? 0 : dynamic_cast<List *>(w);
if (me.bstate & BUTTON2_PRESSED) if (me.bstate & BUTTON2_PRESSED)
{ {
if (list)
list->Highlight(list->Choice()+Config.lines_scrolled);
else
Scroll(wPageDown); Scroll(wPageDown);
} }
else if (me.bstate & BUTTON4_PRESSED) else if (me.bstate & BUTTON4_PRESSED)
{ {
if (list)
list->Highlight(list->Choice() > Config.lines_scrolled ? list->Choice()-Config.lines_scrolled : 0);
else
Scroll(wPageUp); Scroll(wPageUp);
} }
} }

View File

@@ -315,6 +315,7 @@ void DefaultConfiguration(ncmpcpp_config &conf)
conf.allow_physical_directories_deletion = false; conf.allow_physical_directories_deletion = false;
conf.ask_before_clearing_main_playlist = false; conf.ask_before_clearing_main_playlist = false;
conf.mouse_support = true; conf.mouse_support = true;
conf.mouse_list_scroll_whole_page = true;
conf.new_design = false; conf.new_design = false;
conf.visualizer_use_wave = true; conf.visualizer_use_wave = true;
conf.browser_sort_by_mtime = false; conf.browser_sort_by_mtime = false;
@@ -839,6 +840,10 @@ void ReadConfiguration(ncmpcpp_config &conf)
{ {
conf.mouse_support = v == "yes"; conf.mouse_support = v == "yes";
} }
else if (cl.find("mouse_list_scroll_whole_page") != std::string::npos)
{
conf.mouse_list_scroll_whole_page = v == "yes";
}
else if (cl.find("user_interface") != std::string::npos) else if (cl.find("user_interface") != std::string::npos)
{ {
conf.new_design = v == "alternative"; conf.new_design = v == "alternative";

View File

@@ -208,6 +208,7 @@ struct ncmpcpp_config
bool allow_physical_directories_deletion; bool allow_physical_directories_deletion;
bool ask_before_clearing_main_playlist; bool ask_before_clearing_main_playlist;
bool mouse_support; bool mouse_support;
bool mouse_list_scroll_whole_page;
bool new_design; bool new_design;
bool visualizer_use_wave; bool visualizer_use_wave;
bool browser_sort_by_mtime; bool browser_sort_by_mtime;