# HG changeset patch # User Shai Ayal # Date 1260637720 -7200 # Node ID cd8f355157b88eeda91ab9f7ea3da32a0d6eb774 # Parent d32a6cc0193b308048f0cfff94303382c6c4bca8 Handle figure visibility in fltk backend diff -r d32a6cc0193b -r cd8f355157b8 src/ChangeLog --- a/src/ChangeLog Fri Dec 11 21:42:02 2009 -0500 +++ b/src/ChangeLog Sat Dec 12 19:08:40 2009 +0200 @@ -1,3 +1,12 @@ +2009-12-12 Shai Ayal + + * DLD-FUNCTIONS/fltk_backend.cc (plot_window::plot_window): + Handle case where window is created but not visible. Cache + window label. + (figure_manager::toggle_window_visibility, + (figure_manager::do_toggle_window_visibility): New methods. + (fltk_backend::property_change): Handle figure visibility change. + 2009-12-11 John W. Eaton * graphics.h.in (base_properties::all_dynamic_properties): diff -r d32a6cc0193b -r cd8f355157b8 src/DLD-FUNCTIONS/fltk_backend.cc --- a/src/DLD-FUNCTIONS/fltk_backend.cc Fri Dec 11 21:42:02 2009 -0500 +++ b/src/DLD-FUNCTIONS/fltk_backend.cc Sat Dec 12 19:08:40 2009 +0200 @@ -269,9 +269,12 @@ // This allows us to have a valid OpenGL context right away. canvas->mode (FL_DEPTH | FL_DOUBLE ); - show (); - canvas->show (); - canvas->make_current (); + if (fp.is_visible ()) + { + show (); + canvas->show (); + canvas->make_current (); + } } end (); @@ -284,7 +287,8 @@ std::stringstream name; name << "octave: figure " << number (); - label (name.str ().c_str ()); + window_label = name.str (); + label (window_label.c_str ()); } ~plot_window (void) @@ -316,6 +320,9 @@ } private: + // window name -- this must exists for the duration of the window's + // life + std::string window_label; // Figure properties. figure::properties& fp; @@ -675,6 +682,17 @@ delete_window (str2idx (idx_str)); } + static void toggle_window_visibility (int idx, bool is_visible) + { + if (instance_ok ()) + instance->do_toggle_window_visibility (idx, is_visible); + } + + static void toggle_window_visibility (std::string idx_str, bool is_visible) + { + toggle_window_visibility (str2idx (idx_str), is_visible); + } + static void mark_modified (int idx) { if (instance_ok ()) @@ -752,6 +770,20 @@ } } + void do_toggle_window_visibility (int idx, bool is_visible) + { + wm_iterator win; + if ((win = windows.find (idx)) != windows.end ()) + { + if (is_visible) + win->second->show (); + else + win->second->hide (); + + win->second->redraw (); + } + } + void do_mark_modified (int idx) { wm_iterator win; @@ -911,10 +943,13 @@ if (! ov.is_empty ()) { + const figure::properties& fp = + dynamic_cast (go.get_properties ()); + switch (id) { case base_properties::VISIBLE: - // FIXME -- something to do here. + figure_manager::toggle_window_visibility (ov.string_value(), fp.is_visible ()); break; } }