Merge branch 'master' of https://github.com/prusa3d/Slic3r into et_selection_rectangle
This commit is contained in:
commit
07d8fe6f11
@ -248,20 +248,21 @@ RawBytes Raster::save(Raster::Compression comp)
|
||||
{
|
||||
assert(m_impl);
|
||||
|
||||
std::uint8_t *ptr = nullptr; size_t s = 0;
|
||||
std::vector<std::uint8_t> data; size_t s = 0;
|
||||
|
||||
switch(comp) {
|
||||
case Compression::PNG: {
|
||||
|
||||
void *rawdata = tdefl_write_image_to_png_file_in_memory(
|
||||
m_impl->buffer().data(),
|
||||
int(resolution().width_px),
|
||||
int(resolution().height_px), 1, &s);
|
||||
|
||||
if(rawdata == nullptr) break;
|
||||
|
||||
ptr = static_cast<std::uint8_t*>(rawdata);
|
||||
|
||||
auto ptr = static_cast<std::uint8_t*>(rawdata);
|
||||
|
||||
data.reserve(s); std::copy(ptr, ptr + s, std::back_inserter(data));
|
||||
|
||||
MZ_FREE(rawdata);
|
||||
break;
|
||||
}
|
||||
case Compression::RAW: {
|
||||
@ -270,21 +271,19 @@ RawBytes Raster::save(Raster::Compression comp)
|
||||
std::to_string(m_impl->resolution().height_px) + " " + "255 ";
|
||||
|
||||
auto sz = m_impl->buffer().size()*sizeof(Impl::TBuffer::value_type);
|
||||
|
||||
s = sz + header.size();
|
||||
ptr = static_cast<std::uint8_t*>(MZ_MALLOC(s));
|
||||
|
||||
|
||||
data.reserve(s);
|
||||
|
||||
auto buff = reinterpret_cast<std::uint8_t*>(m_impl->buffer().data());
|
||||
std::copy(buff, buff+sz, ptr + header.size());
|
||||
std::copy(header.begin(), header.end(), std::back_inserter(data));
|
||||
std::copy(buff, buff+sz, std::back_inserter(data));
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return {ptr, s};
|
||||
}
|
||||
|
||||
void RawBytes::MinzDeleter::operator()(uint8_t *rawptr)
|
||||
{
|
||||
MZ_FREE(rawptr);
|
||||
return {std::move(data)};
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,34 +15,25 @@ class ExPolygon;
|
||||
// Raw byte buffer paired with its size. Suitable for compressed PNG data.
|
||||
class RawBytes {
|
||||
|
||||
class MinzDeleter {
|
||||
public:
|
||||
void operator()(std::uint8_t *rawptr);
|
||||
};
|
||||
|
||||
std::unique_ptr<std::uint8_t, MinzDeleter> m_buffer = nullptr;
|
||||
size_t m_size = 0;
|
||||
|
||||
std::vector<std::uint8_t> m_buffer;
|
||||
public:
|
||||
|
||||
RawBytes() = default;
|
||||
RawBytes(std::uint8_t *rawptr, size_t s): m_buffer(rawptr), m_size(s) {}
|
||||
|
||||
size_t size() const { return m_size; }
|
||||
const uint8_t * data() { return m_buffer.get(); }
|
||||
RawBytes(std::vector<std::uint8_t>&& data): m_buffer(std::move(data)) {}
|
||||
|
||||
size_t size() const { return m_buffer.size(); }
|
||||
const uint8_t * data() { return m_buffer.data(); }
|
||||
|
||||
// /////////////////////////////////////////////////////////////////////////
|
||||
// FIXME: the following is needed for MSVC2013 compatibility
|
||||
// /////////////////////////////////////////////////////////////////////////
|
||||
|
||||
RawBytes(const RawBytes&) = delete;
|
||||
RawBytes(RawBytes&& mv):
|
||||
m_buffer(std::move(mv.m_buffer)), m_size(mv.m_size) {}
|
||||
RawBytes(RawBytes&& mv) : m_buffer(std::move(mv.m_buffer)) {}
|
||||
|
||||
RawBytes& operator=(const RawBytes&) = delete;
|
||||
RawBytes& operator=(RawBytes&& mv) {
|
||||
m_buffer.swap(mv.m_buffer);
|
||||
m_size = mv.m_size;
|
||||
m_buffer = std::move(mv.m_buffer);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -846,6 +846,16 @@ public:
|
||||
if(!meshcache_valid) merged_mesh();
|
||||
return model_height;
|
||||
}
|
||||
|
||||
// Intended to be called after the generation is fully complete
|
||||
void clear_support_data() {
|
||||
merged_mesh(); // in case the mesh is not generated, it should be...
|
||||
m_heads.clear();
|
||||
m_pillars.clear();
|
||||
m_junctions.clear();
|
||||
m_bridges.clear();
|
||||
m_compact_bridges.clear();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@ -2285,6 +2295,7 @@ SLASupportTree::SLASupportTree(const std::vector<SupportPoint> &points,
|
||||
{
|
||||
m_impl->ground_level = emesh.ground_level() - cfg.object_elevation_mm;
|
||||
generate(points, emesh, cfg, ctl);
|
||||
m_impl->clear_support_data();
|
||||
}
|
||||
|
||||
SLASupportTree::SLASupportTree(const SLASupportTree &c):
|
||||
|
@ -436,6 +436,12 @@ SLAPrint::ApplyStatus SLAPrint::apply(const Model &model, const DynamicPrintConf
|
||||
if (new_objects)
|
||||
update_apply_status(false);
|
||||
}
|
||||
|
||||
if(m_objects.empty()) {
|
||||
m_printer.release();
|
||||
m_printer_input.clear();
|
||||
m_print_statistics.clear();
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
check_model_ids_equal(m_model, model);
|
||||
@ -669,7 +675,7 @@ void SLAPrint::process()
|
||||
// Slicing the model object. This method is oversimplified and needs to
|
||||
// be compared with the fff slicing algorithm for verification
|
||||
auto slice_model = [this, ilhs, ilh](SLAPrintObject& po) {
|
||||
TriangleMesh mesh = po.transformed_mesh();
|
||||
const TriangleMesh& mesh = po.transformed_mesh();
|
||||
|
||||
// We need to prepare the slice index...
|
||||
|
||||
@ -708,7 +714,7 @@ void SLAPrint::process()
|
||||
po.m_model_height_levels.emplace_back(it->slice_level());
|
||||
}
|
||||
|
||||
mesh.require_shared_vertices(); // TriangleMeshSlicer needs this
|
||||
// mesh.require_shared_vertices(); // TriangleMeshSlicer needs this
|
||||
TriangleMeshSlicer slicer(&mesh);
|
||||
|
||||
po.m_model_slices.clear();
|
||||
@ -1534,7 +1540,7 @@ SLAPrintObject::SLAPrintObject(SLAPrint *print, ModelObject *model_object):
|
||||
Inherited(print, model_object),
|
||||
m_stepmask(slaposCount, true),
|
||||
m_transformed_rmesh( [this](TriangleMesh& obj){
|
||||
obj = m_model_object->raw_mesh(); obj.transform(m_trafo);
|
||||
obj = m_model_object->raw_mesh(); obj.transform(m_trafo); obj.require_shared_vertices();
|
||||
})
|
||||
{
|
||||
}
|
||||
@ -1823,7 +1829,7 @@ void SLAPrint::StatusReporter::operator()(
|
||||
SLAPrint &p, double st, const std::string &msg, unsigned flags)
|
||||
{
|
||||
m_st = st;
|
||||
BOOST_LOG_TRIVIAL(info) << st << "% " << msg;
|
||||
BOOST_LOG_TRIVIAL(info) << st << "% " << msg << log_memory_info();
|
||||
p.set_status(int(std::round(st)), msg, flags);
|
||||
}
|
||||
|
||||
|
@ -133,13 +133,15 @@ void AboutDialog::on_dpi_changed(const wxRect &suggested_rect)
|
||||
|
||||
const int& em = em_unit();
|
||||
|
||||
msw_buttons_rescale(this, em, { wxID_CLOSE });
|
||||
|
||||
m_html->SetMinSize(wxSize(-1, 16 * em));
|
||||
m_html->Refresh();
|
||||
|
||||
const wxSize& size = wxSize(65 * em, 30 * em);
|
||||
|
||||
SetMinSize(size);
|
||||
SetSize(size);
|
||||
Fit();
|
||||
|
||||
Refresh();
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "libslic3r/Utils.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "wxExtensions.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
@ -144,10 +145,12 @@ void ConfigSnapshotDialog::on_dpi_changed(const wxRect &suggested_rect)
|
||||
html->Refresh();
|
||||
|
||||
const int& em = em_unit();
|
||||
const wxSize& size = wxSize(45 * em, 40 * em);
|
||||
|
||||
msw_buttons_rescale(this, em, { wxID_CLOSE});
|
||||
|
||||
const wxSize& size = wxSize(45 * em, 40 * em);
|
||||
SetMinSize(size);
|
||||
SetSize(size);
|
||||
Fit();
|
||||
|
||||
Refresh();
|
||||
}
|
||||
|
@ -194,6 +194,9 @@ PrinterPicker::PrinterPicker(wxWindow *parent, const VendorProfile &vendor, wxSt
|
||||
title_sizer->Add(sel_all_std, 0, wxRIGHT, BTN_SPACING);
|
||||
title_sizer->Add(sel_all, 0, wxRIGHT, BTN_SPACING);
|
||||
title_sizer->Add(sel_none);
|
||||
|
||||
// fill button indexes used later for buttons rescaling
|
||||
m_button_indexes = { sel_all_std->GetId(), sel_all->GetId(), sel_none->GetId() };
|
||||
}
|
||||
|
||||
sizer->Add(title_sizer, 0, wxEXPAND | wxBOTTOM, BTN_SPACING);
|
||||
@ -1057,8 +1060,8 @@ ConfigWizard::ConfigWizard(wxWindow *parent, RunReason reason)
|
||||
topsizer->AddSpacer(INDEX_MARGIN);
|
||||
topsizer->Add(p->hscroll, 1, wxEXPAND);
|
||||
|
||||
auto *btn_sel_all = new wxButton(this, wxID_ANY, _(L("Select all standard printers")));
|
||||
p->btnsizer->Add(btn_sel_all);
|
||||
p->btn_sel_all = new wxButton(this, wxID_ANY, _(L("Select all standard printers")));
|
||||
p->btnsizer->Add(p->btn_sel_all);
|
||||
|
||||
p->btn_prev = new wxButton(this, wxID_ANY, _(L("< &Back")));
|
||||
p->btn_next = new wxButton(this, wxID_ANY, _(L("&Next >")));
|
||||
@ -1130,7 +1133,7 @@ ConfigWizard::ConfigWizard(wxWindow *parent, RunReason reason)
|
||||
p->btn_finish->Bind(wxEVT_BUTTON, [this](const wxCommandEvent &) { this->EndModal(wxID_OK); });
|
||||
p->btn_finish->Hide();
|
||||
|
||||
btn_sel_all->Bind(wxEVT_BUTTON, [this](const wxCommandEvent &) {
|
||||
p->btn_sel_all->Bind(wxEVT_BUTTON, [this](const wxCommandEvent &) {
|
||||
p->page_fff->select_all(true, false);
|
||||
p->page_msla->select_all(true, false);
|
||||
p->index->go_to(p->page_update);
|
||||
@ -1179,6 +1182,20 @@ const wxString& ConfigWizard::name(const bool from_menu/* = false*/)
|
||||
void ConfigWizard::on_dpi_changed(const wxRect &suggested_rect)
|
||||
{
|
||||
p->index->msw_rescale();
|
||||
|
||||
const int& em = em_unit();
|
||||
|
||||
msw_buttons_rescale(this, em, { wxID_APPLY,
|
||||
wxID_CANCEL,
|
||||
p->btn_sel_all->GetId(),
|
||||
p->btn_next->GetId(),
|
||||
p->btn_prev->GetId() });
|
||||
|
||||
for (auto printer_picker: p->page_fff->printer_pickers)
|
||||
msw_buttons_rescale(this, em, printer_picker->get_button_indexes());
|
||||
|
||||
// FIXME VK SetSize(???)
|
||||
|
||||
Refresh();
|
||||
}
|
||||
|
||||
|
@ -69,8 +69,11 @@ struct PrinterPicker: wxPanel
|
||||
void on_checkbox(const Checkbox *cbox, bool checked);
|
||||
|
||||
int get_width() const { return width; }
|
||||
const std::vector<int>& get_button_indexes() { return m_button_indexes; }
|
||||
private:
|
||||
int width;
|
||||
|
||||
std::vector<int> m_button_indexes;
|
||||
};
|
||||
|
||||
struct ConfigWizardPage: wxPanel
|
||||
@ -267,6 +270,7 @@ struct ConfigWizard::priv
|
||||
wxBoxSizer *btnsizer = nullptr;
|
||||
ConfigWizardPage *page_current = nullptr;
|
||||
ConfigWizardIndex *index = nullptr;
|
||||
wxButton *btn_sel_all = nullptr;
|
||||
wxButton *btn_prev = nullptr;
|
||||
wxButton *btn_next = nullptr;
|
||||
wxButton *btn_finish = nullptr;
|
||||
|
@ -379,8 +379,8 @@ void TextCtrl::change_field_value(wxEvent& event)
|
||||
|
||||
void CheckBox::BUILD() {
|
||||
auto size = wxSize(wxDefaultSize);
|
||||
if (m_opt.height >= 0) size.SetHeight(m_opt.height);
|
||||
if (m_opt.width >= 0) size.SetWidth(m_opt.width);
|
||||
if (m_opt.height >= 0) size.SetHeight(m_opt.height*m_em_unit);
|
||||
if (m_opt.width >= 0) size.SetWidth(m_opt.width*m_em_unit);
|
||||
|
||||
bool check_value = m_opt.type == coBool ?
|
||||
m_opt.default_value->getBool() : m_opt.type == coBools ?
|
||||
@ -413,6 +413,14 @@ boost::any& CheckBox::get_value()
|
||||
return m_value;
|
||||
}
|
||||
|
||||
void CheckBox::msw_rescale()
|
||||
{
|
||||
Field::msw_rescale();
|
||||
|
||||
wxCheckBox* field = dynamic_cast<wxCheckBox*>(window);
|
||||
field->SetMinSize(wxSize(-1, int(1.5f*field->GetFont().GetPixelSize().y +0.5f)));
|
||||
}
|
||||
|
||||
int undef_spin_val = -9999; //! Probably, It's not necessary
|
||||
|
||||
void SpinCtrl::BUILD() {
|
||||
@ -849,9 +857,11 @@ void Choice::msw_rescale()
|
||||
*/
|
||||
field->Clear();
|
||||
wxSize size(wxDefaultSize);
|
||||
if (m_opt.height >= 0) size.SetHeight(m_opt.height * m_em_unit);
|
||||
size.SetWidth((m_opt.width > 0 ? m_opt.width : m_width) * m_em_unit);
|
||||
|
||||
|
||||
// Set rescaled min height to correct layout
|
||||
field->SetMinSize(wxSize(-1, int(1.5f*field->GetFont().GetPixelSize().y + 0.5f)));
|
||||
// Set rescaled size
|
||||
field->SetSize(size);
|
||||
|
||||
size_t idx, counter = idx = 0;
|
||||
|
@ -319,6 +319,8 @@ public:
|
||||
}
|
||||
boost::any& get_value() override;
|
||||
|
||||
void msw_rescale() override;
|
||||
|
||||
void enable() override { dynamic_cast<wxCheckBox*>(window)->Enable(); }
|
||||
void disable() override { dynamic_cast<wxCheckBox*>(window)->Disable(); }
|
||||
wxWindow* getWindow() override { return window; }
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,6 +12,14 @@ namespace Slic3r {
|
||||
|
||||
class FirmwareDialog: public GUI::DPIDialog
|
||||
{
|
||||
enum {
|
||||
DIALOG_MARGIN = 15,
|
||||
SPACING = 10,
|
||||
MIN_WIDTH = 50,
|
||||
MIN_HEIGHT = /*18*/25,
|
||||
MIN_HEIGHT_EXPANDED = 40,
|
||||
};
|
||||
|
||||
public:
|
||||
FirmwareDialog(wxWindow *parent);
|
||||
FirmwareDialog(FirmwareDialog &&) = delete;
|
||||
@ -23,7 +31,7 @@ public:
|
||||
static void run(wxWindow *parent);
|
||||
|
||||
protected:
|
||||
void on_dpi_changed(const wxRect &suggested_rect) override{;}
|
||||
void on_dpi_changed(const wxRect &suggested_rect) override;
|
||||
private:
|
||||
struct priv;
|
||||
std::unique_ptr<priv> p;
|
||||
|
@ -196,11 +196,14 @@ void KBShortcutsDialog::on_dpi_changed(const wxRect &suggested_rect)
|
||||
for (wxStaticBitmap* bmp : m_head_bitmaps)
|
||||
bmp->SetBitmap(m_logo_bmp.bmp());
|
||||
|
||||
const int& em = em_unit();
|
||||
const int em = em_unit();
|
||||
|
||||
msw_buttons_rescale(this, em, { wxID_OK });
|
||||
|
||||
const wxSize& size = wxSize(85 * em, 75 * em);
|
||||
|
||||
SetMinSize(size);
|
||||
SetSize(size);
|
||||
Fit();
|
||||
|
||||
Refresh();
|
||||
}
|
||||
|
@ -516,17 +516,19 @@ void ConfigOptionsGroup::msw_rescale()
|
||||
{
|
||||
auto label = dynamic_cast<wxStaticText*>(label_item->GetWindow());
|
||||
if (label != nullptr) {
|
||||
label->SetMinSize(wxSize(label_width*em, -1));
|
||||
const int label_height = int(1.5f*label->GetFont().GetPixelSize().y + 0.5f);
|
||||
label->SetMinSize(wxSize(label_width*em, /*-1*/label_height));
|
||||
}
|
||||
}
|
||||
else if (label_item->IsSizer()) // case when we nave near_label_widget
|
||||
else if (label_item->IsSizer()) // case when we have near_label_widget
|
||||
{
|
||||
const wxSizerItem* l_item = label_item->GetSizer()->GetItem(1);
|
||||
if (l_item->IsWindow())
|
||||
{
|
||||
auto label = dynamic_cast<wxStaticText*>(l_item->GetWindow());
|
||||
if (label != nullptr) {
|
||||
label->SetMinSize(wxSize(label_width*em, -1));
|
||||
const int label_height = int(1.5f*label->GetFont().GetPixelSize().y + 0.5f);
|
||||
label->SetMinSize(wxSize(label_width*em, /*-1*/label_height));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ namespace GUI {
|
||||
|
||||
PreferencesDialog::PreferencesDialog(wxWindow* parent) :
|
||||
DPIDialog(parent, wxID_ANY, _(L("Preferences")), wxDefaultPosition,
|
||||
wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
|
||||
wxDefaultSize, wxDEFAULT_DIALOG_STYLE)
|
||||
{
|
||||
build();
|
||||
}
|
||||
@ -146,11 +146,14 @@ void PreferencesDialog::on_dpi_changed(const wxRect &suggested_rect)
|
||||
{
|
||||
m_optgroup->msw_rescale();
|
||||
|
||||
const int& em = em_unit();
|
||||
const wxSize& size = wxSize(50 * em, 29 * em);
|
||||
const int em = em_unit();
|
||||
|
||||
msw_buttons_rescale(this, em, { wxID_OK, wxID_CANCEL });
|
||||
|
||||
const wxSize& size = wxSize(47 * em, 28 * em);
|
||||
|
||||
SetMinSize(size);
|
||||
SetSize(size);
|
||||
Fit();
|
||||
|
||||
Refresh();
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "MsgDialog.hpp"
|
||||
#include "I18N.hpp"
|
||||
#include "../Utils/PrintHost.hpp"
|
||||
#include "wxExtensions.hpp"
|
||||
|
||||
namespace fs = boost::filesystem;
|
||||
|
||||
@ -136,8 +137,6 @@ PrintHostQueueDialog::PrintHostQueueDialog(wxWindow *parent)
|
||||
, on_error_evt(this, EVT_PRINTHOST_ERROR, &PrintHostQueueDialog::on_error, this)
|
||||
, on_cancel_evt(this, EVT_PRINTHOST_CANCEL, &PrintHostQueueDialog::on_cancel, this)
|
||||
{
|
||||
enum { HEIGHT = 60, WIDTH = 30, SPACING = 5 };
|
||||
|
||||
const auto em = GetTextExtent("m").x;
|
||||
|
||||
SetSize(wxSize(HEIGHT * em, WIDTH * em));
|
||||
@ -202,6 +201,18 @@ void PrintHostQueueDialog::append_job(const PrintHostJob &job)
|
||||
job_list->AppendItem(fields, static_cast<wxUIntPtr>(ST_NEW));
|
||||
}
|
||||
|
||||
void PrintHostQueueDialog::on_dpi_changed(const wxRect &suggested_rect)
|
||||
{
|
||||
const int& em = em_unit();
|
||||
|
||||
msw_buttons_rescale(this, em, { wxID_DELETE, wxID_CANCEL, btn_error->GetId() });
|
||||
|
||||
SetMinSize(wxSize(HEIGHT * em, WIDTH * em));
|
||||
|
||||
Fit();
|
||||
Refresh();
|
||||
}
|
||||
|
||||
PrintHostQueueDialog::JobState PrintHostQueueDialog::get_state(int idx)
|
||||
{
|
||||
wxCHECK_MSG(idx >= 0 && idx < job_list->GetItemCount(), ST_ERROR, "Out of bounds access to job list");
|
||||
|
@ -64,7 +64,7 @@ public:
|
||||
void append_job(const PrintHostJob &job);
|
||||
|
||||
protected:
|
||||
void on_dpi_changed(const wxRect &suggested_rect) override { Refresh(); }
|
||||
void on_dpi_changed(const wxRect &suggested_rect) override;
|
||||
|
||||
private:
|
||||
enum Column {
|
||||
@ -85,6 +85,8 @@ private:
|
||||
ST_COMPLETED,
|
||||
};
|
||||
|
||||
enum { HEIGHT = 60, WIDTH = 30, SPACING = 5 };
|
||||
|
||||
wxButton *btn_cancel;
|
||||
wxButton *btn_error;
|
||||
wxDataViewListCtrl *job_list;
|
||||
|
@ -117,9 +117,10 @@ SysInfoDialog::SysInfoDialog()
|
||||
}
|
||||
|
||||
wxStdDialogButtonSizer* buttons = this->CreateStdDialogButtonSizer(wxOK);
|
||||
auto btn_copy_to_clipboard = new wxButton(this, wxID_ANY, "Copy to Clipboard", wxDefaultPosition, wxDefaultSize);
|
||||
buttons->Insert(0, btn_copy_to_clipboard, 0, wxLEFT, 5);
|
||||
btn_copy_to_clipboard->Bind(wxEVT_BUTTON, &SysInfoDialog::onCopyToClipboard, this);
|
||||
m_btn_copy_to_clipboard = new wxButton(this, wxID_ANY, "Copy to Clipboard", wxDefaultPosition, wxDefaultSize);
|
||||
|
||||
buttons->Insert(0, m_btn_copy_to_clipboard, 0, wxLEFT, 5);
|
||||
m_btn_copy_to_clipboard->Bind(wxEVT_BUTTON, &SysInfoDialog::onCopyToClipboard, this);
|
||||
|
||||
this->SetEscapeId(wxID_OK);
|
||||
this->Bind(wxEVT_BUTTON, &SysInfoDialog::onCloseDialog, this, wxID_OK);
|
||||
@ -146,6 +147,8 @@ void SysInfoDialog::on_dpi_changed(const wxRect &suggested_rect)
|
||||
|
||||
const int& em = em_unit();
|
||||
|
||||
msw_buttons_rescale(this, em, { wxID_OK, m_btn_copy_to_clipboard->GetId() });
|
||||
|
||||
m_opengl_info_html->SetMinSize(wxSize(-1, 16 * em));
|
||||
m_opengl_info_html->SetFonts(font.GetFaceName(), font.GetFaceName(), font_size);
|
||||
m_opengl_info_html->Refresh();
|
||||
@ -153,7 +156,7 @@ void SysInfoDialog::on_dpi_changed(const wxRect &suggested_rect)
|
||||
const wxSize& size = wxSize(65 * em, 55 * em);
|
||||
|
||||
SetMinSize(size);
|
||||
SetSize(size);
|
||||
Fit();
|
||||
|
||||
Refresh();
|
||||
}
|
||||
|
@ -17,6 +17,8 @@ class SysInfoDialog : public DPIDialog
|
||||
wxHtmlWindow* m_opengl_info_html;
|
||||
wxHtmlWindow* m_html;
|
||||
|
||||
wxButton* m_btn_copy_to_clipboard;
|
||||
|
||||
public:
|
||||
SysInfoDialog();
|
||||
|
||||
|
@ -267,6 +267,22 @@ void wxDataViewTreeCtrlComboPopup::OnDataViewTreeCtrlSelection(wxCommandEvent& e
|
||||
cmb->SetText(selected);
|
||||
}
|
||||
|
||||
/* Function for rescale of buttons in Dialog under MSW if dpi is changed.
|
||||
* btn_ids - vector of buttons identifiers
|
||||
*/
|
||||
void msw_buttons_rescale(wxDialog* dlg, const int em_unit, const std::vector<int>& btn_ids)
|
||||
{
|
||||
const wxSize& btn_size = wxSize(-1, int(2.5f * em_unit + 0.5f));
|
||||
|
||||
for (int btn_id : btn_ids) {
|
||||
// There is a case [FirmwareDialog], when we have wxControl instead of wxButton
|
||||
// so let casting everything to the wxControl
|
||||
wxControl* btn = static_cast<wxControl*>(dlg->FindWindowById(btn_id, dlg));
|
||||
if (btn)
|
||||
btn->SetMinSize(btn_size);
|
||||
}
|
||||
}
|
||||
|
||||
/* Function for getting of em_unit value from correct parent.
|
||||
* In most of cases it is m_em_unit value from GUI_App,
|
||||
* but for DPIDialogs it's its own value.
|
||||
|
@ -31,7 +31,9 @@ wxMenuItem* append_submenu(wxMenu* menu, wxMenu* sub_menu, int id, const wxStrin
|
||||
wxMenuItem* append_menu_radio_item(wxMenu* menu, int id, const wxString& string, const wxString& description,
|
||||
std::function<void(wxCommandEvent& event)> cb, wxEvtHandler* event_handler);
|
||||
|
||||
int em_unit(wxWindow* win);
|
||||
class wxDialog;
|
||||
void msw_buttons_rescale(wxDialog* dlg, const int em_unit, const std::vector<int>& btn_ids);
|
||||
int em_unit(wxWindow* win);
|
||||
|
||||
wxBitmap create_scaled_bitmap(wxWindow *win, const std::string& bmp_name, const int px_cnt = 16, const bool is_horizontal = false);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user