diff options
author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2009-06-06 23:01:28 +0200 |
---|---|---|
committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2009-06-06 23:01:28 +0200 |
commit | 2208308f3f567bda1f1134abdbb550ff388c9477 (patch) | |
tree | 3325639ec8b28821059f33b8a3a82ba1804c813d /src | |
parent | 574196d698f3e5437d19e6f9476046f2bf09156f (diff) |
add manual hide / unhide
Diffstat (limited to 'src')
-rw-r--r-- | src/GipfelWidget.H | 1 | ||||
-rw-r--r-- | src/GipfelWidget.cxx | 40 |
2 files changed, 32 insertions, 9 deletions
diff --git a/src/GipfelWidget.H b/src/GipfelWidget.H index 2e440c5..90f5ef5 100644 --- a/src/GipfelWidget.H +++ b/src/GipfelWidget.H @@ -39,6 +39,7 @@ class GipfelWidget : public Fl_Group { int get_rel_track_width(Hill *m); static void find_peak_cb(Fl_Widget *o, void *f); + static void toggle_hidden_cb(Fl_Widget *o, void *f); public: typedef enum { diff --git a/src/GipfelWidget.cxx b/src/GipfelWidget.cxx index 7e9f6fc..214d2e1 100644 --- a/src/GipfelWidget.cxx +++ b/src/GipfelWidget.cxx @@ -543,6 +543,20 @@ GipfelWidget::find_peak_cb(Fl_Widget *, void *f) { } } +void +GipfelWidget::toggle_hidden_cb(Fl_Widget *, void *f) { + GipfelWidget *g = (GipfelWidget*) f; + + Hill *m = g->find_mountain(g->pan->get_visible_mountains(), g->mouse_x, g->mouse_y); + if (!m) + return; + + if (m->flags & Hill::HIDDEN) + m->flags &= ~Hill::HIDDEN; + else + m->flags |= Hill::HIDDEN; +} + void GipfelWidget::set_height_dist_ratio(double r) { pan->set_height_dist_ratio(r); @@ -630,15 +644,23 @@ GipfelWidget::handle(int event) { redraw(); } } else if (Fl::event_button() == FL_RIGHT_MOUSE) { - Fl_Menu_Item rclick_menu[] = { - {"Find Peak", 0, find_peak_cb, this}, - {0} - }; - const Fl_Menu_Item *mi = - rclick_menu->popup(Fl::event_x(), Fl::event_y(), 0, 0, 0); - - if (mi) - mi->do_callback(0, mi->user_data()); + Fl_Menu_Button rclick_menu(Fl::event_x_root(), + Fl::event_y_root(), 80, 1); + Hill *m = find_mountain(pan->get_visible_mountains(), + mouse_x, mouse_y); + char buf[1024]; + + rclick_menu.add("Find Peak", 0, find_peak_cb, this); + if (m) { + if (m->flags & Hill::HIDDEN) + snprintf(buf, sizeof(buf), "Unhide %s", m->name); + else + snprintf(buf, sizeof(buf), "Hide %s", m->name); + + rclick_menu.add(buf, 0, toggle_hidden_cb, this); + } + + rclick_menu.popup(); } Fl::focus(this); |