This commit is contained in:
enricoturri1966 2020-09-07 08:35:54 +02:00
commit 014a90b51b
16 changed files with 165 additions and 58 deletions

View file

@ -0,0 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg" width="800" height="800" viewBox="0 0 800 800">
<circle cx="400" cy="400" r="400" fill="#fff"/>
<path d="M599.3,186.8c-93.9-93.9-246.1-93.9-340,0s-93.9,246.1,0,340Z" transform="translate(0 0)" fill="#363636"/>
<path d="M202.7,612.5c93.9,93.9,246.1,93.9,340,0s93.9-246.1,0-340" transform="translate(0 0)" fill="#ed6b21"/>
</svg>

After

Width:  |  Height:  |  Size: 374 B

View file

@ -52,7 +52,7 @@ CopyrightsDialog::CopyrightsDialog()
m_html = new wxHtmlWindow(this, wxID_ANY, wxDefaultPosition,
wxSize(40 * em_unit(), 20 * em_unit()), wxHW_SCROLLBAR_AUTO);
wxFont font = GetFont();
wxFont font = get_default_font_for_dpi(get_dpi_for_window(this));// GetFont();
const int fs = font.GetPointSize();
const int fs2 = static_cast<int>(1.2f*fs);
int size[] = { fs, fs, fs, fs, fs2, fs2, fs2 };
@ -249,7 +249,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 = GetFont();
wxFont font = get_default_font_for_dpi(get_dpi_for_window(this));// GetFont();
const auto text_clr = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
auto text_clr_str = wxString::Format(wxT("#%02X%02X%02X"), text_clr.Red(), text_clr.Green(), text_clr.Blue());
auto bgr_clr_str = wxString::Format(wxT("#%02X%02X%02X"), bgr_clr.Red(), bgr_clr.Green(), bgr_clr.Blue());

View file

@ -114,7 +114,7 @@ ConfigSnapshotDialog::ConfigSnapshotDialog(const Config::SnapshotDB &snapshot_db
// text
html = new wxHtmlWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO);
{
wxFont font = wxGetApp().normal_font();//wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
wxFont font = get_default_font_for_dpi(get_dpi_for_window(this));// wxGetApp().normal_font();//wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
#ifdef __WXMSW__
const int fs = font.GetPointSize();
const int fs1 = static_cast<int>(0.8f*fs);
@ -140,7 +140,7 @@ ConfigSnapshotDialog::ConfigSnapshotDialog(const Config::SnapshotDB &snapshot_db
void ConfigSnapshotDialog::on_dpi_changed(const wxRect &suggested_rect)
{
wxFont font = GetFont();
wxFont font = get_default_font_for_dpi(get_dpi_for_window(this));// GetFont();
const int fs = font.GetPointSize();
const int fs1 = static_cast<int>(0.8f*fs);
const int fs2 = static_cast<int>(1.1f*fs);

View file

@ -30,6 +30,7 @@
#include <wx/dialog.h>
#include <wx/textctrl.h>
#include <wx/splash.h>
#include "libslic3r/Utils.hpp"
#include "libslic3r/Model.hpp"
@ -76,6 +77,46 @@ namespace GUI {
class MainFrame;
class SplashScreen : public wxSplashScreen
{
public:
SplashScreen(const wxBitmap& bitmap, long splashStyle, int milliseconds, wxWindow* parent)
: wxSplashScreen(bitmap, splashStyle, milliseconds, parent, wxID_ANY)
{
wxASSERT(bitmap.IsOk());
m_main_bitmap = bitmap;
}
void SetText(const wxString& text)
{
SetBmp(m_main_bitmap);
if (!text.empty()) {
wxBitmap bitmap(m_main_bitmap);
wxMemoryDC memDC;
memDC.SelectObject(bitmap);
memDC.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).Bold());
memDC.SetTextForeground(wxColour(237, 107, 33));
memDC.DrawText(text, 120, 120);
memDC.SelectObject(wxNullBitmap);
SetBmp(bitmap);
}
wxYield();
}
void SetBmp(wxBitmap& bmp)
{
m_window->SetBitmap(bmp);
m_window->Refresh();
m_window->Update();
}
private:
wxBitmap m_main_bitmap;
};
wxString file_wildcards(FileType file_type, const std::string &custom_extension)
{
static const std::string defaults[FT_SIZE] = {
@ -389,6 +430,10 @@ bool GUI_App::on_init_inner()
app_config->set("version", SLIC3R_VERSION);
app_config->save();
wxBitmap bitmap = create_scaled_bitmap("prusa_slicer_logo", nullptr, 400);
SplashScreen* scrn = new SplashScreen(bitmap, wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_TIMEOUT, 4000, nullptr);
scrn->SetText(_L("Loading configuration..."));
preset_bundle = new PresetBundle();
@ -439,6 +484,8 @@ bool GUI_App::on_init_inner()
// application frame
if (wxImage::FindHandler(wxBITMAP_TYPE_PNG) == nullptr)
wxImage::AddHandler(new wxPNGHandler());
scrn->SetText(_L("Creating settings tabs..."));
mainframe = new MainFrame();
// hide settings tabs after first Layout
mainframe->select_tab(0);

View file

@ -219,16 +219,12 @@ private:
{
this->Freeze();
#if wxVERSION_EQUAL_OR_GREATER_THAN(3,1,3)
if (m_force_rescale) {
#endif // wxVERSION_EQUAL_OR_GREATER_THAN
// rescale fonts of all controls
scale_controls_fonts(this, m_new_font_point_size);
// rescale current window font
scale_win_font(this, m_new_font_point_size);
#if wxVERSION_EQUAL_OR_GREATER_THAN(3,1,3)
m_force_rescale = false;
}
m_force_rescale = false;
#if !wxVERSION_EQUAL_OR_GREATER_THAN(3,1,3)
// rescale fonts of all controls
scale_controls_fonts(this, m_new_font_point_size);
// rescale current window font
scale_win_font(this, m_new_font_point_size);
#endif // wxVERSION_EQUAL_OR_GREATER_THAN
// set normal application font as a current window font

View file

@ -285,5 +285,12 @@ void GLGizmoFdmSupports::update_from_model_object()
}
PainterGizmoType GLGizmoFdmSupports::get_painter_type() const
{
return PainterGizmoType::FDM_SUPPORTS;
}
} // namespace GUI
} // namespace Slic3r

View file

@ -27,6 +27,7 @@ private:
void on_opening() override {}
void on_shutdown() override;
PainterGizmoType get_painter_type() const override;
void select_facets_by_angle(float threshold, bool block);
float m_angle_threshold_deg = 45.f;

View file

@ -28,13 +28,19 @@ GLGizmoPainterBase::GLGizmoPainterBase(GLCanvas3D& parent, const std::string& ic
void GLGizmoPainterBase::activate_internal_undo_redo_stack(bool activate)
{
if (activate && ! m_internal_stack_active) {
Plater::TakeSnapshot(wxGetApp().plater(), _L("FDM gizmo turned on"));
wxString str = get_painter_type() == PainterGizmoType::FDM_SUPPORTS
? _L("Supports gizmo turned on")
: _L("Seam gizmo turned on");
Plater::TakeSnapshot(wxGetApp().plater(), str);
wxGetApp().plater()->enter_gizmos_stack();
m_internal_stack_active = true;
}
if (! activate && m_internal_stack_active) {
wxString str = get_painter_type() == PainterGizmoType::SEAM
? _L("Seam gizmo turned off")
: _L("Supports gizmo turned off");
wxGetApp().plater()->leave_gizmos_stack();
Plater::TakeSnapshot(wxGetApp().plater(), _L("FDM gizmo turned off"));
Plater::TakeSnapshot(wxGetApp().plater(), str);
m_internal_stack_active = false;
}
}
@ -356,11 +362,28 @@ bool GLGizmoPainterBase::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
if ((action == SLAGizmoEventType::LeftUp || action == SLAGizmoEventType::RightUp)
&& m_button_down != Button::None) {
// Take snapshot and update ModelVolume data.
wxString action_name = shift_down
? _L("Remove selection")
: (m_button_down == Button::Left
? _L("Add supports")
: _L("Block supports"));
wxString action_name;
if (get_painter_type() == PainterGizmoType::FDM_SUPPORTS) {
if (shift_down)
action_name = _L("Remove selection");
else {
if (m_button_down == Button::Left)
action_name = _L("Add supports");
else
action_name = _L("Block supports");
}
}
if (get_painter_type() == PainterGizmoType::SEAM) {
if (shift_down)
action_name = _L("Remove selection");
else {
if (m_button_down == Button::Left)
action_name = _L("Enforce seam");
else
action_name = _L("Block seam");
}
}
activate_internal_undo_redo_stack(true);
Plater::TakeSnapshot(wxGetApp().plater(), action_name);
update_model_object();

View file

@ -22,6 +22,10 @@ namespace GUI {
enum class SLAGizmoEventType : unsigned char;
class ClippingPlane;
enum class PainterGizmoType {
FDM_SUPPORTS,
SEAM
};
class TriangleSelectorGUI : public TriangleSelector {
@ -103,6 +107,7 @@ protected:
virtual void on_opening() = 0;
virtual void on_shutdown() = 0;
virtual PainterGizmoType get_painter_type() const = 0;
bool on_is_activable() const override;
bool on_is_selectable() const override;

View file

@ -204,5 +204,12 @@ void GLGizmoSeam::update_from_model_object()
}
PainterGizmoType GLGizmoSeam::get_painter_type() const
{
return PainterGizmoType::SEAM;
}
} // namespace GUI
} // namespace Slic3r

View file

@ -16,6 +16,7 @@ public:
protected:
void on_render_input_window(float x, float y, float bottom_limit) override;
std::string on_get_name() const override;
PainterGizmoType get_painter_type() const override;
private:
bool on_init() override;

View file

@ -55,29 +55,6 @@ enum class ERescaleTarget
SettingsDialog
};
static void rescale_dialog_after_dpi_change(MainFrame& mainframe, SettingsDialog& dialog, ERescaleTarget target)
{
int mainframe_dpi = get_dpi_for_window(&mainframe);
int dialog_dpi = get_dpi_for_window(&dialog);
if (mainframe_dpi != dialog_dpi) {
if (target == ERescaleTarget::SettingsDialog) {
dialog.enable_force_rescale();
#if wxVERSION_EQUAL_OR_GREATER_THAN(3,1,3)
dialog.GetEventHandler()->AddPendingEvent(wxDPIChangedEvent(wxSize(mainframe_dpi, mainframe_dpi), wxSize(dialog_dpi, dialog_dpi)));
#else
dialog.GetEventHandler()->AddPendingEvent(DpiChangedEvent(EVT_DPI_CHANGED_SLICER, dialog_dpi, dialog.GetRect()));
#endif // wxVERSION_EQUAL_OR_GREATER_THAN
} else {
#if wxVERSION_EQUAL_OR_GREATER_THAN(3,1,3)
mainframe.GetEventHandler()->AddPendingEvent(wxDPIChangedEvent(wxSize(dialog_dpi, dialog_dpi), wxSize(mainframe_dpi, mainframe_dpi)));
#else
mainframe.enable_force_rescale();
mainframe.GetEventHandler()->AddPendingEvent(DpiChangedEvent(EVT_DPI_CHANGED_SLICER, mainframe_dpi, mainframe.GetRect()));
#endif // wxVERSION_EQUAL_OR_GREATER_THAN
}
}
}
MainFrame::MainFrame() :
DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, "mainframe"),
m_printhost_queue_dlg(new PrintHostQueueDialog(this))
@ -310,9 +287,6 @@ void MainFrame::update_layout()
m_plater_page = nullptr;
}
if (m_layout == ESettingsLayout::Dlg)
rescale_dialog_after_dpi_change(*this, m_settings_dialog, ERescaleTarget::Mainframe);
clean_sizer(m_main_sizer);
clean_sizer(m_settings_dialog.GetSizer());
@ -347,6 +321,16 @@ void MainFrame::update_layout()
if (m_layout != ESettingsLayout::Unknown)
restore_to_creation();
#ifdef __WXMSW__
enum class State {
noUpdate,
fromDlg,
toDlg
};
State update_scaling_state = m_layout == ESettingsLayout::Dlg ? State::fromDlg :
layout == ESettingsLayout::Dlg ? State::toDlg : State::noUpdate;
#endif //__WXMSW__
m_layout = layout;
// From the very beginning the Print settings should be selected
@ -383,9 +367,6 @@ void MainFrame::update_layout()
m_main_sizer->Add(m_plater, 1, wxEXPAND);
m_tabpanel->Reparent(&m_settings_dialog);
m_settings_dialog.GetSizer()->Add(m_tabpanel, 1, wxEXPAND);
rescale_dialog_after_dpi_change(*this, m_settings_dialog, ERescaleTarget::SettingsDialog);
m_tabpanel->Show();
m_plater->Show();
break;
@ -400,6 +381,36 @@ void MainFrame::update_layout()
#endif // ENABLE_GCODE_VIEWER
}
#ifdef __WXMSW__
if (update_scaling_state != State::noUpdate)
{
int mainframe_dpi = get_dpi_for_window(this);
int dialog_dpi = get_dpi_for_window(&m_settings_dialog);
if (mainframe_dpi != dialog_dpi) {
wxSize oldDPI = update_scaling_state == State::fromDlg ? wxSize(dialog_dpi, dialog_dpi) : wxSize(mainframe_dpi, mainframe_dpi);
wxSize newDPI = update_scaling_state == State::toDlg ? wxSize(dialog_dpi, dialog_dpi) : wxSize(mainframe_dpi, mainframe_dpi);
if (update_scaling_state == State::fromDlg)
this->enable_force_rescale();
else
(&m_settings_dialog)->enable_force_rescale();
wxWindow* win { nullptr };
if (update_scaling_state == State::fromDlg)
win = this;
else
win = &m_settings_dialog;
#if wxVERSION_EQUAL_OR_GREATER_THAN(3,1,3)
m_tabpanel->MSWUpdateOnDPIChange(oldDPI, newDPI);
win->GetEventHandler()->AddPendingEvent(wxDPIChangedEvent(oldDPI, newDPI));
#else
win->GetEventHandler()->AddPendingEvent(DpiChangedEvent(EVT_DPI_CHANGED_SLICER, newDPI, win->GetRect()));
#endif // wxVERSION_EQUAL_OR_GREATER_THAN
}
}
#endif //__WXMSW__
//#ifdef __APPLE__
// // Using SetMinSize() on Mac messes up the window position in some cases
// // cf. https://groups.google.com/forum/#!topic/wx-users/yUKPBBfXWO0
@ -787,9 +798,6 @@ void MainFrame::on_dpi_changed(const wxRect& suggested_rect)
this->SetSize(sz);
this->Maximize(is_maximized);
if (m_layout == ESettingsLayout::Dlg)
rescale_dialog_after_dpi_change(*this, m_settings_dialog, ERescaleTarget::SettingsDialog);
}
void MainFrame::on_sys_color_changed()
@ -1988,7 +1996,14 @@ SettingsDialog::SettingsDialog(MainFrame* mainframe)
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMINIMIZE_BOX | wxMAXIMIZE_BOX, "settings_dialog"),
m_main_frame(mainframe)
{
#if ENABLE_WX_3_1_3_DPI_CHANGED_EVENT && defined(__WXMSW__)
// ys_FIXME! temporary workaround for correct font scaling
// Because of from wxWidgets 3.1.3 auto rescaling is implemented for the Fonts,
// From the very beginning set dialog font to the wxSYS_DEFAULT_GUI_FONT
this->SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
#else
this->SetFont(wxGetApp().normal_font());
#endif // ENABLE_WX_3_1_3_DPI_CHANGED_EVENT
this->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));

