summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)