diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-06-29 16:02:11 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-06-29 17:48:19 +0300 |
commit | 37f849a6ae4d96a22d7b972d3021c235aa294ad8 (patch) | |
tree | 5f6ed8b8ab59ed1cde7019eb9d207cbe348c14ae /src/gui/widgets/listbox.cpp | |
parent | 80623e124244977c4ba52829fe830fed103532ff (diff) | |
download | manaplus-37f849a6ae4d96a22d7b972d3021c235aa294ad8.tar.gz manaplus-37f849a6ae4d96a22d7b972d3021c235aa294ad8.tar.bz2 manaplus-37f849a6ae4d96a22d7b972d3021c235aa294ad8.tar.xz manaplus-37f849a6ae4d96a22d7b972d3021c235aa294ad8.zip |
Add support for multilines in extendedlistbox.
Diffstat (limited to 'src/gui/widgets/listbox.cpp')
-rw-r--r-- | src/gui/widgets/listbox.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp index 2f0f8d941..e5229eca6 100644 --- a/src/gui/widgets/listbox.cpp +++ b/src/gui/widgets/listbox.cpp @@ -209,8 +209,7 @@ void ListBox::mousePressed1(gcn::MouseEvent &mouseEvent) { if (mouseEvent.getButton() == gcn::MouseEvent::LEFT) { - setSelected(std::max(0, mouseEvent.getY() - mPadding) - / getRowHeight()); + setSelected(std::max(0, getSelectionByMouse(mouseEvent.getY()))); distributeActionEvent(); } } @@ -222,7 +221,7 @@ void ListBox::mouseDragged(gcn::MouseEvent &event) // Make list selection update on drag, but guard against negative y if (getRowHeight()) - setSelected(std::max(0, event.getY() - mPadding) / getRowHeight()); + setSelected(std::max(0, getSelectionByMouse(event.getY()))); } void ListBox::refocus() @@ -249,3 +248,8 @@ void ListBox::logic() { adjustSize(); } + +int ListBox::getSelectionByMouse(const int y) const +{ + return (y - mPadding) / getRowHeight(); +} |