View file

@ -1194,7 +1194,7 @@ SavePresetDialog::~SavePresetDialog()
void SavePresetDialog::build(std::vector<Preset::Type> types, std::string suffix)
{
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
#if ENABLE_WX_3_1_3_DPI_CHANGED_EVENT
#if ENABLE_WX_3_1_3_DPI_CHANGED_EVENT && defined(__WXMSW__)
// ys_FIXME! temporary workaround for correct font scaling
// Because of from wxWidgets 3.1.3 auto rescaling is implemented for the Fonts,
// From the very beginning set dialog font to the wxSYS_DEFAULT_GUI_FONT

View file

@ -109,7 +109,7 @@ SysInfoDialog::SysInfoDialog()
}
// main_info_text
wxFont font = wxGetApp().normal_font();
wxFont font = get_default_font_for_dpi(get_dpi_for_window(this));// wxGetApp().normal_font();
const auto text_clr = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
auto text_clr_str = wxString::Format(wxT("#%02X%02X%02X"), text_clr.Red(), text_clr.Green(), text_clr.Blue());
auto bgr_clr_str = wxString::Format(wxT("#%02X%02X%02X"), bgr_clr.Red(), bgr_clr.Green(), bgr_clr.Blue());
@ -175,7 +175,7 @@ void SysInfoDialog::on_dpi_changed(const wxRect &suggested_rect)
m_logo_bmp.msw_rescale();
m_logo->SetBitmap(m_logo_bmp.bmp());
wxFont font = GetFont();
wxFont font = get_default_font_for_dpi(get_dpi_for_window(this));// GetFont();
const int fs = font.GetPointSize() - 1;
int font_size[] = { static_cast<int>(fs*1.5), static_cast<int>(fs*1.4), static_cast<int>(fs*1.3), fs, fs, fs, fs };

View file

@ -102,7 +102,7 @@ Tab::Tab(wxNotebook* parent, const wxString& title, Preset::Type type) :
wxGetApp().tabs_list.push_back(this);
m_em_unit = wxGetApp().em_unit();
m_em_unit = em_unit(m_parent); //wxGetApp().em_unit();
m_config_manipulation = get_config_manipulation();

View file

@ -531,7 +531,7 @@ void UnsavedChangesDialog::build(Preset::Type type, PresetCollection* dependent_
wxColour bgr_clr = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
SetBackgroundColour(bgr_clr);
#if ENABLE_WX_3_1_3_DPI_CHANGED_EVENT
#if ENABLE_WX_3_1_3_DPI_CHANGED_EVENT && defined(__WXMSW__)
// ys_FIXME! temporary workaround for correct font scaling
// Because of from wxWidgets 3.1.3 auto rescaling is implemented for the Fonts,
// From the very beginning set dialog font to the wxSYS_DEFAULT_GUI_FONT