Fixed scaling on MSW for new OptionsGroup

This commit is contained in:
YuSanka 2020-09-22 16:16:35 +02:00
parent 398ff9053d
commit 35d225d673
8 changed files with 59 additions and 18 deletions

View file

@ -252,6 +252,7 @@ void BedShapePanel::build_panel(const ConfigOptionPoints& default_pt, const Conf
return sizer;
};
optgroup->append_line(line);
optgroup->activate();
wxPanel* texture_panel = init_texture_panel();
wxPanel* model_panel = init_model_panel();
@ -373,6 +374,7 @@ wxPanel* BedShapePanel::init_texture_panel()
return sizer;
};
optgroup->append_line(line);
optgroup->activate();
panel->SetSizerAndFit(optgroup->sizer);
@ -452,6 +454,7 @@ wxPanel* BedShapePanel::init_model_panel()
return sizer;
};
optgroup->append_line(line);
optgroup->activate();
panel->SetSizerAndFit(optgroup->sizer);

View file

@ -80,22 +80,27 @@ namespace GUI {
class MainFrame;
class InitTimer
class TaskTimer
{
std::chrono::milliseconds start_timer;
std::chrono::milliseconds start_timer;
std::string task_name;
public:
InitTimer()
TaskTimer(std::string task_name):
task_name(task_name.empty() ? "task" : task_name)
{
start_timer = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now().time_since_epoch());
}
~InitTimer()
~TaskTimer()
{
std::chrono::milliseconds stop_timer = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now().time_since_epoch());
auto process_duration = std::chrono::milliseconds(stop_timer - start_timer).count();
printf("on_init duration = %lld ms \n", process_duration);
std::string out = (boost::format("\n!!! %1% duration = %2% ms \n\n") % task_name % process_duration).str();
printf(out.c_str());
std::wstring stemp = std::wstring(out.begin(), out.end());
OutputDebugString(stemp.c_str());
}
};
@ -617,7 +622,7 @@ bool GUI_App::OnInit()
bool GUI_App::on_init_inner()
{
InitTimer local_timer;
TaskTimer timer("on_init");
// Verify resources path
const wxString resources_dir = from_u8(Slic3r::resources_dir());
wxCHECK_MSG(wxDirExists(resources_dir), false,

View file

@ -345,8 +345,9 @@ void MainFrame::update_layout()
fromDlg,
toDlg
};
State update_scaling_state = m_layout == ESettingsLayout::Dlg ? State::fromDlg :
layout == ESettingsLayout::Dlg ? State::toDlg : State::noUpdate;
State update_scaling_state = m_layout == ESettingsLayout::Unknown ? State::noUpdate : // don't scale settings dialog from the application start
m_layout == ESettingsLayout::Dlg ? State::fromDlg :
layout == ESettingsLayout::Dlg ? State::toDlg : State::noUpdate;
#endif //__WXMSW__
m_layout = layout;

View file

@ -632,7 +632,7 @@ void ConfigOptionsGroup::msw_rescale()
const int em = em_unit(parent());
// rescale width of label column
if (!m_options_mode.empty() && label_width > 1)
if (m_grid_sizer && !m_options_mode.empty() && label_width > 1)
{
const int cols = m_grid_sizer->GetCols();
const int rows = m_grid_sizer->GetEffectiveRowsCount();

View file

@ -374,6 +374,7 @@ void PhysicalPrinterDialog::build_printhost_settings(ConfigOptionsGroup* m_optgr
m_optgroup->append_single_option_line(option);
}
m_optgroup->activate();
update();
}
@ -434,6 +435,7 @@ void PhysicalPrinterDialog::on_dpi_changed(const wxRect& suggested_rect)
{
const int& em = em_unit();
m_add_preset_btn->msw_rescale();
m_printhost_browse_btn->msw_rescale();
m_printhost_test_btn->msw_rescale();
if (m_printhost_cafile_browse_btn)

View file

@ -140,6 +140,8 @@ void PreferencesDialog::build()
option = Option(def, "show_splash_screen");
m_optgroup_general->append_single_option_line(option);
m_optgroup_general->activate();
m_optgroup_camera = std::make_shared<ConfigOptionsGroup>(this, _(L("Camera")));
m_optgroup_camera->label_width = 40;
m_optgroup_camera->m_on_change = [this](t_config_option_key opt_key, boost::any value) {
@ -160,6 +162,8 @@ void PreferencesDialog::build()
option = Option(def, "use_free_camera");
m_optgroup_camera->append_single_option_line(option);
m_optgroup_camera->activate();
m_optgroup_gui = std::make_shared<ConfigOptionsGroup>(this, _(L("GUI")));
m_optgroup_gui->label_width = 40;
m_optgroup_gui->m_on_change = [this](t_config_option_key opt_key, boost::any value) {
@ -184,6 +188,8 @@ void PreferencesDialog::build()
option = Option(def, "use_custom_toolbar_size");
m_optgroup_gui->append_single_option_line(option);
m_optgroup_gui->activate();
create_icon_size_slider();
m_icon_size_sizer->ShowItems(app_config->get("use_custom_toolbar_size") == "1");
@ -202,6 +208,8 @@ void PreferencesDialog::build()
def.set_default_value(new ConfigOptionBool{ app_config->get("use_environment_map") == "1" });
option = Option(def, "use_environment_map");
m_optgroup_render->append_single_option_line(option);
m_optgroup_render->activate();
#endif // ENABLE_ENVIRONMENT_MAP
auto sizer = new wxBoxSizer(wxVERTICAL);

View file

@ -882,8 +882,10 @@ void Tab::msw_rescale()
m_treectrl->AssignImageList(m_icons);
// rescale options_groups
for (auto page : m_pages)
page->msw_rescale();
if (m_active_page)
m_active_page->msw_rescale();
//for (auto page : m_pages)
// page->msw_rescale();
Layout();
}
@ -1169,7 +1171,9 @@ void Tab::build_preset_description_line(ConfigOptionsGroup* optgroup)
};
auto detach_preset_btn = [this](wxWindow* parent) {
add_scaled_button(parent, &m_detach_preset_btn, "lock_open_sys", _(L("Detach from system preset")), wxBU_LEFT | wxBU_EXACTFIT);
//add_scaled_button(parent, &m_detach_preset_btn, "lock_open_sys", _(L("Detach from system preset")), wxBU_LEFT | wxBU_EXACTFIT);
m_detach_preset_btn = new ScalableButton(parent, wxID_ANY, "lock_open_sys", _L("Detach from system preset"),
wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT, true);
ScalableButton* btn = m_detach_preset_btn;
btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
@ -2668,8 +2672,10 @@ void TabPrinter::build_unregular_pages()
optgroup = page->new_optgroup(L("Preview"));
auto reset_to_filament_color = [this, extruder_idx](wxWindow* parent) {
add_scaled_button(parent, &m_reset_to_filament_color, "undo",
_(L("Reset to Filament Color")), wxBU_LEFT | wxBU_EXACTFIT);
//add_scaled_button(parent, &m_reset_to_filament_color, "undo",
// _(L("Reset to Filament Color")), wxBU_LEFT | wxBU_EXACTFIT);
m_reset_to_filament_color = new ScalableButton(parent, wxID_ANY, "undo", _L("Reset to Filament Color"),
wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT, true);
ScalableButton* btn = m_reset_to_filament_color;
btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
auto sizer = new wxBoxSizer(wxHORIZONTAL);
@ -2776,6 +2782,12 @@ void TabPrinter::active_selected_page()
m_active_page->set_value("extruders_count", int(m_extruders_count));
}
void TabPrinter::clear_pages()
{
Tab::clear_pages();
m_reset_to_filament_color = nullptr;
}
void TabPrinter::toggle_options()
{
if (!m_active_page || m_presets->get_edited_preset().printer_technology() == ptSLA)
@ -3289,9 +3301,15 @@ void Tab::clear_pages()
for (auto p : m_pages)
p->clear();
// nulling description lines pointers
// nulling pointers
m_parent_preset_description_line = nullptr;
m_detach_preset_btn = nullptr;
m_compatible_printers.checkbox = nullptr;
m_compatible_printers.btn = nullptr;
m_compatible_prints.checkbox = nullptr;
m_compatible_prints.btn = nullptr;
}
void Tab::update_description_lines()
@ -3574,7 +3592,9 @@ wxSizer* Tab::compatible_widget_create(wxWindow* parent, PresetDependencies &dep
{
deps.checkbox = new wxCheckBox(parent, wxID_ANY, _(L("All")));
deps.checkbox->SetFont(Slic3r::GUI::wxGetApp().normal_font());
add_scaled_button(parent, &deps.btn, "printer_white", from_u8((boost::format(" %s %s") % _utf8(L("Set")) % std::string(dots.ToUTF8())).str()), wxBU_LEFT | wxBU_EXACTFIT);
// add_scaled_button(parent, &deps.btn, "printer_white", from_u8((boost::format(" %s %s") % _utf8(L("Set")) % std::string(dots.ToUTF8())).str()), wxBU_LEFT | wxBU_EXACTFIT);
deps.btn = new ScalableButton(parent, wxID_ANY, "printer_white", from_u8((boost::format(" %s %s") % _utf8(L("Set")) % std::string(dots.ToUTF8())).str()),
wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT, true);
deps.btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
BlinkingBitmap* bbmp = new BlinkingBitmap(parent);
@ -3652,8 +3672,9 @@ wxSizer* Tab::compatible_widget_create(wxWindow* parent, PresetDependencies &dep
// Return a callback to create a TabPrinter widget to edit bed shape
wxSizer* TabPrinter::create_bed_shape_widget(wxWindow* parent)
{
ScalableButton* btn;
add_scaled_button(parent, &btn, "printer_white", " " + _(L("Set")) + " " + dots, wxBU_LEFT | wxBU_EXACTFIT);
ScalableButton* btn = new ScalableButton(parent, wxID_ANY, "printer_white", " " + _(L("Set")) + " " + dots,
wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT, true);
// add_scaled_button(parent, &btn, "printer_white", " " + _(L("Set")) + " " + dots, wxBU_LEFT | wxBU_EXACTFIT);
btn->SetFont(wxGetApp().normal_font());
BlinkingBitmap* bbmp = new BlinkingBitmap(parent);

View file

@ -441,6 +441,7 @@ public:
void build_fff();
void build_sla();
void active_selected_page() override;
void clear_pages() override;
void toggle_options() override;
void update() override;
void update_fff();