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

master
Andrzej Rybczak 17 years ago
parent c6e26e121f
commit 35a182d79e
  1. 2
      doc/config
  2. 3
      doc/ncmpcpp.1
  3. 9
      src/menu.h
  4. 12
      src/screen.h
  5. 5
      src/settings.cpp
  6. 1
      src/settings.h

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

@ -153,6 +153,9 @@ If enabled, content of other columns will be updated immediately while scrolling
.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)
.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
Number of lines that are scrolled with mouse wheel.
.TP

@ -52,6 +52,15 @@ namespace NCurses
///
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()
///
virtual bool Empty() const = 0;

@ -239,13 +239,21 @@ template <typename WindowType> void Screen<WindowType>::Scroll(Where where, cons
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)
{
Scroll(wPageDown);
if (list)
list->Highlight(list->Choice()+Config.lines_scrolled);
else
Scroll(wPageDown);
}
else if (me.bstate & BUTTON4_PRESSED)
{
Scroll(wPageUp);
if (list)
list->Highlight(list->Choice() > Config.lines_scrolled ? list->Choice()-Config.lines_scrolled : 0);
else
Scroll(wPageUp);
}
}

@ -315,6 +315,7 @@ void DefaultConfiguration(ncmpcpp_config &conf)
conf.allow_physical_directories_deletion = false;
conf.ask_before_clearing_main_playlist = false;
conf.mouse_support = true;
conf.mouse_list_scroll_whole_page = true;
conf.new_design = false;
conf.visualizer_use_wave = true;
conf.browser_sort_by_mtime = false;
@ -839,6 +840,10 @@ void ReadConfiguration(ncmpcpp_config &conf)
{
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)
{
conf.new_design = v == "alternative";

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

Loading…
Cancel
Save