diff --git a/doc/file/format.txt b/doc/file/format.txt index 87ec02bf..45677c7a 100644 --- a/doc/file/format.txt +++ b/doc/file/format.txt @@ -33,13 +33,16 @@ A heirachical file can contain a reference to another file: Where filename must be an absolute or relative [[type:filename]]. That file is included literally into the current one; except for indentation, the included file never escapes from the level the 'include file' line is on. - -If the file to be included can vary depending on the locale that is selected, use: ->>>include localized file: filename - -MSE will take the filename and add "_" followed by the name of the currently selected locale at the end of it. -So for example, if the locale used is the folder "en.mse-locale", the file that will be included is "filename_en" -You must provide a version of the file for each locale found in the data folder, even if it is simply a copy of the english one. + +If the file to be included can vary depending on the locale that is selected, use: +>>>include localized file: filename +MSE will take the filename and add "_" followed by the name of the currently selected locale at the end of it. +So for example, if the locale used is the folder "en.mse-locale", the file that will be included is "filename_en" +You must provide a version of the file for each locale found in the data folder, even if it is simply a copy of the english one. + +If the file to be included can vary depending on if dark mode is selected, use: +>>>include dark file: filename +MSE will take the filename and add "_dark" if the app is currently in dark mode. If not, then nothing is added to the filename. --Example-- For example, a [[type:set]] might look like this: diff --git a/doc/function/get_mse_dark_mode.txt b/doc/function/get_mse_dark_mode.txt new file mode 100644 index 00000000..43d17909 --- /dev/null +++ b/doc/function/get_mse_dark_mode.txt @@ -0,0 +1,6 @@ +Function: get_mse_dark_mode + +--Usage-- +> get_mse_dark_mode() + +Returns true if the app is currently displayed in dark mode, false if in light mode. diff --git a/doc/function/index.txt b/doc/function/index.txt index b363f26a..de23672b 100644 --- a/doc/function/index.txt +++ b/doc/function/index.txt @@ -125,6 +125,7 @@ These functions are built into the program, other [[type:function]]s can be defi | [[fun:get_mse_version]] Get the MSE app version. | [[fun:get_mse_locale]] Get the name of the currently selected locale. | [[fun:get_mse_path]] Get the MSE app folder absolute path. +| [[fun:get_mse_dark_mode]] Check if the app is displayed in dark mode or light mode. | [[fun:trace]] Output a message for debugging purposes. | [[fun:assert]] Check a condition for debugging purposes. | [[fun:warning]] Output a warning message. diff --git a/resource/about.png b/resource/about.png index 5c0ae3d7..a63686fd 100644 Binary files a/resource/about.png and b/resource/about.png differ diff --git a/resource/dark_about.png b/resource/dark_about.png new file mode 100644 index 00000000..109f156e Binary files /dev/null and b/resource/dark_about.png differ diff --git a/resource/dark_btn_collapse_down.png b/resource/dark_btn_collapse_down.png new file mode 100644 index 00000000..d5c37b13 Binary files /dev/null and b/resource/dark_btn_collapse_down.png differ diff --git a/resource/dark_btn_collapse_focus.png b/resource/dark_btn_collapse_focus.png new file mode 100644 index 00000000..8f70ddb2 Binary files /dev/null and b/resource/dark_btn_collapse_focus.png differ diff --git a/resource/dark_btn_collapse_hover.png b/resource/dark_btn_collapse_hover.png new file mode 100644 index 00000000..329f498e Binary files /dev/null and b/resource/dark_btn_collapse_hover.png differ diff --git a/resource/dark_btn_collapse_normal.png b/resource/dark_btn_collapse_normal.png new file mode 100644 index 00000000..96ed1557 Binary files /dev/null and b/resource/dark_btn_collapse_normal.png differ diff --git a/resource/dark_btn_expand_down.png b/resource/dark_btn_expand_down.png new file mode 100644 index 00000000..2a93caea Binary files /dev/null and b/resource/dark_btn_expand_down.png differ diff --git a/resource/dark_btn_expand_focus.png b/resource/dark_btn_expand_focus.png new file mode 100644 index 00000000..e7a5e97b Binary files /dev/null and b/resource/dark_btn_expand_focus.png differ diff --git a/resource/dark_btn_expand_hover.png b/resource/dark_btn_expand_hover.png new file mode 100644 index 00000000..4c7f6db2 Binary files /dev/null and b/resource/dark_btn_expand_hover.png differ diff --git a/resource/dark_btn_expand_normal.png b/resource/dark_btn_expand_normal.png new file mode 100644 index 00000000..7bbb20c2 Binary files /dev/null and b/resource/dark_btn_expand_normal.png differ diff --git a/resource/dark_selected_no.png b/resource/dark_selected_no.png new file mode 100644 index 00000000..21b63b84 Binary files /dev/null and b/resource/dark_selected_no.png differ diff --git a/resource/dark_selected_yes.png b/resource/dark_selected_yes.png new file mode 100644 index 00000000..0cdc4916 Binary files /dev/null and b/resource/dark_selected_yes.png differ diff --git a/resource/tool/dark_bold.png b/resource/tool/dark_bold.png new file mode 100644 index 00000000..5f815bed Binary files /dev/null and b/resource/tool/dark_bold.png differ diff --git a/resource/tool/dark_circle.png b/resource/tool/dark_circle.png new file mode 100644 index 00000000..c4ea300f Binary files /dev/null and b/resource/tool/dark_circle.png differ diff --git a/resource/tool/dark_cut.png b/resource/tool/dark_cut.png new file mode 100644 index 00000000..cac865e8 Binary files /dev/null and b/resource/tool/dark_cut.png differ diff --git a/resource/tool/dark_find.png b/resource/tool/dark_find.png new file mode 100644 index 00000000..dc93464c Binary files /dev/null and b/resource/tool/dark_find.png differ diff --git a/resource/tool/dark_italic.png b/resource/tool/dark_italic.png new file mode 100644 index 00000000..789c0d02 Binary files /dev/null and b/resource/tool/dark_italic.png differ diff --git a/resource/tool/dark_mode_paint.png b/resource/tool/dark_mode_paint.png new file mode 100644 index 00000000..cc21bebc Binary files /dev/null and b/resource/tool/dark_mode_paint.png differ diff --git a/resource/tool/dark_mode_rotate.png b/resource/tool/dark_mode_rotate.png new file mode 100644 index 00000000..795be254 Binary files /dev/null and b/resource/tool/dark_mode_rotate.png differ diff --git a/resource/tool/dark_no_auto.png b/resource/tool/dark_no_auto.png new file mode 100644 index 00000000..89a88aa6 Binary files /dev/null and b/resource/tool/dark_no_auto.png differ diff --git a/resource/tool/dark_rectangle.png b/resource/tool/dark_rectangle.png new file mode 100644 index 00000000..4b7178ed Binary files /dev/null and b/resource/tool/dark_rectangle.png differ diff --git a/resource/tool/dark_redo.png b/resource/tool/dark_redo.png new file mode 100644 index 00000000..3d02ceb7 Binary files /dev/null and b/resource/tool/dark_redo.png differ diff --git a/resource/tool/dark_reminder.png b/resource/tool/dark_reminder.png new file mode 100644 index 00000000..035d5e96 Binary files /dev/null and b/resource/tool/dark_reminder.png differ diff --git a/resource/tool/dark_star.png b/resource/tool/dark_star.png new file mode 100644 index 00000000..00a6e52e Binary files /dev/null and b/resource/tool/dark_star.png differ diff --git a/resource/tool/dark_symbol.png b/resource/tool/dark_symbol.png new file mode 100644 index 00000000..24ae74ec Binary files /dev/null and b/resource/tool/dark_symbol.png differ diff --git a/resource/tool/dark_triangle.png b/resource/tool/dark_triangle.png new file mode 100644 index 00000000..6ba2a772 Binary files /dev/null and b/resource/tool/dark_triangle.png differ diff --git a/resource/tool/dark_underline.png b/resource/tool/dark_underline.png new file mode 100644 index 00000000..85cd8fdb Binary files /dev/null and b/resource/tool/dark_underline.png differ diff --git a/resource/tool/dark_undo.png b/resource/tool/dark_undo.png new file mode 100644 index 00000000..5b7653a3 Binary files /dev/null and b/resource/tool/dark_undo.png differ diff --git a/resource/tool/dark_window_keywords.png b/resource/tool/dark_window_keywords.png new file mode 100644 index 00000000..e92d62f8 Binary files /dev/null and b/resource/tool/dark_window_keywords.png differ diff --git a/resource/tool/dark_window_set_info.png b/resource/tool/dark_window_set_info.png new file mode 100644 index 00000000..8419828b Binary files /dev/null and b/resource/tool/dark_window_set_info.png differ diff --git a/resource/tool/export.png b/resource/tool/export.png index 7fbf0b84..b3ab3693 100644 Binary files a/resource/tool/export.png and b/resource/tool/export.png differ diff --git a/resource/tool/find.png b/resource/tool/find.png index 589944b3..cd6452da 100644 Binary files a/resource/tool/find.png and b/resource/tool/find.png differ diff --git a/resource/tool/grid.png b/resource/tool/grid.png index 441910a7..9d5626c4 100644 Binary files a/resource/tool/grid.png and b/resource/tool/grid.png differ diff --git a/resource/tool/save.png b/resource/tool/save.png index 245d716e..13f10ed0 100644 Binary files a/resource/tool/save.png and b/resource/tool/save.png differ diff --git a/resource/tool/underline.png b/resource/tool/underline.png index 90d0df28..0622dd72 100644 Binary files a/resource/tool/underline.png and b/resource/tool/underline.png differ diff --git a/resource/tool/window_cards.png b/resource/tool/window_cards.png index cbd1b395..6d18b7de 100644 Binary files a/resource/tool/window_cards.png and b/resource/tool/window_cards.png differ diff --git a/resource/tool/window_random_pack.png b/resource/tool/window_random_pack.png index a9731622..a3432158 100644 Binary files a/resource/tool/window_random_pack.png and b/resource/tool/window_random_pack.png differ diff --git a/resource/tool/window_statistics.png b/resource/tool/window_statistics.png index 8e38f538..c737417c 100644 Binary files a/resource/tool/window_statistics.png and b/resource/tool/window_statistics.png differ diff --git a/resource/win32_res.rc b/resource/win32_res.rc index 0679722b..4d052b5c 100644 --- a/resource/win32_res.rc +++ b/resource/win32_res.rc @@ -31,17 +31,26 @@ tool/print IMAGE "tool/print.png" tool/print_preview IMAGE "tool/print_preview.png" tool/undo IMAGE "tool/undo.png" +tool/dark_undo IMAGE "tool/dark_undo.png" tool/redo IMAGE "tool/redo.png" +tool/dark_redo IMAGE "tool/dark_redo.png" tool/cut IMAGE "tool/cut.png" +tool/dark_cut IMAGE "tool/dark_cut.png" tool/copy IMAGE "tool/copy.png" tool/paste IMAGE "tool/paste.png" tool/find IMAGE "tool/find.png" +tool/dark_find IMAGE "tool/dark_find.png" tool/bold IMAGE "tool/bold.png" +tool/dark_bold IMAGE "tool/dark_bold.png" tool/italic IMAGE "tool/italic.png" +tool/dark_italic IMAGE "tool/dark_italic.png" tool/underline IMAGE "tool/underline.png" +tool/dark_underline IMAGE "tool/dark_underline.png" tool/symbol IMAGE "tool/symbol.png" +tool/dark_symbol IMAGE "tool/dark_symbol.png" tool/reminder IMAGE "tool/reminder.png" +tool/dark_reminder IMAGE "tool/dark_reminder.png" tool/no_auto IMAGE "tool/no_auto.png" tool/card_add IMAGE "tool/card_add.png" @@ -68,8 +77,10 @@ tool/clear_console IMAGE "tool/clear_console.png" tool/window_cards IMAGE "tool/window_cards.png" tool/window_set_info IMAGE "tool/window_set_info.png" +tool/dark_window_set_info IMAGE "tool/dark_window_set_info.png" tool/window_style IMAGE "tool/window_style.png" tool/window_keywords IMAGE "tool/window_keywords.png" +tool/dark_window_keywords IMAGE "tool/dark_window_keywords.png" tool/window_statistics IMAGE "tool/window_statistics.png" tool/window_random_pack IMAGE "tool/window_random_pack.png" tool/window_console IMAGE "tool/window_console.png" @@ -93,14 +104,20 @@ tool/lock_dir IMAGE "tool/lock_dir.png" tool/lock_size IMAGE "tool/lock_size.png" tool/circle IMAGE "tool/circle.png" +tool/dark_circle IMAGE "tool/dark_circle.png" tool/rectangle IMAGE "tool/rectangle.png" +tool/dark_rectangle IMAGE "tool/dark_rectangle.png" tool/triangle IMAGE "tool/triangle.png" +tool/dark_triangle IMAGE "tool/dark_triangle.png" tool/star IMAGE "tool/star.png" +tool/dark_star IMAGE "tool/dark_star.png" tool/mode_select IMAGE "tool/mode_select.png" tool/mode_rotate IMAGE "tool/mode_rotate.png" +tool/dark_mode_rotate IMAGE "tool/dark_mode_rotate.png" tool/mode_curve IMAGE "tool/mode_curve.png" tool/mode_paint IMAGE "tool/mode_paint.png" +tool/dark_mode_paint IMAGE "tool/dark_mode_paint.png" tool/mode_symmetry IMAGE "tool/mode_symmetry.png" tool/apply IMAGE "tool/apply.png" tool/duplicate IMAGE "tool/duplicate.png" @@ -145,12 +162,15 @@ sort_desc IMAGE "sort_desc.png" plus IMAGE "plus.png" minus IMAGE "minus.png" selected IMAGE "selected_yes.png" +dark_selected IMAGE "dark_selected_yes.png" deselected IMAGE "selected_no.png" +dark_deselected IMAGE "dark_selected_no.png" bool_yes IMAGE "bool_yes.png" bool_no IMAGE "bool_no.png" about IMAGE "about.png" +dark_about IMAGE "dark_about.png" btn_normal IMAGE "btn_normal.png" btn_hover IMAGE "btn_hover.png" btn_focus IMAGE "btn_focus.png" @@ -160,13 +180,21 @@ btn_ok_hover IMAGE "btn_ok_hover.png" btn_ok_focus IMAGE "btn_ok_focus.png" btn_ok_down IMAGE "btn_ok_down.png" btn_collapse_normal IMAGE "btn_collapse_normal.png" +dark_btn_collapse_normal IMAGE "dark_btn_collapse_normal.png" btn_collapse_hover IMAGE "btn_collapse_hover.png" +dark_btn_collapse_hover IMAGE "dark_btn_collapse_hover.png" btn_collapse_focus IMAGE "btn_collapse_focus.png" +dark_btn_collapse_focus IMAGE "dark_btn_collapse_focus.png" btn_collapse_down IMAGE "btn_collapse_down.png" +dark_btn_collapse_down IMAGE "dark_btn_collapse_down.png" btn_expand_normal IMAGE "btn_expand_normal.png" +dark_btn_expand_normal IMAGE "dark_btn_expand_normal.png" btn_expand_hover IMAGE "btn_expand_hover.png" +dark_btn_expand_hover IMAGE "dark_btn_expand_hover.png" btn_expand_focus IMAGE "btn_expand_focus.png" +dark_btn_expand_focus IMAGE "dark_btn_expand_focus.png" btn_expand_down IMAGE "btn_expand_down.png" +dark_btn_expand_down IMAGE "dark_btn_expand_down.png" btn_clear_filter_normal IMAGE "btn_clear_filter_normal.png" btn_clear_filter_hover IMAGE "btn_clear_filter_hover.png" btn_clear_filter_focus IMAGE "btn_clear_filter_focus.png" diff --git a/src/data/settings.cpp b/src/data/settings.cpp index 56b98249..80751bac 100644 --- a/src/data/settings.cpp +++ b/src/data/settings.cpp @@ -101,7 +101,12 @@ void GameSettings::initDefaults(const Game& game) { ar->custom = false; auto_replaces.push_back(ar); } - } + } + // make sure things aren't in a problematic state + for (auto it = cardlist_columns.begin(); it != cardlist_columns.end(); ++it) { + if (it->second.width < 20) it->second.width = 20; + } + if (images_export_filename.Trim().empty()) images_export_filename = _("{card.name}.png"); } IMPLEMENT_REFLECTION_NO_SCRIPT(GameSettings) { @@ -161,6 +166,14 @@ IMPLEMENT_REFLECTION_ENUM(CutterLinesType) { VALUE_N("none", CUTTER_NONE); } +// ----------------------------------------------------------------------------- : Dark mode settings + +IMPLEMENT_REFLECTION_ENUM(DarkModeType) { + VALUE_N("yes", DARKMODE_YES); + VALUE_N("system", DARKMODE_SYSTEM); + VALUE_N("no", DARKMODE_NO); +} + // ----------------------------------------------------------------------------- : Settings Settings settings; @@ -177,6 +190,7 @@ Settings::Settings() , symbol_grid_snap (false) , print_spacing (0.33) , print_cutter_lines (CUTTER_ALL) + , dark_mode_type (DARKMODE_SYSTEM) , internal_scale (1.0) , internal_image_extension(true) #if USE_OLD_STYLE_UPDATE_CHECKER @@ -249,6 +263,20 @@ String Settings::settingsFile() { return user_settings_dir() + _("mse.config"); } +bool Settings::darkMode() { + return wxSystemSettings::GetAppearance().IsDark(); +} + +String Settings::darkModePrefix() { + if (darkMode()) return _("dark_"); + return _(""); +} + +Color Settings::darkModeColor() { + if (darkMode()) return wxColor(15,8,0); + return wxColor(240,247,255); +} + IMPLEMENT_REFLECTION_NO_SCRIPT(Settings) { REFLECT(locale); REFLECT(recent_sets); @@ -267,6 +295,7 @@ IMPLEMENT_REFLECTION_NO_SCRIPT(Settings) { REFLECT(default_game); REFLECT(print_spacing); REFLECT(print_cutter_lines); + REFLECT(dark_mode_type); REFLECT(apprentice_location); REFLECT(internal_scale); REFLECT(internal_image_extension); @@ -305,8 +334,13 @@ void Settings::read() { wxFileInputStream file(filename); if (!file.Ok()) return; // failure is not an error Reader reader(file, nullptr, filename); - reader.handle_greedy(*this); - if (locale.Trim().empty()) locale = _("en"); + reader.handle_greedy(*this); + // make sure things aren't in a problematic state + if (locale.Trim().empty()) locale = _("en"); + if (symbol_grid_size < 30) symbol_grid_size = 30; + if (internal_scale < 1.0) internal_scale = 1.0; + if (default_stylesheet_settings.card_zoom < 0.5) default_stylesheet_settings.card_zoom = 1.0; + if (default_stylesheet_settings.export_zoom < 0.5) default_stylesheet_settings.export_zoom = 1.0; } } diff --git a/src/data/settings.hpp b/src/data/settings.hpp index 07b4141d..61e57762 100644 --- a/src/data/settings.hpp +++ b/src/data/settings.hpp @@ -120,7 +120,13 @@ enum CutterLinesType , CUTTER_NONE }; - +// ----------------------------------------------------------------------------- : Dark mode settings + +enum DarkModeType +{ DARKMODE_SYSTEM +, DARKMODE_NO +, DARKMODE_YES +}; // ----------------------------------------------------------------------------- : Settings @@ -192,7 +198,17 @@ public: double print_spacing; CutterLinesType print_cutter_lines; - + + // --------------------------------------------------- : Dark Mode + + DarkModeType dark_mode_type; + /// Is the app currently displayed in dark mode? + bool darkMode(); + /// Prefix for resource files depending on dark mode + String darkModePrefix(); + /// Background color for windows depending on dark mode + Color darkModeColor(); + // --------------------------------------------------- : Special game stuff String apprentice_location; diff --git a/src/gui/about_window.cpp b/src/gui/about_window.cpp index 63d418f3..fcbfb1e0 100644 --- a/src/gui/about_window.cpp +++ b/src/gui/about_window.cpp @@ -15,8 +15,8 @@ // ----------------------------------------------------------------------------- : About window AboutWindow::AboutWindow(Window* parent) - : wxDialog(parent, wxID_ANY, _TITLE_("about"), wxDefaultPosition, wxSize(510,460), wxCLIP_CHILDREN | wxDEFAULT_DIALOG_STYLE | wxTAB_TRAVERSAL) - , logo(load_resource_image(_("about"))) + : wxDialog(parent, wxID_ANY, _TITLE_("about"), wxDefaultPosition, wxSize(510,340), wxCLIP_CHILDREN | wxDEFAULT_DIALOG_STYLE | wxTAB_TRAVERSAL) + , logo(load_resource_image(settings.darkModePrefix() + _("about"))) { // init controls wxControl* ok_button = new HoverButton(this, wxID_OK, _("btn_ok")); @@ -47,7 +47,7 @@ void AboutWindow::draw(DC& dc) { wxSize ws = GetClientSize(); // draw background dc.SetPen (*wxTRANSPARENT_PEN); - dc.SetBrush(wxColor(240,247,255)); + dc.SetBrush(settings.darkModeColor()); dc.DrawRectangle(0, 0, ws.GetWidth(), ws.GetHeight()); // draw logo dc.DrawBitmap(logo, (ws.GetWidth() - logo.GetWidth()) / 2, 5); diff --git a/src/gui/about_window.hpp b/src/gui/about_window.hpp index 68da6b02..a3e1ccb3 100644 --- a/src/gui/about_window.hpp +++ b/src/gui/about_window.hpp @@ -9,6 +9,7 @@ // ----------------------------------------------------------------------------- : Includes #include +#include // ----------------------------------------------------------------------------- : About window @@ -79,7 +80,7 @@ public: /** name+"_normal", name+"_hover", name+"_focus", name+"_down" * are the resource names of the images used. */ - HoverButton(Window* parent, int id, const String& name, const Color& background = Color(240,247,255), bool accepts_focus = true); + HoverButton(Window* parent, int id, const String& name, const Color& background = settings.darkModeColor(), bool accepts_focus = true); /// Load different bitmaps for this button void loadBitmaps(const String& name); diff --git a/src/gui/control/card_editor.cpp b/src/gui/control/card_editor.cpp index 930827b4..20c2e977 100644 --- a/src/gui/control/card_editor.cpp +++ b/src/gui/control/card_editor.cpp @@ -487,7 +487,7 @@ void DataEditor::onChar(wxKeyEvent& ev) { void DataEditor::onContextMenu(wxContextMenuEvent& ev) { if (current_editor) { wxMenu m; - add_menu_item_tr(&m, ID_EDIT_CUT, "cut", "cut"); + add_menu_item_tr(&m, ID_EDIT_CUT, settings.darkModePrefix() + "cut", "cut"); add_menu_item_tr(&m, ID_EDIT_COPY, "copy", "copy"); add_menu_item_tr(&m, ID_EDIT_PASTE, "paste", "paste"); m.Enable(ID_EDIT_CUT, canCut()); diff --git a/src/gui/control/card_list.cpp b/src/gui/control/card_list.cpp index 8c061c4f..d2195c2b 100644 --- a/src/gui/control/card_list.cpp +++ b/src/gui/control/card_list.cpp @@ -456,7 +456,7 @@ void CardListBase::onDrag(wxMouseEvent& ev) { void CardListBase::onContextMenu(wxContextMenuEvent&) { if (allowModify()) { wxMenu m; - add_menu_item_tr(&m, wxID_CUT, "cut", "cut_card"); + add_menu_item_tr(&m, wxID_CUT, settings.darkModePrefix() + "cut", "cut_card"); add_menu_item_tr(&m, wxID_COPY, "copy", "copy_card"); add_menu_item_tr(&m, ID_CARD_AND_LINK_COPY, "card_copy", "copy card and links"); add_menu_item_tr(&m, wxID_PASTE, "paste", "paste_card"); diff --git a/src/gui/control/keyword_list.cpp b/src/gui/control/keyword_list.cpp index 3ebb1c8a..c032b133 100644 --- a/src/gui/control/keyword_list.cpp +++ b/src/gui/control/keyword_list.cpp @@ -242,7 +242,7 @@ wxListItemAttr* KeywordList::OnGetItemAttr(long pos) const { void KeywordList::onContextMenu(wxContextMenuEvent&) { wxMenu m; - add_menu_item_tr(&m, ID_EDIT_CUT, "cut", "cut_keyword"); + add_menu_item_tr(&m, ID_EDIT_CUT, settings.darkModePrefix() + "cut", "cut_keyword"); add_menu_item_tr(&m, ID_EDIT_COPY, "copy", "copy_keyword"); add_menu_item_tr(&m, ID_EDIT_PASTE, "paste", "paste_keyword"); m.AppendSeparator(); diff --git a/src/gui/control/select_card_list.cpp b/src/gui/control/select_card_list.cpp index 85567967..0b63500c 100644 --- a/src/gui/control/select_card_list.cpp +++ b/src/gui/control/select_card_list.cpp @@ -21,8 +21,8 @@ SelectCardList::SelectCardList(Window* parent, int id, long additional_style) wxImageList* il = new wxImageList(15,15); il->Add(load_resource_image(_("sort_asc")), Color(255,0,255)); il->Add(load_resource_image(_("sort_desc")), Color(255,0,255)); - il->Add(load_resource_image(_("deselected"))); - il->Add(load_resource_image(_("selected"))); + il->Add(load_resource_image(settings.darkModePrefix() + _("deselected"))); + il->Add(load_resource_image(settings.darkModePrefix() + _("selected"))); AssignImageList(il, wxIMAGE_LIST_SMALL); } SelectCardList::~SelectCardList() {} diff --git a/src/gui/preferences_window.cpp b/src/gui/preferences_window.cpp index 55a548ad..348e6ffe 100644 --- a/src/gui/preferences_window.cpp +++ b/src/gui/preferences_window.cpp @@ -39,7 +39,7 @@ public: void store() override; private: - wxComboBox* language; + wxComboBox* language, *dark_mode; wxCheckBox* open_sets_in_new_window; }; @@ -166,6 +166,7 @@ GlobalPreferencesPage::GlobalPreferencesPage(Window* parent) // init controls language = new wxComboBox(this, wxID_ANY, _(""), wxDefaultPosition, wxDefaultSize, 0, nullptr, wxCB_READONLY); open_sets_in_new_window = new wxCheckBox(this, wxID_ANY, _BUTTON_("open sets in new window")); + dark_mode = new wxComboBox(this, wxID_ANY, _(""), wxDefaultPosition, wxDefaultSize, 0, nullptr, wxCB_READONLY); // set values vector locales; package_manager.findMatching(_("*.mse-locale"), locales); @@ -178,18 +179,26 @@ GlobalPreferencesPage::GlobalPreferencesPage(Window* parent) } n++; } - open_sets_in_new_window->SetValue(settings.open_sets_in_new_window); + open_sets_in_new_window->SetValue(settings.open_sets_in_new_window); + dark_mode->Append(_LABEL_("dark mode system")); + dark_mode->Append(_LABEL_("dark mode no")); + dark_mode->Append(_LABEL_("dark mode yes")); + dark_mode->SetSelection((int)settings.dark_mode_type); // init sizer wxSizer* s = new wxBoxSizer(wxVERTICAL); s->SetSizeHints(this); wxSizer* s2 = new wxStaticBoxSizer(wxVERTICAL, this, _LABEL_("language")); - s2->Add(new wxStaticText(this, wxID_ANY, _LABEL_("app language")), 0, wxALL, 4); + s2->Add(new wxStaticText(this, wxID_ANY, _LABEL_("app language")), 0, wxALL, 4); s2->Add(language, 0, wxEXPAND | (wxALL & ~wxTOP), 4); - s2->Add(new wxStaticText(this, wxID_ANY, _HELP_( "app language")), 0, wxALL, 4); + s2->Add(new wxStaticText(this, wxID_ANY, _HELP_( "app language")), 0, wxALL, 4); s->Add(s2, 0, wxEXPAND | wxALL, 8); wxSizer* s3 = new wxStaticBoxSizer(wxVERTICAL, this, _LABEL_("windows")); s3->Add(open_sets_in_new_window, 0, wxALL, 4); s->Add(s3, 0, wxEXPAND | (wxALL & ~wxTOP), 8); + wxSizer* s4 = new wxStaticBoxSizer(wxVERTICAL, this, _LABEL_("dark mode")); + s4->Add(dark_mode, 0, wxEXPAND | (wxALL & ~wxTOP), 4); + s4->Add(new wxStaticText(this, wxID_ANY, _HELP_( "app language")), 0, wxALL, 4); + s->Add(s4, 0, wxEXPAND | wxALL, 8); SetSizer(s); } @@ -202,6 +211,8 @@ void GlobalPreferencesPage::store() { // set the_locale? // open_sets_in_new_window settings.open_sets_in_new_window = open_sets_in_new_window->GetValue(); + // dark mode + settings.dark_mode_type = (DarkModeType)dark_mode->GetSelection(); } // ----------------------------------------------------------------------------- : Preferences page : display diff --git a/src/gui/set/cards_panel.cpp b/src/gui/set/cards_panel.cpp index c5422a47..68a03f12 100644 --- a/src/gui/set/cards_panel.cpp +++ b/src/gui/set/cards_panel.cpp @@ -149,11 +149,11 @@ CardsPanel::CardsPanel(Window* parent, int id) add_menu_item_tr(menuCard, ID_SELECT_COLUMNS, nullptr, "card_list_columns"); menuFormat = new wxMenu(); - add_menu_item_tr(menuFormat, ID_FORMAT_BOLD, "bold", "bold", wxITEM_CHECK); - add_menu_item_tr(menuFormat, ID_FORMAT_ITALIC, "italic", "italic", wxITEM_CHECK); - add_menu_item_tr(menuFormat, ID_FORMAT_UNDERLINE, "underline", "underline", wxITEM_CHECK); - add_menu_item_tr(menuFormat, ID_FORMAT_SYMBOL, "symbol", "symbols", wxITEM_CHECK); - add_menu_item_tr(menuFormat, ID_FORMAT_REMINDER, "reminder", "reminder_text", wxITEM_CHECK); + add_menu_item_tr(menuFormat, ID_FORMAT_BOLD, settings.darkModePrefix() + "bold", "bold", wxITEM_CHECK); + add_menu_item_tr(menuFormat, ID_FORMAT_ITALIC, settings.darkModePrefix() + "italic", "italic", wxITEM_CHECK); + add_menu_item_tr(menuFormat, ID_FORMAT_UNDERLINE, settings.darkModePrefix() + "underline", "underline", wxITEM_CHECK); + add_menu_item_tr(menuFormat, ID_FORMAT_SYMBOL, settings.darkModePrefix() + "symbol", "symbols", wxITEM_CHECK); + add_menu_item_tr(menuFormat, ID_FORMAT_REMINDER, settings.darkModePrefix() + "reminder", "reminder_text", wxITEM_CHECK); menuFormat->AppendSeparator(); insertSymbolMenu = new wxMenuItem(menuFormat, ID_INSERT_SYMBOL, _MENU_("insert symbol")); menuFormat->Append(insertSymbolMenu); @@ -282,11 +282,11 @@ wxMenu* CardsPanel::makeAddCardsSubmenu(bool add_single_card_option) { void CardsPanel::initUI(wxToolBar* tb, wxMenuBar* mb) { // Toolbar - add_tool_tr(tb, ID_FORMAT_BOLD, "bold", "bold", false, wxITEM_CHECK); - add_tool_tr(tb, ID_FORMAT_ITALIC, "italic", "italic", false, wxITEM_CHECK); - add_tool_tr(tb, ID_FORMAT_UNDERLINE, "underline", "underline", false, wxITEM_CHECK); - add_tool_tr(tb, ID_FORMAT_SYMBOL, "symbol", "symbols", false, wxITEM_CHECK); - add_tool_tr(tb, ID_FORMAT_REMINDER, "reminder", "reminder_text", false, wxITEM_CHECK); + add_tool_tr(tb, ID_FORMAT_BOLD, settings.darkModePrefix() + "bold", "bold", false, wxITEM_CHECK); + add_tool_tr(tb, ID_FORMAT_ITALIC, settings.darkModePrefix() + "italic", "italic", false, wxITEM_CHECK); + add_tool_tr(tb, ID_FORMAT_UNDERLINE, settings.darkModePrefix() + "underline", "underline", false, wxITEM_CHECK); + add_tool_tr(tb, ID_FORMAT_SYMBOL, settings.darkModePrefix() + "symbol", "symbols", false, wxITEM_CHECK); + add_tool_tr(tb, ID_FORMAT_REMINDER, settings.darkModePrefix() + "reminder", "reminder_text", false, wxITEM_CHECK); tb->AddSeparator(); toolAddCard = add_tool_tr(tb, ID_CARD_ADD, "card_add", "add_card", false, wxITEM_DROPDOWN); tb->SetDropdownMenu(ID_CARD_ADD, makeAddCardsSubmenu(true)); @@ -377,7 +377,7 @@ void CardsPanel::onUpdateUI(wxUpdateUIEvent& ev) { } case ID_COLLAPSE_NOTES: { bool collapse = notes->GetSize().y > 0; - collapse_notes->loadBitmaps(collapse ? _("btn_collapse") : _("btn_expand")); + collapse_notes->loadBitmaps(settings.darkModePrefix() + (collapse ? _("btn_collapse") : _("btn_expand"))); collapse_notes->SetHelpText(collapse ? _HELP_("collapse notes") : _HELP_("expand notes")); break; } diff --git a/src/gui/set/set_info_panel.cpp b/src/gui/set/set_info_panel.cpp index b7b38976..87bd6dac 100644 --- a/src/gui/set/set_info_panel.cpp +++ b/src/gui/set/set_info_panel.cpp @@ -34,19 +34,19 @@ void SetInfoPanel::onChangeSet() { void SetInfoPanel::initUI(wxToolBar* tb, wxMenuBar* mb) { // Toolbar - add_tool_tr(tb, ID_FORMAT_BOLD, "bold", "bold", false, wxITEM_CHECK); - add_tool_tr(tb, ID_FORMAT_ITALIC, "italic", "italic", false, wxITEM_CHECK); - add_tool_tr(tb, ID_FORMAT_UNDERLINE, "underline", "underline", false, wxITEM_CHECK); - add_tool_tr(tb, ID_FORMAT_SYMBOL, "symbol", "symbols", false, wxITEM_CHECK); - add_tool_tr(tb, ID_FORMAT_REMINDER, "reminder", "reminder_text", false, wxITEM_CHECK); + add_tool_tr(tb, ID_FORMAT_BOLD, settings.darkModePrefix() + "bold", "bold", false, wxITEM_CHECK); + add_tool_tr(tb, ID_FORMAT_ITALIC, settings.darkModePrefix() + "italic", "italic", false, wxITEM_CHECK); + add_tool_tr(tb, ID_FORMAT_UNDERLINE, settings.darkModePrefix() + "underline", "underline", false, wxITEM_CHECK); + add_tool_tr(tb, ID_FORMAT_SYMBOL, settings.darkModePrefix() + "symbol", "symbols", false, wxITEM_CHECK); + add_tool_tr(tb, ID_FORMAT_REMINDER, settings.darkModePrefix() + "reminder", "reminder_text", false, wxITEM_CHECK); tb->Realize(); // Menus auto menuFormat = new wxMenu(); - add_menu_item_tr(menuFormat, ID_FORMAT_BOLD, "bold", "bold", wxITEM_CHECK); - add_menu_item_tr(menuFormat, ID_FORMAT_ITALIC, "italic", "italic", wxITEM_CHECK); - add_menu_item_tr(menuFormat, ID_FORMAT_UNDERLINE, "underline", "underline", wxITEM_CHECK); - add_menu_item_tr(menuFormat, ID_FORMAT_SYMBOL, "symbol", "symbols", wxITEM_CHECK); - add_menu_item_tr(menuFormat, ID_FORMAT_REMINDER, "reminder", "reminder_text", wxITEM_CHECK); + add_menu_item_tr(menuFormat, ID_FORMAT_BOLD, settings.darkModePrefix() + "bold", "bold", wxITEM_CHECK); + add_menu_item_tr(menuFormat, ID_FORMAT_ITALIC, settings.darkModePrefix() + "italic", "italic", wxITEM_CHECK); + add_menu_item_tr(menuFormat, ID_FORMAT_UNDERLINE, settings.darkModePrefix() + "underline", "underline", wxITEM_CHECK); + add_menu_item_tr(menuFormat, ID_FORMAT_SYMBOL, settings.darkModePrefix() + "symbol", "symbols", wxITEM_CHECK); + add_menu_item_tr(menuFormat, ID_FORMAT_REMINDER, settings.darkModePrefix() + "reminder", "reminder_text", wxITEM_CHECK); mb->Insert(2, menuFormat, _MENU_("format")); // focus on editor editor->SetFocus(); diff --git a/src/gui/set/window.cpp b/src/gui/set/window.cpp index 2e166913..dacf7c49 100644 --- a/src/gui/set/window.cpp +++ b/src/gui/set/window.cpp @@ -79,17 +79,17 @@ SetWindow::SetWindow(Window* parent, const SetP& set) menuBar->Append(menuFile, _MENU_("file")); auto menuEdit = new wxMenu(); - add_menu_item(menuEdit, ID_EDIT_UNDO, "undo", _MENU_1_("undo",wxEmptyString), _HELP_("undo")); - add_menu_item(menuEdit, ID_EDIT_REDO, "redo", _MENU_1_("redo",wxEmptyString), _HELP_("redo")); + add_menu_item(menuEdit, ID_EDIT_UNDO, settings.darkModePrefix() + "undo", _MENU_1_("undo",wxEmptyString), _HELP_("undo")); + add_menu_item(menuEdit, ID_EDIT_REDO, settings.darkModePrefix() + "redo", _MENU_1_("redo",wxEmptyString), _HELP_("redo")); menuEdit->AppendSeparator(); - add_menu_item_tr(menuEdit, ID_EDIT_CUT, "cut", "cut"); + add_menu_item_tr(menuEdit, ID_EDIT_CUT, settings.darkModePrefix() + "cut", "cut"); add_menu_item_tr(menuEdit, ID_EDIT_COPY, "copy", "copy"); add_menu_item_tr(menuEdit, ID_EDIT_PASTE, "paste", "paste"); menuEdit->AppendSeparator(); add_menu_item_tr(menuEdit, ID_EDIT_SELECT_ALL, nullptr, "select_all"); menuEdit->AppendSeparator(); - add_menu_item_tr(menuEdit, ID_EDIT_FIND, "find", "find"); - add_menu_item_tr(menuEdit, ID_EDIT_FIND_NEXT, nullptr, "find_next"); + add_menu_item_tr(menuEdit, ID_EDIT_FIND, settings.darkModePrefix() + "find", "find"); + add_menu_item_tr(menuEdit, ID_EDIT_FIND_NEXT, settings.darkModePrefix() + "find", "find_next"); add_menu_item_tr(menuEdit, ID_EDIT_REPLACE, nullptr, "replace"); add_menu_item_tr(menuEdit, ID_EDIT_AUTO_REPLACE, nullptr, "auto_replace"); menuEdit->AppendSeparator(); @@ -122,12 +122,12 @@ SetWindow::SetWindow(Window* parent, const SetP& set) tb->AddSeparator(); add_tool_tr(tb, ID_FILE_EXPORT, "export", "export"); tb->AddSeparator(); - add_tool_tr(tb, ID_EDIT_CUT, "cut", "cut"); + add_tool_tr(tb, ID_EDIT_CUT, settings.darkModePrefix() + "cut", "cut"); add_tool_tr(tb, ID_EDIT_COPY, "copy", "copy"); add_tool_tr(tb, ID_EDIT_PASTE, "paste", "paste"); tb->AddSeparator(); - add_tool(tb, ID_EDIT_UNDO, "undo", {}, _TOOLTIP_1_("undo", {}), _HELP_("undo")); - add_tool(tb, ID_EDIT_REDO, "redo", {}, _TOOLTIP_1_("redo", {}), _HELP_("redo")); + add_tool(tb, ID_EDIT_UNDO, settings.darkModePrefix() + "undo", {}, _TOOLTIP_1_("undo", {}), _HELP_("undo")); + add_tool(tb, ID_EDIT_REDO, settings.darkModePrefix() + "redo", {}, _TOOLTIP_1_("redo", {}), _HELP_("redo")); tb->AddSeparator(); tb->Realize(); @@ -145,13 +145,13 @@ SetWindow::SetWindow(Window* parent, const SetP& set) #endif // panels - addPanel(menuWindow, tabBar, new CardsPanel (this, wxID_ANY), 0, _("window_cards"), _("cards tab")); - addPanel(menuWindow, tabBar, new StylePanel (this, wxID_ANY), 1, _("window_style"), _("style tab")); - addPanel(menuWindow, tabBar, new SetInfoPanel (this, wxID_ANY), 2, _("window_set_info"), _("set info tab")); - addPanel(menuWindow, tabBar, new KeywordsPanel (this, wxID_ANY), 3, _("window_keywords"), _("keywords tab")); - addPanel(menuWindow, tabBar, new StatsPanel (this, wxID_ANY), 4, _("window_statistics"), _("stats tab")); - addPanel(menuWindow, tabBar, new RandomPackPanel(this, wxID_ANY), 5, _("window_random_pack"),_("random pack tab")); - addPanel(menuWindow, tabBar, new ConsolePanel (this, wxID_ANY), 6, _("window_console"), _("console tab")); + addPanel(menuWindow, tabBar, new CardsPanel (this, wxID_ANY), 0, _("window_cards"), _("cards tab")); + addPanel(menuWindow, tabBar, new StylePanel (this, wxID_ANY), 1, _("window_style"), _("style tab")); + addPanel(menuWindow, tabBar, new SetInfoPanel (this, wxID_ANY), 2, settings.darkModePrefix() + _("window_set_info"), _("set info tab")); + addPanel(menuWindow, tabBar, new KeywordsPanel (this, wxID_ANY), 3, settings.darkModePrefix() + _("window_keywords"), _("keywords tab")); + addPanel(menuWindow, tabBar, new StatsPanel (this, wxID_ANY), 4, _("window_statistics"), _("stats tab")); + addPanel(menuWindow, tabBar, new RandomPackPanel(this, wxID_ANY), 5, _("window_random_pack"),_("random pack tab")); + addPanel(menuWindow, tabBar, new ConsolePanel (this, wxID_ANY), 6, _("window_console"), _("console tab")); selectPanel(ID_WINDOW_CARDS); // select cards panel // loose ends diff --git a/src/gui/symbol/basic_shape_editor.cpp b/src/gui/symbol/basic_shape_editor.cpp index cac7178b..fb6e349d 100644 --- a/src/gui/symbol/basic_shape_editor.cpp +++ b/src/gui/symbol/basic_shape_editor.cpp @@ -42,10 +42,10 @@ void SymbolBasicShapeEditor::initUI(wxToolBar* tb, wxMenuBar* mb) { sides->SetHelpText(_HELP_("sides")); sides->SetSize(50, -1); tb->AddSeparator(); - add_tool_tr(tb, ID_SHAPE_CIRCLE, "circle", "ellipse", true, wxITEM_CHECK); - add_tool_tr(tb, ID_SHAPE_RECTANGLE, "rectangle", "rectangle",true, wxITEM_CHECK); - add_tool_tr(tb, ID_SHAPE_POLYGON, "triangle", "polygon", true, wxITEM_CHECK); - add_tool_tr(tb, ID_SHAPE_STAR, "star", "star", true, wxITEM_CHECK); + add_tool_tr(tb, ID_SHAPE_CIRCLE, settings.darkModePrefix() + "circle", "ellipse", true, wxITEM_CHECK); + add_tool_tr(tb, ID_SHAPE_RECTANGLE, settings.darkModePrefix() + "rectangle", "rectangle",true, wxITEM_CHECK); + add_tool_tr(tb, ID_SHAPE_POLYGON, settings.darkModePrefix() + "triangle", "polygon", true, wxITEM_CHECK); + add_tool_tr(tb, ID_SHAPE_STAR, settings.darkModePrefix() + "star", "star", true, wxITEM_CHECK); // tb->AddControl(sidesL); tb->AddControl(sides); tb->Realize(); diff --git a/src/gui/symbol/window.cpp b/src/gui/symbol/window.cpp index 2ab47263..0cedab2b 100644 --- a/src/gui/symbol/window.cpp +++ b/src/gui/symbol/window.cpp @@ -83,8 +83,8 @@ void SymbolWindow::init(Window* parent, SymbolP symbol) { menuBar->Append(menuFile, _MENU_("file")); auto menuEdit = new wxMenu(); - add_menu_item(menuEdit, ID_EDIT_UNDO, "undo", _MENU_1_("undo",wxEmptyString), _HELP_("undo")); - add_menu_item(menuEdit, ID_EDIT_REDO, "redo", _MENU_1_("redo",wxEmptyString), _HELP_("redo")); + add_menu_item(menuEdit, ID_EDIT_UNDO, settings.darkModePrefix() + "undo", _MENU_1_("undo",wxEmptyString), _HELP_("undo")); + add_menu_item(menuEdit, ID_EDIT_REDO, settings.darkModePrefix() + "redo", _MENU_1_("redo",wxEmptyString), _HELP_("redo")); menuEdit->AppendSeparator(); add_menu_item_tr(menuEdit, ID_EDIT_GROUP, "group", "group"); add_menu_item_tr(menuEdit, ID_EDIT_UNGROUP, "ungroup", "ungroup"); @@ -94,11 +94,11 @@ void SymbolWindow::init(Window* parent, SymbolP symbol) { auto menuTool = new wxMenu(); add_menu_item_tr(menuTool, ID_MODE_SELECT, "mode_select", "select", wxITEM_CHECK); - add_menu_item_tr(menuTool, ID_MODE_ROTATE, "mode_rotate", "rotate", wxITEM_CHECK); + add_menu_item_tr(menuTool, ID_MODE_ROTATE, settings.darkModePrefix() + "mode_rotate", "rotate", wxITEM_CHECK); add_menu_item_tr(menuTool, ID_MODE_POINTS, "mode_curve", "points", wxITEM_CHECK); - add_menu_item_tr(menuTool, ID_MODE_SHAPES, "circle", "basic_shapes", wxITEM_CHECK); + add_menu_item_tr(menuTool, ID_MODE_SHAPES, settings.darkModePrefix() + "circle", "basic_shapes", wxITEM_CHECK); add_menu_item_tr(menuTool, ID_MODE_SYMMETRY, "mode_symmetry", "symmetry", wxITEM_CHECK); - add_menu_item_tr(menuTool, ID_MODE_PAINT, "mode_paint", "paint", wxITEM_CHECK); + add_menu_item_tr(menuTool, ID_MODE_PAINT, settings.darkModePrefix() + "mode_paint", "paint", wxITEM_CHECK); menuBar->Append(menuTool, _MENU_("tool")); SetMenuBar(menuBar); @@ -111,8 +111,8 @@ void SymbolWindow::init(Window* parent, SymbolP symbol) { wxToolBar* tb = CreateToolBar(wxTB_FLAT | wxNO_BORDER | wxTB_HORIZONTAL | wxTB_TEXT); add_tool_tr(tb, ID_FILE_STORE, "apply", "store_symbol", true); tb->AddSeparator(); - add_tool(tb, ID_EDIT_UNDO, "undo", _TOOL_("undo"), _TOOLTIP_1_("undo",wxEmptyString), _HELP_("undo")); - add_tool(tb, ID_EDIT_REDO, "redo", _TOOL_("redo"), _TOOLTIP_1_("redo",wxEmptyString), _HELP_("redo")); + add_tool(tb, ID_EDIT_UNDO, settings.darkModePrefix() + "undo", _TOOL_("undo"), _TOOLTIP_1_("undo",wxEmptyString), _HELP_("undo")); + add_tool(tb, ID_EDIT_REDO, settings.darkModePrefix() + "redo", _TOOL_("redo"), _TOOLTIP_1_("redo",wxEmptyString), _HELP_("redo")); tb->AddSeparator(); add_tool_tr(tb, ID_VIEW_GRID, "grid", "grid", true, wxITEM_CHECK); add_tool_tr(tb, ID_VIEW_GRID_SNAP, "grid_snap", "snap", true, wxITEM_CHECK); @@ -123,13 +123,13 @@ void SymbolWindow::init(Window* parent, SymbolP symbol) { wxToolBar* em = new wxToolBar(emp, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTB_FLAT | wxTB_VERTICAL | wxTB_HORZ_TEXT); em->SetToolBitmapSize(wxSize(17,17)); add_tool_tr(em, ID_MODE_SELECT, "mode_select", "select", true, wxITEM_CHECK); - add_tool_tr(em, ID_MODE_ROTATE, "mode_rotate", "rotate", true, wxITEM_CHECK); + add_tool_tr(em, ID_MODE_ROTATE, settings.darkModePrefix() + "mode_rotate", "rotate", true, wxITEM_CHECK); em->AddSeparator(); add_tool_tr(em, ID_MODE_POINTS, "mode_curve", "points", true, wxITEM_CHECK); em->AddSeparator(); - add_tool_tr(em, ID_MODE_SHAPES, "circle", "basic shapes", true, wxITEM_CHECK); + add_tool_tr(em, ID_MODE_SHAPES, settings.darkModePrefix() + "circle", "basic shapes", true, wxITEM_CHECK); add_tool_tr(em, ID_MODE_SYMMETRY, "mode_symmetry", "symmetry", true, wxITEM_CHECK); - //add_tool_tr(em, ID_MODE_PAINT, "mode_paint", "paint", true, wxITEM_CHECK); + //add_tool_tr(em, ID_MODE_PAINT, settings.darkModePrefix() + "mode_paint", "paint", true, wxITEM_CHECK); em->Realize(); // Lay out @@ -176,13 +176,13 @@ void SymbolWindow::init(Window* parent, SymbolP symbol) { em = new wxToolBar(emp, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTB_FLAT | wxTB_VERTICAL | wxTB_HORZ_TEXT); em->SetToolBitmapSize(wxSize(17,17)); String spaces(max(0,n-1), _(' ')); - add_tool(em, ID_MODE_SELECT, "mode_select", _TOOL_("select") + spaces, _TOOLTIP_("select"), _HELP_("select"), wxITEM_CHECK); - add_tool(em, ID_MODE_ROTATE, "mode_rotate", _TOOL_("rotate") + spaces, _TOOLTIP_("rotate"), _HELP_("rotate"), wxITEM_CHECK); + add_tool(em, ID_MODE_SELECT, "mode_select", _TOOL_("select") + spaces, _TOOLTIP_("select"), _HELP_("select"), wxITEM_CHECK); + add_tool(em, ID_MODE_ROTATE, settings.darkModePrefix() + "mode_rotate", _TOOL_("rotate") + spaces, _TOOLTIP_("rotate"), _HELP_("rotate"), wxITEM_CHECK); em->AddSeparator(); - add_tool(em, ID_MODE_POINTS, "mode_curve", _TOOL_("points") + spaces, _TOOLTIP_("points"), _HELP_("points"), wxITEM_CHECK); + add_tool(em, ID_MODE_POINTS, "mode_curve", _TOOL_("points") + spaces, _TOOLTIP_("points"), _HELP_("points"), wxITEM_CHECK); em->AddSeparator(); - add_tool(em, ID_MODE_SHAPES, "circle", _TOOL_("basic shapes") + spaces, _TOOLTIP_("basic shapes"),_HELP_("basic shapes"), wxITEM_CHECK); - add_tool(em, ID_MODE_SYMMETRY, "mode_symmetry", _TOOL_("symmetry") + spaces, _TOOLTIP_("symmetry"), _HELP_("symmetry"), wxITEM_CHECK); + add_tool(em, ID_MODE_SHAPES, settings.darkModePrefix() + "circle", _TOOL_("basic shapes") + spaces, _TOOLTIP_("basic shapes"), _HELP_("basic shapes"), wxITEM_CHECK); + add_tool(em, ID_MODE_SYMMETRY, "mode_symmetry", _TOOL_("symmetry") + spaces, _TOOLTIP_("symmetry"), _HELP_("symmetry"), wxITEM_CHECK); em->Realize(); es = new wxBoxSizer(wxVERTICAL); diff --git a/src/gui/value/symbol.cpp b/src/gui/value/symbol.cpp index 84edca36..5a4a925b 100644 --- a/src/gui/value/symbol.cpp +++ b/src/gui/value/symbol.cpp @@ -44,7 +44,8 @@ void SymbolValueEditor::drawButton(RotatedDC& dc, int button, const String& text double y = 0; // draw button draw_button(&editor(), dc.getDC(), dc.trRectToBB(RealRect(x,y,width,height)), false, down, true); - // draw text + // draw text + dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); RealSize text_size = dc.GetTextExtent(text); dc.DrawText(text, align_in_rect((Alignment)(ALIGN_BOTTOM | ALIGN_CENTER), text_size, RealRect(x, y, width,height*0.9))); // draw image diff --git a/src/gui/welcome_window.cpp b/src/gui/welcome_window.cpp index 841073d2..aeff5b80 100644 --- a/src/gui/welcome_window.cpp +++ b/src/gui/welcome_window.cpp @@ -31,7 +31,7 @@ bool __compare_package_name(const PackagedP& a, const PackagedP& b) { } WelcomeWindow::WelcomeWindow() : wxFrame(nullptr, wxID_ANY, _TITLE_("magic set editor"), wxDefaultPosition, wxSize(520,380), wxDEFAULT_DIALOG_STYLE | wxTAB_TRAVERSAL | wxCLIP_CHILDREN ) - , logo (load_resource_image(_("about"))) + , logo (load_resource_image(settings.darkModePrefix() + _("about"))) { SetIcon(load_resource_icon(_("app"))); @@ -96,7 +96,7 @@ void WelcomeWindow::draw(DC& dc) { wxSize ws = GetClientSize(); // draw background dc.SetPen (*wxTRANSPARENT_PEN); - dc.SetBrush(Color(240,247,255)); + dc.SetBrush(settings.darkModeColor()); dc.DrawRectangle(0, 0, ws.GetWidth(), ws.GetHeight()); // draw logo dc.DrawBitmap(logo, (ws.GetWidth() - logo.GetWidth()) / 2, 5); diff --git a/src/main.cpp b/src/main.cpp index 7f680d19..745e6ca5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -96,6 +96,7 @@ int MSE::OnRun() { cli.init(); package_manager.init(); settings.read(); + SetAppearance((Appearance)settings.dark_mode_type); the_locale = Locale::byName(settings.locale); nag_about_ascii_version(); diff --git a/src/render/symbol/viewer.cpp b/src/render/symbol/viewer.cpp index 77fa18c0..aa6fe8be 100644 --- a/src/render/symbol/viewer.cpp +++ b/src/render/symbol/viewer.cpp @@ -70,11 +70,7 @@ typedef shared_ptr MemoryDCP; // Return a temporary DC with the same size as the parameter MemoryDCP getTempDC(DC& dc) { wxSize s = dc.GetSize(); - #ifdef __WXMSW__ - Bitmap buffer(s.GetWidth(), s.GetHeight(), 1); - #else - Bitmap buffer(s.GetWidth(), s.GetHeight(), 24); - #endif + Bitmap buffer(s.GetWidth(), s.GetHeight(), 24); MemoryDCP newDC(new wxMemoryDC); newDC->SelectObject(buffer); clearDC(*newDC, *wxBLACK_BRUSH); diff --git a/src/render/text/compound.cpp b/src/render/text/compound.cpp index 27027e7a..c123ed2b 100644 --- a/src/render/text/compound.cpp +++ b/src/render/text/compound.cpp @@ -11,7 +11,7 @@ // ----------------------------------------------------------------------------- : CompoundTextElement -void CompoundTextElement::draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end) const { +void CompoundTextElement::draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end, bool native_look) const { for (auto const& e : children) { size_t start_ = max(start, e->start); size_t end_ = min(end, e->end); @@ -19,7 +19,7 @@ void CompoundTextElement::draw(RotatedDC& dc, double scale, const RealRect& rect e->draw(dc, scale, RealRect(rect.x + xs[start_ - start] - xs[0], rect.y, xs[end_ - start] - xs[start_ - start], rect.height), - xs + start_ - start, what, start_, end_); + xs + start_ - start, what, start_, end_, native_look); } if (end <= e->end) return; // nothing can be after this } @@ -54,18 +54,18 @@ double CompoundTextElement::scaleStep() const { // ----------------------------------------------------------------------------- : AtomTextElement -void AtomTextElement::draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end) const { +void AtomTextElement::draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end, bool native_look) const { if (what & DRAW_ACTIVE) { dc.SetPen(*wxTRANSPARENT_PEN); dc.SetBrush(background_color); dc.DrawRectangle(rect); } - CompoundTextElement::draw(dc, scale, rect, xs, what, start, end); + CompoundTextElement::draw(dc, scale, rect, xs, what, start, end, native_look); } // ----------------------------------------------------------------------------- : ErrorTextElement -void ErrorTextElement::draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end) const { +void ErrorTextElement::draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end, bool native_look) const { // Draw wavy underline if (what & DRAW_ERRORS) { dc.SetPen(*wxRED_PEN); @@ -82,5 +82,5 @@ void ErrorTextElement::draw(RotatedDC& dc, double scale, const RealRect& rect, c } } // Draw the contents - CompoundTextElement::draw(dc, scale, rect, xs, what, start, end); + CompoundTextElement::draw(dc, scale, rect, xs, what, start, end, native_look); } diff --git a/src/render/text/element.hpp b/src/render/text/element.hpp index 69e81d86..ebd130bf 100644 --- a/src/render/text/element.hpp +++ b/src/render/text/element.hpp @@ -58,7 +58,7 @@ public: /// Draw a subsection section of the text in the given rectangle /** xs give the x coordinates for each character * this->start <= start < end <= this->end <= text.size() */ - virtual void draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end) const = 0; + virtual void draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end, bool native_look) const = 0; /// Get information on all characters in the range [start...end) and store them in out virtual void getCharInfo(RotatedDC& dc, double scale, vector& out) const = 0; /// Return the minimum scale factor allowed (starts at 1) @@ -77,7 +77,7 @@ public: , font(font), draw_as(draw_as), break_style(break_style) {} - void draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end) const override; + void draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end, bool native_look) const override; void getCharInfo(RotatedDC& dc, double scale, vector& out) const override; double minScale() const override; double scaleStep() const override; @@ -96,7 +96,7 @@ public: , font(font), ctx(*ctx) {} - void draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end) const override; + void draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end, bool native_look) const override; void getCharInfo(RotatedDC& dc, double scale, vector& out) const override; double minScale() const override; double scaleStep() const override; @@ -113,7 +113,7 @@ class CompoundTextElement : public TextElement { public: CompoundTextElement(size_t start, size_t end) : TextElement(start, end) {} - void draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end) const override; + void draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end, bool native_look) const override; void getCharInfo(RotatedDC& dc, double scale, vector& out) const override; double minScale() const override; double scaleStep() const override; @@ -130,7 +130,7 @@ class AtomTextElement : public CompoundTextElement { public: AtomTextElement(size_t start, size_t end, Color background_color) : CompoundTextElement(start, end), background_color(background_color) {} - void draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end) const override; + void draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end, bool native_look) const override; private: Color background_color; }; @@ -140,7 +140,7 @@ class ErrorTextElement : public CompoundTextElement { public: ErrorTextElement(size_t start, size_t end) : CompoundTextElement(start, end) {} - void draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end) const override; + void draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end, bool native_look) const override; }; // ----------------------------------------------------------------------------- : TextElements diff --git a/src/render/text/font.cpp b/src/render/text/font.cpp index 54f96328..c4c43ec8 100644 --- a/src/render/text/font.cpp +++ b/src/render/text/font.cpp @@ -12,16 +12,23 @@ // ----------------------------------------------------------------------------- : FontTextElement -void FontTextElement::draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end) const { +void FontTextElement::draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end, bool native_look) const { if ((what & draw_as) != draw_as) return; // don't draw // text String text = content.substr(start - this->start, end - start); if (!text.empty() && text.GetChar(text.size() - 1) == _('\n')) { text = text.substr(0, text.size() - 1); // don't draw last \n } - // draw + // draw + Color font_color = font->color; + RealSize margin(0, 0); + if (native_look) { + font->color = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); + margin = RealSize(1., 0); + } dc.SetFont(*font, scale); - dc.DrawTextWithShadow(text, *font, rect.position()); + dc.DrawTextWithShadow(text, *font, rect.position() + margin); + if (native_look) font->color = font_color; } void FontTextElement::getCharInfo(RotatedDC& dc, double scale, vector& out) const { diff --git a/src/render/text/symbol.cpp b/src/render/text/symbol.cpp index 134b8a2f..a16dcc6e 100644 --- a/src/render/text/symbol.cpp +++ b/src/render/text/symbol.cpp @@ -12,7 +12,7 @@ // ----------------------------------------------------------------------------- : SymbolTextElement -void SymbolTextElement::draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end) const { +void SymbolTextElement::draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end, bool native_look) const { if (!(what & DRAW_NORMAL)) return; if (font.font) { font.font->draw(dc, ctx, rect, font.size * scale, font.alignment, content.substr(start - this->start, end-start)); diff --git a/src/render/text/viewer.cpp b/src/render/text/viewer.cpp index cae26541..79a8fcc2 100644 --- a/src/render/text/viewer.cpp +++ b/src/render/text/viewer.cpp @@ -72,7 +72,7 @@ TextViewer::~TextViewer() {} // ----------------------------------------------------------------------------- : Drawing -void TextViewer::draw(RotatedDC& dc, const TextStyle& style, DrawWhat what) { +void TextViewer::draw(RotatedDC& dc, const TextStyle& style, DrawWhat what, bool native_look) { assert(!lines.empty()); // draw anything? if (what == DRAW_NOTHING) return; @@ -88,11 +88,11 @@ void TextViewer::draw(RotatedDC& dc, const TextStyle& style, DrawWhat what) { // Draw characters separatly for (size_t i = 0 ; i < l.positions.size() - 1 ; ++i) { RealRect rect(l.positions[i], l.top, l.positions[i+1] - l.positions[i] , l.line_height); - elements.draw(dc, scale, rect, &l.positions[i], what, l.start + i, l.start + i + 1); + elements.draw(dc, scale, rect, &l.positions[i], what, l.start + i, l.start + i + 1, native_look); } } else { RealRect rect(l.positions.front(), l.top, l.width(), l.line_height); - elements.draw(dc, scale, rect, &*l.positions.begin(), what, l.start, l.end()); + elements.draw(dc, scale, rect, &*l.positions.begin(), what, l.start, l.end(), native_look); } } } diff --git a/src/render/text/viewer.hpp b/src/render/text/viewer.hpp index 762e4a7c..3df0baad 100644 --- a/src/render/text/viewer.hpp +++ b/src/render/text/viewer.hpp @@ -46,7 +46,7 @@ public: /** The drawing information is cached, * before calling draw again with different text/style reset() should be called */ - void draw(RotatedDC& dc, const TextStyle& style, DrawWhat what); + void draw(RotatedDC& dc, const TextStyle& style, DrawWhat what, bool native_look); /// Draw an indicator for selected text void drawSelection(RotatedDC& dc, const TextStyle& style, size_t sel_start, size_t sel_end); /// Draw separators for tags diff --git a/src/render/value/choice.cpp b/src/render/value/choice.cpp index 0ddd01f1..f863fbe9 100644 --- a/src/render/value/choice.cpp +++ b/src/render/value/choice.cpp @@ -21,7 +21,13 @@ bool ChoiceValueViewer::prepare(RotatedDC& dc) { } void ChoiceValueViewer::draw(RotatedDC& dc) { drawFieldBorder(dc); - if (style().render_style & RENDER_HIDDEN) return; + if (style().render_style & RENDER_HIDDEN) return; + // render background + if (nativeLook()) { + dc.SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); + dc.SetPen(*wxTRANSPARENT_PEN); + dc.DrawRectangle(RealRect(0, 0, dc.getWidth(), dc.getHeight())); + } draw_choice_viewer(dc, *this, style(), value().value()); } @@ -101,11 +107,18 @@ void draw_choice_viewer(RotatedDC& dc, ValueViewer& viewer, ChoiceStyle& style, Alignment text_align = style.alignment; if (style.render_style & RENDER_IMAGE) { text_align = ALIGN_MIDDLE_LEFT; // can't align both text and image in the same way + } + Font& font = style.font; + Color font_color = font.color; + if (viewer.nativeLook()) { + font.color = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); + margin += 1.; } - dc.SetFont(style.font, 1.0); + dc.SetFont(font, 1.0); RealSize size = dc.GetTextExtent(text); - RealPoint pos = align_in_rect(text_align, size, dc.getInternalRect()) + RealSize(margin, 0); - dc.DrawTextWithShadow(text, style.font, pos); + RealPoint text_pos = align_in_rect(text_align, size, dc.getInternalRect()) + RealSize(margin, 0); + dc.DrawTextWithShadow(text, font, text_pos); + if (viewer.nativeLook()) font.color = font_color; } } diff --git a/src/render/value/color.cpp b/src/render/value/color.cpp index 83eaa060..45c3f4f6 100644 --- a/src/render/value/color.cpp +++ b/src/render/value/color.cpp @@ -16,8 +16,6 @@ IMPLEMENT_VALUE_VIEWER(Color); void ColorValueViewer::draw(RotatedDC& dc) { // draw in the value color - dc.SetPen(*wxTRANSPARENT_PEN); - dc.SetBrush(value().value()); if (nativeLook()) { // native look // find name of color @@ -31,15 +29,20 @@ void ColorValueViewer::draw(RotatedDC& dc) { break; } } - } - // draw name and color - dc.SetPen(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); - dc.DrawRectangle(RealRect(0, 0, 40, dc.getHeight())); - dc.SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); + } + // draw background dc.SetPen(*wxTRANSPARENT_PEN); + dc.SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); dc.DrawRectangle(RealRect(40, 0, dc.getWidth()-40, dc.getHeight())); - dc.DrawText(color_name, RealPoint(43, 3)); + // draw color + dc.SetPen(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); + dc.SetBrush(value().value()); + dc.DrawRectangle(RealRect(0, 0, 40, dc.getHeight())); + // draw name + dc.DrawText(color_name, RealPoint(45, 3)); } else { + dc.SetPen(*wxTRANSPARENT_PEN); + dc.SetBrush(value().value()); // is there a mask? const AlphaMask& alpha_mask = getMask(dc); if (alpha_mask.isLoaded()) { diff --git a/src/render/value/multiple_choice.cpp b/src/render/value/multiple_choice.cpp index 0145e387..a0e54239 100644 --- a/src/render/value/multiple_choice.cpp +++ b/src/render/value/multiple_choice.cpp @@ -24,7 +24,13 @@ bool MultipleChoiceValueViewer::prepare(RotatedDC& dc) { void MultipleChoiceValueViewer::draw(RotatedDC& dc) { drawFieldBorder(dc); if (style().render_style & RENDER_HIDDEN) return; - RealPoint pos = align_in_rect(style().alignment, RealSize(0,0), dc.getInternalRect()); + RealPoint pos = align_in_rect(style().alignment, RealSize(0,0), dc.getInternalRect()); + // render background + if (nativeLook()) { + dc.SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); + dc.SetPen(*wxTRANSPARENT_PEN); + dc.DrawRectangle(RealRect(0, 0, dc.getWidth(), dc.getHeight())); + } // selected choices vector selected; value().get(selected); @@ -38,7 +44,7 @@ void MultipleChoiceValueViewer::draw(RotatedDC& dc) { if (active) select_it++; drawChoice(dc, pos, choice, active); } - } else if (style().render_style & RENDER_LIST) { + } else if (style().render_style & RENDER_LIST) { // render only selected choices FOR_EACH(choice, selected) { drawChoice(dc, pos, choice); @@ -70,13 +76,21 @@ void MultipleChoiceValueViewer::drawChoice(RotatedDC& dc, RealPoint& pos, const } } if (style().render_style & RENDER_TEXT) { - // draw text + // draw text + Font& font = style().font; + Color font_color = font.color; + RealSize margin(0, 0); + if (nativeLook()) { + font.color = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); + margin = RealSize(1., 0); + } String text = tr(getStylePackage(), choice, capitalize_sentence); - dc.SetFont(style().font,1); + dc.SetFont(font,1); RealSize text_size = dc.GetTextExtent(text); - RealPoint text_pos = align_in_rect(ALIGN_MIDDLE_LEFT, text_size, RealRect(pos.x + size.width + 1, pos.y, 0,size.height)); - dc.DrawTextWithShadow(text, style().font, text_pos); + RealPoint text_pos = align_in_rect(ALIGN_MIDDLE_LEFT, text_size, RealRect(pos.x + size.width + 1, pos.y, 0,size.height)) + margin; + dc.DrawTextWithShadow(text, font, text_pos); size = add_horizontal(size, text_size); + if (nativeLook()) font.color = font_color; } // next position pos = move_in_direction(style().direction, pos, size, style().spacing); diff --git a/src/render/value/package_choice.cpp b/src/render/value/package_choice.cpp index 1aff601b..fd40edbb 100644 --- a/src/render/value/package_choice.cpp +++ b/src/render/value/package_choice.cpp @@ -43,7 +43,13 @@ void PackageChoiceValueViewer::initItems() { } void PackageChoiceValueViewer::draw(RotatedDC& dc) { - drawFieldBorder(dc); + drawFieldBorder(dc); + // draw background + if (nativeLook()) { + dc.SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); + dc.SetPen(*wxTRANSPARENT_PEN); + dc.DrawRectangle(RealRect(0, 0, dc.getWidth(), dc.getHeight())); + } // find item String text = value().package_name; Bitmap image; @@ -61,8 +67,16 @@ void PackageChoiceValueViewer::draw(RotatedDC& dc) { if (image.Ok()) { dc.DrawBitmap(image, RealPoint(0,0)); } - // draw text - dc.SetFont(style().font, 1.0); - RealPoint pos = align_in_rect(ALIGN_MIDDLE_LEFT, RealSize(0, dc.GetCharHeight()), dc.getInternalRect()) + RealSize(17., 0); - dc.DrawTextWithShadow(text, style().font, pos); + // draw text + Font& font = style().font; + Color font_color = font.color; + RealSize margin(0, 0); + if (nativeLook()) { + font.color = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); + margin = RealSize(1., 0); + } + dc.SetFont(font, 1.0); + RealPoint pos = align_in_rect(ALIGN_MIDDLE_LEFT, RealSize(0, dc.GetCharHeight()), dc.getInternalRect()) + RealSize(17., 0) + margin; + dc.DrawTextWithShadow(text, font, pos); + if (nativeLook()) font.color = font_color; } diff --git a/src/render/value/text.cpp b/src/render/value/text.cpp index e084e6e9..d3b11eb9 100644 --- a/src/render/value/text.cpp +++ b/src/render/value/text.cpp @@ -20,15 +20,21 @@ bool TextValueViewer::prepare(RotatedDC& dc) { } void TextValueViewer::draw(RotatedDC& dc) { - drawFieldBorder(dc); + drawFieldBorder(dc); + // draw background + if (nativeLook()) { + dc.SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); + dc.SetPen(*wxTRANSPARENT_PEN); + dc.DrawRectangle(RealRect(0, 0, dc.getWidth(), dc.getHeight())); + } if (!v.prepared()) { v.prepare(dc, value().value(), style(), getContext()); dc.setStretch(getStretch()); } DrawWhat what = drawWhat(); - v.draw(dc, style(), (DrawWhat)(what & DRAW_ACTIVE)); + v.draw(dc, style(), (DrawWhat)(what & DRAW_ACTIVE), nativeLook()); setFieldBorderPen(dc); - v.draw(dc, style(), (DrawWhat)(what & ~DRAW_ACTIVE)); + v.draw(dc, style(), (DrawWhat)(what & ~DRAW_ACTIVE), nativeLook()); } void TextValueViewer::onValueChange() { diff --git a/src/script/functions/basic.cpp b/src/script/functions/basic.cpp index 4595c903..4493e8a2 100644 --- a/src/script/functions/basic.cpp +++ b/src/script/functions/basic.cpp @@ -43,6 +43,10 @@ SCRIPT_FUNCTION(get_mse_locale) { SCRIPT_RETURN(settings.locale); } +SCRIPT_FUNCTION(get_mse_dark_mode) { + SCRIPT_RETURN(settings.darkMode()); +} + SCRIPT_FUNCTION(trace) { SCRIPT_PARAM_C(String, input); #if defined(_DEBUG) && 0 @@ -866,10 +870,12 @@ SCRIPT_FUNCTION(rule) { // ----------------------------------------------------------------------------- : Init void init_script_basic_functions(Context& ctx) { - // debugging + // app info ctx.setVariable(_("get_mse_version"), script_get_mse_version); ctx.setVariable(_("get_mse_locale"), script_get_mse_locale); ctx.setVariable(_("get_mse_path"), script_get_mse_path); + ctx.setVariable(_("get_mse_dark_mode"), script_get_mse_dark_mode); + // debugging ctx.setVariable(_("trace"), script_trace); ctx.setVariable(_("warning"), script_warning); ctx.setVariable(_("error"), script_error); diff --git a/src/script/parser.cpp b/src/script/parser.cpp index c98c4a07..c2818d0d 100644 --- a/src/script/parser.cpp +++ b/src/script/parser.cpp @@ -193,6 +193,17 @@ void TokenIterator::readToken() { addToken(TOK_STRING, include_file, pos); addToken(TOK_RPAREN, ")", eol); pos = eol; + } else if (is_substr(pos, end, "include dark file:")) { + pos += 18; // "include dark file:" + const char* newlines = "\r\n"; + auto eol = find_first_of(pos, end, newlines, newlines + 2); + String include_file = trim(StringView(pos, eol)) + (settings.darkMode() ? _("_dark") : _("")); + // include_file("filename_dark") + addToken(TOK_NAME, "include_file", pos - 18); + addToken(TOK_LPAREN, "(", pos); + addToken(TOK_STRING, include_file, pos); + addToken(TOK_RPAREN, ")", eol); + pos = eol; } else if (is_substr(pos, end, "include file:")) { pos += 13; // "include file:" const char* newlines = "\r\n"; diff --git a/src/util/io/reader.cpp b/src/util/io/reader.cpp index a2d3183f..caa3b45d 100644 --- a/src/util/io/reader.cpp +++ b/src/util/io/reader.cpp @@ -357,10 +357,14 @@ template <> void Reader::handle(Vector2D& vec) { template <> void Reader::handle(LocalFileName& f) { f = LocalFileName::fromReadString(this->getValue()); } - -String Reader::addLocale(String filename) { - return filename + _("_") + settings.locale; -} + +String Reader::addLocale(String filename) { + return filename + _("_") + settings.locale; +} + +String Reader::addDark(String filename) { + return filename + (settings.darkMode() ? _("_dark") : _("")); +} // ----------------------------------------------------------------------------- : EnumReader diff --git a/src/util/io/reader.hpp b/src/util/io/reader.hpp index 6c4f3983..d5597ad1 100644 --- a/src/util/io/reader.hpp +++ b/src/util/io/reader.hpp @@ -116,9 +116,10 @@ public: /// The package being read from inline Packaged* getPackage() const { return package; } - - String addLocale(String); - + + String addLocale(String); + String addDark(String); + /// Set the value that will be returned by the next getValue() call (may mess up the state of the reader) inline void setValue(const String& value) { state = UNHANDLED; previous_value = value; }; @@ -180,8 +181,8 @@ private: /** Maybe the key is "include file" */ template void unknownKey(T& v) { - if (key == _("include_file") || key == _("include_localized_file")) { - value = key == _("include_localized_file") ? addLocale(value) : value; + if (key == _("include_file") || key == _("include_localized_file") || key == _("include_dark_file")) { + value = key == _("include_localized_file") ? addLocale(value) : key == _("include_dark_file") ? addDark(value) : value; auto [stream, include_package] = openFileFromPackage(package, value); Reader sub_reader(*stream, include_package, value, ignore_invalid); if (sub_reader.file_app_version == 0) { diff --git a/tools/website/drupal/mse-drupal-modules/highlight.inc b/tools/website/drupal/mse-drupal-modules/highlight.inc index 65de9a64..73fc78fe 100644 --- a/tools/website/drupal/mse-drupal-modules/highlight.inc +++ b/tools/website/drupal/mse-drupal-modules/highlight.inc @@ -194,6 +194,8 @@ function highlight_script($code) { $ret .= "" . $matches[0] . ""; } else if (preg_match("@^(include localized file:)(.*)@",$code, $matches)) { $ret .= "" . $matches[1] . "" . $matches[2]; + } else if (preg_match("@^(include dark file:)(.*)@",$code, $matches)) { + $ret .= "" . $matches[1] . "" . $matches[2]; } else if (preg_match("@^(include file:)(.*)@",$code, $matches)) { $ret .= "" . $matches[1] . "" . $matches[2]; } else if (preg_match("@^([0-9][0-9.]*|true|false)@",$code, $matches)) {