WIP (NewUI with fonts): Next improvements for fonts.

* AboutDialog, SysInfoDialog, ConfigSnapshotDialog, ConfigWizard: Set correct/scaled font.
* PreferencesDialog:
  * Use SpinInput instead of wxSpinCtrl.
  * Added layout of the activated tab.
  * Remove "suppress_round_corners" option and ignore its value for whole application.
+ Plater: fixed obj_list() function to check existence of the control to avoid crash on recreate_GUI().
+ GLCanvas3D: Increased delta value between current and new values of the toolbar icon scale.
This commit is contained in:
YuSanka 2023-07-26 08:49:03 +02:00 committed by Lukas Matena
parent f27ad88d55
commit 1f0b834a70
10 changed files with 30 additions and 23 deletions

View File

@ -70,7 +70,7 @@ CopyrightsDialog::CopyrightsDialog()
m_html = new wxHtmlWindow(this, wxID_ANY, wxDefaultPosition,
wxSize(40 * em_unit(), 20 * em_unit()), wxHW_SCROLLBAR_AUTO);
wxFont font = get_default_font(this);
wxFont font = this->GetFont();// get_default_font(this);
const int fs = font.GetPointSize();
const int fs2 = static_cast<int>(1.2f*fs);
int size[] = { fs, fs, fs, fs, fs2, fs2, fs2 };
@ -244,7 +244,7 @@ AboutDialog::AboutDialog()
wxStaticText* title = new wxStaticText(this, wxID_ANY, wxGetApp().is_editor() ? SLIC3R_APP_NAME : GCODEVIEWER_APP_NAME, wxDefaultPosition, wxDefaultSize);
wxFont title_font = GUI::wxGetApp().bold_font();
title_font.SetFamily(wxFONTFAMILY_ROMAN);
title_font.SetPointSize(24);
title_font.SetPointSize(int(2.5 * title_font.GetPointSize()));//title_font.SetPointSize(24);
title->SetFont(title_font);
vsizer->Add(title, 0, wxALIGN_LEFT | wxTOP, 10);
}
@ -267,7 +267,7 @@ AboutDialog::AboutDialog()
m_html = new wxHtmlWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO/*NEVER*/);
{
m_html->SetMinSize(wxSize(-1, 16 * wxGetApp().em_unit()));
wxFont font = get_default_font(this);
wxFont font = wxGetApp().normal_font();// get_default_font(this);
const auto text_clr = wxGetApp().get_label_clr_default();
const auto text_clr_str = encode_color(ColorRGB(text_clr.Red(), text_clr.Green(), text_clr.Blue()));
const auto bgr_clr_str = encode_color(ColorRGB(bgr_clr.Red(), bgr_clr.Green(), bgr_clr.Blue()));

View File

@ -141,7 +141,7 @@ ConfigSnapshotDialog::ConfigSnapshotDialog(const Config::SnapshotDB &snapshot_db
// text
html = new wxHtmlWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO);
{
wxFont font = get_default_font(this);
wxFont font = this->GetFont();// get_default_font(this);
#ifdef __WXMSW__
const int fs = font.GetPointSize();
const int fs1 = static_cast<int>(0.8f*fs);

View File

@ -1342,8 +1342,7 @@ PageUpdate::PageUpdate(ConfigWizard *parent)
, preset_update(true)
{
const AppConfig *app_config = wxGetApp().app_config;
auto boldfont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
boldfont.SetWeight(wxFONTWEIGHT_BOLD);
auto boldfont = wxGetApp().bold_font();
auto *box_slic3r = new wxCheckBox(this, wxID_ANY, _L("Check for application updates"));
box_slic3r->SetValue(app_config->get("notify_release") != "none");

View File

@ -6247,7 +6247,7 @@ void GLCanvas3D::_check_and_update_toolbar_icon_scale()
#if ENABLE_RETINA_GL
new_scale /= m_retina_helper->get_scale_factor();
#endif
if (fabs(new_scale - scale) > 0.01) // scale is changed by 1% and more
if (fabs(new_scale - scale) > 0.015) // scale is changed by 1.5% and more
wxGetApp().set_auto_toolbar_icon_scale(new_scale);
}

View File

@ -1758,7 +1758,7 @@ bool GUI_App::tabs_as_menu() const
bool GUI_App::suppress_round_corners() const
{
return app_config->get("suppress_round_corners") == "1";
return true;// app_config->get("suppress_round_corners") == "1";
}
wxSize GUI_App::get_min_size() const
@ -2129,6 +2129,9 @@ int GUI_App::GetSingleChoiceIndex(const wxString& message,
#ifdef _WIN32
wxSingleChoiceDialog dialog(nullptr, message, caption, choices);
wxGetApp().UpdateDlgDarkUI(&dialog);
auto children = dialog.GetChildren();
for (auto child : children)
child->SetFont(normal_font());
dialog.SetSelection(initialSelection);
return dialog.ShowModal() == wxID_OK ? dialog.GetSelection() : -1;
@ -2960,7 +2963,8 @@ ObjectSettings* GUI_App::obj_settings()
ObjectList* GUI_App::obj_list()
{
return sidebar().obj_list();
// If this method is called before plater_ has been initialized, return nullptr (to avoid a crash)
return plater_ ? sidebar().obj_list() : nullptr;
}
ObjectLayers* GUI_App::obj_layers()

View File

@ -96,6 +96,8 @@ public:
if (font_point_size > 0)
m_normal_font.SetPointSize(font_point_size);
else if (parent)
m_normal_font.SetPointSize(parent->GetFont().GetPointSize());
/* Because of default window font is a primary display font,
* We should set correct font for window before getting em_unit value.

View File

@ -742,9 +742,7 @@ void MainFrame::init_tabpanel()
wxGetApp().UpdateDarkUI(m_tabpanel);
#ifndef __WXOSX__ // Don't call SetFont under OSX to avoid name cutting in ObjectList
m_tabpanel->SetFont(Slic3r::GUI::wxGetApp().normal_font());
#endif
m_tabpanel->Hide();
m_settings_dialog.set_tabpanel(m_tabpanel);
@ -2305,8 +2303,6 @@ SettingsDialog::SettingsDialog(MainFrame* mainframe)
if (wxGetApp().is_gcode_viewer())
return;
// this->SetFont(wxGetApp().normal_font());
// Load the icon either from the exe, or from the ico file.
#if _WIN32
{

View File

@ -789,6 +789,7 @@ void Sidebar::priv::hide_rich_tip(wxButton* btn)
Sidebar::Sidebar(Plater *parent)
: wxPanel(parent, wxID_ANY, wxDefaultPosition, wxSize(42 * wxGetApp().em_unit(), -1)), p(new priv(parent))
{
SetFont(wxGetApp().normal_font());
p->scrolled = new wxScrolledWindow(this);
// p->scrolled->SetScrollbars(0, 100, 1, 2); // ys_DELETE_after_testing. pixelsPerUnitY = 100 from https://github.com/prusa3d/PrusaSlicer/commit/8f019e5fa992eac2c9a1e84311c990a943f80b01,
// but this cause the bad layout of the sidebar, when all infoboxes appear.
@ -796,7 +797,6 @@ Sidebar::Sidebar(Plater *parent)
// But if we set this value to 5, layout will be better
p->scrolled->SetScrollRate(0, 5);
SetFont(wxGetApp().normal_font());
#ifndef __APPLE__
#ifdef _WIN32
wxGetApp().UpdateDarkUI(this);
@ -2092,8 +2092,6 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
, collapse_toolbar(GLToolbar::Normal, "Collapse")
, m_project_filename(wxEmptyString)
{
this->q->SetFont(Slic3r::GUI::wxGetApp().normal_font());
background_process.set_fff_print(&fff_print);
background_process.set_sla_print(&sla_print);
background_process.set_gcode_result(&gcode_result);
@ -4472,7 +4470,10 @@ void Plater::priv::on_action_layersediting(SimpleEvent&)
void Plater::priv::on_object_select(SimpleEvent& evt)
{
wxGetApp().obj_list()->update_selections();
if (auto obj_list = wxGetApp().obj_list())
obj_list->update_selections();
else
return;
selection_changed();
}

View File

@ -21,6 +21,8 @@
#include "GLCanvas3D.hpp"
#include "ConfigWizard.hpp"
#include "Widgets/SpinInput.hpp"
#include <boost/dll/runtime_symbol_info.hpp>
#ifdef WIN32
@ -151,6 +153,8 @@ static void activate_options_tab(std::shared_ptr<ConfigOptionsGroup> optgroup)
wxBoxSizer* sizer = static_cast<wxBoxSizer*>(static_cast<wxPanel*>(optgroup->parent())->GetSizer());
sizer->Add(optgroup->sizer, 0, wxEXPAND | wxALL, 10);
optgroup->parent()->Layout();
// apply sercher
wxGetApp().sidebar().get_searcher().append_preferences_options(optgroup->get_lines());
}
@ -526,14 +530,14 @@ void PreferencesDialog::build()
#endif
m_optgroup_gui->append_separator();
/*
append_bool_option(m_optgroup_gui, "suppress_round_corners",
L("Suppress round corners for controls (experimental)"),
L("If enabled, Settings Tabs will be placed as menu items. If disabled, old UI will be used."),
app_config->get("suppress_round_corners") == "1");
m_optgroup_gui->append_separator();
*/
append_bool_option(m_optgroup_gui, "show_hints",
L("Show \"Tip of the day\" notification after start"),
L("If enabled, useful hints are displayed at startup."),
@ -1079,16 +1083,17 @@ void PreferencesDialog::create_settings_font_widget()
wxStaticText* font_example = new wxStaticText(parent, wxID_ANY, "Application text");
int val = wxGetApp().normal_font().GetPointSize();
wxSpinCtrl* size_sc = new wxSpinCtrl(parent, wxID_ANY, format_wxstr("%1%", val), wxDefaultPosition, wxSize(15*em_unit(), -1), wxTE_PROCESS_ENTER | wxSP_ARROW_KEYS
SpinInput* size_sc = new SpinInput(parent, format_wxstr("%1%", val), "", wxDefaultPosition, wxSize(15 * em_unit(), -1), wxTE_PROCESS_ENTER | wxSP_ARROW_KEYS
#ifdef _WIN32
| wxBORDER_SIMPLE
#endif
, 8, 20);
wxGetApp().UpdateDarkUI(size_sc);
auto apply_font = [this, font_example, opt_key](const int val, const wxFont& font) {
auto apply_font = [this, font_example, opt_key, stb_sizer](const int val, const wxFont& font) {
font_example->SetFont(font);
m_values[opt_key] = format("%1%", val);
stb_sizer->Layout();
refresh_og(m_optgroup_other);
};

View File

@ -122,13 +122,13 @@ SysInfoDialog::SysInfoDialog()
wxStaticText* title = new wxStaticText(this, wxID_ANY, wxGetApp().is_editor() ? SLIC3R_APP_NAME : GCODEVIEWER_APP_NAME, wxDefaultPosition, wxDefaultSize);
wxFont title_font = wxGetApp().bold_font();
title_font.SetFamily(wxFONTFAMILY_ROMAN);
title_font.SetPointSize(22);
title_font.SetPointSize(int(2.5 * title_font.GetPointSize()));//title_font.SetPointSize(22);
title->SetFont(title_font);
vsizer->Add(title, 0, wxEXPAND | wxALIGN_LEFT | wxTOP, wxGetApp().em_unit()/*50*/);
}
// main_info_text
wxFont font = get_default_font(this);
wxFont font = GetFont();// get_default_font(this);
const auto text_clr = wxGetApp().get_label_clr_default();
auto text_clr_str = encode_color(ColorRGB(text_clr.Red(), text_clr.Green(), text_clr.Blue()));
auto bgr_clr_str = encode_color(ColorRGB(bgr_clr.Red(), bgr_clr.Green(), bgr_clr.Blue()));