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

@@ -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;

View File

@@ -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);
}
}

View File

@@ -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";

View File

@@ -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;