From f4a67d1d4592cace46156dd84dbd5f4c5a3e6dfd Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Sat, 16 Nov 2002 23:23:35 +0000 Subject: [PATCH] Save more window positions + polish previous commit (restore defaults) --- Common/Context.h | 3 +++ Common/DefaultOptions.h | 12 +++++++++++ Common/Options.cpp | 26 +++++++++++++++++++++- Common/Options.h | 6 ++++++ Fltk/Callbacks.cpp | 8 +++++-- Fltk/GUI.cpp | 48 ++++++++++++----------------------------- Fltk/Message.cpp | 8 ++++++- doc/VERSIONS | 7 +++--- 8 files changed, 77 insertions(+), 41 deletions(-) diff --git a/Common/Context.h b/Common/Context.h index 959ca6df3a..0dabad2cb5 100644 --- a/Common/Context.h +++ b/Common/Context.h @@ -69,6 +69,9 @@ public : int gl_position[2]; // position of the graphic window on the screen int msg_position[2]; // position of the message window on the screen int msg_size[2]; // size of the message window on the screen + int opt_position[2]; // position of the option window on the screen + int vis_position[2]; // position of the visibility window on the screen + int stat_position[2]; // position of the statistics window on the screen int center_windows; // center popup windows on the menu window int default_plugins; // do we load default plugins on startup? diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h index 306fc5f0f4..8fffc5da9e 100644 --- a/Common/DefaultOptions.h +++ b/Common/DefaultOptions.h @@ -500,6 +500,10 @@ StringXNumber GeneralOptions_Number[] = { { F|O, "MovingLight" , opt_general_moving_light , 0. , "Use a moving (i.e. which follows the model) light source" }, + { F|S, "OptionsPositionX" , opt_general_option_position0 , 650. , + "Horizontal position (in pixels) of the upper left corner of the option window" }, + { F|S, "OptionsPositionY" , opt_general_option_position1 , 150. , + "Vertical position (in pixels) of the upper left corner of the option window" }, { F|O, "Orthographic" , opt_general_orthographic , 1. , "Orthographic projection mode (0=perspective projection)" }, @@ -534,6 +538,10 @@ StringXNumber GeneralOptions_Number[] = { "X position of small axes (negative values for right alignment)" }, { F|O, "SmallAxesPositionY" , opt_general_small_axes_position1 , -35. , "Y position of small axes (negative values for bottom alignment)" }, + { F|S, "StatisticsPositionX" , opt_general_statistics_position0 , 650. , + "Horizontal position (in pixels) of the upper left corner of the statistic window" }, + { F|S, "StatisticsPositionY" , opt_general_statistics_position1 , 150. , + "Vertical position (in pixels) of the upper left corner of the statistic window" }, #ifdef _FLTK { F|O, "Terminal" , opt_general_terminal , 0. , @@ -563,6 +571,10 @@ StringXNumber GeneralOptions_Number[] = { { F|O, "Verbosity" , opt_general_verbosity , 2. , "Level of information printed during processing (0=no information)" }, + { F|S, "VisibilityPositionX" , opt_general_visibility_position0 , 650. , + "Horizontal position (in pixels) of the upper left corner of the visibility window" }, + { F|S, "VisibilityPositionY" , opt_general_visibility_position1 , 150. , + "Vertical position (in pixels) of the upper left corner of the visibility window" }, { F|O, "ZoomFactor" , opt_general_zoom_factor , 1.1 , "'Speed' of the middle mouse button zoom" }, diff --git a/Common/Options.cpp b/Common/Options.cpp index 4e827780d0..20ddebf191 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -1,4 +1,4 @@ -// $Id: Options.cpp,v 1.94 2002-11-16 21:53:23 geuzaine Exp $ +// $Id: Options.cpp,v 1.95 2002-11-16 23:23:34 geuzaine Exp $ // // Copyright (C) 1997 - 2002 C. Geuzaine, J.-F. Remacle // @@ -995,6 +995,30 @@ double opt_general_message_size1(OPT_ARGS_NUM){ if(action & GMSH_SET) CTX.msg_size[1] = (int)val; return CTX.msg_size[1]; } +double opt_general_option_position0(OPT_ARGS_NUM){ + if(action & GMSH_SET) CTX.opt_position[0] = (int)val; + return CTX.opt_position[0]; +} +double opt_general_option_position1(OPT_ARGS_NUM){ + if(action & GMSH_SET) CTX.opt_position[1] = (int)val; + return CTX.opt_position[1]; +} +double opt_general_statistics_position0(OPT_ARGS_NUM){ + if(action & GMSH_SET) CTX.stat_position[0] = (int)val; + return CTX.stat_position[0]; +} +double opt_general_statistics_position1(OPT_ARGS_NUM){ + if(action & GMSH_SET) CTX.stat_position[1] = (int)val; + return CTX.stat_position[1]; +} +double opt_general_visibility_position0(OPT_ARGS_NUM){ + if(action & GMSH_SET) CTX.vis_position[0] = (int)val; + return CTX.vis_position[0]; +} +double opt_general_visibility_position1(OPT_ARGS_NUM){ + if(action & GMSH_SET) CTX.vis_position[1] = (int)val; + return CTX.vis_position[1]; +} double opt_general_center_windows(OPT_ARGS_NUM){ if(action & GMSH_SET) CTX.center_windows = (int)val; return CTX.center_windows; diff --git a/Common/Options.h b/Common/Options.h index 39276cabc6..f5dd32b3fb 100644 --- a/Common/Options.h +++ b/Common/Options.h @@ -198,6 +198,12 @@ double opt_general_message_position0(OPT_ARGS_NUM); double opt_general_message_position1(OPT_ARGS_NUM); double opt_general_message_size0(OPT_ARGS_NUM); double opt_general_message_size1(OPT_ARGS_NUM); +double opt_general_option_position0(OPT_ARGS_NUM); +double opt_general_option_position1(OPT_ARGS_NUM); +double opt_general_statistics_position0(OPT_ARGS_NUM); +double opt_general_statistics_position1(OPT_ARGS_NUM); +double opt_general_visibility_position0(OPT_ARGS_NUM); +double opt_general_visibility_position1(OPT_ARGS_NUM); double opt_general_center_windows(OPT_ARGS_NUM); double opt_general_session_save(OPT_ARGS_NUM); double opt_general_options_save(OPT_ARGS_NUM); diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp index d3ef2a54c9..5be45e25d2 100644 --- a/Fltk/Callbacks.cpp +++ b/Fltk/Callbacks.cpp @@ -1,4 +1,4 @@ -// $Id: Callbacks.cpp,v 1.152 2002-11-16 21:53:24 geuzaine Exp $ +// $Id: Callbacks.cpp,v 1.153 2002-11-16 23:23:34 geuzaine Exp $ // // Copyright (C) 1997 - 2002 C. Geuzaine, J.-F. Remacle // @@ -624,9 +624,11 @@ void options_save_cb(CALLBACK_ARGS) { #include <unistd.h> void options_restore_defaults_cb(CALLBACK_ARGS) { - unlink(CTX.optionsrc_filename); + unlink(CTX.optionsrc_filename); // not sure if we have to remove the file... ReInit_Options(0); Init_Options_GUI(0); + if(WID && WID->get_context() == 3) // hack to refresh the buttons + WID->set_context(menu_post,0); Draw(); } @@ -2158,6 +2160,8 @@ void view_remove_cb(CALLBACK_ARGS){ if(WID->get_context() == 3) WID->set_context(menu_post, 0); + WID->reset_option_browser(); + if(!REMOVE_ALL_VIEWS) Draw(); } diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp index fafd5b0adc..1ffdb2affc 100644 --- a/Fltk/GUI.cpp +++ b/Fltk/GUI.cpp @@ -1,4 +1,4 @@ -// $Id: GUI.cpp,v 1.214 2002-11-16 21:53:24 geuzaine Exp $ +// $Id: GUI.cpp,v 1.215 2002-11-16 23:23:34 geuzaine Exp $ // // Copyright (C) 1997 - 2002 C. Geuzaine, J.-F. Remacle // @@ -664,9 +664,9 @@ GUI::GUI(int argc, char **argv) { create_option_window(); create_message_window(); + create_statistics_window(); create_visibility_window(); create_about_window(); - for(i=0; i<MAXSOLVERS; i++){ solver[i].window = NULL; create_solver_window(i); @@ -731,9 +731,8 @@ void GUI::create_menu_window(int argc, char **argv){ MH = BH + BH+6 ; #endif - m_window = new Fl_Window(width,MH); + m_window = new Fl_Window(width,MH,"Gmsh"); m_window->box(WINDOW_BOX); - m_window->label("Gmsh"); m_window->callback(file_quit_cb); #if defined(__APPLE__) && defined(APPLE_USE_SYS_MENU) @@ -1223,9 +1222,8 @@ void GUI::create_option_window(){ return; } - opt_window = new Fl_Window(width,height); + opt_window = new Fl_Window(width,height,"Options"); opt_window->box(WINDOW_BOX); - opt_window->label("Options"); // Buttons @@ -2050,10 +2048,7 @@ void GUI::create_option_window(){ view_window->end(); - - if(CTX.center_windows) - opt_window->position(m_window->x()+m_window->w()/2-(width+BROWSERW)/2, - m_window->y()+9*BH-height/2); + opt_window->position(CTX.opt_position[0], CTX.opt_position[1]); opt_window->end(); } @@ -2205,9 +2200,8 @@ void GUI::create_statistics_window(){ int width = 26*CTX.fontsize; int height = 5*WB+17*BH ; - stat_window = new Fl_Window(width,height); + stat_window = new Fl_Window(width,height,"Statistics"); stat_window->box(WINDOW_BOX); - stat_window->label("Statistics"); { Fl_Tabs* o = new Fl_Tabs(WB, WB, width-2*WB, height-3*WB-BH); { @@ -2280,15 +2274,9 @@ void GUI::create_statistics_window(){ o->callback(cancel_cb, (void*)stat_window); } - if(CTX.center_windows) - stat_window->position(m_window->x()+m_window->w()/2-width/2, - m_window->y()+9*BH-height/2); - stat_window->end(); - - stat_window->show(); - set_statistics(); - stat_window->redraw(); + stat_window->position(CTX.stat_position[0], CTX.stat_position[1]); + stat_window->end(); } void GUI::set_statistics(){ @@ -2494,9 +2482,8 @@ void GUI::create_message_window(){ int width = CTX.msg_size[0]; int height = CTX.msg_size[1]; - msg_window = new Fl_Window(width,height); + msg_window = new Fl_Window(width,height,"Messages"); msg_window->box(WINDOW_BOX); - msg_window->label("Messages"); msg_browser = new Fl_Browser(WB, WB, width-2*WB, height-3*WB-BH); msg_browser->textfont(FL_COURIER); @@ -2595,9 +2582,8 @@ void GUI::create_visibility_window(){ int width = cols[0]+cols[1]+cols[2]+cols[3]+2*WB; int height = 15*BH ; - vis_window = new Fl_Window(width,height); + vis_window = new Fl_Window(width,height,"Visibility"); vis_window->box(WINDOW_BOX); - vis_window->label("Visibility"); int brw = width-2*WB; @@ -2654,9 +2640,7 @@ void GUI::create_visibility_window(){ o->callback(cancel_cb, (void*)vis_window); } - if(CTX.center_windows) - vis_window->position(m_window->x()+m_window->w()/2-width/2, - m_window->y()+9*BH-height/2); + vis_window->position(CTX.vis_position[0], CTX.vis_position[1]); vis_window->end(); } @@ -2673,9 +2657,8 @@ void GUI::create_about_window(){ int width = 40*CTX.fontsize; int height = 10*BH ; - about_window = new Fl_Window(width,height); + about_window = new Fl_Window(width,height,"About Gmsh"); about_window->box(WINDOW_BOX); - about_window->label("About Gmsh"); { Fl_Box *o = new Fl_Box(2*WB, WB, about_width, height-3*WB-BH); @@ -2738,9 +2721,8 @@ void GUI::create_geometry_context_window(int num){ int width = 31*CTX.fontsize; int height = 5*WB+9*BH ; - context_geometry_window = new Fl_Window(width,height); + context_geometry_window = new Fl_Window(width,height,"Contextual geometry definitions"); context_geometry_window->box(WINDOW_BOX); - context_geometry_window->label("Contextual geometry definitions"); { Fl_Tabs* o = new Fl_Tabs(WB, WB, width-2*WB, height-3*WB-BH); // 0: Parameter @@ -2874,9 +2856,8 @@ void GUI::create_mesh_context_window(int num){ int width = 31*CTX.fontsize; int height = 5*WB+5*BH ; - context_mesh_window = new Fl_Window(width,height); + context_mesh_window = new Fl_Window(width,height,"Contextual mesh definitions"); context_mesh_window->box(WINDOW_BOX); - context_mesh_window->label("Contextual mesh definitions"); { Fl_Tabs* o = new Fl_Tabs(WB, WB, width-2*WB, height-3*WB-BH); // 0: Characteristic length @@ -3060,7 +3041,6 @@ void GUI::create_solver_window(int num){ o->callback(cancel_cb, (void*)solver[num].window); } - if(CTX.center_windows) solver[num].window->position(m_window->x()+m_window->w()/2-width/2, m_window->y()+9*BH-height/2); diff --git a/Fltk/Message.cpp b/Fltk/Message.cpp index e652363c6d..ce8192586c 100644 --- a/Fltk/Message.cpp +++ b/Fltk/Message.cpp @@ -1,4 +1,4 @@ -// $Id: Message.cpp,v 1.32 2002-09-19 21:44:12 geuzaine Exp $ +// $Id: Message.cpp,v 1.33 2002-11-16 23:23:34 geuzaine Exp $ // // Copyright (C) 1997 - 2002 C. Geuzaine, J.-F. Remacle // @@ -181,6 +181,12 @@ void Exit(int level){ CTX.msg_position[1] = WID->msg_window->y(); CTX.msg_size[0] = WID->msg_window->w(); CTX.msg_size[1] = WID->msg_window->h(); + CTX.opt_position[0] = WID->opt_window->x(); + CTX.opt_position[1] = WID->opt_window->y(); + CTX.stat_position[0] = WID->stat_window->x(); + CTX.stat_position[1] = WID->stat_window->y(); + CTX.vis_position[0] = WID->vis_window->x(); + CTX.vis_position[1] = WID->vis_window->y(); Print_Options(0, GMSH_SESSIONRC, CTX.sessionrc_filename); } if(CTX.options_save) diff --git a/doc/VERSIONS b/doc/VERSIONS index 6f50e09b48..e24ad7373f 100644 --- a/doc/VERSIONS +++ b/doc/VERSIONS @@ -1,10 +1,11 @@ -$Date: 2002-11-16 21:53:24 $ +$Date: 2002-11-16 23:23:35 $ New in 1.36: Enhanced view duplication (one can now use "Duplicata View[num]" in the input file); Merged all option dialogs in a new general option window; enhanced discoverability of the view option -menus; new 3D point display; small bug fixes ("Print" format in -parser, post-processing statistics, smooth normals, etc.); +menus; new 3D point and line display; many small bug fixes and +enhancements ("Print" format in parser, post-processing statistics, +smooth normals, save window positions, restore default options, etc.); New in 1.35: Graphical user interface upgraded to FLTK 1.1 (tooltips, new file chooser with multiple selection, full keyboard navigation, -- GitLab