changeset 9973:cd8f355157b8

Handle figure visibility in fltk backend
author Shai Ayal <shaiay@users.sourceforge.net>
date Sat, 12 Dec 2009 19:08:40 +0200
parents d32a6cc0193b
children 118158f10628
files src/ChangeLog src/DLD-FUNCTIONS/fltk_backend.cc
diffstat 2 files changed, 49 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,12 @@
+2009-12-12  Shai Ayal  <shaiay@users.sourceforge.net>
+
+	* 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  <jwe@octave.org>
 
 	* graphics.h.in (base_properties::all_dynamic_properties):
--- a/src/DLD-FUNCTIONS/fltk_backend.cc
+++ b/src/DLD-FUNCTIONS/fltk_backend.cc
@@ -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<const figure::properties&> (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;
 	      }
 	  }