diff --git a/Common/Context.h b/Common/Context.h index d84b1dc4cc09a8768d79bf3e4b5f7ed1952a3bea..0ccf203e1fc1840a4861a5451692373af9ef530e 100644 --- a/Common/Context.h +++ b/Common/Context.h @@ -110,6 +110,8 @@ class CTX { std::string display; // FLTK theme std::string guiTheme; + // FLTK color scheme + int guiColorScheme; // print messages on to the terminal? int terminal; // number of graphical windows/tiles diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h index ec1bf764e16ccf13282808d8394b8dc18b6b3876..763234f12b3407c4996f28b31991812c29847ec4 100644 --- a/Common/DefaultOptions.h +++ b/Common/DefaultOptions.h @@ -58,7 +58,7 @@ StringXString GeneralOptions_String[] = { { F, "FileName" , opt_general_filename , "" , "Current project file name (read-only)" }, - { F|O, "FltkTheme" , opt_general_gui_theme , "" , + { F|S, "FltkTheme" , opt_general_gui_theme , "" , "FLTK user interface theme (try e.g. plastic or gtk+)" }, { F|O, "GraphicsFont" , opt_general_graphics_font , "Helvetica" , @@ -433,7 +433,7 @@ StringXNumber GeneralOptions_Number[] = { { F|O, "ClipWholeElements" , opt_general_clip_whole_elements , 0. , "Clip whole elements" }, { F|O, "ColorScheme", opt_general_color_scheme , 1. , - "Default color scheme (0=dark, 1=light or 2=grayscale)" }, + "Default color scheme for graphics (0=dark, 1=light or 2=grayscale)" }, { F|O, "ConfirmOverwrite" , opt_general_confirm_overwrite, 1. , "Ask confirmation before overwriting files?" }, { F|S, "ContextPositionX" , opt_general_context_position0 , 650. , @@ -481,6 +481,8 @@ StringXNumber GeneralOptions_Number[] = { { F|S, "FileChooserPositionY" , opt_general_file_chooser_position1 , 200. , "Vertical position (in pixels) of the upper left corner of the file chooser " "windows" }, + { F|S, "FltkColorScheme" , opt_general_gui_color_scheme , 0. , + "FLTK user interface color theme (0: standard, 1:dark)" }, { F|O, "FontSize" , opt_general_fontsize , -1. , "Size of the font in the user interface (-1=automatic)" }, diff --git a/Common/Options.cpp b/Common/Options.cpp index 0e76656ccbd843e8b9765df4a8bd5a321940d141..a0f30d8b92917b0cd578bb9ecd02c95d0df955cf 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -1942,6 +1942,13 @@ double opt_general_fontsize(OPT_ARGS_NUM) return CTX::instance()->fontSize; } +double opt_general_gui_color_scheme(OPT_ARGS_NUM) +{ + if(action & GMSH_SET) + CTX::instance()->guiColorScheme = (int)val; + return CTX::instance()->guiColorScheme; +} + double opt_general_graphics_fontsize(OPT_ARGS_NUM) { if(action & GMSH_SET) diff --git a/Common/Options.h b/Common/Options.h index c4ed742ad0e6cf5ead4816c1240edeeb7f7c4b44..0ec901da7c872cd1ff8234482d51b5c6c9162324 100644 --- a/Common/Options.h +++ b/Common/Options.h @@ -119,6 +119,7 @@ std::string opt_print_parameter_command(OPT_ARGS_STR); double opt_general_initial_context(OPT_ARGS_NUM); double opt_general_fontsize(OPT_ARGS_NUM); +double opt_general_gui_color_scheme(OPT_ARGS_NUM); double opt_general_graphics_fontsize(OPT_ARGS_NUM); double opt_general_graphics_fontsize_title(OPT_ARGS_NUM); double opt_general_graphics_position0(OPT_ARGS_NUM); diff --git a/Fltk/FlGui.cpp b/Fltk/FlGui.cpp index a2e94115c9c17100e30b754d7fba9eab84a3542a..7f7940eb23abe0176b09d5edf428dd3726281130 100644 --- a/Fltk/FlGui.cpp +++ b/Fltk/FlGui.cpp @@ -252,17 +252,16 @@ FlGui::FlGui(int argc, char **argv) if(CTX::instance()->display.size()) Fl::display(CTX::instance()->display.c_str()); -//#define DARK_SCHEME -#if defined(DARK_SCHEME) - Fl::background(50, 50, 50); - Fl::background2(130, 130, 130); - Fl::foreground(245, 245, 245); - for (int i = 0; i < FL_NUM_GRAY; i++) { - double min = 0., max = 135.; - int d = (int)(min + i * (max - min) / (FL_NUM_GRAY - 1.)); - Fl::set_color(fl_gray_ramp(i), d, d, d); + if(CTX::instance()->guiColorScheme){ // dark mode + Fl::background(50, 50, 50); + Fl::background2(130, 130, 130); + Fl::foreground(245, 245, 245); + for (int i = 0; i < FL_NUM_GRAY; i++) { + double min = 0., max = 135.; + int d = (int)(min + i * (max - min) / (FL_NUM_GRAY - 1.)); + Fl::set_color(fl_gray_ramp(i), d, d, d); + } } -#endif // add new box types (dx dy dw dh) Fl::set_boxtype(GMSH_SIMPLE_RIGHT_BOX, simple_right_box_draw, 0, 0, 1, 0); @@ -287,8 +286,9 @@ FlGui::FlGui(int argc, char **argv) Fl::scheme(CTX::instance()->guiTheme.c_str()); Fl_Tooltip::size(FL_NORMAL_SIZE); Fl_Tooltip::delay(0.5); -#if defined(__APPLE__) && !defined(DARK_SCHEME) - Fl_Tooltip::color(FL_LIGHT2); +#if defined(__APPLE__) + if(!CTX::instance()->guiColorScheme) + Fl_Tooltip::color(FL_LIGHT2); #endif // use retina resolution if available @@ -353,9 +353,8 @@ FlGui::FlGui(int argc, char **argv) graph[0]->getWindow()->show(argc >0 ? 1 : 0, argv); if(graph[0]->getMenuWindow()) graph[0]->getMenuWindow()->show(); -#if defined(DARK_SCHEME) - Fl::set_color(FL_SELECTION_COLOR, 200, 200, 200); -#endif + if(CTX::instance()->guiColorScheme) + Fl::set_color(FL_SELECTION_COLOR, 200, 200, 200); // graphic window should have the initial focus (so we can e.g. directly loop // through time steps with the keyboard)