changeset 12484:9c831d357e6f

fix initial canvas size issue
author Konstantinos Poulios <logari81@googlemail.com>
date Sun, 27 Feb 2011 16:52:04 +0100
parents 7a5aacf65f81
children f5a5e5252b5a
files src/ChangeLog src/DLD-FUNCTIONS/__init_fltk__.cc
diffstat 2 files changed, 41 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,4 +1,11 @@
-2010-02-26  Rik  <octave@nomad.inbox5.com>
+2011-02-26  Konstantinos Poulios  <logari81@googlemail.com>
+
+	* DLD-FUNCTIONS/__init_fltk__.cc (plot_window::plot_window):
+	Move canvas allocation after the configuration of the menubar.
+	(plot_window::show_menubar, plot_window::hide_menubar):
+	Simplify source code.
+
+2011-02-26  Rik  <octave@nomad.inbox5.com>
 
 	* DLD-FUNCTIONS/besselj.cc, DLD-FUNCTIONS/cellfun.cc,
 	DLD-FUNCTIONS/filter.cc, DLD-FUNCTIONS/matrix_type.cc,
--- a/src/DLD-FUNCTIONS/__init_fltk__.cc
+++ b/src/DLD-FUNCTIONS/__init_fltk__.cc
@@ -720,17 +720,6 @@
       status->textfont (FL_COURIER);
       status->textsize (10);
       status->box (FL_ENGRAVED_BOX);
-
-      // This allows us to have a valid OpenGL context right away.
-      canvas->mode (FL_DEPTH | FL_DOUBLE );
-      if (fp.is_visible ())
-        {
-          show ();
-          if (fp.get_currentaxes ().ok())
-            show_canvas ();
-          else
-            hide_canvas ();
-        }
     }
     end ();
 
@@ -748,6 +737,21 @@
       show_menubar ();
     else
       hide_menubar ();
+
+    begin ();
+    {
+      // This allows us to have a valid OpenGL context right away.
+      canvas->mode (FL_DEPTH | FL_DOUBLE );
+      if (fp.is_visible ())
+        {
+          show ();
+          if (fp.get_currentaxes ().ok())
+            show_canvas ();
+          else
+            hide_canvas ();
+        }
+    }
+    end ();
   }
 
   ~plot_window (void)
@@ -776,28 +780,28 @@
 
   void show_menubar (void)
   {
-    int dm = menu_h;
-    if (uimenu->is_visible ())
-      dm = 0;
-    canvas->resize (canvas->x (),
-                    canvas->y () + dm,
-                    canvas->w (),
-                    canvas->h () - dm);
-    uimenu->show ();
-    mark_modified ();
+    if (!uimenu->is_visible ())
+      {
+        canvas->resize (canvas->x (),
+                        canvas->y () + menu_h,
+                        canvas->w (),
+                        canvas->h () - menu_h);
+        uimenu->show ();
+        mark_modified ();
+      }
   }
 
   void hide_menubar (void)
   {
-    int dm = menu_h;
-    if (!uimenu->is_visible ())
-      dm = 0;
-    canvas->resize (canvas->x (),
-                    canvas->y () - dm,
-                    canvas->w (),
-                    canvas->h () + dm);
-    uimenu->hide ();
-    mark_modified ();
+    if (uimenu->is_visible ())
+      {
+        canvas->resize (canvas->x (),
+                        canvas->y () - menu_h,
+                        canvas->w (),
+                        canvas->h () + menu_h);
+        uimenu->hide ();
+        mark_modified ();
+      }
   }
 
   void uimenu_update(graphics_handle gh, int id)