Merge branch 'master' of https://github.com/prusa3d/PrusaSlicer into et_gcode_viewer
This commit is contained in:
commit
4b581ccdd8
@ -78,24 +78,36 @@ namespace GUI {
|
||||
|
||||
class MainFrame;
|
||||
|
||||
// ysFIXME
|
||||
static int get_dpi_for_main_display()
|
||||
static float get_scale_for_main_display()
|
||||
{
|
||||
// ysFIXME : Workaround :
|
||||
// wxFrame is created on the main monitor, so we can take a scale factor from this one
|
||||
// before The Application and the Mainframe are created
|
||||
wxFrame fr(nullptr, wxID_ANY, wxEmptyString);
|
||||
return get_dpi_for_window(&fr);
|
||||
|
||||
#if ENABLE_WX_3_1_3_DPI_CHANGED_EVENT && !defined(__WXGTK__)
|
||||
int dpi = get_dpi_for_window(&fr);
|
||||
float sf = dpi != DPI_DEFAULT ? sf = (float)dpi / DPI_DEFAULT : 1.0;
|
||||
#else
|
||||
printf("dpi = %d\n", get_dpi_for_window(&fr));
|
||||
// initialize default width_unit according to the width of the one symbol ("m") of the currently active font of this window.
|
||||
float sf = 0.1 * std::max<size_t>(10, fr.GetTextExtent("m").x - 1);
|
||||
#endif // ENABLE_WX_3_1_3_DPI_CHANGED_EVENT
|
||||
|
||||
printf("scale factor = %f\n", sf);
|
||||
return sf;
|
||||
}
|
||||
|
||||
// scale input bitmap and return scale factor
|
||||
static float scale_bitmap(wxBitmap& bmp)
|
||||
{
|
||||
int dpi = get_dpi_for_main_display();
|
||||
float sf = 1.0;
|
||||
float sf = get_scale_for_main_display();
|
||||
|
||||
// scale bitmap if needed
|
||||
if (dpi != DPI_DEFAULT) {
|
||||
if (sf > 1.0) {
|
||||
wxImage image = bmp.ConvertToImage();
|
||||
if (image.IsOk() && image.GetWidth() != 0 && image.GetHeight() != 0)
|
||||
{
|
||||
sf = (float)dpi / DPI_DEFAULT;
|
||||
int width = int(sf * image.GetWidth());
|
||||
int height = int(sf * image.GetHeight());
|
||||
image.Rescale(width, height, wxIMAGE_QUALITY_BILINEAR);
|
||||
@ -103,11 +115,15 @@ static float scale_bitmap(wxBitmap& bmp)
|
||||
bmp = wxBitmap(std::move(image));
|
||||
}
|
||||
}
|
||||
|
||||
return sf;
|
||||
}
|
||||
|
||||
static void word_wrap_string(wxString& input, int line_len)
|
||||
static void word_wrap_string(wxString& input, int line_px_len, float scalef)
|
||||
{
|
||||
// calculate count od symbols in one line according to the scale
|
||||
int line_len = std::roundf( (float)line_px_len / (scalef * 10)) + 10;
|
||||
|
||||
int idx = -1;
|
||||
int cur_len = 0;
|
||||
for (size_t i = 0; i < input.Len(); i++)
|
||||
@ -137,11 +153,12 @@ static void DecorateSplashScreen(wxBitmap& bmp)
|
||||
wxMemoryDC memDc(bmp);
|
||||
|
||||
// draw an dark grey box at the left of the splashscreen.
|
||||
// this box will be 2/9 of the weight of the bitmap, and be at the left.
|
||||
const wxRect bannerRect(wxPoint(0, (bmp.GetHeight() / 9) * 2 - 2), wxPoint((bmp.GetWidth() / 5) * 2, bmp.GetHeight()));
|
||||
// this box will be 2/5 of the weight of the bitmap, and be at the left.
|
||||
int banner_width = (bmp.GetWidth() / 5) * 2 - 2;
|
||||
const wxRect banner_rect(wxPoint(0, (bmp.GetHeight() / 9) * 2), wxPoint(banner_width, bmp.GetHeight()));
|
||||
wxDCBrushChanger bc(memDc, wxBrush(wxColour(51, 51, 51)));
|
||||
wxDCPenChanger pc(memDc, wxPen(wxColour(51, 51, 51)));
|
||||
memDc.DrawRectangle(bannerRect);
|
||||
memDc.DrawRectangle(banner_rect);
|
||||
|
||||
// title
|
||||
wxString title_string = SLIC3R_APP_NAME;
|
||||
@ -157,14 +174,14 @@ static void DecorateSplashScreen(wxBitmap& bmp)
|
||||
wxString cr_symbol = wxString::FromUTF8("\xc2\xa9");
|
||||
wxString copyright_string = wxString::Format("%s 2016-%s Prusa Research.\n"
|
||||
"%s 2011-2018 Alessandro Ranellucci.",
|
||||
cr_symbol, year.Mid(year.Length() - 4), cr_symbol);
|
||||
cr_symbol, year.Mid(year.Length() - 4), cr_symbol) + "\n\n";
|
||||
wxFont copyright_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).Larger();
|
||||
|
||||
copyright_string += "Slic3r" + _L("is licensed under the") + _L("GNU Affero General Public License, version 3") + "\n\n" +
|
||||
copyright_string += //"Slic3r" + _L("is licensed under the") + _L("GNU Affero General Public License, version 3") + "\n\n" +
|
||||
_L("PrusaSlicer is based on Slic3r by Alessandro Ranellucci and the RepRap community.") + "\n\n" +
|
||||
_L("Contributions by Henrik Brix Andersen, Nicolas Dandrimont, Mark Hindess, Petr Ledvina, Joseph Lenox, Y. Sapir, Mike Sheldrake, Vojtech Bubnik and numerous others.");
|
||||
|
||||
word_wrap_string(copyright_string, 50);
|
||||
word_wrap_string(copyright_string, banner_width, scale_factor);
|
||||
|
||||
wxCoord margin = int(scale_factor * 20);
|
||||
|
||||
@ -172,27 +189,26 @@ static void DecorateSplashScreen(wxBitmap& bmp)
|
||||
memDc.SetTextForeground(wxColour(237, 107, 33));
|
||||
|
||||
memDc.SetFont(title_font);
|
||||
memDc.DrawLabel(title_string, bannerRect.Deflate(margin, 0), wxALIGN_TOP | wxALIGN_LEFT);
|
||||
memDc.DrawLabel(title_string, banner_rect.Deflate(margin, 0), wxALIGN_TOP | wxALIGN_LEFT);
|
||||
|
||||
memDc.SetFont(version_font);
|
||||
memDc.DrawLabel(version_string, bannerRect.Deflate(margin, 2 * margin), wxALIGN_TOP | wxALIGN_LEFT);
|
||||
memDc.DrawLabel(version_string, banner_rect.Deflate(margin, 2 * margin), wxALIGN_TOP | wxALIGN_LEFT);
|
||||
|
||||
memDc.SetFont(copyright_font);
|
||||
memDc.DrawLabel(copyright_string, bannerRect.Deflate(margin, 2 * margin), wxALIGN_BOTTOM | wxALIGN_LEFT);
|
||||
memDc.DrawLabel(copyright_string, banner_rect.Deflate(margin, 2 * margin), wxALIGN_BOTTOM | wxALIGN_LEFT);
|
||||
}
|
||||
|
||||
class SplashScreen : public wxSplashScreen
|
||||
{
|
||||
public:
|
||||
SplashScreen(const wxBitmap& bitmap, long splashStyle, int milliseconds, wxWindow* parent)
|
||||
: wxSplashScreen(bitmap, splashStyle, milliseconds, parent, wxID_ANY)
|
||||
: wxSplashScreen(bitmap, splashStyle, milliseconds, parent, wxID_ANY, wxDefaultPosition, wxDefaultSize,
|
||||
wxSIMPLE_BORDER | wxFRAME_NO_TASKBAR)
|
||||
{
|
||||
wxASSERT(bitmap.IsOk());
|
||||
m_main_bitmap = bitmap;
|
||||
|
||||
int dpi = get_dpi_for_main_display();
|
||||
if (dpi != DPI_DEFAULT)
|
||||
m_scale_factor = (float)dpi / DPI_DEFAULT;
|
||||
m_scale_factor = get_scale_for_main_display();
|
||||
}
|
||||
|
||||
void SetText(const wxString& text)
|
||||
|
@ -92,10 +92,13 @@ public:
|
||||
#ifndef __WXOSX__ // Don't call SetFont under OSX to avoid name cutting in ObjectList
|
||||
this->SetFont(m_normal_font);
|
||||
#endif
|
||||
// initialize default width_unit according to the width of the one symbol ("m") of the currently active font of this window.
|
||||
#if ENABLE_WX_3_1_3_DPI_CHANGED_EVENT
|
||||
|
||||
// Linux specific issue : get_dpi_for_window(this) still doesn't responce to the Display's scale in new wxWidgets(3.1.3).
|
||||
// So, calculate the m_em_unit value from the font size, as before
|
||||
#if ENABLE_WX_3_1_3_DPI_CHANGED_EVENT && !defined(__WXGTK__)
|
||||
m_em_unit = std::max<size_t>(10, 10.0f * m_scale_factor);
|
||||
#else
|
||||
// initialize default width_unit according to the width of the one symbol ("m") of the currently active font of this window.
|
||||
m_em_unit = std::max<size_t>(10, this->GetTextExtent("m").x - 1);
|
||||
#endif // ENABLE_WX_3_1_3_DPI_CHANGED_EVENT
|
||||
|
||||
|
@ -187,8 +187,7 @@ PhysicalPrinterDialog::PhysicalPrinterDialog(wxString printer_name) :
|
||||
PhysicalPrinter* printer = printers.find_printer(into_u8(printer_name));
|
||||
if (!printer) {
|
||||
const Preset& preset = wxGetApp().preset_bundle->printers.get_edited_preset();
|
||||
//FIXME Vojtech: WTF??? Memory leak?
|
||||
printer = new PhysicalPrinter(into_u8(printer_name), m_printer.config, preset);
|
||||
m_printer = PhysicalPrinter(into_u8(printer_name), m_printer.config, preset);
|
||||
// if printer_name is empty it means that new printer is created, so enable all items in the preset list
|
||||
m_presets.emplace_back(new PresetForPrinter(this, preset.name));
|
||||
}
|
||||
@ -197,9 +196,8 @@ PhysicalPrinterDialog::PhysicalPrinterDialog(wxString printer_name) :
|
||||
const std::set<std::string>& preset_names = printer->get_preset_names();
|
||||
for (const std::string& preset_name : preset_names)
|
||||
m_presets.emplace_back(new PresetForPrinter(this, preset_name));
|
||||
}
|
||||
assert(printer);
|
||||
m_printer = *printer;
|
||||
}
|
||||
|
||||
if (m_presets.size() == 1)
|
||||
m_presets.front()->SuppressDelete();
|
||||
|
Loading…
Reference in New Issue
Block a user