summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Steinbrink <B.Steinbrink@gmx.de>2006-03-08 23:19:02 +0000
committerBjörn Steinbrink <B.Steinbrink@gmx.de>2006-03-08 23:19:02 +0000
commit0aca9d9da8a0817d0651168620c985a6813bf954 (patch)
tree0e0226a32792952340d5e2b48ed33b70b19b1602
parent38ac38af6ea1c6643fcae3aeb11b80354b923126 (diff)
downloadmana-client-0aca9d9da8a0817d0651168620c985a6813bf954.tar.gz
mana-client-0aca9d9da8a0817d0651168620c985a6813bf954.tar.bz2
mana-client-0aca9d9da8a0817d0651168620c985a6813bf954.tar.xz
mana-client-0aca9d9da8a0817d0651168620c985a6813bf954.zip
Make the MouseOverLink functor dynamic and use a STL algorithm in one more place.
-rw-r--r--ChangeLog5
-rw-r--r--src/gui/browserbox.cpp26
2 files changed, 13 insertions, 18 deletions
diff --git a/ChangeLog b/ChangeLog
index 4b0658f8..3caaf8f2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-03-09 Björn Steinbrink <B.Steinbrink@gmx.de>
+
+ * src/gui/browserbox.cpp: Make the MouseOverLink functor dynamic and
+ use a STL algorithm in one more place.
+
2006-03-08 Bjørn Lindeijer <bjorn@lindeijer.nl>
* src/gui/browserbox.h, src/gui/menuwindow.cpp, src/gui/buysell.cpp:
diff --git a/src/gui/browserbox.cpp b/src/gui/browserbox.cpp
index 8a636679..1f67670e 100644
--- a/src/gui/browserbox.cpp
+++ b/src/gui/browserbox.cpp
@@ -229,22 +229,21 @@ void BrowserBox::clearRows()
mSelectedLink = -1;
}
-struct MouseOverLinkFunctor
+struct MouseOverLink
{
+ MouseOverLink(int x, int y) : mX(x),mY(y) { }
bool operator() (BROWSER_LINK &link)
{
return (mX >= link.x1 && mX < link.x2 &&
mY >= link.y1 && mY < link.y2);
}
int mX, mY;
-} mouseOverLink;
+};
void BrowserBox::mousePress(int mx, int my, int button)
{
- mouseOverLink.mX = mx;
- mouseOverLink.mY = my;
-
- LinkIterator i = find_if(mLinks.begin(), mLinks.end(), mouseOverLink);
+ LinkIterator i = find_if(mLinks.begin(), mLinks.end(),
+ MouseOverLink(mx, my));
if (i != mLinks.end()) {
mLinkHandler->handleLink(i->link);
@@ -253,19 +252,10 @@ void BrowserBox::mousePress(int mx, int my, int button)
void BrowserBox::mouseMotion(int mx, int my)
{
- mouseOverLink.mX = mx;
- mouseOverLink.mY = my;
-
- mSelectedLink = -1;
+ LinkIterator i = find_if(mLinks.begin(), mLinks.end(),
+ MouseOverLink(mx, my));
- for (unsigned int i = 0; i < mLinks.size(); i++)
- {
- if (mouseOverLink(mLinks[i]))
- {
- mSelectedLink = (int) i;
- break;
- }
- }
+ mSelectedLink = (i != mLinks.end()) ? (i - mLinks.begin()) : -1;
}
void BrowserBox::draw(gcn::Graphics* graphics)