summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2009-02-26 17:40:01 +0100
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2009-02-26 17:40:01 +0100
commit74923b083ff863c9514f23437d39b5749fa5743e (patch)
tree34a62e2fddb838f1be6eae67973f62d8bedf3337
parentc0b484f807b517e0dfd41353b7be45fb6eec6010 (diff)
don't compute label in draw() method
-rw-r--r--src/GipfelWidget.H1
-rw-r--r--src/GipfelWidget.cxx15
2 files changed, 10 insertions, 6 deletions
diff --git a/src/GipfelWidget.H b/src/GipfelWidget.H
index 532d395..777e1d5 100644
--- a/src/GipfelWidget.H
+++ b/src/GipfelWidget.H
@@ -23,6 +23,7 @@ class GipfelWidget : public Fl_Group {
int have_gipfel_info;
ImageMetaData *md;
int show_hidden;
+ char focused_mountain_label[128];
int handle(int event);
diff --git a/src/GipfelWidget.cxx b/src/GipfelWidget.cxx
index 9c1bbe8..9dadba1 100644
--- a/src/GipfelWidget.cxx
+++ b/src/GipfelWidget.cxx
@@ -279,19 +279,16 @@ GipfelWidget::draw() {
}
if (focused_mountain) {
- static char buf[128];
m = focused_mountain;
int m_x = w() / 2 + x() + (int) rint(m->x);
int m_y = h() / 2 + y() + (int) rint(m->y);
- snprintf(buf, sizeof(buf) - 1, "%s (%dm), distance %.2fkm",
- m->name, (int) m->height, pan->get_real_distance(m) / 1000.0);
-
fl_color(FL_YELLOW);
- fl_rectf(m_x, m_y - height, (int) fl_width(buf) + 2, height + 2);
+ fl_rectf(m_x, m_y - height,
+ (int) fl_width(focused_mountain_label) + 2, height + 2);
fl_color(FL_BLACK);
- fl_draw(buf, m_x, m_y);
+ fl_draw(focused_mountain_label, m_x, m_y);
}
@@ -614,6 +611,12 @@ GipfelWidget::handle(int event) {
case FL_MOVE:
m = find_mountain(pan->get_visible_mountains(), Fl::event_x()-x(), Fl::event_y()-y());
if (m != focused_mountain && (!m || !known_hills->contains(m))) {
+ if (m)
+ snprintf(focused_mountain_label,
+ sizeof(focused_mountain_label) - 1,
+ "%s (%dm), distance %.2fkm",
+ m->name, (int) m->height, pan->get_real_distance(m) / 1000.0);
+
focused_mountain = m;
redraw();
}