Scaling in PrintHostDialogs, FirmwareDialog, UpdateDialogs

This commit is contained in:
Vojtech Kral 2019-02-21 18:59:21 +01:00
parent 051ca410f6
commit 14b4685ecb
5 changed files with 30 additions and 21 deletions

View file

@ -13,6 +13,7 @@
#include "libslic3r/Utils.hpp"
#include "avrdude/avrdude-slic3r.hpp"
#include "GUI.hpp"
#include "GUI_App.hpp"
#include "I18N.hpp"
#include "MsgDialog.hpp"
#include "../Utils/HexFile.hpp"
@ -36,7 +37,6 @@
#include <wx/collpane.h>
#include <wx/msgdlg.h>
#include <wx/filefn.h>
#include "GUI_App.hpp"
namespace fs = boost::filesystem;
@ -693,11 +693,16 @@ FirmwareDialog::FirmwareDialog(wxWindow *parent) :
enum {
DIALOG_MARGIN = 15,
SPACING = 10,
MIN_WIDTH = 600,
MIN_HEIGHT = 200,
MIN_HEIGHT_EXPANDED = 500,
MIN_WIDTH = 50,
MIN_HEIGHT = 18,
MIN_HEIGHT_EXPANDED = 40,
};
const int em = GUI::wxGetApp().em_unit();
int min_width = MIN_WIDTH * em;
int min_height = MIN_HEIGHT * em;
int min_height_expanded = MIN_HEIGHT_EXPANDED * em;
wxFont status_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
status_font.MakeBold();
wxFont mono_font(wxFontInfo().Family(wxFONTFAMILY_TELETYPE));
@ -769,10 +774,10 @@ FirmwareDialog::FirmwareDialog(wxWindow *parent) :
auto *topsizer = new wxBoxSizer(wxVERTICAL);
topsizer->Add(panel, 1, wxEXPAND | wxALL, DIALOG_MARGIN);
SetMinSize(wxSize(MIN_WIDTH, MIN_HEIGHT));
SetMinSize(wxSize(min_width, min_height));
SetSizerAndFit(topsizer);
const auto size = GetSize();
SetSize(std::max(size.GetWidth(), static_cast<int>(MIN_WIDTH)), std::max(size.GetHeight(), static_cast<int>(MIN_HEIGHT)));
SetSize(std::max(size.GetWidth(), static_cast<int>(min_width)), std::max(size.GetHeight(), static_cast<int>(min_height)));
Layout();
SetEscapeId(wxID_CLOSE); // To close the dialog using "Esc" button
@ -786,13 +791,13 @@ FirmwareDialog::FirmwareDialog(wxWindow *parent) :
}
});
p->spoiler->Bind(wxEVT_COLLAPSIBLEPANE_CHANGED, [this](wxCollapsiblePaneEvent &evt) {
p->spoiler->Bind(wxEVT_COLLAPSIBLEPANE_CHANGED, [=](wxCollapsiblePaneEvent &evt) {
if (evt.GetCollapsed()) {
this->SetMinSize(wxSize(MIN_WIDTH, MIN_HEIGHT));
this->SetMinSize(wxSize(min_width, min_height));
const auto new_height = this->GetSize().GetHeight() - this->p->txt_stdout->GetSize().GetHeight();
this->SetSize(this->GetSize().GetWidth(), new_height);
} else {
this->SetMinSize(wxSize(MIN_WIDTH, MIN_HEIGHT_EXPANDED));
this->SetMinSize(wxSize(min_width, min_height_expanded));
}
this->Layout();

View file

@ -78,6 +78,7 @@ IMPLEMENT_APP(GUI_App)
GUI_App::GUI_App()
: wxApp()
, m_em_unit(10)
#if ENABLE_IMGUI
, m_imgui(new ImGuiWrapper())
#endif // ENABLE_IMGUI

View file

@ -32,8 +32,8 @@ struct MsgDialog : wxDialog
protected:
enum {
CONTENT_WIDTH = 50,//500,
CONTENT_MAX_HEIGHT = 60,//600,
CONTENT_WIDTH = 50,
CONTENT_MAX_HEIGHT = 60,
BORDER = 30,
VERT_SPACING = 15,
HORIZ_SPACING = 5,

View file

@ -38,7 +38,7 @@ PrintHostSendDialog::PrintHostSendDialog(const fs::path &path)
#endif
auto *label_dir_hint = new wxStaticText(this, wxID_ANY, _(L("Use forward slashes ( / ) as a directory separator if needed.")));
label_dir_hint->Wrap(CONTENT_WIDTH);
label_dir_hint->Wrap(CONTENT_WIDTH * wxGetApp().em_unit());
content_sizer->Add(txt_filename, 0, wxEXPAND);
content_sizer->Add(label_dir_hint);
@ -135,10 +135,11 @@ PrintHostQueueDialog::PrintHostQueueDialog(wxWindow *parent)
, on_error_evt(this, EVT_PRINTHOST_ERROR, &PrintHostQueueDialog::on_error, this)
, on_cancel_evt(this, EVT_PRINTHOST_CANCEL, &PrintHostQueueDialog::on_cancel, this)
{
enum { HEIGHT = 800, WIDTH = 400, SPACING = 5 };
enum { HEIGHT = 60, WIDTH = 30, SPACING = 5 };
SetSize(wxSize(HEIGHT, WIDTH));
SetSize(GetMinSize());
const auto em = GetTextExtent("m").x;
SetSize(wxSize(HEIGHT * em, WIDTH * em));
auto *topsizer = new wxBoxSizer(wxVERTICAL);

View file

@ -12,6 +12,7 @@
#include "libslic3r/libslic3r.h"
#include "libslic3r/Utils.hpp"
#include "GUI.hpp"
#include "GUI_App.hpp"
#include "I18N.hpp"
#include "ConfigWizard.hpp"
@ -34,7 +35,8 @@ MsgUpdateSlic3r::MsgUpdateSlic3r(const Semver &ver_current, const Semver &ver_on
auto *text = new wxStaticText(this, wxID_ANY, _(L("To download, follow the link below.")));
const auto link_width = link->GetSize().GetWidth();
text->Wrap(CONTENT_WIDTH > link_width ? CONTENT_WIDTH : link_width);
const int content_width = CONTENT_WIDTH * wxGetApp().em_unit();
text->Wrap(content_width > link_width ? content_width : link_width);
content_sizer->Add(text);
content_sizer->AddSpacer(VERT_SPACING);
@ -75,7 +77,7 @@ MsgUpdateConfig::MsgUpdateConfig(const std::unordered_map<std::string, std::stri
"should there be a problem with the new version.\n\n"
"Updated configuration bundles:"
)));
text->Wrap(CONTENT_WIDTH);
text->Wrap(CONTENT_WIDTH * wxGetApp().em_unit());
content_sizer->Add(text);
content_sizer->AddSpacer(VERT_SPACING);
@ -115,16 +117,16 @@ MsgDataIncompatible::MsgDataIncompatible(const std::unordered_map<std::string, w
"You may either exit Slic3r and try again with a newer version, or you may re-run the initial configuration. "
"Doing so will create a backup snapshot of the existing configuration before installing files compatible with this Slic3r.\n"
)));
text->Wrap(CONTENT_WIDTH);
text->Wrap(CONTENT_WIDTH * wxGetApp().em_unit());
content_sizer->Add(text);
auto *text2 = new wxStaticText(this, wxID_ANY, wxString::Format(_(L("This Slic3r PE version: %s")), SLIC3R_VERSION));
text2->Wrap(CONTENT_WIDTH);
text2->Wrap(CONTENT_WIDTH * wxGetApp().em_unit());
content_sizer->Add(text2);
content_sizer->AddSpacer(VERT_SPACING);
auto *text3 = new wxStaticText(this, wxID_ANY, _(L("Incompatible bundles:")));
text3->Wrap(CONTENT_WIDTH);
text3->Wrap(CONTENT_WIDTH * wxGetApp().em_unit());
content_sizer->Add(text3);
content_sizer->AddSpacer(VERT_SPACING);
@ -175,7 +177,7 @@ MsgDataLegacy::MsgDataLegacy() :
)),
ConfigWizard::name()
));
text->Wrap(CONTENT_WIDTH);
text->Wrap(CONTENT_WIDTH * wxGetApp().em_unit());
content_sizer->Add(text);
content_sizer->AddSpacer(VERT_SPACING);