Dark mode

This commit is contained in:
GenevensiS
2025-10-09 17:57:20 +02:00
committed by GitHub
parent 78b93e5701
commit 513612cd0e
76 changed files with 323 additions and 144 deletions
+10 -7
View File
@@ -33,13 +33,16 @@ A heirachical file can contain a reference to another file:
Where filename must be an absolute or relative [[type:filename]]. 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. 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: If the file to be included can vary depending on the locale that is selected, use:
>>>include localized file: <em>filename</em> >>>include localized file: <em>filename</em>
MSE will take the filename and add "_" followed by the name of the currently selected locale at the end of it.
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"
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.
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: <em>filename</em>
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-- --Example--
For example, a [[type:set]] might look like this: For example, a [[type:set]] might look like this:
+6
View File
@@ -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.
+1
View File
@@ -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_version]] Get the MSE app version.
| [[fun:get_mse_locale]] Get the name of the currently selected locale. | [[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_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:trace]] Output a message for debugging purposes.
| [[fun:assert]] Check a condition for debugging purposes. | [[fun:assert]] Check a condition for debugging purposes.
| [[fun:warning]] Output a warning message. | [[fun:warning]] Output a warning message.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 260 B

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 150 B

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 122 B

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 138 B

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 273 B

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 362 B

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 580 B

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 469 B

After

Width:  |  Height:  |  Size: 4.4 KiB

+28
View File
@@ -31,17 +31,26 @@ tool/print IMAGE "tool/print.png"
tool/print_preview IMAGE "tool/print_preview.png" tool/print_preview IMAGE "tool/print_preview.png"
tool/undo IMAGE "tool/undo.png" tool/undo IMAGE "tool/undo.png"
tool/dark_undo IMAGE "tool/dark_undo.png"
tool/redo IMAGE "tool/redo.png" tool/redo IMAGE "tool/redo.png"
tool/dark_redo IMAGE "tool/dark_redo.png"
tool/cut IMAGE "tool/cut.png" tool/cut IMAGE "tool/cut.png"
tool/dark_cut IMAGE "tool/dark_cut.png"
tool/copy IMAGE "tool/copy.png" tool/copy IMAGE "tool/copy.png"
tool/paste IMAGE "tool/paste.png" tool/paste IMAGE "tool/paste.png"
tool/find IMAGE "tool/find.png" tool/find IMAGE "tool/find.png"
tool/dark_find IMAGE "tool/dark_find.png"
tool/bold IMAGE "tool/bold.png" tool/bold IMAGE "tool/bold.png"
tool/dark_bold IMAGE "tool/dark_bold.png"
tool/italic IMAGE "tool/italic.png" tool/italic IMAGE "tool/italic.png"
tool/dark_italic IMAGE "tool/dark_italic.png"
tool/underline IMAGE "tool/underline.png" tool/underline IMAGE "tool/underline.png"
tool/dark_underline IMAGE "tool/dark_underline.png"
tool/symbol IMAGE "tool/symbol.png" tool/symbol IMAGE "tool/symbol.png"
tool/dark_symbol IMAGE "tool/dark_symbol.png"
tool/reminder IMAGE "tool/reminder.png" tool/reminder IMAGE "tool/reminder.png"
tool/dark_reminder IMAGE "tool/dark_reminder.png"
tool/no_auto IMAGE "tool/no_auto.png" tool/no_auto IMAGE "tool/no_auto.png"
tool/card_add IMAGE "tool/card_add.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_cards IMAGE "tool/window_cards.png"
tool/window_set_info IMAGE "tool/window_set_info.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_style IMAGE "tool/window_style.png"
tool/window_keywords IMAGE "tool/window_keywords.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_statistics IMAGE "tool/window_statistics.png"
tool/window_random_pack IMAGE "tool/window_random_pack.png" tool/window_random_pack IMAGE "tool/window_random_pack.png"
tool/window_console IMAGE "tool/window_console.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/lock_size IMAGE "tool/lock_size.png"
tool/circle IMAGE "tool/circle.png" tool/circle IMAGE "tool/circle.png"
tool/dark_circle IMAGE "tool/dark_circle.png"
tool/rectangle IMAGE "tool/rectangle.png" tool/rectangle IMAGE "tool/rectangle.png"
tool/dark_rectangle IMAGE "tool/dark_rectangle.png"
tool/triangle IMAGE "tool/triangle.png" tool/triangle IMAGE "tool/triangle.png"
tool/dark_triangle IMAGE "tool/dark_triangle.png"
tool/star IMAGE "tool/star.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_select IMAGE "tool/mode_select.png"
tool/mode_rotate IMAGE "tool/mode_rotate.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_curve IMAGE "tool/mode_curve.png"
tool/mode_paint IMAGE "tool/mode_paint.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/mode_symmetry IMAGE "tool/mode_symmetry.png"
tool/apply IMAGE "tool/apply.png" tool/apply IMAGE "tool/apply.png"
tool/duplicate IMAGE "tool/duplicate.png" tool/duplicate IMAGE "tool/duplicate.png"
@@ -145,12 +162,15 @@ sort_desc IMAGE "sort_desc.png"
plus IMAGE "plus.png" plus IMAGE "plus.png"
minus IMAGE "minus.png" minus IMAGE "minus.png"
selected IMAGE "selected_yes.png" selected IMAGE "selected_yes.png"
dark_selected IMAGE "dark_selected_yes.png"
deselected IMAGE "selected_no.png" deselected IMAGE "selected_no.png"
dark_deselected IMAGE "dark_selected_no.png"
bool_yes IMAGE "bool_yes.png" bool_yes IMAGE "bool_yes.png"
bool_no IMAGE "bool_no.png" bool_no IMAGE "bool_no.png"
about IMAGE "about.png" about IMAGE "about.png"
dark_about IMAGE "dark_about.png"
btn_normal IMAGE "btn_normal.png" btn_normal IMAGE "btn_normal.png"
btn_hover IMAGE "btn_hover.png" btn_hover IMAGE "btn_hover.png"
btn_focus IMAGE "btn_focus.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_focus IMAGE "btn_ok_focus.png"
btn_ok_down IMAGE "btn_ok_down.png" btn_ok_down IMAGE "btn_ok_down.png"
btn_collapse_normal IMAGE "btn_collapse_normal.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" 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" 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" 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" 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" 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" 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" 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_normal IMAGE "btn_clear_filter_normal.png"
btn_clear_filter_hover IMAGE "btn_clear_filter_hover.png" btn_clear_filter_hover IMAGE "btn_clear_filter_hover.png"
btn_clear_filter_focus IMAGE "btn_clear_filter_focus.png" btn_clear_filter_focus IMAGE "btn_clear_filter_focus.png"
+37 -3
View File
@@ -101,7 +101,12 @@ void GameSettings::initDefaults(const Game& game) {
ar->custom = false; ar->custom = false;
auto_replaces.push_back(ar); 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) { IMPLEMENT_REFLECTION_NO_SCRIPT(GameSettings) {
@@ -161,6 +166,14 @@ IMPLEMENT_REFLECTION_ENUM(CutterLinesType) {
VALUE_N("none", CUTTER_NONE); 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 settings; Settings settings;
@@ -177,6 +190,7 @@ Settings::Settings()
, symbol_grid_snap (false) , symbol_grid_snap (false)
, print_spacing (0.33) , print_spacing (0.33)
, print_cutter_lines (CUTTER_ALL) , print_cutter_lines (CUTTER_ALL)
, dark_mode_type (DARKMODE_SYSTEM)
, internal_scale (1.0) , internal_scale (1.0)
, internal_image_extension(true) , internal_image_extension(true)
#if USE_OLD_STYLE_UPDATE_CHECKER #if USE_OLD_STYLE_UPDATE_CHECKER
@@ -249,6 +263,20 @@ String Settings::settingsFile() {
return user_settings_dir() + _("mse.config"); 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) { IMPLEMENT_REFLECTION_NO_SCRIPT(Settings) {
REFLECT(locale); REFLECT(locale);
REFLECT(recent_sets); REFLECT(recent_sets);
@@ -267,6 +295,7 @@ IMPLEMENT_REFLECTION_NO_SCRIPT(Settings) {
REFLECT(default_game); REFLECT(default_game);
REFLECT(print_spacing); REFLECT(print_spacing);
REFLECT(print_cutter_lines); REFLECT(print_cutter_lines);
REFLECT(dark_mode_type);
REFLECT(apprentice_location); REFLECT(apprentice_location);
REFLECT(internal_scale); REFLECT(internal_scale);
REFLECT(internal_image_extension); REFLECT(internal_image_extension);
@@ -305,8 +334,13 @@ void Settings::read() {
wxFileInputStream file(filename); wxFileInputStream file(filename);
if (!file.Ok()) return; // failure is not an error if (!file.Ok()) return; // failure is not an error
Reader reader(file, nullptr, filename); Reader reader(file, nullptr, filename);
reader.handle_greedy(*this); reader.handle_greedy(*this);
if (locale.Trim().empty()) locale = _("en"); // 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;
} }
} }
+18 -2
View File
@@ -120,7 +120,13 @@ enum CutterLinesType
, CUTTER_NONE , CUTTER_NONE
}; };
// ----------------------------------------------------------------------------- : Dark mode settings
enum DarkModeType
{ DARKMODE_SYSTEM
, DARKMODE_NO
, DARKMODE_YES
};
// ----------------------------------------------------------------------------- : Settings // ----------------------------------------------------------------------------- : Settings
@@ -192,7 +198,17 @@ public:
double print_spacing; double print_spacing;
CutterLinesType print_cutter_lines; 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 // --------------------------------------------------- : Special game stuff
String apprentice_location; String apprentice_location;
+3 -3
View File
@@ -15,8 +15,8 @@
// ----------------------------------------------------------------------------- : About window // ----------------------------------------------------------------------------- : About window
AboutWindow::AboutWindow(Window* parent) AboutWindow::AboutWindow(Window* parent)
: wxDialog(parent, wxID_ANY, _TITLE_("about"), wxDefaultPosition, wxSize(510,460), wxCLIP_CHILDREN | wxDEFAULT_DIALOG_STYLE | wxTAB_TRAVERSAL) : wxDialog(parent, wxID_ANY, _TITLE_("about"), wxDefaultPosition, wxSize(510,340), wxCLIP_CHILDREN | wxDEFAULT_DIALOG_STYLE | wxTAB_TRAVERSAL)
, logo(load_resource_image(_("about"))) , logo(load_resource_image(settings.darkModePrefix() + _("about")))
{ {
// init controls // init controls
wxControl* ok_button = new HoverButton(this, wxID_OK, _("btn_ok")); wxControl* ok_button = new HoverButton(this, wxID_OK, _("btn_ok"));
@@ -47,7 +47,7 @@ void AboutWindow::draw(DC& dc) {
wxSize ws = GetClientSize(); wxSize ws = GetClientSize();
// draw background // draw background
dc.SetPen (*wxTRANSPARENT_PEN); dc.SetPen (*wxTRANSPARENT_PEN);
dc.SetBrush(wxColor(240,247,255)); dc.SetBrush(settings.darkModeColor());
dc.DrawRectangle(0, 0, ws.GetWidth(), ws.GetHeight()); dc.DrawRectangle(0, 0, ws.GetWidth(), ws.GetHeight());
// draw logo // draw logo
dc.DrawBitmap(logo, (ws.GetWidth() - logo.GetWidth()) / 2, 5); dc.DrawBitmap(logo, (ws.GetWidth() - logo.GetWidth()) / 2, 5);
+2 -1
View File
@@ -9,6 +9,7 @@
// ----------------------------------------------------------------------------- : Includes // ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp> #include <util/prec.hpp>
#include <data/settings.hpp>
// ----------------------------------------------------------------------------- : About window // ----------------------------------------------------------------------------- : About window
@@ -79,7 +80,7 @@ public:
/** name+"_normal", name+"_hover", name+"_focus", name+"_down" /** name+"_normal", name+"_hover", name+"_focus", name+"_down"
* are the resource names of the images used. * 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 /// Load different bitmaps for this button
void loadBitmaps(const String& name); void loadBitmaps(const String& name);
+1 -1
View File
@@ -487,7 +487,7 @@ void DataEditor::onChar(wxKeyEvent& ev) {
void DataEditor::onContextMenu(wxContextMenuEvent& ev) { void DataEditor::onContextMenu(wxContextMenuEvent& ev) {
if (current_editor) { if (current_editor) {
wxMenu m; 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_COPY, "copy", "copy");
add_menu_item_tr(&m, ID_EDIT_PASTE, "paste", "paste"); add_menu_item_tr(&m, ID_EDIT_PASTE, "paste", "paste");
m.Enable(ID_EDIT_CUT, canCut()); m.Enable(ID_EDIT_CUT, canCut());
+1 -1
View File
@@ -456,7 +456,7 @@ void CardListBase::onDrag(wxMouseEvent& ev) {
void CardListBase::onContextMenu(wxContextMenuEvent&) { void CardListBase::onContextMenu(wxContextMenuEvent&) {
if (allowModify()) { if (allowModify()) {
wxMenu m; 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, 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, ID_CARD_AND_LINK_COPY, "card_copy", "copy card and links");
add_menu_item_tr(&m, wxID_PASTE, "paste", "paste_card"); add_menu_item_tr(&m, wxID_PASTE, "paste", "paste_card");
+1 -1
View File
@@ -242,7 +242,7 @@ wxListItemAttr* KeywordList::OnGetItemAttr(long pos) const {
void KeywordList::onContextMenu(wxContextMenuEvent&) { void KeywordList::onContextMenu(wxContextMenuEvent&) {
wxMenu m; 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_COPY, "copy", "copy_keyword");
add_menu_item_tr(&m, ID_EDIT_PASTE, "paste", "paste_keyword"); add_menu_item_tr(&m, ID_EDIT_PASTE, "paste", "paste_keyword");
m.AppendSeparator(); m.AppendSeparator();
+2 -2
View File
@@ -21,8 +21,8 @@ SelectCardList::SelectCardList(Window* parent, int id, long additional_style)
wxImageList* il = new wxImageList(15,15); wxImageList* il = new wxImageList(15,15);
il->Add(load_resource_image(_("sort_asc")), Color(255,0,255)); 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(_("sort_desc")), Color(255,0,255));
il->Add(load_resource_image(_("deselected"))); il->Add(load_resource_image(settings.darkModePrefix() + _("deselected")));
il->Add(load_resource_image(_("selected"))); il->Add(load_resource_image(settings.darkModePrefix() + _("selected")));
AssignImageList(il, wxIMAGE_LIST_SMALL); AssignImageList(il, wxIMAGE_LIST_SMALL);
} }
SelectCardList::~SelectCardList() {} SelectCardList::~SelectCardList() {}
+15 -4
View File
@@ -39,7 +39,7 @@ public:
void store() override; void store() override;
private: private:
wxComboBox* language; wxComboBox* language, *dark_mode;
wxCheckBox* open_sets_in_new_window; wxCheckBox* open_sets_in_new_window;
}; };
@@ -166,6 +166,7 @@ GlobalPreferencesPage::GlobalPreferencesPage(Window* parent)
// init controls // init controls
language = new wxComboBox(this, wxID_ANY, _(""), wxDefaultPosition, wxDefaultSize, 0, nullptr, wxCB_READONLY); 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")); 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 // set values
vector<PackagedP> locales; vector<PackagedP> locales;
package_manager.findMatching(_("*.mse-locale"), locales); package_manager.findMatching(_("*.mse-locale"), locales);
@@ -178,18 +179,26 @@ GlobalPreferencesPage::GlobalPreferencesPage(Window* parent)
} }
n++; 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 // init sizer
wxSizer* s = new wxBoxSizer(wxVERTICAL); wxSizer* s = new wxBoxSizer(wxVERTICAL);
s->SetSizeHints(this); s->SetSizeHints(this);
wxSizer* s2 = new wxStaticBoxSizer(wxVERTICAL, this, _LABEL_("language")); 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(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); s->Add(s2, 0, wxEXPAND | wxALL, 8);
wxSizer* s3 = new wxStaticBoxSizer(wxVERTICAL, this, _LABEL_("windows")); wxSizer* s3 = new wxStaticBoxSizer(wxVERTICAL, this, _LABEL_("windows"));
s3->Add(open_sets_in_new_window, 0, wxALL, 4); s3->Add(open_sets_in_new_window, 0, wxALL, 4);
s->Add(s3, 0, wxEXPAND | (wxALL & ~wxTOP), 8); 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); SetSizer(s);
} }
@@ -202,6 +211,8 @@ void GlobalPreferencesPage::store() {
// set the_locale? // set the_locale?
// open_sets_in_new_window // open_sets_in_new_window
settings.open_sets_in_new_window = open_sets_in_new_window->GetValue(); 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 // ----------------------------------------------------------------------------- : Preferences page : display
+11 -11
View File
@@ -149,11 +149,11 @@ CardsPanel::CardsPanel(Window* parent, int id)
add_menu_item_tr(menuCard, ID_SELECT_COLUMNS, nullptr, "card_list_columns"); add_menu_item_tr(menuCard, ID_SELECT_COLUMNS, nullptr, "card_list_columns");
menuFormat = new wxMenu(); menuFormat = new wxMenu();
add_menu_item_tr(menuFormat, ID_FORMAT_BOLD, "bold", "bold", wxITEM_CHECK); add_menu_item_tr(menuFormat, ID_FORMAT_BOLD, settings.darkModePrefix() + "bold", "bold", wxITEM_CHECK);
add_menu_item_tr(menuFormat, ID_FORMAT_ITALIC, "italic", "italic", wxITEM_CHECK); add_menu_item_tr(menuFormat, ID_FORMAT_ITALIC, settings.darkModePrefix() + "italic", "italic", wxITEM_CHECK);
add_menu_item_tr(menuFormat, ID_FORMAT_UNDERLINE, "underline", "underline", wxITEM_CHECK); add_menu_item_tr(menuFormat, ID_FORMAT_UNDERLINE, settings.darkModePrefix() + "underline", "underline", wxITEM_CHECK);
add_menu_item_tr(menuFormat, ID_FORMAT_SYMBOL, "symbol", "symbols", wxITEM_CHECK); add_menu_item_tr(menuFormat, ID_FORMAT_SYMBOL, settings.darkModePrefix() + "symbol", "symbols", wxITEM_CHECK);
add_menu_item_tr(menuFormat, ID_FORMAT_REMINDER, "reminder", "reminder_text", wxITEM_CHECK); add_menu_item_tr(menuFormat, ID_FORMAT_REMINDER, settings.darkModePrefix() + "reminder", "reminder_text", wxITEM_CHECK);
menuFormat->AppendSeparator(); menuFormat->AppendSeparator();
insertSymbolMenu = new wxMenuItem(menuFormat, ID_INSERT_SYMBOL, _MENU_("insert symbol")); insertSymbolMenu = new wxMenuItem(menuFormat, ID_INSERT_SYMBOL, _MENU_("insert symbol"));
menuFormat->Append(insertSymbolMenu); menuFormat->Append(insertSymbolMenu);
@@ -282,11 +282,11 @@ wxMenu* CardsPanel::makeAddCardsSubmenu(bool add_single_card_option) {
void CardsPanel::initUI(wxToolBar* tb, wxMenuBar* mb) { void CardsPanel::initUI(wxToolBar* tb, wxMenuBar* mb) {
// Toolbar // Toolbar
add_tool_tr(tb, ID_FORMAT_BOLD, "bold", "bold", false, wxITEM_CHECK); add_tool_tr(tb, ID_FORMAT_BOLD, settings.darkModePrefix() + "bold", "bold", false, wxITEM_CHECK);
add_tool_tr(tb, ID_FORMAT_ITALIC, "italic", "italic", false, wxITEM_CHECK); add_tool_tr(tb, ID_FORMAT_ITALIC, settings.darkModePrefix() + "italic", "italic", false, wxITEM_CHECK);
add_tool_tr(tb, ID_FORMAT_UNDERLINE, "underline", "underline", false, wxITEM_CHECK); add_tool_tr(tb, ID_FORMAT_UNDERLINE, settings.darkModePrefix() + "underline", "underline", false, wxITEM_CHECK);
add_tool_tr(tb, ID_FORMAT_SYMBOL, "symbol", "symbols", false, wxITEM_CHECK); add_tool_tr(tb, ID_FORMAT_SYMBOL, settings.darkModePrefix() + "symbol", "symbols", false, wxITEM_CHECK);
add_tool_tr(tb, ID_FORMAT_REMINDER, "reminder", "reminder_text", false, wxITEM_CHECK); add_tool_tr(tb, ID_FORMAT_REMINDER, settings.darkModePrefix() + "reminder", "reminder_text", false, wxITEM_CHECK);
tb->AddSeparator(); tb->AddSeparator();
toolAddCard = add_tool_tr(tb, ID_CARD_ADD, "card_add", "add_card", false, wxITEM_DROPDOWN); toolAddCard = add_tool_tr(tb, ID_CARD_ADD, "card_add", "add_card", false, wxITEM_DROPDOWN);
tb->SetDropdownMenu(ID_CARD_ADD, makeAddCardsSubmenu(true)); tb->SetDropdownMenu(ID_CARD_ADD, makeAddCardsSubmenu(true));
@@ -377,7 +377,7 @@ void CardsPanel::onUpdateUI(wxUpdateUIEvent& ev) {
} }
case ID_COLLAPSE_NOTES: { case ID_COLLAPSE_NOTES: {
bool collapse = notes->GetSize().y > 0; 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")); collapse_notes->SetHelpText(collapse ? _HELP_("collapse notes") : _HELP_("expand notes"));
break; break;
} }
+10 -10
View File
@@ -34,19 +34,19 @@ void SetInfoPanel::onChangeSet() {
void SetInfoPanel::initUI(wxToolBar* tb, wxMenuBar* mb) { void SetInfoPanel::initUI(wxToolBar* tb, wxMenuBar* mb) {
// Toolbar // Toolbar
add_tool_tr(tb, ID_FORMAT_BOLD, "bold", "bold", false, wxITEM_CHECK); add_tool_tr(tb, ID_FORMAT_BOLD, settings.darkModePrefix() + "bold", "bold", false, wxITEM_CHECK);
add_tool_tr(tb, ID_FORMAT_ITALIC, "italic", "italic", false, wxITEM_CHECK); add_tool_tr(tb, ID_FORMAT_ITALIC, settings.darkModePrefix() + "italic", "italic", false, wxITEM_CHECK);
add_tool_tr(tb, ID_FORMAT_UNDERLINE, "underline", "underline", false, wxITEM_CHECK); add_tool_tr(tb, ID_FORMAT_UNDERLINE, settings.darkModePrefix() + "underline", "underline", false, wxITEM_CHECK);
add_tool_tr(tb, ID_FORMAT_SYMBOL, "symbol", "symbols", false, wxITEM_CHECK); add_tool_tr(tb, ID_FORMAT_SYMBOL, settings.darkModePrefix() + "symbol", "symbols", false, wxITEM_CHECK);
add_tool_tr(tb, ID_FORMAT_REMINDER, "reminder", "reminder_text", false, wxITEM_CHECK); add_tool_tr(tb, ID_FORMAT_REMINDER, settings.darkModePrefix() + "reminder", "reminder_text", false, wxITEM_CHECK);
tb->Realize(); tb->Realize();
// Menus // Menus
auto menuFormat = new wxMenu(); auto menuFormat = new wxMenu();
add_menu_item_tr(menuFormat, ID_FORMAT_BOLD, "bold", "bold", wxITEM_CHECK); add_menu_item_tr(menuFormat, ID_FORMAT_BOLD, settings.darkModePrefix() + "bold", "bold", wxITEM_CHECK);
add_menu_item_tr(menuFormat, ID_FORMAT_ITALIC, "italic", "italic", wxITEM_CHECK); add_menu_item_tr(menuFormat, ID_FORMAT_ITALIC, settings.darkModePrefix() + "italic", "italic", wxITEM_CHECK);
add_menu_item_tr(menuFormat, ID_FORMAT_UNDERLINE, "underline", "underline", wxITEM_CHECK); add_menu_item_tr(menuFormat, ID_FORMAT_UNDERLINE, settings.darkModePrefix() + "underline", "underline", wxITEM_CHECK);
add_menu_item_tr(menuFormat, ID_FORMAT_SYMBOL, "symbol", "symbols", wxITEM_CHECK); add_menu_item_tr(menuFormat, ID_FORMAT_SYMBOL, settings.darkModePrefix() + "symbol", "symbols", wxITEM_CHECK);
add_menu_item_tr(menuFormat, ID_FORMAT_REMINDER, "reminder", "reminder_text", wxITEM_CHECK); add_menu_item_tr(menuFormat, ID_FORMAT_REMINDER, settings.darkModePrefix() + "reminder", "reminder_text", wxITEM_CHECK);
mb->Insert(2, menuFormat, _MENU_("format")); mb->Insert(2, menuFormat, _MENU_("format"));
// focus on editor // focus on editor
editor->SetFocus(); editor->SetFocus();
+15 -15
View File
@@ -79,17 +79,17 @@ SetWindow::SetWindow(Window* parent, const SetP& set)
menuBar->Append(menuFile, _MENU_("file")); menuBar->Append(menuFile, _MENU_("file"));
auto menuEdit = new wxMenu(); auto menuEdit = new wxMenu();
add_menu_item(menuEdit, ID_EDIT_UNDO, "undo", _MENU_1_("undo",wxEmptyString), _HELP_("undo")); add_menu_item(menuEdit, ID_EDIT_UNDO, settings.darkModePrefix() + "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_REDO, settings.darkModePrefix() + "redo", _MENU_1_("redo",wxEmptyString), _HELP_("redo"));
menuEdit->AppendSeparator(); 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_COPY, "copy", "copy");
add_menu_item_tr(menuEdit, ID_EDIT_PASTE, "paste", "paste"); add_menu_item_tr(menuEdit, ID_EDIT_PASTE, "paste", "paste");
menuEdit->AppendSeparator(); menuEdit->AppendSeparator();
add_menu_item_tr(menuEdit, ID_EDIT_SELECT_ALL, nullptr, "select_all"); add_menu_item_tr(menuEdit, ID_EDIT_SELECT_ALL, nullptr, "select_all");
menuEdit->AppendSeparator(); menuEdit->AppendSeparator();
add_menu_item_tr(menuEdit, ID_EDIT_FIND, "find", "find"); add_menu_item_tr(menuEdit, ID_EDIT_FIND, settings.darkModePrefix() + "find", "find");
add_menu_item_tr(menuEdit, ID_EDIT_FIND_NEXT, nullptr, "find_next"); 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_REPLACE, nullptr, "replace");
add_menu_item_tr(menuEdit, ID_EDIT_AUTO_REPLACE, nullptr, "auto_replace"); add_menu_item_tr(menuEdit, ID_EDIT_AUTO_REPLACE, nullptr, "auto_replace");
menuEdit->AppendSeparator(); menuEdit->AppendSeparator();
@@ -122,12 +122,12 @@ SetWindow::SetWindow(Window* parent, const SetP& set)
tb->AddSeparator(); tb->AddSeparator();
add_tool_tr(tb, ID_FILE_EXPORT, "export", "export"); add_tool_tr(tb, ID_FILE_EXPORT, "export", "export");
tb->AddSeparator(); 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_COPY, "copy", "copy");
add_tool_tr(tb, ID_EDIT_PASTE, "paste", "paste"); add_tool_tr(tb, ID_EDIT_PASTE, "paste", "paste");
tb->AddSeparator(); tb->AddSeparator();
add_tool(tb, ID_EDIT_UNDO, "undo", {}, _TOOLTIP_1_("undo", {}), _HELP_("undo")); add_tool(tb, ID_EDIT_UNDO, settings.darkModePrefix() + "undo", {}, _TOOLTIP_1_("undo", {}), _HELP_("undo"));
add_tool(tb, ID_EDIT_REDO, "redo", {}, _TOOLTIP_1_("redo", {}), _HELP_("redo")); add_tool(tb, ID_EDIT_REDO, settings.darkModePrefix() + "redo", {}, _TOOLTIP_1_("redo", {}), _HELP_("redo"));
tb->AddSeparator(); tb->AddSeparator();
tb->Realize(); tb->Realize();
@@ -145,13 +145,13 @@ SetWindow::SetWindow(Window* parent, const SetP& set)
#endif #endif
// panels // panels
addPanel(menuWindow, tabBar, new CardsPanel (this, wxID_ANY), 0, _("window_cards"), _("cards 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 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 SetInfoPanel (this, wxID_ANY), 2, settings.darkModePrefix() + _("window_set_info"), _("set info tab"));
addPanel(menuWindow, tabBar, new KeywordsPanel (this, wxID_ANY), 3, _("window_keywords"), _("keywords 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 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 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 ConsolePanel (this, wxID_ANY), 6, _("window_console"), _("console tab"));
selectPanel(ID_WINDOW_CARDS); // select cards panel selectPanel(ID_WINDOW_CARDS); // select cards panel
// loose ends // loose ends
+4 -4
View File
@@ -42,10 +42,10 @@ void SymbolBasicShapeEditor::initUI(wxToolBar* tb, wxMenuBar* mb) {
sides->SetHelpText(_HELP_("sides")); sides->SetHelpText(_HELP_("sides"));
sides->SetSize(50, -1); sides->SetSize(50, -1);
tb->AddSeparator(); tb->AddSeparator();
add_tool_tr(tb, ID_SHAPE_CIRCLE, "circle", "ellipse", true, wxITEM_CHECK); add_tool_tr(tb, ID_SHAPE_CIRCLE, settings.darkModePrefix() + "circle", "ellipse", true, wxITEM_CHECK);
add_tool_tr(tb, ID_SHAPE_RECTANGLE, "rectangle", "rectangle",true, wxITEM_CHECK); add_tool_tr(tb, ID_SHAPE_RECTANGLE, settings.darkModePrefix() + "rectangle", "rectangle",true, wxITEM_CHECK);
add_tool_tr(tb, ID_SHAPE_POLYGON, "triangle", "polygon", true, wxITEM_CHECK); add_tool_tr(tb, ID_SHAPE_POLYGON, settings.darkModePrefix() + "triangle", "polygon", true, wxITEM_CHECK);
add_tool_tr(tb, ID_SHAPE_STAR, "star", "star", true, wxITEM_CHECK); add_tool_tr(tb, ID_SHAPE_STAR, settings.darkModePrefix() + "star", "star", true, wxITEM_CHECK);
// tb->AddControl(sidesL); // tb->AddControl(sidesL);
tb->AddControl(sides); tb->AddControl(sides);
tb->Realize(); tb->Realize();
+15 -15
View File
@@ -83,8 +83,8 @@ void SymbolWindow::init(Window* parent, SymbolP symbol) {
menuBar->Append(menuFile, _MENU_("file")); menuBar->Append(menuFile, _MENU_("file"));
auto menuEdit = new wxMenu(); auto menuEdit = new wxMenu();
add_menu_item(menuEdit, ID_EDIT_UNDO, "undo", _MENU_1_("undo",wxEmptyString), _HELP_("undo")); add_menu_item(menuEdit, ID_EDIT_UNDO, settings.darkModePrefix() + "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_REDO, settings.darkModePrefix() + "redo", _MENU_1_("redo",wxEmptyString), _HELP_("redo"));
menuEdit->AppendSeparator(); menuEdit->AppendSeparator();
add_menu_item_tr(menuEdit, ID_EDIT_GROUP, "group", "group"); add_menu_item_tr(menuEdit, ID_EDIT_GROUP, "group", "group");
add_menu_item_tr(menuEdit, ID_EDIT_UNGROUP, "ungroup", "ungroup"); 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(); auto menuTool = new wxMenu();
add_menu_item_tr(menuTool, ID_MODE_SELECT, "mode_select", "select", wxITEM_CHECK); 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_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_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")); menuBar->Append(menuTool, _MENU_("tool"));
SetMenuBar(menuBar); SetMenuBar(menuBar);
@@ -111,8 +111,8 @@ void SymbolWindow::init(Window* parent, SymbolP symbol) {
wxToolBar* tb = CreateToolBar(wxTB_FLAT | wxNO_BORDER | wxTB_HORIZONTAL | wxTB_TEXT); wxToolBar* tb = CreateToolBar(wxTB_FLAT | wxNO_BORDER | wxTB_HORIZONTAL | wxTB_TEXT);
add_tool_tr(tb, ID_FILE_STORE, "apply", "store_symbol", true); add_tool_tr(tb, ID_FILE_STORE, "apply", "store_symbol", true);
tb->AddSeparator(); tb->AddSeparator();
add_tool(tb, ID_EDIT_UNDO, "undo", _TOOL_("undo"), _TOOLTIP_1_("undo",wxEmptyString), _HELP_("undo")); add_tool(tb, ID_EDIT_UNDO, settings.darkModePrefix() + "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_REDO, settings.darkModePrefix() + "redo", _TOOL_("redo"), _TOOLTIP_1_("redo",wxEmptyString), _HELP_("redo"));
tb->AddSeparator(); tb->AddSeparator();
add_tool_tr(tb, ID_VIEW_GRID, "grid", "grid", true, wxITEM_CHECK); 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); 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); wxToolBar* em = new wxToolBar(emp, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTB_FLAT | wxTB_VERTICAL | wxTB_HORZ_TEXT);
em->SetToolBitmapSize(wxSize(17,17)); em->SetToolBitmapSize(wxSize(17,17));
add_tool_tr(em, ID_MODE_SELECT, "mode_select", "select", true, wxITEM_CHECK); 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(); em->AddSeparator();
add_tool_tr(em, ID_MODE_POINTS, "mode_curve", "points", true, wxITEM_CHECK); add_tool_tr(em, ID_MODE_POINTS, "mode_curve", "points", true, wxITEM_CHECK);
em->AddSeparator(); 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_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(); em->Realize();
// Lay out // 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 = new wxToolBar(emp, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTB_FLAT | wxTB_VERTICAL | wxTB_HORZ_TEXT);
em->SetToolBitmapSize(wxSize(17,17)); em->SetToolBitmapSize(wxSize(17,17));
String spaces(max(0,n-1), _(' ')); 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_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_ROTATE, settings.darkModePrefix() + "mode_rotate", _TOOL_("rotate") + spaces, _TOOLTIP_("rotate"), _HELP_("rotate"), wxITEM_CHECK);
em->AddSeparator(); 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(); 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_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); add_tool(em, ID_MODE_SYMMETRY, "mode_symmetry", _TOOL_("symmetry") + spaces, _TOOLTIP_("symmetry"), _HELP_("symmetry"), wxITEM_CHECK);
em->Realize(); em->Realize();
es = new wxBoxSizer(wxVERTICAL); es = new wxBoxSizer(wxVERTICAL);
+2 -1
View File
@@ -44,7 +44,8 @@ void SymbolValueEditor::drawButton(RotatedDC& dc, int button, const String& text
double y = 0; double y = 0;
// draw button // draw button
draw_button(&editor(), dc.getDC(), dc.trRectToBB(RealRect(x,y,width,height)), false, down, true); 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); 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))); dc.DrawText(text, align_in_rect((Alignment)(ALIGN_BOTTOM | ALIGN_CENTER), text_size, RealRect(x, y, width,height*0.9)));
// draw image // draw image
+2 -2
View File
@@ -31,7 +31,7 @@ bool __compare_package_name(const PackagedP& a, const PackagedP& b) {
} }
WelcomeWindow::WelcomeWindow() WelcomeWindow::WelcomeWindow()
: wxFrame(nullptr, wxID_ANY, _TITLE_("magic set editor"), wxDefaultPosition, wxSize(520,380), wxDEFAULT_DIALOG_STYLE | wxTAB_TRAVERSAL | wxCLIP_CHILDREN ) : 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"))); SetIcon(load_resource_icon(_("app")));
@@ -96,7 +96,7 @@ void WelcomeWindow::draw(DC& dc) {
wxSize ws = GetClientSize(); wxSize ws = GetClientSize();
// draw background // draw background
dc.SetPen (*wxTRANSPARENT_PEN); dc.SetPen (*wxTRANSPARENT_PEN);
dc.SetBrush(Color(240,247,255)); dc.SetBrush(settings.darkModeColor());
dc.DrawRectangle(0, 0, ws.GetWidth(), ws.GetHeight()); dc.DrawRectangle(0, 0, ws.GetWidth(), ws.GetHeight());
// draw logo // draw logo
dc.DrawBitmap(logo, (ws.GetWidth() - logo.GetWidth()) / 2, 5); dc.DrawBitmap(logo, (ws.GetWidth() - logo.GetWidth()) / 2, 5);
+1
View File
@@ -96,6 +96,7 @@ int MSE::OnRun() {
cli.init(); cli.init();
package_manager.init(); package_manager.init();
settings.read(); settings.read();
SetAppearance((Appearance)settings.dark_mode_type);
the_locale = Locale::byName(settings.locale); the_locale = Locale::byName(settings.locale);
nag_about_ascii_version(); nag_about_ascii_version();
+1 -5
View File
@@ -70,11 +70,7 @@ typedef shared_ptr<wxMemoryDC> MemoryDCP;
// Return a temporary DC with the same size as the parameter // Return a temporary DC with the same size as the parameter
MemoryDCP getTempDC(DC& dc) { MemoryDCP getTempDC(DC& dc) {
wxSize s = dc.GetSize(); wxSize s = dc.GetSize();
#ifdef __WXMSW__ Bitmap buffer(s.GetWidth(), s.GetHeight(), 24);
Bitmap buffer(s.GetWidth(), s.GetHeight(), 1);
#else
Bitmap buffer(s.GetWidth(), s.GetHeight(), 24);
#endif
MemoryDCP newDC(new wxMemoryDC); MemoryDCP newDC(new wxMemoryDC);
newDC->SelectObject(buffer); newDC->SelectObject(buffer);
clearDC(*newDC, *wxBLACK_BRUSH); clearDC(*newDC, *wxBLACK_BRUSH);
+6 -6
View File
@@ -11,7 +11,7 @@
// ----------------------------------------------------------------------------- : CompoundTextElement // ----------------------------------------------------------------------------- : 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) { for (auto const& e : children) {
size_t start_ = max(start, e->start); size_t start_ = max(start, e->start);
size_t end_ = min(end, e->end); 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, e->draw(dc, scale,
RealRect(rect.x + xs[start_ - start] - xs[0], rect.y, RealRect(rect.x + xs[start_ - start] - xs[0], rect.y,
xs[end_ - start] - xs[start_ - start], rect.height), 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 if (end <= e->end) return; // nothing can be after this
} }
@@ -54,18 +54,18 @@ double CompoundTextElement::scaleStep() const {
// ----------------------------------------------------------------------------- : AtomTextElement // ----------------------------------------------------------------------------- : 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) { if (what & DRAW_ACTIVE) {
dc.SetPen(*wxTRANSPARENT_PEN); dc.SetPen(*wxTRANSPARENT_PEN);
dc.SetBrush(background_color); dc.SetBrush(background_color);
dc.DrawRectangle(rect); dc.DrawRectangle(rect);
} }
CompoundTextElement::draw(dc, scale, rect, xs, what, start, end); CompoundTextElement::draw(dc, scale, rect, xs, what, start, end, native_look);
} }
// ----------------------------------------------------------------------------- : ErrorTextElement // ----------------------------------------------------------------------------- : 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 // Draw wavy underline
if (what & DRAW_ERRORS) { if (what & DRAW_ERRORS) {
dc.SetPen(*wxRED_PEN); dc.SetPen(*wxRED_PEN);
@@ -82,5 +82,5 @@ void ErrorTextElement::draw(RotatedDC& dc, double scale, const RealRect& rect, c
} }
} }
// Draw the contents // Draw the contents
CompoundTextElement::draw(dc, scale, rect, xs, what, start, end); CompoundTextElement::draw(dc, scale, rect, xs, what, start, end, native_look);
} }
+6 -6
View File
@@ -58,7 +58,7 @@ public:
/// Draw a subsection section of the text in the given rectangle /// Draw a subsection section of the text in the given rectangle
/** xs give the x coordinates for each character /** xs give the x coordinates for each character
* this->start <= start < end <= this->end <= text.size() */ * 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 /// Get information on all characters in the range [start...end) and store them in out
virtual void getCharInfo(RotatedDC& dc, double scale, vector<CharInfo>& out) const = 0; virtual void getCharInfo(RotatedDC& dc, double scale, vector<CharInfo>& out) const = 0;
/// Return the minimum scale factor allowed (starts at 1) /// Return the minimum scale factor allowed (starts at 1)
@@ -77,7 +77,7 @@ public:
, font(font), draw_as(draw_as), break_style(break_style) , 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<CharInfo>& out) const override; void getCharInfo(RotatedDC& dc, double scale, vector<CharInfo>& out) const override;
double minScale() const override; double minScale() const override;
double scaleStep() const override; double scaleStep() const override;
@@ -96,7 +96,7 @@ public:
, font(font), ctx(*ctx) , 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<CharInfo>& out) const override; void getCharInfo(RotatedDC& dc, double scale, vector<CharInfo>& out) const override;
double minScale() const override; double minScale() const override;
double scaleStep() const override; double scaleStep() const override;
@@ -113,7 +113,7 @@ class CompoundTextElement : public TextElement {
public: public:
CompoundTextElement(size_t start, size_t end) : TextElement(start, end) {} 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<CharInfo>& out) const override; void getCharInfo(RotatedDC& dc, double scale, vector<CharInfo>& out) const override;
double minScale() const override; double minScale() const override;
double scaleStep() const override; double scaleStep() const override;
@@ -130,7 +130,7 @@ class AtomTextElement : public CompoundTextElement {
public: public:
AtomTextElement(size_t start, size_t end, Color background_color) : CompoundTextElement(start, end), background_color(background_color) {} 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: private:
Color background_color; Color background_color;
}; };
@@ -140,7 +140,7 @@ class ErrorTextElement : public CompoundTextElement {
public: public:
ErrorTextElement(size_t start, size_t end) : CompoundTextElement(start, end) {} 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 // ----------------------------------------------------------------------------- : TextElements
+10 -3
View File
@@ -12,16 +12,23 @@
// ----------------------------------------------------------------------------- : FontTextElement // ----------------------------------------------------------------------------- : 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 if ((what & draw_as) != draw_as) return; // don't draw
// text // text
String text = content.substr(start - this->start, end - start); String text = content.substr(start - this->start, end - start);
if (!text.empty() && text.GetChar(text.size() - 1) == _('\n')) { if (!text.empty() && text.GetChar(text.size() - 1) == _('\n')) {
text = text.substr(0, text.size() - 1); // don't draw last \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.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<CharInfo>& out) const { void FontTextElement::getCharInfo(RotatedDC& dc, double scale, vector<CharInfo>& out) const {
+1 -1
View File
@@ -12,7 +12,7 @@
// ----------------------------------------------------------------------------- : SymbolTextElement // ----------------------------------------------------------------------------- : 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 (!(what & DRAW_NORMAL)) return;
if (font.font) { if (font.font) {
font.font->draw(dc, ctx, rect, font.size * scale, font.alignment, content.substr(start - this->start, end-start)); font.font->draw(dc, ctx, rect, font.size * scale, font.alignment, content.substr(start - this->start, end-start));
+3 -3
View File
@@ -72,7 +72,7 @@ TextViewer::~TextViewer() {}
// ----------------------------------------------------------------------------- : Drawing // ----------------------------------------------------------------------------- : 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()); assert(!lines.empty());
// draw anything? // draw anything?
if (what == DRAW_NOTHING) return; if (what == DRAW_NOTHING) return;
@@ -88,11 +88,11 @@ void TextViewer::draw(RotatedDC& dc, const TextStyle& style, DrawWhat what) {
// Draw characters separatly // Draw characters separatly
for (size_t i = 0 ; i < l.positions.size() - 1 ; ++i) { 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); 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 { } else {
RealRect rect(l.positions.front(), l.top, l.width(), l.line_height); 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);
} }
} }
} }
+1 -1
View File
@@ -46,7 +46,7 @@ public:
/** The drawing information is cached, /** The drawing information is cached,
* before calling draw again with different text/style reset() should be called * 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 /// Draw an indicator for selected text
void drawSelection(RotatedDC& dc, const TextStyle& style, size_t sel_start, size_t sel_end); void drawSelection(RotatedDC& dc, const TextStyle& style, size_t sel_start, size_t sel_end);
/// Draw separators for <line> tags /// Draw separators for <line> tags
+17 -4
View File
@@ -21,7 +21,13 @@ bool ChoiceValueViewer::prepare(RotatedDC& dc) {
} }
void ChoiceValueViewer::draw(RotatedDC& dc) { void ChoiceValueViewer::draw(RotatedDC& dc) {
drawFieldBorder(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()); 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; Alignment text_align = style.alignment;
if (style.render_style & RENDER_IMAGE) { if (style.render_style & RENDER_IMAGE) {
text_align = ALIGN_MIDDLE_LEFT; // can't align both text and image in the same way 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); RealSize size = dc.GetTextExtent(text);
RealPoint pos = align_in_rect(text_align, size, dc.getInternalRect()) + RealSize(margin, 0); RealPoint text_pos = align_in_rect(text_align, size, dc.getInternalRect()) + RealSize(margin, 0);
dc.DrawTextWithShadow(text, style.font, pos); dc.DrawTextWithShadow(text, font, text_pos);
if (viewer.nativeLook()) font.color = font_color;
} }
} }
+11 -8
View File
@@ -16,8 +16,6 @@ IMPLEMENT_VALUE_VIEWER(Color);
void ColorValueViewer::draw(RotatedDC& dc) { void ColorValueViewer::draw(RotatedDC& dc) {
// draw in the value color // draw in the value color
dc.SetPen(*wxTRANSPARENT_PEN);
dc.SetBrush(value().value());
if (nativeLook()) { if (nativeLook()) {
// native look // native look
// find name of color // find name of color
@@ -31,15 +29,20 @@ void ColorValueViewer::draw(RotatedDC& dc) {
break; break;
} }
} }
} }
// draw name and color // draw background
dc.SetPen(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
dc.DrawRectangle(RealRect(0, 0, 40, dc.getHeight()));
dc.SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
dc.SetPen(*wxTRANSPARENT_PEN); dc.SetPen(*wxTRANSPARENT_PEN);
dc.SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
dc.DrawRectangle(RealRect(40, 0, dc.getWidth()-40, dc.getHeight())); 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 { } else {
dc.SetPen(*wxTRANSPARENT_PEN);
dc.SetBrush(value().value());
// is there a mask? // is there a mask?
const AlphaMask& alpha_mask = getMask(dc); const AlphaMask& alpha_mask = getMask(dc);
if (alpha_mask.isLoaded()) { if (alpha_mask.isLoaded()) {
+20 -6
View File
@@ -24,7 +24,13 @@ bool MultipleChoiceValueViewer::prepare(RotatedDC& dc) {
void MultipleChoiceValueViewer::draw(RotatedDC& dc) { void MultipleChoiceValueViewer::draw(RotatedDC& dc) {
drawFieldBorder(dc); drawFieldBorder(dc);
if (style().render_style & RENDER_HIDDEN) return; 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 // selected choices
vector<String> selected; vector<String> selected;
value().get(selected); value().get(selected);
@@ -38,7 +44,7 @@ void MultipleChoiceValueViewer::draw(RotatedDC& dc) {
if (active) select_it++; if (active) select_it++;
drawChoice(dc, pos, choice, active); drawChoice(dc, pos, choice, active);
} }
} else if (style().render_style & RENDER_LIST) { } else if (style().render_style & RENDER_LIST) {
// render only selected choices // render only selected choices
FOR_EACH(choice, selected) { FOR_EACH(choice, selected) {
drawChoice(dc, pos, choice); drawChoice(dc, pos, choice);
@@ -70,13 +76,21 @@ void MultipleChoiceValueViewer::drawChoice(RotatedDC& dc, RealPoint& pos, const
} }
} }
if (style().render_style & RENDER_TEXT) { 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); String text = tr(getStylePackage(), choice, capitalize_sentence);
dc.SetFont(style().font,1); dc.SetFont(font,1);
RealSize text_size = dc.GetTextExtent(text); 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)); 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, style().font, text_pos); dc.DrawTextWithShadow(text, font, text_pos);
size = add_horizontal(size, text_size); size = add_horizontal(size, text_size);
if (nativeLook()) font.color = font_color;
} }
// next position // next position
pos = move_in_direction(style().direction, pos, size, style().spacing); pos = move_in_direction(style().direction, pos, size, style().spacing);
+19 -5
View File
@@ -43,7 +43,13 @@ void PackageChoiceValueViewer::initItems() {
} }
void PackageChoiceValueViewer::draw(RotatedDC& dc) { 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 // find item
String text = value().package_name; String text = value().package_name;
Bitmap image; Bitmap image;
@@ -61,8 +67,16 @@ void PackageChoiceValueViewer::draw(RotatedDC& dc) {
if (image.Ok()) { if (image.Ok()) {
dc.DrawBitmap(image, RealPoint(0,0)); dc.DrawBitmap(image, RealPoint(0,0));
} }
// draw text // draw text
dc.SetFont(style().font, 1.0); Font& font = style().font;
RealPoint pos = align_in_rect(ALIGN_MIDDLE_LEFT, RealSize(0, dc.GetCharHeight()), dc.getInternalRect()) + RealSize(17., 0); Color font_color = font.color;
dc.DrawTextWithShadow(text, style().font, pos); 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;
} }
+9 -3
View File
@@ -20,15 +20,21 @@ bool TextValueViewer::prepare(RotatedDC& dc) {
} }
void TextValueViewer::draw(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()) { if (!v.prepared()) {
v.prepare(dc, value().value(), style(), getContext()); v.prepare(dc, value().value(), style(), getContext());
dc.setStretch(getStretch()); dc.setStretch(getStretch());
} }
DrawWhat what = drawWhat(); DrawWhat what = drawWhat();
v.draw(dc, style(), (DrawWhat)(what & DRAW_ACTIVE)); v.draw(dc, style(), (DrawWhat)(what & DRAW_ACTIVE), nativeLook());
setFieldBorderPen(dc); setFieldBorderPen(dc);
v.draw(dc, style(), (DrawWhat)(what & ~DRAW_ACTIVE)); v.draw(dc, style(), (DrawWhat)(what & ~DRAW_ACTIVE), nativeLook());
} }
void TextValueViewer::onValueChange() { void TextValueViewer::onValueChange() {
+7 -1
View File
@@ -43,6 +43,10 @@ SCRIPT_FUNCTION(get_mse_locale) {
SCRIPT_RETURN(settings.locale); SCRIPT_RETURN(settings.locale);
} }
SCRIPT_FUNCTION(get_mse_dark_mode) {
SCRIPT_RETURN(settings.darkMode());
}
SCRIPT_FUNCTION(trace) { SCRIPT_FUNCTION(trace) {
SCRIPT_PARAM_C(String, input); SCRIPT_PARAM_C(String, input);
#if defined(_DEBUG) && 0 #if defined(_DEBUG) && 0
@@ -866,10 +870,12 @@ SCRIPT_FUNCTION(rule) {
// ----------------------------------------------------------------------------- : Init // ----------------------------------------------------------------------------- : Init
void init_script_basic_functions(Context& ctx) { void init_script_basic_functions(Context& ctx) {
// debugging // app info
ctx.setVariable(_("get_mse_version"), script_get_mse_version); ctx.setVariable(_("get_mse_version"), script_get_mse_version);
ctx.setVariable(_("get_mse_locale"), script_get_mse_locale); ctx.setVariable(_("get_mse_locale"), script_get_mse_locale);
ctx.setVariable(_("get_mse_path"), script_get_mse_path); 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(_("trace"), script_trace);
ctx.setVariable(_("warning"), script_warning); ctx.setVariable(_("warning"), script_warning);
ctx.setVariable(_("error"), script_error); ctx.setVariable(_("error"), script_error);
+11
View File
@@ -193,6 +193,17 @@ void TokenIterator::readToken() {
addToken(TOK_STRING, include_file, pos); addToken(TOK_STRING, include_file, pos);
addToken(TOK_RPAREN, ")", eol); addToken(TOK_RPAREN, ")", eol);
pos = 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:")) { } else if (is_substr(pos, end, "include file:")) {
pos += 13; // "include file:" pos += 13; // "include file:"
const char* newlines = "\r\n"; const char* newlines = "\r\n";
+8 -4
View File
@@ -357,10 +357,14 @@ template <> void Reader::handle(Vector2D& vec) {
template <> void Reader::handle(LocalFileName& f) { template <> void Reader::handle(LocalFileName& f) {
f = LocalFileName::fromReadString(this->getValue()); f = LocalFileName::fromReadString(this->getValue());
} }
String Reader::addLocale(String filename) { String Reader::addLocale(String filename) {
return filename + _("_") + settings.locale; return filename + _("_") + settings.locale;
} }
String Reader::addDark(String filename) {
return filename + (settings.darkMode() ? _("_dark") : _(""));
}
// ----------------------------------------------------------------------------- : EnumReader // ----------------------------------------------------------------------------- : EnumReader
+6 -5
View File
@@ -116,9 +116,10 @@ public:
/// The package being read from /// The package being read from
inline Packaged* getPackage() const { return package; } 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) /// 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; }; inline void setValue(const String& value) { state = UNHANDLED; previous_value = value; };
@@ -180,8 +181,8 @@ private:
/** Maybe the key is "include file" */ /** Maybe the key is "include file" */
template <typename T> template <typename T>
void unknownKey(T& v) { void unknownKey(T& v) {
if (key == _("include_file") || key == _("include_localized_file")) { if (key == _("include_file") || key == _("include_localized_file") || key == _("include_dark_file")) {
value = key == _("include_localized_file") ? addLocale(value) : value; value = key == _("include_localized_file") ? addLocale(value) : key == _("include_dark_file") ? addDark(value) : value;
auto [stream, include_package] = openFileFromPackage(package, value); auto [stream, include_package] = openFileFromPackage(package, value);
Reader sub_reader(*stream, include_package, value, ignore_invalid); Reader sub_reader(*stream, include_package, value, ignore_invalid);
if (sub_reader.file_app_version == 0) { if (sub_reader.file_app_version == 0) {
@@ -194,6 +194,8 @@ function highlight_script($code) {
$ret .= "<span class='hl-kw'>" . $matches[0] . "</span>"; $ret .= "<span class='hl-kw'>" . $matches[0] . "</span>";
} else if (preg_match("@^(include localized file:)(.*)@",$code, $matches)) { } else if (preg_match("@^(include localized file:)(.*)@",$code, $matches)) {
$ret .= "<span class='hl-key'>" . $matches[1] . "</span>" . $matches[2]; $ret .= "<span class='hl-key'>" . $matches[1] . "</span>" . $matches[2];
} else if (preg_match("@^(include dark file:)(.*)@",$code, $matches)) {
$ret .= "<span class='hl-key'>" . $matches[1] . "</span>" . $matches[2];
} else if (preg_match("@^(include file:)(.*)@",$code, $matches)) { } else if (preg_match("@^(include file:)(.*)@",$code, $matches)) {
$ret .= "<span class='hl-key'>" . $matches[1] . "</span>" . $matches[2]; $ret .= "<span class='hl-key'>" . $matches[1] . "</span>" . $matches[2];
} else if (preg_match("@^([0-9][0-9.]*|true|false)@",$code, $matches)) { } else if (preg_match("@^([0-9][0-9.]*|true|false)@",$code, $matches)) {