mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 16:57:53 -06:00
Application Scaling for MSW: Next big step
- Added rescale() function for the most of controls - Created PrusaBitmap and PrusaButton classes like a wrap to wxBitmap and wxButton accordingly
This commit is contained in:
parent
a74c608c7a
commit
f7ddddcff5
22 changed files with 737 additions and 250 deletions
|
@ -111,6 +111,7 @@ public:
|
|||
|
||||
bool showing_manifold_warning_icon;
|
||||
void show_sizer(bool show);
|
||||
void rescale();
|
||||
};
|
||||
|
||||
ObjectInfo::ObjectInfo(wxWindow *parent) :
|
||||
|
@ -118,10 +119,10 @@ ObjectInfo::ObjectInfo(wxWindow *parent) :
|
|||
{
|
||||
GetStaticBox()->SetFont(wxGetApp().bold_font());
|
||||
|
||||
auto *grid_sizer = new wxFlexGridSizer(4, 5, 5);
|
||||
auto *grid_sizer = new wxFlexGridSizer(4, 5, 15);
|
||||
grid_sizer->SetFlexibleDirection(wxHORIZONTAL);
|
||||
grid_sizer->AddGrowableCol(1, 1);
|
||||
grid_sizer->AddGrowableCol(3, 1);
|
||||
// grid_sizer->AddGrowableCol(1, 1);
|
||||
// grid_sizer->AddGrowableCol(3, 1);
|
||||
|
||||
auto init_info_label = [parent, grid_sizer](wxStaticText **info_label, wxString text_label) {
|
||||
auto *text = new wxStaticText(parent, wxID_ANY, text_label+":");
|
||||
|
@ -161,6 +162,11 @@ void ObjectInfo::show_sizer(bool show)
|
|||
manifold_warning_icon->Show(showing_manifold_warning_icon && show);
|
||||
}
|
||||
|
||||
void ObjectInfo::rescale()
|
||||
{
|
||||
manifold_warning_icon->SetBitmap(create_scaled_bitmap(nullptr, "exclamation_mark_"));
|
||||
}
|
||||
|
||||
enum SlisedInfoIdx
|
||||
{
|
||||
siFilament_m,
|
||||
|
@ -282,11 +288,12 @@ wxBitmapComboBox(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(15 *
|
|||
});
|
||||
}
|
||||
|
||||
edit_btn = new wxButton(parent, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER);
|
||||
#ifdef __WINDOWS__
|
||||
edit_btn->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||
#endif
|
||||
edit_btn->SetBitmap(create_scaled_bitmap(this, "cog"));
|
||||
// edit_btn = new wxButton(parent, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER);
|
||||
// #ifdef __WINDOWS__
|
||||
// edit_btn->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||
// #endif
|
||||
// edit_btn->SetBitmap(create_scaled_bitmap(this, "cog"));
|
||||
edit_btn = new PrusaButton(parent, wxID_ANY, "cog");
|
||||
edit_btn->SetToolTip(_(L("Click to edit preset")));
|
||||
|
||||
edit_btn->Bind(wxEVT_BUTTON, ([preset_type, this](wxCommandEvent)
|
||||
|
@ -332,6 +339,13 @@ void PresetComboBox::check_selection()
|
|||
this->last_selected = GetSelection();
|
||||
}
|
||||
|
||||
void PresetComboBox::rescale()
|
||||
{
|
||||
// update min control's height from new scaled size
|
||||
this->SetMinSize(wxSize(20*wxGetApp().em_unit(), this->GetSize().GetHeight()));
|
||||
edit_btn->rescale();
|
||||
}
|
||||
|
||||
// Frequently changed parameters
|
||||
|
||||
class FreqChangedParams : public OG_Settings
|
||||
|
@ -429,7 +443,7 @@ FreqChangedParams::FreqChangedParams(wxWindow* parent, const int label_width) :
|
|||
|
||||
option = m_og->get_option("fill_density");
|
||||
option.opt.label = L("Infill");
|
||||
option.opt.width = 6 * wxGetApp().em_unit();
|
||||
option.opt.width = 6;
|
||||
option.opt.sidetext = " ";
|
||||
line.append_option(option);
|
||||
|
||||
|
@ -615,9 +629,9 @@ void Sidebar::priv::show_preset_comboboxes()
|
|||
// Sidebar / public
|
||||
|
||||
Sidebar::Sidebar(Plater *parent)
|
||||
: wxPanel(parent), p(new priv(parent))
|
||||
: wxPanel(parent, wxID_ANY, wxDefaultPosition, wxSize(40 * wxGetApp().em_unit(), -1)), p(new priv(parent))
|
||||
{
|
||||
p->scrolled = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, wxSize(40 * wxGetApp().em_unit(), -1));
|
||||
p->scrolled = new wxScrolledWindow(this, wxID_ANY/*, wxDefaultPosition, wxSize(40 * wxGetApp().em_unit(), -1)*/);
|
||||
p->scrolled->SetScrollbars(0, 20, 1, 2);
|
||||
|
||||
|
||||
|
@ -676,13 +690,8 @@ Sidebar::Sidebar(Plater *parent)
|
|||
init_combo(&p->combo_sla_material, _(L("SLA material")), Preset::TYPE_SLA_MATERIAL, false);
|
||||
init_combo(&p->combo_printer, _(L("Printer")), Preset::TYPE_PRINTER, false);
|
||||
|
||||
// calculate width of the preset labels
|
||||
// p->sizer_presets->Layout();
|
||||
// const wxArrayInt& ar = p->sizer_presets->GetColWidths();
|
||||
// const int label_width = ar.IsEmpty() ? 10*wxGetApp().em_unit() : ar.front()-4;
|
||||
|
||||
const int margin_5 = int(0.5*wxGetApp().em_unit());// 5;
|
||||
const int margin_10 = int(1.5*wxGetApp().em_unit());// 15;
|
||||
const int margin_10 = 10;//int(1.5*wxGetApp().em_unit());// 15;
|
||||
|
||||
p->sizer_params = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
|
@ -704,10 +713,6 @@ Sidebar::Sidebar(Plater *parent)
|
|||
p->object_settings->Hide();
|
||||
p->sizer_params->Add(p->object_settings->get_sizer(), 0, wxEXPAND | wxTOP, margin_5);
|
||||
|
||||
p->btn_send_gcode = new wxButton(this, wxID_ANY, _(L("Send to printer")));
|
||||
p->btn_send_gcode->SetFont(wxGetApp().bold_font());
|
||||
p->btn_send_gcode->Hide();
|
||||
|
||||
// Info boxes
|
||||
p->object_info = new ObjectInfo(p->scrolled);
|
||||
p->sliced_info = new SlicedInfo(p->scrolled);
|
||||
|
@ -722,10 +727,16 @@ Sidebar::Sidebar(Plater *parent)
|
|||
scrolled_sizer->Add(p->sliced_info, 0, wxEXPAND | wxTOP | wxLEFT, margin_5);
|
||||
|
||||
// Buttons underneath the scrolled area
|
||||
p->btn_export_gcode = new wxButton(this, wxID_ANY, _(L("Export G-code")) + dots);
|
||||
p->btn_export_gcode->SetFont(wxGetApp().bold_font());
|
||||
p->btn_reslice = new wxButton(this, wxID_ANY, _(L("Slice now")));
|
||||
p->btn_reslice->SetFont(wxGetApp().bold_font());
|
||||
|
||||
auto init_btn = [this](wxButton **btn, wxString label) {
|
||||
*btn = new wxButton(this, wxID_ANY, label);
|
||||
(*btn)->SetFont(wxGetApp().bold_font());
|
||||
};
|
||||
|
||||
init_btn(&p->btn_send_gcode, _(L("Send to printer")));
|
||||
p->btn_send_gcode->Hide();
|
||||
init_btn(&p->btn_export_gcode, _(L("Export G-code")) + dots);
|
||||
init_btn(&p->btn_reslice, _(L("Slice now")));
|
||||
enable_buttons(false);
|
||||
|
||||
auto *btns_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
|
@ -888,6 +899,40 @@ void Sidebar::update_reslice_btn_tooltip() const
|
|||
p->btn_reslice->SetToolTip(tooltip);
|
||||
}
|
||||
|
||||
void Sidebar::rescale()
|
||||
{
|
||||
SetMinSize(wxSize(40 * wxGetApp().em_unit(), -1));
|
||||
|
||||
p->mode_sizer->rescale();
|
||||
|
||||
// first of all : recreate preset comboboxes, because of
|
||||
// in AddBitmap() function autonaticaly set the size of controll
|
||||
update_all_preset_comboboxes();
|
||||
// then rescale them to current min size to correct layout of the sidebar
|
||||
for (PresetComboBox* combo : std::vector<PresetComboBox*> { p->combo_print,
|
||||
p->combo_sla_print,
|
||||
p->combo_sla_material,
|
||||
p->combo_printer } )
|
||||
combo->rescale();
|
||||
|
||||
for (PresetComboBox* combo : p->combos_filament)
|
||||
combo->rescale();
|
||||
|
||||
p->frequently_changed_parameters->get_og(true)->rescale();
|
||||
p->frequently_changed_parameters->get_og(false)->rescale();
|
||||
|
||||
p->object_list->rescale();
|
||||
|
||||
p->object_manipulation->get_og()->rescale();
|
||||
p->object_settings->rescale();
|
||||
|
||||
p->object_info->rescale();
|
||||
|
||||
p->scrolled->Layout();
|
||||
p->plater->Layout();
|
||||
p->plater->GetParent()->Layout();
|
||||
}
|
||||
|
||||
ObjectManipulation* Sidebar::obj_manipul()
|
||||
{
|
||||
return p->object_manipulation;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue