mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 16:57:53 -06:00
Added msw_buttons_rescale() - Function for a scaling Dialog's buttons under MSW
This commit is contained in:
parent
3f978f6afe
commit
708037158e
17 changed files with 149 additions and 43 deletions
|
@ -18,6 +18,7 @@
|
|||
#include "MsgDialog.hpp"
|
||||
#include "../Utils/HexFile.hpp"
|
||||
#include "../Utils/Serial.hpp"
|
||||
#include "wxExtensions.hpp"
|
||||
|
||||
// wx includes need to come after asio because of the WinSock.h problem
|
||||
#include "FirmwareDialog.hpp"
|
||||
|
@ -118,6 +119,10 @@ struct FirmwareDialog::priv
|
|||
|
||||
wxTimer timer_pulse;
|
||||
|
||||
int min_width;
|
||||
int min_height;
|
||||
int min_height_expanded;
|
||||
|
||||
// Async modal dialog during flashing
|
||||
std::mutex mutex;
|
||||
int modal_response;
|
||||
|
@ -735,18 +740,10 @@ FirmwareDialog::FirmwareDialog(wxWindow *parent) :
|
|||
GUI::DPIDialog(parent, wxID_ANY, _(L("Firmware flasher")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER),
|
||||
p(new priv(this))
|
||||
{
|
||||
enum {
|
||||
DIALOG_MARGIN = 15,
|
||||
SPACING = 10,
|
||||
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;
|
||||
p->min_width = MIN_WIDTH * em;
|
||||
p->min_height = MIN_HEIGHT * em;
|
||||
p->min_height_expanded = MIN_HEIGHT_EXPANDED * em;
|
||||
|
||||
/* get current font from application,
|
||||
* because of wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT) function
|
||||
|
@ -825,10 +822,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(p->min_width, p->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>(p->min_width)), std::max(size.GetHeight(), static_cast<int>(p->min_height)));
|
||||
Layout();
|
||||
|
||||
SetEscapeId(wxID_CLOSE); // To close the dialog using "Esc" button
|
||||
|
@ -844,11 +841,11 @@ FirmwareDialog::FirmwareDialog(wxWindow *parent) :
|
|||
|
||||
p->spoiler->Bind(wxEVT_COLLAPSIBLEPANE_CHANGED, [=](wxCollapsiblePaneEvent &evt) {
|
||||
if (evt.GetCollapsed()) {
|
||||
this->SetMinSize(wxSize(min_width, min_height));
|
||||
this->SetMinSize(wxSize(p->min_width, p->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(p->min_width, p->min_height_expanded));
|
||||
}
|
||||
|
||||
this->Layout();
|
||||
|
@ -903,5 +900,25 @@ void FirmwareDialog::run(wxWindow *parent)
|
|||
dialog.ShowModal();
|
||||
}
|
||||
|
||||
void FirmwareDialog::on_dpi_changed(const wxRect &suggested_rect)
|
||||
{
|
||||
const int& em = em_unit();
|
||||
|
||||
msw_buttons_rescale(this, em, { p->btn_close->GetId(),
|
||||
p->btn_rescan->GetId(),
|
||||
p->btn_flash->GetId(),
|
||||
p->hex_picker->GetPickerCtrl()->GetId()
|
||||
});
|
||||
|
||||
p->min_width = MIN_WIDTH * em;
|
||||
p->min_height = MIN_HEIGHT * em;
|
||||
p->min_height_expanded = MIN_HEIGHT_EXPANDED * em;
|
||||
|
||||
const int min_height = p->spoiler->IsExpanded() ? p->min_height_expanded : p->min_height;
|
||||
SetMinSize(wxSize(p->min_width, min_height));
|
||||
Fit();
|
||||
|
||||
Refresh();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue