mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-11-02 20:51:23 -07:00 
			
		
		
		
	Fixed a Dialog position under OSX
Always set parent for the Dialog, if we want to see the Dialog in the same display as a parent. Dialog will be shown in the primary monitor otherwise. + fixed a draw of the canvas legend when we move application between Retina and non-Retina displays
This commit is contained in:
		
							parent
							
								
									95d808f7c4
								
							
						
					
					
						commit
						f0a339758b
					
				
					 14 changed files with 38 additions and 26 deletions
				
			
		| 
						 | 
				
			
			@ -38,12 +38,12 @@ void AboutDialogLogo::onRepaint(wxEvent &event)
 | 
			
		|||
// -----------------------------------------
 | 
			
		||||
CopyrightsDialog::CopyrightsDialog()
 | 
			
		||||
#if ENABLE_GCODE_VIEWER
 | 
			
		||||
    : DPIDialog(NULL, wxID_ANY, from_u8((boost::format("%1% - %2%")
 | 
			
		||||
    : DPIDialog((wxWindow*)wxGetApp().mainframe, wxID_ANY, from_u8((boost::format("%1% - %2%")
 | 
			
		||||
        % (wxGetApp().is_editor() ? SLIC3R_APP_NAME : GCODEVIEWER_APP_NAME)
 | 
			
		||||
        % _utf8(L("Portions copyright"))).str()),
 | 
			
		||||
        wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
 | 
			
		||||
#else
 | 
			
		||||
    : DPIDialog(NULL, wxID_ANY, from_u8((boost::format("%1% - %2%")
 | 
			
		||||
    : DPIDialog((wxWindow*)wxGetApp().mainframe, wxID_ANY, from_u8((boost::format("%1% - %2%")
 | 
			
		||||
                                                       % SLIC3R_APP_NAME
 | 
			
		||||
                                                       % _utf8(L("Portions copyright"))).str()),
 | 
			
		||||
                wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
 | 
			
		||||
| 
						 | 
				
			
			@ -209,10 +209,10 @@ void CopyrightsDialog::onCloseDialog(wxEvent &)
 | 
			
		|||
 | 
			
		||||
AboutDialog::AboutDialog()
 | 
			
		||||
#if ENABLE_GCODE_VIEWER
 | 
			
		||||
    : DPIDialog(NULL, wxID_ANY, from_u8((boost::format(_utf8(L("About %s"))) % (wxGetApp().is_editor() ? SLIC3R_APP_NAME : GCODEVIEWER_APP_NAME)).str()), wxDefaultPosition,
 | 
			
		||||
    : DPIDialog((wxWindow*)wxGetApp().mainframe, wxID_ANY, from_u8((boost::format(_utf8(L("About %s"))) % (wxGetApp().is_editor() ? SLIC3R_APP_NAME : GCODEVIEWER_APP_NAME)).str()), wxDefaultPosition,
 | 
			
		||||
        wxDefaultSize, /*wxCAPTION*/wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
 | 
			
		||||
#else
 | 
			
		||||
    : DPIDialog(NULL, wxID_ANY, from_u8((boost::format(_utf8(L("About %s"))) % SLIC3R_APP_NAME).str()), wxDefaultPosition,
 | 
			
		||||
    : DPIDialog((wxWindow*)wxGetApp().mainframe, wxID_ANY, from_u8((boost::format(_utf8(L("About %s"))) % SLIC3R_APP_NAME).str()), wxDefaultPosition,
 | 
			
		||||
                wxDefaultSize, /*wxCAPTION*/wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
 | 
			
		||||
#endif // ENABLE_GCODE_VIEWER
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -109,7 +109,7 @@ static wxString generate_html_page(const Config::SnapshotDB &snapshot_db, const
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
ConfigSnapshotDialog::ConfigSnapshotDialog(const Config::SnapshotDB &snapshot_db, const wxString &on_snapshot)
 | 
			
		||||
    : DPIDialog(NULL, wxID_ANY, _(L("Configuration Snapshots")), wxDefaultPosition, 
 | 
			
		||||
    : DPIDialog((wxWindow*)wxGetApp().mainframe, wxID_ANY, _(L("Configuration Snapshots")), wxDefaultPosition,
 | 
			
		||||
               wxSize(45 * wxGetApp().em_unit(), 40 * wxGetApp().em_unit()), 
 | 
			
		||||
               wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,7 +20,7 @@ namespace Slic3r {
 | 
			
		|||
namespace GUI {
 | 
			
		||||
 | 
			
		||||
ExtruderSequenceDialog::ExtruderSequenceDialog(const DoubleSlider::ExtrudersSequence& sequence)
 | 
			
		||||
    : DPIDialog(NULL, wxID_ANY, wxString(SLIC3R_APP_NAME) + " - " + _(L("Set extruder sequence")),
 | 
			
		||||
    : DPIDialog((wxWindow*)wxGetApp().mainframe, wxID_ANY, wxString(SLIC3R_APP_NAME) + " - " + _(L("Set extruder sequence")),
 | 
			
		||||
        wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER),
 | 
			
		||||
    m_sequence(sequence)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -86,7 +86,7 @@ class SplashScreen : public wxSplashScreen
 | 
			
		|||
{
 | 
			
		||||
public:
 | 
			
		||||
    SplashScreen(const wxBitmap& bitmap, long splashStyle, int milliseconds, wxPoint pos = wxDefaultPosition)
 | 
			
		||||
        : wxSplashScreen(bitmap, splashStyle, milliseconds, nullptr, wxID_ANY, wxDefaultPosition, wxDefaultSize, 
 | 
			
		||||
        : wxSplashScreen(bitmap, splashStyle, milliseconds, (wxWindow*)wxGetApp().mainframe, wxID_ANY, wxDefaultPosition, wxDefaultSize, 
 | 
			
		||||
#ifdef __APPLE__
 | 
			
		||||
            wxSIMPLE_BORDER | wxFRAME_NO_TASKBAR | wxSTAY_ON_TOP
 | 
			
		||||
#else
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -95,6 +95,7 @@ public:
 | 
			
		|||
#ifndef __WXOSX__ // Don't call SetFont under OSX to avoid name cutting in ObjectList 
 | 
			
		||||
        this->SetFont(m_normal_font);
 | 
			
		||||
#endif
 | 
			
		||||
        this->CenterOnParent();
 | 
			
		||||
 | 
			
		||||
        // 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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -34,9 +34,9 @@ namespace GUI {
 | 
			
		|||
 | 
			
		||||
KBShortcutsDialog::KBShortcutsDialog()
 | 
			
		||||
#if ENABLE_GCODE_VIEWER
 | 
			
		||||
    : DPIDialog(NULL, wxID_ANY, wxString(wxGetApp().is_editor() ? SLIC3R_APP_NAME : GCODEVIEWER_APP_NAME) + " - " + _L("Keyboard Shortcuts"),
 | 
			
		||||
    : DPIDialog((wxWindow*)wxGetApp().mainframe, wxID_ANY, wxString(wxGetApp().is_editor() ? SLIC3R_APP_NAME : GCODEVIEWER_APP_NAME) + " - " + _L("Keyboard Shortcuts"),
 | 
			
		||||
#else
 | 
			
		||||
    : DPIDialog(NULL, wxID_ANY, wxString(SLIC3R_APP_NAME) + " - " + _L("Keyboard Shortcuts"),
 | 
			
		||||
    : DPIDialog((wxWindow*)wxGetApp().mainframe, wxID_ANY, wxString(SLIC3R_APP_NAME) + " - " + _L("Keyboard Shortcuts"),
 | 
			
		||||
#endif // ENABLE_GCODE_VIEWER
 | 
			
		||||
    wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -238,6 +238,17 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S
 | 
			
		|||
        event.Skip();
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
// OSX specific issue:
 | 
			
		||||
// When we move application between Retina and non-Retina displays, The legend on a canvas doesn't redraw
 | 
			
		||||
// So, redraw explicitly canvas, when application is moved
 | 
			
		||||
#ifdef ENABLE_RETINA_GL
 | 
			
		||||
    Bind(wxEVT_MOVE, [this](wxMoveEvent& event) {
 | 
			
		||||
        wxGetApp().plater()->get_current_canvas3D()->set_as_dirty();
 | 
			
		||||
        wxGetApp().plater()->get_current_canvas3D()->request_extra_frame();
 | 
			
		||||
        event.Skip();
 | 
			
		||||
    });
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    wxGetApp().persist_window_geometry(this, true);
 | 
			
		||||
    wxGetApp().persist_window_geometry(&m_settings_dialog, true);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -151,8 +151,8 @@ void PresetForPrinter::msw_rescale()
 | 
			
		|||
//          PhysicalPrinterDialog
 | 
			
		||||
//------------------------------------------
 | 
			
		||||
 | 
			
		||||
PhysicalPrinterDialog::PhysicalPrinterDialog(wxString printer_name) : 
 | 
			
		||||
    DPIDialog(NULL, wxID_ANY, _L("Physical Printer"), wxDefaultPosition, wxSize(45 * wxGetApp().em_unit(), -1), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER),
 | 
			
		||||
PhysicalPrinterDialog::PhysicalPrinterDialog(wxWindow* parent, wxString printer_name) :
 | 
			
		||||
    DPIDialog(parent, wxID_ANY, _L("Physical Printer"), wxDefaultPosition, wxSize(45 * wxGetApp().em_unit(), -1), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER),
 | 
			
		||||
    m_printer("", wxGetApp().preset_bundle->physical_printers.default_config())
 | 
			
		||||
{
 | 
			
		||||
    SetFont(wxGetApp().normal_font());
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -82,7 +82,7 @@ class PhysicalPrinterDialog : public DPIDialog
 | 
			
		|||
    void AddPreset(wxEvent& event);
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    PhysicalPrinterDialog(wxString printer_name);
 | 
			
		||||
    PhysicalPrinterDialog(wxWindow* parent, wxString printer_name);
 | 
			
		||||
    ~PhysicalPrinterDialog();
 | 
			
		||||
 | 
			
		||||
    void        update();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -253,14 +253,14 @@ void PresetComboBox::edit_physical_printer()
 | 
			
		|||
    if (!m_preset_bundle->physical_printers.has_selection())
 | 
			
		||||
        return;
 | 
			
		||||
 | 
			
		||||
    PhysicalPrinterDialog dlg(this->GetString(this->GetSelection()));
 | 
			
		||||
    PhysicalPrinterDialog dlg(this->GetParent(),this->GetString(this->GetSelection()));
 | 
			
		||||
    if (dlg.ShowModal() == wxID_OK)
 | 
			
		||||
        update();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void PresetComboBox::add_physical_printer()
 | 
			
		||||
{
 | 
			
		||||
    if (PhysicalPrinterDialog(wxEmptyString).ShowModal() == wxID_OK)
 | 
			
		||||
    if (PhysicalPrinterDialog(this->GetParent(), wxEmptyString).ShowModal() == wxID_OK)
 | 
			
		||||
        update();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -675,7 +675,7 @@ void PlaterPresetComboBox::show_add_menu()
 | 
			
		|||
 | 
			
		||||
    append_menu_item(menu, wxID_ANY, _L("Add physical printer"), "",
 | 
			
		||||
        [this](wxCommandEvent&) {
 | 
			
		||||
            PhysicalPrinterDialog dlg(wxEmptyString);
 | 
			
		||||
            PhysicalPrinterDialog dlg(this->GetParent(), wxEmptyString);
 | 
			
		||||
            if (dlg.ShowModal() == wxID_OK)
 | 
			
		||||
                update();
 | 
			
		||||
        }, "edit_uni", menu, []() { return true; }, wxGetApp().plater());
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -171,14 +171,14 @@ void SavePresetDialog::Item::accept()
 | 
			
		|||
//          SavePresetDialog
 | 
			
		||||
//-----------------------------------------------
 | 
			
		||||
 | 
			
		||||
SavePresetDialog::SavePresetDialog(Preset::Type type, std::string suffix)
 | 
			
		||||
    : DPIDialog(nullptr, wxID_ANY, _L("Save preset"), wxDefaultPosition, wxSize(45 * wxGetApp().em_unit(), 5 * wxGetApp().em_unit()), wxDEFAULT_DIALOG_STYLE | wxICON_WARNING | wxRESIZE_BORDER)
 | 
			
		||||
SavePresetDialog::SavePresetDialog(wxWindow* parent, Preset::Type type, std::string suffix)
 | 
			
		||||
    : DPIDialog(parent, wxID_ANY, _L("Save preset"), wxDefaultPosition, wxSize(45 * wxGetApp().em_unit(), 5 * wxGetApp().em_unit()), wxDEFAULT_DIALOG_STYLE | wxICON_WARNING | wxRESIZE_BORDER)
 | 
			
		||||
{
 | 
			
		||||
    build(std::vector<Preset::Type>{type}, suffix);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
SavePresetDialog::SavePresetDialog(std::vector<Preset::Type> types, std::string suffix)
 | 
			
		||||
    : DPIDialog(nullptr, wxID_ANY, _L("Save preset"), wxDefaultPosition, wxSize(45 * wxGetApp().em_unit(), 5 * wxGetApp().em_unit()), wxDEFAULT_DIALOG_STYLE | wxICON_WARNING | wxRESIZE_BORDER)
 | 
			
		||||
SavePresetDialog::SavePresetDialog(wxWindow* parent, std::vector<Preset::Type> types, std::string suffix)
 | 
			
		||||
    : DPIDialog(parent, wxID_ANY, _L("Save preset"), wxDefaultPosition, wxSize(45 * wxGetApp().em_unit(), 5 * wxGetApp().em_unit()), wxDEFAULT_DIALOG_STYLE | wxICON_WARNING | wxRESIZE_BORDER)
 | 
			
		||||
{
 | 
			
		||||
    build(types, suffix);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -73,8 +73,8 @@ class SavePresetDialog : public DPIDialog
 | 
			
		|||
 | 
			
		||||
public:
 | 
			
		||||
 | 
			
		||||
    SavePresetDialog(Preset::Type type, std::string suffix = "");
 | 
			
		||||
    SavePresetDialog(std::vector<Preset::Type> types, std::string suffix = "");
 | 
			
		||||
    SavePresetDialog(wxWindow* parent, Preset::Type type, std::string suffix = "");
 | 
			
		||||
    SavePresetDialog(wxWindow* parent, std::vector<Preset::Type> types, std::string suffix = "");
 | 
			
		||||
    ~SavePresetDialog();
 | 
			
		||||
 | 
			
		||||
    void AddItem(Preset::Type type, const std::string& suffix);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3338,7 +3338,7 @@ void Tab::save_preset(std::string name /*= ""*/, bool detach)
 | 
			
		|||
//!	m_treectrl->OnSetFocus();
 | 
			
		||||
 | 
			
		||||
    if (name.empty()) {
 | 
			
		||||
        SavePresetDialog dlg(m_type, detach ? _u8L("Detached") : "");
 | 
			
		||||
        SavePresetDialog dlg(m_parent, m_type, detach ? _u8L("Detached") : "");
 | 
			
		||||
        if (dlg.ShowModal() != wxID_OK)
 | 
			
		||||
            return;
 | 
			
		||||
        name = dlg.get_name();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -522,7 +522,7 @@ void UnsavedChangesModel::Rescale()
 | 
			
		|||
//------------------------------------------
 | 
			
		||||
 | 
			
		||||
UnsavedChangesDialog::UnsavedChangesDialog(const wxString& header)
 | 
			
		||||
    : DPIDialog(nullptr, wxID_ANY, _L("Closing PrusaSlicer: Unsaved Changes"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
 | 
			
		||||
    : DPIDialog((wxWindow*)wxGetApp().mainframe , wxID_ANY, _L("Closing PrusaSlicer: Unsaved Changes"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
 | 
			
		||||
{
 | 
			
		||||
    m_app_config_key = "default_action_on_close_application";
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -539,7 +539,7 @@ UnsavedChangesDialog::UnsavedChangesDialog(const wxString& header)
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
UnsavedChangesDialog::UnsavedChangesDialog(Preset::Type type, PresetCollection* dependent_presets, const std::string& new_selected_preset)
 | 
			
		||||
    : DPIDialog(nullptr, wxID_ANY, _L("Switching Presets: Unsaved Changes"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
 | 
			
		||||
    : DPIDialog((wxWindow*)wxGetApp().mainframe, wxID_ANY, _L("Switching Presets: Unsaved Changes"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
 | 
			
		||||
{
 | 
			
		||||
    m_app_config_key = "default_action_on_select_preset";
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -781,7 +781,7 @@ bool UnsavedChangesDialog::save(PresetCollection* dependent_presets)
 | 
			
		|||
 | 
			
		||||
        // for system/default/external presets we should take an edited name
 | 
			
		||||
        if (preset.is_system || preset.is_default || preset.is_external) {
 | 
			
		||||
            SavePresetDialog save_dlg(preset.type);
 | 
			
		||||
            SavePresetDialog save_dlg(this, preset.type);
 | 
			
		||||
            if (save_dlg.ShowModal() != wxID_OK) {
 | 
			
		||||
                m_exit_action = Action::Discard;
 | 
			
		||||
                return false;
 | 
			
		||||
| 
						 | 
				
			
			@ -809,7 +809,7 @@ bool UnsavedChangesDialog::save(PresetCollection* dependent_presets)
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
        if (!types_for_save.empty()) {
 | 
			
		||||
            SavePresetDialog save_dlg(types_for_save);
 | 
			
		||||
            SavePresetDialog save_dlg(this, types_for_save);
 | 
			
		||||
            if (save_dlg.ShowModal() != wxID_OK) {
 | 
			
		||||
                m_exit_action = Action::Discard;
 | 
			
		||||
                return false;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue