From: Pierre Ossman Date: Wed, 7 Sep 2022 08:41:44 +0000 (+0200) Subject: Split general FLTK appearance to separate file X-Git-Tag: v1.13.90~108^2~11 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=adf32175be3b2357d33752750d5b98a34dadb274;p=tigervnc.git Split general FLTK appearance to separate file These are general things and not specific to TigerVNC, so let's move it to the fltk specific directory for clarity. --- diff --git a/vncviewer/CMakeLists.txt b/vncviewer/CMakeLists.txt index 95180454..2596b10b 100644 --- a/vncviewer/CMakeLists.txt +++ b/vncviewer/CMakeLists.txt @@ -5,6 +5,7 @@ include_directories(${CMAKE_SOURCE_DIR}/common) add_executable(vncviewer fltk/MonitorArrangement.cxx + fltk/theme.cxx menukey.cxx BaseTouchHandler.cxx CConn.cxx diff --git a/vncviewer/fltk/theme.cxx b/vncviewer/fltk/theme.cxx new file mode 100644 index 00000000..7478cd88 --- /dev/null +++ b/vncviewer/fltk/theme.cxx @@ -0,0 +1,57 @@ +/* Copyright 2011-2022 Pierre Ossman for Cendio AB + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include + +#include "theme.h" + +void init_theme() +{ + // Basic text size (10pt @ 96 dpi => 13px) + FL_NORMAL_SIZE = 13; + + // Select a FLTK scheme and background color that looks somewhat + // close to modern systems + Fl::scheme("gtk+"); + Fl::background(220, 220, 220); + + // macOS has a slightly brighter default background though +#ifdef __APPLE__ + Fl::background(240, 240, 240); +#endif + + // This makes the "icon" in dialogs rounded, which fits better + // with the above schemes. + fl_message_icon()->box(FL_UP_BOX); + +#ifdef WIN32 + // Most "normal" Windows apps use this font for UI elements. + Fl::set_font(FL_HELVETICA, "Tahoma"); +#endif +} diff --git a/vncviewer/fltk/theme.h b/vncviewer/fltk/theme.h new file mode 100644 index 00000000..aa4b3586 --- /dev/null +++ b/vncviewer/fltk/theme.h @@ -0,0 +1,29 @@ +/* Copyright 2022 Pierre Ossman for Cendio AB + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef __FLTK_THEME_H__ +#define __FLTK_THEME_H__ + +void init_theme(); + +#endif diff --git a/vncviewer/vncviewer.cxx b/vncviewer/vncviewer.cxx index 13441900..a7e99ffb 100644 --- a/vncviewer/vncviewer.cxx +++ b/vncviewer/vncviewer.cxx @@ -60,13 +60,12 @@ #include #include -#include -#include #include #include #include #include +#include "fltk/theme.h" #include "fltk/util.h" #include "i18n.h" #include "parameters.h" @@ -323,18 +322,8 @@ static const char* getlocaledir() } static void init_fltk() { - // Basic text size (10pt @ 96 dpi => 13px) - FL_NORMAL_SIZE = 13; - - // Select a FLTK scheme and background color that looks somewhat - // close to modern systems - Fl::scheme("gtk+"); - Fl::background(220, 220, 220); - - // macOS has a slightly brighter default background though -#ifdef __APPLE__ - Fl::background(240, 240, 240); -#endif + // Adjust look of FLTK + init_theme(); // Proper Gnome Shell integration requires that we set a sensible // WM_CLASS for the window. @@ -395,21 +384,12 @@ static void init_fltk() delete icons[i]; #endif - // This makes the "icon" in dialogs rounded, which fits better - // with the above schemes. - fl_message_icon()->box(FL_UP_BOX); - // Turn off the annoying behaviour where popups track the mouse. fl_message_hotspot(false); // Avoid empty titles for popups fl_message_title_default(_("TigerVNC Viewer")); -#ifdef WIN32 - // Most "normal" Windows apps use this font for UI elements. - Fl::set_font(FL_HELVETICA, "Tahoma"); -#endif - // FLTK exposes these so that we can translate them. fl_no = _("No"); fl_yes = _("Yes");