mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 16:57:53 -06:00
Resize of the KBShortcutsDialog according to the display size
This commit is contained in:
parent
c7cdb2fd3e
commit
7929bda24a
2 changed files with 28 additions and 9 deletions
|
@ -9,11 +9,6 @@
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
|
||||||
enum {
|
|
||||||
DLG_WIDTH = 90,
|
|
||||||
DLG_HEIGHT = 60
|
|
||||||
};
|
|
||||||
|
|
||||||
KBShortcutsDialog::KBShortcutsDialog()
|
KBShortcutsDialog::KBShortcutsDialog()
|
||||||
: DPIDialog(NULL, wxID_ANY, wxString(SLIC3R_APP_NAME) + " - " + _(L("Keyboard Shortcuts")),
|
: DPIDialog(NULL, wxID_ANY, wxString(SLIC3R_APP_NAME) + " - " + _(L("Keyboard Shortcuts")),
|
||||||
wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
|
wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
|
||||||
|
@ -39,9 +34,7 @@ KBShortcutsDialog::KBShortcutsDialog()
|
||||||
|
|
||||||
fill_shortcuts();
|
fill_shortcuts();
|
||||||
|
|
||||||
const int em = em_unit();
|
panel = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, get_size());
|
||||||
const wxSize& size = wxSize(DLG_WIDTH * em, DLG_HEIGHT * em);
|
|
||||||
panel = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, size);
|
|
||||||
panel->SetScrollbars(1, 20, 1, 2);
|
panel->SetScrollbars(1, 20, 1, 2);
|
||||||
|
|
||||||
auto main_grid_sizer = new wxFlexGridSizer(2, 10, 10);
|
auto main_grid_sizer = new wxFlexGridSizer(2, 10, 10);
|
||||||
|
@ -216,7 +209,7 @@ void KBShortcutsDialog::on_dpi_changed(const wxRect &suggested_rect)
|
||||||
|
|
||||||
msw_buttons_rescale(this, em, { wxID_OK });
|
msw_buttons_rescale(this, em, { wxID_OK });
|
||||||
|
|
||||||
const wxSize& size = wxSize(DLG_WIDTH * em, DLG_HEIGHT * em);
|
wxSize size = get_size();
|
||||||
|
|
||||||
panel->SetMinSize(size);
|
panel->SetMinSize(size);
|
||||||
|
|
||||||
|
@ -231,5 +224,30 @@ void KBShortcutsDialog::onCloseDialog(wxEvent &)
|
||||||
this->EndModal(wxID_CLOSE);
|
this->EndModal(wxID_CLOSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxSize KBShortcutsDialog::get_size()
|
||||||
|
{
|
||||||
|
wxTopLevelWindow* window = Slic3r::GUI::find_toplevel_parent(this);
|
||||||
|
const int display_idx = wxDisplay::GetFromWindow(window);
|
||||||
|
wxRect display;
|
||||||
|
if (display_idx == wxNOT_FOUND) {
|
||||||
|
display = wxDisplay(0u).GetClientArea();
|
||||||
|
window->Move(display.GetTopLeft());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
display = wxDisplay(display_idx).GetClientArea();
|
||||||
|
}
|
||||||
|
|
||||||
|
const int em = em_unit();
|
||||||
|
wxSize dialog_size = wxSize(90 * em, 85 * em);
|
||||||
|
|
||||||
|
const int margin = 10 * em;
|
||||||
|
if (dialog_size.x > display.GetWidth())
|
||||||
|
dialog_size.x = display.GetWidth() - margin;
|
||||||
|
if (dialog_size.y > display.GetHeight())
|
||||||
|
dialog_size.y = display.GetHeight() - margin;
|
||||||
|
|
||||||
|
return dialog_size;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace GUI
|
} // namespace GUI
|
||||||
} // namespace Slic3r
|
} // namespace Slic3r
|
||||||
|
|
|
@ -39,6 +39,7 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void onCloseDialog(wxEvent &);
|
void onCloseDialog(wxEvent &);
|
||||||
|
wxSize get_size();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace GUI
|
} // namespace GUI
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue