summaryrefslogtreecommitdiff
path: root/src/gui/widgets/listbox.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-06-29 16:02:11 +0300
committerAndrei Karas <akaras@inbox.ru>2013-06-29 17:48:19 +0300
commit37f849a6ae4d96a22d7b972d3021c235aa294ad8 (patch)
tree5f6ed8b8ab59ed1cde7019eb9d207cbe348c14ae /src/gui/widgets/listbox.cpp
parent80623e124244977c4ba52829fe830fed103532ff (diff)
downloadplus-37f849a6ae4d96a22d7b972d3021c235aa294ad8.tar.gz
plus-37f849a6ae4d96a22d7b972d3021c235aa294ad8.tar.bz2
plus-37f849a6ae4d96a22d7b972d3021c235aa294ad8.tar.xz
plus-37f849a6ae4d96a22d7b972d3021c235aa294ad8.zip
Add support for multilines in extendedlistbox.
Diffstat (limited to 'src/gui/widgets/listbox.cpp')
-rw-r--r--src/gui/widgets/listbox.cpp10
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();
+}