Application Scaling for MSW: Next big step
- Added rescale() function for the most of controls - Created PrusaBitmap and PrusaButton classes like a wrap to wxBitmap and wxButton accordingly
This commit is contained in:
parent
a74c608c7a
commit
f7ddddcff5
@ -131,7 +131,7 @@ void PrintConfigDef::init_fff_params()
|
||||
"as [layer_num] and [layer_z].");
|
||||
def->multiline = true;
|
||||
def->full_width = true;
|
||||
def->height = 50;
|
||||
def->height = 5;
|
||||
def->mode = comExpert;
|
||||
def->default_value = new ConfigOptionString("");
|
||||
|
||||
@ -140,7 +140,7 @@ void PrintConfigDef::init_fff_params()
|
||||
def->tooltip = L("This code is inserted between objects when using sequential printing. By default extruder and bed temperature are reset using non-wait command; however if M104, M109, M140 or M190 are detected in this custom code, Slic3r will not add temperature commands. Note that you can use placeholder variables for all Slic3r settings, so you can put a \"M109 S[first_layer_temperature]\" command wherever you want.");
|
||||
def->multiline = true;
|
||||
def->full_width = true;
|
||||
def->height = 120;
|
||||
def->height = 12;
|
||||
def->mode = comExpert;
|
||||
def->default_value = new ConfigOptionString("");
|
||||
|
||||
@ -360,7 +360,7 @@ void PrintConfigDef::init_fff_params()
|
||||
"Note that you can use placeholder variables for all Slic3r settings.");
|
||||
def->multiline = true;
|
||||
def->full_width = true;
|
||||
def->height = 120;
|
||||
def->height = 12;
|
||||
def->mode = comExpert;
|
||||
def->default_value = new ConfigOptionString("M104 S0 ; turn off temperature\nG28 X0 ; home X axis\nM84 ; disable motors\n");
|
||||
|
||||
@ -539,7 +539,7 @@ void PrintConfigDef::init_fff_params()
|
||||
def->tooltip = L("If layer print time is estimated below this number of seconds, fan will be enabled "
|
||||
"and its speed will be calculated by interpolating the minimum and maximum speeds.");
|
||||
def->sidetext = L("approximate seconds");
|
||||
def->width = 60;
|
||||
def->width = 6;
|
||||
def->min = 0;
|
||||
def->max = 1000;
|
||||
def->mode = comExpert;
|
||||
@ -556,7 +556,7 @@ void PrintConfigDef::init_fff_params()
|
||||
def->tooltip = L("You can put your notes regarding the filament here.");
|
||||
def->multiline = true;
|
||||
def->full_width = true;
|
||||
def->height = 130;
|
||||
def->height = 13;
|
||||
def->mode = comAdvanced;
|
||||
def->default_value = new ConfigOptionStrings { "" };
|
||||
|
||||
@ -1007,7 +1007,7 @@ void PrintConfigDef::init_fff_params()
|
||||
def->label = L("Inherits profile");
|
||||
def->tooltip = L("Name of the profile, from which this profile inherits.");
|
||||
def->full_width = true;
|
||||
def->height = 50;
|
||||
def->height = 5;
|
||||
def->default_value = new ConfigOptionString();
|
||||
def->cli = ConfigOptionDef::nocli;
|
||||
|
||||
@ -1034,7 +1034,7 @@ void PrintConfigDef::init_fff_params()
|
||||
def->cli = "after-layer-gcode|layer-gcode";
|
||||
def->multiline = true;
|
||||
def->full_width = true;
|
||||
def->height = 50;
|
||||
def->height = 5;
|
||||
def->mode = comExpert;
|
||||
def->default_value = new ConfigOptionString("");
|
||||
|
||||
@ -1053,7 +1053,7 @@ void PrintConfigDef::init_fff_params()
|
||||
def->mode = comExpert;
|
||||
def->default_value = new ConfigOptionBool(true);
|
||||
|
||||
const int machine_limits_opt_width = 70;
|
||||
const int machine_limits_opt_width = 7;
|
||||
{
|
||||
struct AxisDefault {
|
||||
std::string name;
|
||||
@ -1252,7 +1252,7 @@ void PrintConfigDef::init_fff_params()
|
||||
"header comments.");
|
||||
def->multiline = true;
|
||||
def->full_width = true;
|
||||
def->height = 130;
|
||||
def->height = 13;
|
||||
def->mode = comAdvanced;
|
||||
def->default_value = new ConfigOptionString("");
|
||||
|
||||
@ -1387,7 +1387,7 @@ void PrintConfigDef::init_fff_params()
|
||||
def->gui_flags = "serialized";
|
||||
def->multiline = true;
|
||||
def->full_width = true;
|
||||
def->height = 60;
|
||||
def->height = 6;
|
||||
def->mode = comExpert;
|
||||
def->default_value = new ConfigOptionStrings();
|
||||
|
||||
@ -1402,7 +1402,7 @@ void PrintConfigDef::init_fff_params()
|
||||
def->tooltip = L("You can put your notes regarding the printer here.");
|
||||
def->multiline = true;
|
||||
def->full_width = true;
|
||||
def->height = 130;
|
||||
def->height = 13;
|
||||
def->mode = comAdvanced;
|
||||
def->default_value = new ConfigOptionString("");
|
||||
|
||||
@ -1589,7 +1589,7 @@ void PrintConfigDef::init_fff_params()
|
||||
def->label = "";
|
||||
def->full_label = L("Serial port");
|
||||
def->tooltip = L("USB/serial port for printer connection.");
|
||||
def->width = 200;
|
||||
def->width = 20;
|
||||
def->default_value = new ConfigOptionString("");
|
||||
|
||||
def = this->add("serial_speed", coInt);
|
||||
@ -1635,7 +1635,7 @@ void PrintConfigDef::init_fff_params()
|
||||
def->tooltip = L("If layer print time is estimated below this number of seconds, print moves "
|
||||
"speed will be scaled down to extend duration to this value.");
|
||||
def->sidetext = L("approximate seconds");
|
||||
def->width = 60;
|
||||
def->width = 6;
|
||||
def->min = 0;
|
||||
def->max = 1000;
|
||||
def->mode = comExpert;
|
||||
@ -1742,7 +1742,7 @@ void PrintConfigDef::init_fff_params()
|
||||
"a \"M109 S[first_layer_temperature]\" command wherever you want.");
|
||||
def->multiline = true;
|
||||
def->full_width = true;
|
||||
def->height = 120;
|
||||
def->height = 12;
|
||||
def->mode = comExpert;
|
||||
def->default_value = new ConfigOptionString("G28 ; home all axes\nG1 Z5 F5000 ; lift nozzle\n");
|
||||
|
||||
@ -1758,7 +1758,7 @@ void PrintConfigDef::init_fff_params()
|
||||
"in extruder order.");
|
||||
def->multiline = true;
|
||||
def->full_width = true;
|
||||
def->height = 120;
|
||||
def->height = 12;
|
||||
def->mode = comExpert;
|
||||
def->default_value = new ConfigOptionStrings { "; Filament gcode\n" };
|
||||
|
||||
@ -2008,7 +2008,7 @@ void PrintConfigDef::init_fff_params()
|
||||
"as [previous_extruder] and [next_extruder].");
|
||||
def->multiline = true;
|
||||
def->full_width = true;
|
||||
def->height = 50;
|
||||
def->height = 5;
|
||||
def->mode = comExpert;
|
||||
def->default_value = new ConfigOptionString("");
|
||||
|
||||
@ -2330,7 +2330,7 @@ void PrintConfigDef::init_sla_params()
|
||||
def->tooltip = L("You can put your notes regarding the SLA print material here.");
|
||||
def->multiline = true;
|
||||
def->full_width = true;
|
||||
def->height = 130;
|
||||
def->height = 13;
|
||||
def->mode = comAdvanced;
|
||||
def->default_value = new ConfigOptionString("");
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "GUI.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
#include "I18N.hpp"
|
||||
#include "wxExtensions.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
@ -23,7 +24,7 @@ ButtonsDescription::ButtonsDescription(wxWindow* parent, t_icon_descriptions* ic
|
||||
// Icon description
|
||||
for (auto pair : *m_icon_descriptions)
|
||||
{
|
||||
auto icon = new wxStaticBitmap(this, wxID_ANY, *pair.first);
|
||||
auto icon = new wxStaticBitmap(this, wxID_ANY, /***/pair.first->bmp());
|
||||
grid_sizer->Add(icon, -1, wxALIGN_CENTRE_VERTICAL);
|
||||
|
||||
std::istringstream f(pair.second);
|
||||
|
@ -4,10 +4,12 @@
|
||||
#include <wx/dialog.h>
|
||||
#include <vector>
|
||||
|
||||
class PrusaBitmap;
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
using t_icon_descriptions = std::vector<std::pair<wxBitmap*, std::string>>;
|
||||
using t_icon_descriptions = std::vector<std::pair</*wxBitmap*/PrusaBitmap*, std::string>>;
|
||||
|
||||
class ButtonsDescription : public wxDialog
|
||||
{
|
||||
|
@ -33,22 +33,21 @@ wxString double_to_string(double const value, const int max_precision /*= 4*/)
|
||||
void Field::PostInitialize()
|
||||
{
|
||||
auto color = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
|
||||
m_Undo_btn = new MyButton(m_parent, wxID_ANY, "", wxDefaultPosition,wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER);
|
||||
m_Undo_to_sys_btn = new MyButton(m_parent, wxID_ANY, "", wxDefaultPosition,wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER);
|
||||
if (wxMSW) {
|
||||
m_Undo_btn->SetBackgroundColour(color);
|
||||
m_Undo_btn->SetBackgroundStyle(wxBG_STYLE_PAINT);
|
||||
m_Undo_to_sys_btn->SetBackgroundColour(color);
|
||||
m_Undo_to_sys_btn->SetBackgroundStyle(wxBG_STYLE_PAINT);
|
||||
}
|
||||
m_Undo_btn = new RevertButton(m_parent, "bullet_white.png");//(m_parent, wxID_ANY, "", wxDefaultPosition,wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER);
|
||||
m_Undo_to_sys_btn = new RevertButton(m_parent, "bullet_white.png");//(m_parent, wxID_ANY, "", wxDefaultPosition,wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER);
|
||||
// if (wxMSW) {
|
||||
// m_Undo_btn->SetBackgroundColour(color);
|
||||
// m_Undo_btn->SetBackgroundStyle(wxBG_STYLE_PAINT);
|
||||
// m_Undo_to_sys_btn->SetBackgroundColour(color);
|
||||
// m_Undo_to_sys_btn->SetBackgroundStyle(wxBG_STYLE_PAINT);
|
||||
// }
|
||||
m_Undo_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent) { on_back_to_initial_value(); }));
|
||||
m_Undo_to_sys_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent) { on_back_to_sys_value(); }));
|
||||
|
||||
//set default bitmap
|
||||
wxBitmap bmp;
|
||||
bmp.LoadFile(from_u8(var("bullet_white.png")), wxBITMAP_TYPE_PNG);
|
||||
set_undo_bitmap(&bmp);
|
||||
set_undo_to_sys_bitmap(&bmp);
|
||||
// wxBitmap bmp = create_scaled_bitmap(m_parent, "bullet_white.png" );
|
||||
// set_undo_bitmap(&bmp);
|
||||
// set_undo_to_sys_bitmap(&bmp);
|
||||
|
||||
switch (m_opt.type)
|
||||
{
|
||||
@ -213,8 +212,8 @@ bool is_defined_input_value(wxWindow* win, const ConfigOptionType& type)
|
||||
|
||||
void TextCtrl::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*wxGetApp().em_unit());
|
||||
if (m_opt.width >= 0) size.SetWidth(m_opt.width*wxGetApp().em_unit());
|
||||
|
||||
wxString text_value = wxString("");
|
||||
|
||||
@ -358,6 +357,21 @@ boost::any& TextCtrl::get_value()
|
||||
return m_value;
|
||||
}
|
||||
|
||||
void TextCtrl::rescale()
|
||||
{
|
||||
Field::rescale();
|
||||
auto size = wxSize(wxDefaultSize);
|
||||
if (m_opt.height >= 0) size.SetHeight(m_opt.height*wxGetApp().em_unit());
|
||||
if (m_opt.width >= 0) size.SetWidth(m_opt.width*wxGetApp().em_unit());
|
||||
|
||||
if (size != wxDefaultSize)
|
||||
{
|
||||
wxTextCtrl* field = dynamic_cast<wxTextCtrl*>(window);
|
||||
field->SetMinSize(size);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void TextCtrl::enable() { dynamic_cast<wxTextCtrl*>(window)->Enable(); dynamic_cast<wxTextCtrl*>(window)->SetEditable(true); }
|
||||
void TextCtrl::disable() { dynamic_cast<wxTextCtrl*>(window)->Disable(); dynamic_cast<wxTextCtrl*>(window)->SetEditable(false); }
|
||||
|
||||
@ -380,7 +394,8 @@ void CheckBox::BUILD() {
|
||||
static_cast<const ConfigOptionBools*>(m_opt.default_value)->get_at(m_opt_idx) :
|
||||
false;
|
||||
|
||||
auto temp = new wxCheckBox(m_parent, wxID_ANY, wxString(""), wxDefaultPosition, size);
|
||||
// Set Label as a string of at least one space simbol to correct system scaling of a CheckBox
|
||||
auto temp = new wxCheckBox(m_parent, wxID_ANY, wxString(" "), wxDefaultPosition, size);
|
||||
temp->SetFont(Slic3r::GUI::wxGetApp().normal_font());
|
||||
temp->SetBackgroundStyle(wxBG_STYLE_PAINT);
|
||||
temp->SetValue(check_value);
|
||||
@ -505,10 +520,18 @@ void SpinCtrl::propagate_value()
|
||||
on_change_field();
|
||||
}
|
||||
|
||||
void SpinCtrl::rescale()
|
||||
{
|
||||
Field::rescale();
|
||||
|
||||
wxSpinCtrl* field = dynamic_cast<wxSpinCtrl*>(window);
|
||||
field->SetMinSize(wxSize(-1, int(1.9f*field->GetFont().GetPixelSize().y)));
|
||||
}
|
||||
|
||||
void Choice::BUILD() {
|
||||
wxSize size(15 * wxGetApp().em_unit(), -1);
|
||||
if (m_opt.height >= 0) size.SetHeight(m_opt.height);
|
||||
if (m_opt.width >= 0) size.SetWidth(m_opt.width);
|
||||
wxSize size(m_width * wxGetApp().em_unit(), -1);
|
||||
if (m_opt.height >= 0) size.SetHeight(m_opt.height*wxGetApp().em_unit());
|
||||
if (m_opt.width >= 0) size.SetWidth(m_opt.width*wxGetApp().em_unit());
|
||||
|
||||
wxBitmapComboBox* temp;
|
||||
if (!m_opt.gui_type.empty() && m_opt.gui_type.compare("select_open") != 0) {
|
||||
@ -817,6 +840,48 @@ boost::any& Choice::get_value()
|
||||
return m_value;
|
||||
}
|
||||
|
||||
void Choice::rescale()
|
||||
{
|
||||
Field::rescale();
|
||||
|
||||
wxBitmapComboBox* field = dynamic_cast<wxBitmapComboBox*>(window);
|
||||
|
||||
const wxString selection = field->GetStringSelection();
|
||||
|
||||
/* To correct scaling (set new controll size) of a wxBitmapCombobox
|
||||
* we need to refill control with new bitmaps. So, in our case :
|
||||
* 1. clear conrol
|
||||
* 2. add content
|
||||
* 3. add scaled "empty" bitmap to the at least one item
|
||||
*/
|
||||
field->Clear();
|
||||
wxSize size(wxDefaultSize);
|
||||
if (m_opt.height >= 0) size.SetHeight(m_opt.height * wxGetApp().em_unit());
|
||||
size.SetWidth((m_opt.width > 0 ? m_opt.width : m_width) * wxGetApp().em_unit());
|
||||
|
||||
field->SetSize(size);
|
||||
|
||||
size_t idx, counter = idx = 0;
|
||||
if (m_opt.enum_labels.empty() && m_opt.enum_values.empty()) {}
|
||||
else{
|
||||
for (auto el : m_opt.enum_labels.empty() ? m_opt.enum_values : m_opt.enum_labels) {
|
||||
const wxString& str = _(el);
|
||||
field->Append(str);
|
||||
if (el.compare(selection) == 0)
|
||||
idx = counter;
|
||||
++counter;
|
||||
}
|
||||
}
|
||||
|
||||
wxBitmap empty_bmp(1, field->GetFont().GetPixelSize().y + 2);
|
||||
empty_bmp.SetWidth(0);
|
||||
field->SetItemBitmap(0, empty_bmp);
|
||||
|
||||
idx == m_opt.enum_values.size() ?
|
||||
field->SetValue(selection) :
|
||||
field->SetSelection(idx);
|
||||
}
|
||||
|
||||
void ColourPicker::BUILD()
|
||||
{
|
||||
auto size = wxSize(wxDefaultSize);
|
||||
@ -944,8 +1009,8 @@ boost::any& PointCtrl::get_value()
|
||||
void StaticText::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*wxGetApp().em_unit());
|
||||
if (m_opt.width >= 0) size.SetWidth(m_opt.width*wxGetApp().em_unit());
|
||||
|
||||
const wxString legend(static_cast<const ConfigOptionString*>(m_opt.default_value)->value);
|
||||
auto temp = new wxStaticText(m_parent, wxID_ANY, legend, wxDefaultPosition, size, wxST_ELLIPSIZE_MIDDLE);
|
||||
@ -959,6 +1024,21 @@ void StaticText::BUILD()
|
||||
temp->SetToolTip(get_tooltip_text(legend));
|
||||
}
|
||||
|
||||
void StaticText::rescale()
|
||||
{
|
||||
Field::rescale();
|
||||
|
||||
auto size = wxSize(wxDefaultSize);
|
||||
if (m_opt.height >= 0) size.SetHeight(m_opt.height*wxGetApp().em_unit());
|
||||
if (m_opt.width >= 0) size.SetWidth(m_opt.width*wxGetApp().em_unit());
|
||||
|
||||
if (size != wxDefaultSize)
|
||||
{
|
||||
wxStaticText* field = dynamic_cast<wxStaticText*>(window);
|
||||
field->SetSize(size);
|
||||
}
|
||||
}
|
||||
|
||||
void SliderCtrl::BUILD()
|
||||
{
|
||||
auto size = wxSize(wxDefaultSize);
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "libslic3r/Utils.hpp"
|
||||
|
||||
#include "GUI.hpp"
|
||||
#include "wxExtensions.hpp"
|
||||
|
||||
#ifdef __WXMSW__
|
||||
#define wxMSW true
|
||||
@ -36,19 +37,24 @@ using t_back_to_init = std::function<void(const std::string&)>;
|
||||
|
||||
wxString double_to_string(double const value, const int max_precision = 4);
|
||||
|
||||
class MyButton : public wxButton
|
||||
class RevertButton : public /*wxButton*/PrusaButton
|
||||
{
|
||||
bool hidden = false; // never show button if it's hidden ones
|
||||
public:
|
||||
MyButton() {}
|
||||
MyButton(wxWindow* parent, wxWindowID id, const wxString& label = wxEmptyString,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize, long style = 0,
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxTextCtrlNameStr)
|
||||
{
|
||||
this->Create(parent, id, label, pos, size, style, validator, name);
|
||||
}
|
||||
// RevertButton() {}
|
||||
// RevertButton(wxWindow* parent, wxWindowID id, const wxString& label = wxEmptyString,
|
||||
// const wxPoint& pos = wxDefaultPosition,
|
||||
// const wxSize& size = wxDefaultSize, long style = 0,
|
||||
// const wxValidator& validator = wxDefaultValidator,
|
||||
// const wxString& name = wxTextCtrlNameStr)
|
||||
// {
|
||||
// this->Create(parent, id, label, pos, size, style, validator, name);
|
||||
// }
|
||||
RevertButton(
|
||||
wxWindow *parent,
|
||||
const std::string& icon_name = ""
|
||||
) :
|
||||
PrusaButton(parent, wxID_ANY, icon_name) {}
|
||||
|
||||
// overridden from wxWindow base class
|
||||
virtual bool
|
||||
@ -154,19 +160,19 @@ public:
|
||||
return std::move(p); //!p;
|
||||
}
|
||||
|
||||
bool set_undo_bitmap(const wxBitmap *bmp) {
|
||||
bool set_undo_bitmap(const /*wxBitmap*/PrusaBitmap *bmp) {
|
||||
if (m_undo_bitmap != bmp) {
|
||||
m_undo_bitmap = bmp;
|
||||
m_Undo_btn->SetBitmap(*bmp);
|
||||
m_Undo_btn->SetBitmap_(*bmp);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool set_undo_to_sys_bitmap(const wxBitmap *bmp) {
|
||||
bool set_undo_to_sys_bitmap(const /*wxBitmap*/PrusaBitmap *bmp) {
|
||||
if (m_undo_to_sys_bitmap != bmp) {
|
||||
m_undo_to_sys_bitmap = bmp;
|
||||
m_Undo_to_sys_btn->SetBitmap(*bmp);
|
||||
m_Undo_to_sys_btn->SetBitmap_(*bmp);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -211,14 +217,19 @@ public:
|
||||
m_side_text = side_text;
|
||||
}
|
||||
|
||||
virtual void rescale() {
|
||||
m_Undo_to_sys_btn->rescale();
|
||||
m_Undo_btn->rescale();
|
||||
}
|
||||
|
||||
protected:
|
||||
MyButton* m_Undo_btn = nullptr;
|
||||
RevertButton* m_Undo_btn = nullptr;
|
||||
// Bitmap and Tooltip text for m_Undo_btn. The wxButton will be updated only if the new wxBitmap pointer differs from the currently rendered one.
|
||||
const wxBitmap* m_undo_bitmap = nullptr;
|
||||
const /*wxBitmap*/PrusaBitmap* m_undo_bitmap = nullptr;
|
||||
const wxString* m_undo_tooltip = nullptr;
|
||||
MyButton* m_Undo_to_sys_btn = nullptr;
|
||||
RevertButton* m_Undo_to_sys_btn = nullptr;
|
||||
// Bitmap and Tooltip text for m_Undo_to_sys_btn. The wxButton will be updated only if the new wxBitmap pointer differs from the currently rendered one.
|
||||
const wxBitmap* m_undo_to_sys_bitmap = nullptr;
|
||||
const /*wxBitmap*/PrusaBitmap* m_undo_to_sys_bitmap = nullptr;
|
||||
const wxString* m_undo_to_sys_tooltip = nullptr;
|
||||
|
||||
wxStaticText* m_Label = nullptr;
|
||||
@ -273,6 +284,8 @@ public:
|
||||
}
|
||||
|
||||
boost::any& get_value() override;
|
||||
|
||||
void rescale() override;
|
||||
|
||||
virtual void enable();
|
||||
virtual void disable();
|
||||
@ -337,6 +350,8 @@ public:
|
||||
return m_value = tmp_value;
|
||||
}
|
||||
|
||||
void rescale() override;
|
||||
|
||||
void enable() override { dynamic_cast<wxSpinCtrl*>(window)->Enable(); }
|
||||
void disable() override { dynamic_cast<wxSpinCtrl*>(window)->Disable(); }
|
||||
wxWindow* getWindow() override { return window; }
|
||||
@ -344,6 +359,7 @@ public:
|
||||
|
||||
class Choice : public Field {
|
||||
using Field::Field;
|
||||
int m_width{ 15 };
|
||||
public:
|
||||
Choice(const ConfigOptionDef& opt, const t_config_option_key& id) : Field(opt, id) {}
|
||||
Choice(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id) : Field(parent, opt, id) {}
|
||||
@ -363,6 +379,8 @@ public:
|
||||
void set_values(const std::vector<std::string> &values);
|
||||
boost::any& get_value() override;
|
||||
|
||||
void rescale() override;
|
||||
|
||||
void enable() override { dynamic_cast<wxBitmapComboBox*>(window)->Enable(); };
|
||||
void disable() override{ dynamic_cast<wxBitmapComboBox*>(window)->Disable(); };
|
||||
wxWindow* getWindow() override { return window; }
|
||||
@ -446,6 +464,8 @@ public:
|
||||
|
||||
boost::any& get_value()override { return m_value; }
|
||||
|
||||
void rescale() override;
|
||||
|
||||
void enable() override { dynamic_cast<wxStaticText*>(window)->Enable(); };
|
||||
void disable() override{ dynamic_cast<wxStaticText*>(window)->Disable(); };
|
||||
wxWindow* getWindow() override { return window; }
|
||||
|
@ -325,6 +325,13 @@ void GUI_App::init_fonts()
|
||||
#endif /*__WXMAC__*/
|
||||
}
|
||||
|
||||
void GUI_App::scale_fonts(const float scale_f)
|
||||
{
|
||||
m_small_font = m_small_font.Scaled(scale_f);
|
||||
m_bold_font = m_bold_font.Scaled(scale_f);
|
||||
m_normal_font = m_normal_font.Scaled(scale_f);
|
||||
}
|
||||
|
||||
void GUI_App::set_label_clr_modified(const wxColour& clr) {
|
||||
m_color_label_modified = clr;
|
||||
auto clr_str = wxString::Format(wxT("#%02X%02X%02X"), clr.Red(), clr.Green(), clr.Blue());
|
||||
|
@ -98,6 +98,7 @@ public:
|
||||
void init_label_colours();
|
||||
void update_label_colours_from_appconfig();
|
||||
void init_fonts();
|
||||
void scale_fonts(const float scale_f);
|
||||
void set_label_clr_modified(const wxColour& clr);
|
||||
void set_label_clr_sys(const wxColour& clr);
|
||||
|
||||
|
@ -2613,6 +2613,18 @@ void ObjectList::update_item_error_icon(const int obj_idx, const int vol_idx) co
|
||||
}
|
||||
}
|
||||
|
||||
void ObjectList::rescale()
|
||||
{
|
||||
// update min size !!! Width shouldn't be a wxDefaultCoord
|
||||
SetMinSize(wxSize(1, 15 * wxGetApp().em_unit()));
|
||||
|
||||
GetColumn(0)->SetWidth(19 * wxGetApp().em_unit());
|
||||
GetColumn(1)->SetWidth(8 * wxGetApp().em_unit());
|
||||
GetColumn(2)->SetWidth(int(2 * wxGetApp().em_unit()));
|
||||
|
||||
Layout();
|
||||
}
|
||||
|
||||
void ObjectList::ItemValueChanged(wxDataViewEvent &event)
|
||||
{
|
||||
if (event.GetColumn() == 0)
|
||||
|
@ -285,6 +285,9 @@ public:
|
||||
void rename_item();
|
||||
void fix_through_netfabb() const;
|
||||
void update_item_error_icon(const int obj_idx, int vol_idx) const ;
|
||||
|
||||
void rescale();
|
||||
|
||||
private:
|
||||
void OnChar(wxKeyEvent& event);
|
||||
void OnContextMenu(wxDataViewEvent &event);
|
||||
|
@ -23,7 +23,7 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
|
||||
#endif // __APPLE__
|
||||
{
|
||||
m_og->set_name(_(L("Object Manipulation")));
|
||||
m_og->label_width = 12 * wxGetApp().em_unit();//125;
|
||||
m_og->label_width = 12;//125;
|
||||
m_og->set_grid_vgap(5);
|
||||
|
||||
m_og->m_on_change = std::bind(&ObjectManipulation::on_change, this, std::placeholders::_1, std::placeholders::_2);
|
||||
@ -45,11 +45,11 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
|
||||
def.label = L("Name");
|
||||
def.gui_type = "legend";
|
||||
def.tooltip = L("Object name");
|
||||
def.width = 21 * wxGetApp().em_unit();
|
||||
def.width = 21;
|
||||
def.default_value = new ConfigOptionString{ " " };
|
||||
m_og->append_single_option_line(Option(def, "object_name"));
|
||||
|
||||
const int field_width = 5 * wxGetApp().em_unit()/*50*/;
|
||||
const int field_width = 5;
|
||||
|
||||
// Legend for object modification
|
||||
auto line = Line{ "", "" };
|
||||
|
@ -59,6 +59,8 @@ ObjectSettings::ObjectSettings(wxWindow* parent) :
|
||||
|
||||
m_settings_list_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
m_og->sizer->Add(m_settings_list_sizer, 1, wxEXPAND | wxLEFT, 5);
|
||||
|
||||
m_bmp_delete = PrusaBitmap(parent, "cross");
|
||||
}
|
||||
|
||||
void ObjectSettings::update_settings_list()
|
||||
@ -77,11 +79,12 @@ void ObjectSettings::update_settings_list()
|
||||
{
|
||||
auto opt_key = (line.get_options())[0].opt_id; //we assume that we have one option per line
|
||||
|
||||
auto btn = new wxBitmapButton(parent, wxID_ANY, create_scaled_bitmap(m_parent, "cross"/*"colorchange_delete_on.png"*/),
|
||||
wxDefaultPosition, wxDefaultSize, wxBORDER_NONE);
|
||||
#ifdef __WXMSW__
|
||||
btn->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||
#endif // __WXMSW__
|
||||
// auto btn = new wxBitmapButton(parent, wxID_ANY, create_scaled_bitmap(m_parent, "cross"/*"colorchange_delete_on.png"*/),
|
||||
// wxDefaultPosition, wxDefaultSize, wxBORDER_NONE);
|
||||
auto btn = new PrusaButton(parent, wxID_ANY, m_bmp_delete);
|
||||
//#ifdef __WXMSW__
|
||||
// btn->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||
//#endif // __WXMSW__
|
||||
btn->Bind(wxEVT_BUTTON, [opt_key, config, this](wxEvent &event) {
|
||||
config->erase(opt_key);
|
||||
wxGetApp().obj_list()->part_settings_changed();
|
||||
@ -123,7 +126,7 @@ void ObjectSettings::update_settings_list()
|
||||
continue;
|
||||
|
||||
auto optgroup = std::make_shared<ConfigOptionsGroup>(m_og->ctrl_parent(), cat.first, config, false, extra_column);
|
||||
optgroup->label_width = 15 * wxGetApp().em_unit();
|
||||
optgroup->label_width = 15;
|
||||
optgroup->sidetext_width = 5.5 * wxGetApp().em_unit();
|
||||
|
||||
optgroup->m_on_change = [](const t_config_option_key& opt_id, const boost::any& value) {
|
||||
@ -139,6 +142,15 @@ void ObjectSettings::update_settings_list()
|
||||
}
|
||||
optgroup->reload_config();
|
||||
m_settings_list_sizer->Add(optgroup->sizer, 0, wxEXPAND | wxALL, 0);
|
||||
|
||||
// call back for rescaling of the extracolumn control
|
||||
optgroup->rescale_extra_column = [this](wxWindow* win) {
|
||||
auto *ctrl = dynamic_cast<PrusaButton*>(win);
|
||||
if (ctrl == nullptr)
|
||||
return;
|
||||
ctrl->SetBitmap_(m_bmp_delete);
|
||||
};
|
||||
|
||||
m_og_settings.push_back(optgroup);
|
||||
|
||||
categories.push_back(cat.first);
|
||||
@ -163,5 +175,13 @@ void ObjectSettings::UpdateAndShow(const bool show)
|
||||
OG_Settings::UpdateAndShow(show);
|
||||
}
|
||||
|
||||
void ObjectSettings::rescale()
|
||||
{
|
||||
m_bmp_delete.rescale();
|
||||
|
||||
for (auto group : m_og_settings)
|
||||
group->rescale();
|
||||
}
|
||||
|
||||
} //namespace GUI
|
||||
} //namespace Slic3r
|
@ -4,6 +4,7 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <wx/panel.h>
|
||||
#include "wxExtensions.hpp"
|
||||
|
||||
class wxBoxSizer;
|
||||
|
||||
@ -37,12 +38,15 @@ class ObjectSettings : public OG_Settings
|
||||
// option groups for settings
|
||||
std::vector <std::shared_ptr<ConfigOptionsGroup>> m_og_settings;
|
||||
|
||||
PrusaBitmap m_bmp_delete;
|
||||
|
||||
public:
|
||||
ObjectSettings(wxWindow* parent);
|
||||
~ObjectSettings() {}
|
||||
|
||||
void update_settings_list();
|
||||
void UpdateAndShow(const bool show) override;
|
||||
void rescale();
|
||||
};
|
||||
|
||||
}}
|
||||
|
@ -256,6 +256,7 @@ bool MainFrame::can_delete_all() const
|
||||
return (m_plater != nullptr) ? !m_plater->model().objects.empty() : false;
|
||||
}
|
||||
|
||||
// scale font for existing controls
|
||||
static void scale(wxWindow *window, const float scale_f)
|
||||
{
|
||||
auto children = window->GetChildren();
|
||||
@ -268,10 +269,9 @@ static void scale(wxWindow *window, const float scale_f)
|
||||
|
||||
// const wxSize& sz = child->GetSize();
|
||||
// if (sz != wxDefaultSize)
|
||||
// child->SetSize(sz*scale_f);
|
||||
|
||||
child->Layout();
|
||||
// child->SetSize(sz*scale_f);
|
||||
}
|
||||
window->Layout();
|
||||
}
|
||||
|
||||
void MainFrame::on_dpi_changed(const wxRect &suggested_rect)
|
||||
@ -286,28 +286,24 @@ void MainFrame::on_dpi_changed(const wxRect &suggested_rect)
|
||||
{
|
||||
Freeze();
|
||||
|
||||
scale(this, new_sc_factor / old_sc_factor);
|
||||
wxGetApp().scale_fonts(new_sc_factor / old_sc_factor);
|
||||
|
||||
const auto new_em_unit = wxGetApp().em_unit()*new_sc_factor / old_sc_factor;
|
||||
|
||||
scale(this, new_sc_factor / old_sc_factor/*, 1/new_em_unit*/);
|
||||
|
||||
wxGetApp().set_em_unit(std::max<size_t>(10, new_em_unit));
|
||||
|
||||
/* Load default preset bitmaps before a tabpanel initialization,
|
||||
* but after filling of an em_unit value
|
||||
*/
|
||||
wxGetApp().preset_bundle->load_default_preset_bitmaps();
|
||||
wxGetApp().preset_bundle->load_default_preset_bitmaps(this);
|
||||
|
||||
wxGetApp().sidebar().scrolled_panel()->SetSize(40 * wxGetApp().em_unit(), -1);
|
||||
wxGetApp().sidebar().scrolled_panel()->Layout();
|
||||
// update preset comboboxes on Plater
|
||||
wxGetApp().sidebar().rescale();
|
||||
|
||||
// update preset comboboxes on Tabs
|
||||
for (auto tab : wxGetApp().tabs_list)
|
||||
tab->rescale();//update_tab_ui();
|
||||
tab->rescale();
|
||||
|
||||
// update preset comboboxes on Plater
|
||||
wxGetApp().sidebar().update_all_preset_comboboxes();
|
||||
|
||||
Refresh();
|
||||
Layout();
|
||||
|
||||
Thaw();
|
||||
|
@ -166,8 +166,11 @@ void OptionsGroup::append_line(const Line& line, wxStaticText** full_Label/* = n
|
||||
#endif /* __WXGTK__ */
|
||||
|
||||
// if we have an extra column, build it
|
||||
if (extra_column)
|
||||
grid_sizer->Add(extra_column(this->ctrl_parent(), line), 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 3);
|
||||
if (extra_column)
|
||||
{
|
||||
m_extra_column_ptrs.push_back(extra_column(this->ctrl_parent(), line));
|
||||
grid_sizer->Add(m_extra_column_ptrs.back(), 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 3);
|
||||
}
|
||||
|
||||
// Build a label if we have it
|
||||
wxStaticText* label=nullptr;
|
||||
@ -180,10 +183,10 @@ void OptionsGroup::append_line(const Line& line, wxStaticText** full_Label/* = n
|
||||
label_style |= staticbox ? 0 : wxST_ELLIPSIZE_END;
|
||||
#endif /* __WXGTK__ */
|
||||
label = new wxStaticText(this->ctrl_parent(), wxID_ANY, line.label + (line.label.IsEmpty() ? "" : ": "),
|
||||
wxDefaultPosition, wxSize(label_width, -1), label_style);
|
||||
wxDefaultPosition, wxSize(label_width*wxGetApp().em_unit(), -1), label_style);
|
||||
label->SetBackgroundStyle(wxBG_STYLE_PAINT);
|
||||
label->SetFont(label_font);
|
||||
label->Wrap(label_width); // avoid a Linux/GTK bug
|
||||
label->SetFont(wxGetApp().normal_font());
|
||||
label->Wrap(label_width*wxGetApp().em_unit()); // avoid a Linux/GTK bug
|
||||
if (!line.near_label_widget)
|
||||
grid_sizer->Add(label, 0, (staticbox ? 0 : wxALIGN_RIGHT | wxRIGHT) | wxALIGN_CENTER_VERTICAL, line.label.IsEmpty() ? 0 : 5);
|
||||
else if (line.near_label_widget && line.label.IsEmpty())
|
||||
@ -235,14 +238,13 @@ void OptionsGroup::append_line(const Line& line, wxStaticText** full_Label/* = n
|
||||
wxSizer* sizer_tmp = sizer;
|
||||
// add label if any
|
||||
if (option.label != "") {
|
||||
// wxString str_label = _(option.label);
|
||||
//! To correct translation by context have to use wxGETTEXT_IN_CONTEXT macro from wxWidget 3.1.1
|
||||
wxString str_label = (option.label == "Top" || option.label == "Bottom") ?
|
||||
_CTX(option.label, "Layers") :
|
||||
_(option.label);
|
||||
label = new wxStaticText(this->ctrl_parent(), wxID_ANY, str_label + ": ", wxDefaultPosition, wxDefaultSize);
|
||||
label->SetBackgroundStyle(wxBG_STYLE_PAINT);
|
||||
label->SetFont(label_font);
|
||||
label->SetFont(wxGetApp().normal_font());
|
||||
sizer_tmp->Add(label, 0, /*wxALIGN_RIGHT |*/ wxALIGN_CENTER_VERTICAL, 0);
|
||||
}
|
||||
|
||||
@ -269,7 +271,7 @@ void OptionsGroup::append_line(const Line& line, wxStaticText** full_Label/* = n
|
||||
auto sidetext = new wxStaticText( this->ctrl_parent(), wxID_ANY, _(option.sidetext), wxDefaultPosition,
|
||||
wxSize(sidetext_width, -1)/*wxDefaultSize*/, wxALIGN_LEFT);
|
||||
sidetext->SetBackgroundStyle(wxBG_STYLE_PAINT);
|
||||
sidetext->SetFont(sidetext_font);
|
||||
sidetext->SetFont(wxGetApp().normal_font());
|
||||
sizer_tmp->Add(sidetext, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, 4);
|
||||
field->set_side_text_ptr(sidetext);
|
||||
}
|
||||
@ -478,6 +480,50 @@ bool ConfigOptionsGroup::update_visibility(ConfigOptionMode mode) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void ConfigOptionsGroup::rescale()
|
||||
{
|
||||
// update bitmaps for mode markers : set new (rescaled) bitmaps
|
||||
if (rescale_extra_column)
|
||||
for (auto extra_col : m_extra_column_ptrs)
|
||||
rescale_extra_column(extra_col);
|
||||
|
||||
// update undo buttons : rescale bitmaps
|
||||
for (const auto& field : m_fields)
|
||||
field.second->rescale();
|
||||
|
||||
// rescale width of label column
|
||||
if (!m_options_mode.empty() && label_width > 1)
|
||||
{
|
||||
const int cols = m_grid_sizer->GetCols();
|
||||
const int rows = m_grid_sizer->GetEffectiveRowsCount();
|
||||
const int label_col = extra_column == nullptr ? 0 : 1;
|
||||
|
||||
for (int i = 0; i < rows; i++)
|
||||
{
|
||||
const wxSizerItem* label_item = m_grid_sizer->GetItem(i*cols+label_col);
|
||||
if (label_item->IsWindow())
|
||||
{
|
||||
auto label = dynamic_cast<wxStaticText*>(label_item->GetWindow());
|
||||
if (label != nullptr) {
|
||||
label->SetMinSize(wxSize(label_width*wxGetApp().em_unit(), -1));
|
||||
}
|
||||
}
|
||||
else if (label_item->IsSizer()) // case when we nave 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*wxGetApp().em_unit(), -1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
m_grid_sizer->Layout();
|
||||
}
|
||||
}
|
||||
|
||||
boost::any ConfigOptionsGroup::config_value(const std::string& opt_key, int opt_index, bool deserialize) {
|
||||
|
||||
if (deserialize) {
|
||||
|
@ -72,7 +72,7 @@ private:
|
||||
std::vector<widget_t> m_extra_widgets;//! {std::vector<widget_t>()};
|
||||
};
|
||||
|
||||
using column_t = std::function<wxWindow*(wxWindow* parent, const Line&)>;//std::function<wxSizer*(const Line&)>;
|
||||
using column_t = std::function<wxWindow*(wxWindow* parent, const Line&)>;
|
||||
|
||||
using t_optionfield_map = std::map<t_config_option_key, t_field>;
|
||||
using t_opt_map = std::map< std::string, std::pair<std::string, int> >;
|
||||
@ -82,9 +82,10 @@ class OptionsGroup {
|
||||
public:
|
||||
const bool staticbox {true};
|
||||
const wxString title {wxString("")};
|
||||
size_t label_width = 20 * wxGetApp().em_unit();// {200};
|
||||
size_t label_width = 20 ;// {200};
|
||||
wxSizer* sizer {nullptr};
|
||||
column_t extra_column {nullptr};
|
||||
std::function<void(wxWindow* win)> rescale_extra_column { nullptr };
|
||||
t_change m_on_change { nullptr };
|
||||
t_kill_focus m_fill_empty_value { nullptr };
|
||||
t_kill_focus m_set_focus { nullptr };
|
||||
@ -191,6 +192,7 @@ protected:
|
||||
std::map<t_config_option_key, Option> m_options;
|
||||
wxWindow* m_parent {nullptr};
|
||||
std::vector<ConfigOptionMode> m_options_mode;
|
||||
std::vector<wxWindow*> m_extra_column_ptrs;
|
||||
|
||||
/// Field list, contains unique_ptrs of the derived type.
|
||||
/// using types that need to know what it is beyond the public interface
|
||||
@ -259,6 +261,7 @@ public:
|
||||
void Hide();
|
||||
void Show(const bool show);
|
||||
bool update_visibility(ConfigOptionMode mode);
|
||||
void rescale();
|
||||
boost::any config_value(const std::string& opt_key, int opt_index, bool deserialize);
|
||||
// return option value from config
|
||||
boost::any get_config_value(const DynamicPrintConfig& config, const std::string& opt_key, int opt_index = -1);
|
||||
|
@ -111,6 +111,7 @@ public:
|
||||
|
||||
bool showing_manifold_warning_icon;
|
||||
void show_sizer(bool show);
|
||||
void rescale();
|
||||
};
|
||||
|
||||
ObjectInfo::ObjectInfo(wxWindow *parent) :
|
||||
@ -118,10 +119,10 @@ ObjectInfo::ObjectInfo(wxWindow *parent) :
|
||||
{
|
||||
GetStaticBox()->SetFont(wxGetApp().bold_font());
|
||||
|
||||
auto *grid_sizer = new wxFlexGridSizer(4, 5, 5);
|
||||
auto *grid_sizer = new wxFlexGridSizer(4, 5, 15);
|
||||
grid_sizer->SetFlexibleDirection(wxHORIZONTAL);
|
||||
grid_sizer->AddGrowableCol(1, 1);
|
||||
grid_sizer->AddGrowableCol(3, 1);
|
||||
// grid_sizer->AddGrowableCol(1, 1);
|
||||
// grid_sizer->AddGrowableCol(3, 1);
|
||||
|
||||
auto init_info_label = [parent, grid_sizer](wxStaticText **info_label, wxString text_label) {
|
||||
auto *text = new wxStaticText(parent, wxID_ANY, text_label+":");
|
||||
@ -161,6 +162,11 @@ void ObjectInfo::show_sizer(bool show)
|
||||
manifold_warning_icon->Show(showing_manifold_warning_icon && show);
|
||||
}
|
||||
|
||||
void ObjectInfo::rescale()
|
||||
{
|
||||
manifold_warning_icon->SetBitmap(create_scaled_bitmap(nullptr, "exclamation_mark_"));
|
||||
}
|
||||
|
||||
enum SlisedInfoIdx
|
||||
{
|
||||
siFilament_m,
|
||||
@ -282,11 +288,12 @@ wxBitmapComboBox(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(15 *
|
||||
});
|
||||
}
|
||||
|
||||
edit_btn = new wxButton(parent, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER);
|
||||
#ifdef __WINDOWS__
|
||||
edit_btn->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||
#endif
|
||||
edit_btn->SetBitmap(create_scaled_bitmap(this, "cog"));
|
||||
// edit_btn = new wxButton(parent, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER);
|
||||
// #ifdef __WINDOWS__
|
||||
// edit_btn->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||
// #endif
|
||||
// edit_btn->SetBitmap(create_scaled_bitmap(this, "cog"));
|
||||
edit_btn = new PrusaButton(parent, wxID_ANY, "cog");
|
||||
edit_btn->SetToolTip(_(L("Click to edit preset")));
|
||||
|
||||
edit_btn->Bind(wxEVT_BUTTON, ([preset_type, this](wxCommandEvent)
|
||||
@ -332,6 +339,13 @@ void PresetComboBox::check_selection()
|
||||
this->last_selected = GetSelection();
|
||||
}
|
||||
|
||||
void PresetComboBox::rescale()
|
||||
{
|
||||
// update min control's height from new scaled size
|
||||
this->SetMinSize(wxSize(20*wxGetApp().em_unit(), this->GetSize().GetHeight()));
|
||||
edit_btn->rescale();
|
||||
}
|
||||
|
||||
// Frequently changed parameters
|
||||
|
||||
class FreqChangedParams : public OG_Settings
|
||||
@ -429,7 +443,7 @@ FreqChangedParams::FreqChangedParams(wxWindow* parent, const int label_width) :
|
||||
|
||||
option = m_og->get_option("fill_density");
|
||||
option.opt.label = L("Infill");
|
||||
option.opt.width = 6 * wxGetApp().em_unit();
|
||||
option.opt.width = 6;
|
||||
option.opt.sidetext = " ";
|
||||
line.append_option(option);
|
||||
|
||||
@ -615,9 +629,9 @@ void Sidebar::priv::show_preset_comboboxes()
|
||||
// Sidebar / public
|
||||
|
||||
Sidebar::Sidebar(Plater *parent)
|
||||
: wxPanel(parent), p(new priv(parent))
|
||||
: wxPanel(parent, wxID_ANY, wxDefaultPosition, wxSize(40 * wxGetApp().em_unit(), -1)), p(new priv(parent))
|
||||
{
|
||||
p->scrolled = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, wxSize(40 * wxGetApp().em_unit(), -1));
|
||||
p->scrolled = new wxScrolledWindow(this, wxID_ANY/*, wxDefaultPosition, wxSize(40 * wxGetApp().em_unit(), -1)*/);
|
||||
p->scrolled->SetScrollbars(0, 20, 1, 2);
|
||||
|
||||
|
||||
@ -676,13 +690,8 @@ Sidebar::Sidebar(Plater *parent)
|
||||
init_combo(&p->combo_sla_material, _(L("SLA material")), Preset::TYPE_SLA_MATERIAL, false);
|
||||
init_combo(&p->combo_printer, _(L("Printer")), Preset::TYPE_PRINTER, false);
|
||||
|
||||
// calculate width of the preset labels
|
||||
// p->sizer_presets->Layout();
|
||||
// const wxArrayInt& ar = p->sizer_presets->GetColWidths();
|
||||
// const int label_width = ar.IsEmpty() ? 10*wxGetApp().em_unit() : ar.front()-4;
|
||||
|
||||
const int margin_5 = int(0.5*wxGetApp().em_unit());// 5;
|
||||
const int margin_10 = int(1.5*wxGetApp().em_unit());// 15;
|
||||
const int margin_10 = 10;//int(1.5*wxGetApp().em_unit());// 15;
|
||||
|
||||
p->sizer_params = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
@ -704,10 +713,6 @@ Sidebar::Sidebar(Plater *parent)
|
||||
p->object_settings->Hide();
|
||||
p->sizer_params->Add(p->object_settings->get_sizer(), 0, wxEXPAND | wxTOP, margin_5);
|
||||
|
||||
p->btn_send_gcode = new wxButton(this, wxID_ANY, _(L("Send to printer")));
|
||||
p->btn_send_gcode->SetFont(wxGetApp().bold_font());
|
||||
p->btn_send_gcode->Hide();
|
||||
|
||||
// Info boxes
|
||||
p->object_info = new ObjectInfo(p->scrolled);
|
||||
p->sliced_info = new SlicedInfo(p->scrolled);
|
||||
@ -722,10 +727,16 @@ Sidebar::Sidebar(Plater *parent)
|
||||
scrolled_sizer->Add(p->sliced_info, 0, wxEXPAND | wxTOP | wxLEFT, margin_5);
|
||||
|
||||
// Buttons underneath the scrolled area
|
||||
p->btn_export_gcode = new wxButton(this, wxID_ANY, _(L("Export G-code")) + dots);
|
||||
p->btn_export_gcode->SetFont(wxGetApp().bold_font());
|
||||
p->btn_reslice = new wxButton(this, wxID_ANY, _(L("Slice now")));
|
||||
p->btn_reslice->SetFont(wxGetApp().bold_font());
|
||||
|
||||
auto init_btn = [this](wxButton **btn, wxString label) {
|
||||
*btn = new wxButton(this, wxID_ANY, label);
|
||||
(*btn)->SetFont(wxGetApp().bold_font());
|
||||
};
|
||||
|
||||
init_btn(&p->btn_send_gcode, _(L("Send to printer")));
|
||||
p->btn_send_gcode->Hide();
|
||||
init_btn(&p->btn_export_gcode, _(L("Export G-code")) + dots);
|
||||
init_btn(&p->btn_reslice, _(L("Slice now")));
|
||||
enable_buttons(false);
|
||||
|
||||
auto *btns_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
@ -888,6 +899,40 @@ void Sidebar::update_reslice_btn_tooltip() const
|
||||
p->btn_reslice->SetToolTip(tooltip);
|
||||
}
|
||||
|
||||
void Sidebar::rescale()
|
||||
{
|
||||
SetMinSize(wxSize(40 * wxGetApp().em_unit(), -1));
|
||||
|
||||
p->mode_sizer->rescale();
|
||||
|
||||
// first of all : recreate preset comboboxes, because of
|
||||
// in AddBitmap() function autonaticaly set the size of controll
|
||||
update_all_preset_comboboxes();
|
||||
// then rescale them to current min size to correct layout of the sidebar
|
||||
for (PresetComboBox* combo : std::vector<PresetComboBox*> { p->combo_print,
|
||||
p->combo_sla_print,
|
||||
p->combo_sla_material,
|
||||
p->combo_printer } )
|
||||
combo->rescale();
|
||||
|
||||
for (PresetComboBox* combo : p->combos_filament)
|
||||
combo->rescale();
|
||||
|
||||
p->frequently_changed_parameters->get_og(true)->rescale();
|
||||
p->frequently_changed_parameters->get_og(false)->rescale();
|
||||
|
||||
p->object_list->rescale();
|
||||
|
||||
p->object_manipulation->get_og()->rescale();
|
||||
p->object_settings->rescale();
|
||||
|
||||
p->object_info->rescale();
|
||||
|
||||
p->scrolled->Layout();
|
||||
p->plater->Layout();
|
||||
p->plater->GetParent()->Layout();
|
||||
}
|
||||
|
||||
ObjectManipulation* Sidebar::obj_manipul()
|
||||
{
|
||||
return p->object_manipulation;
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "GLTexture.hpp"
|
||||
|
||||
class wxButton;
|
||||
class PrusaButton;
|
||||
class wxBoxSizer;
|
||||
class wxGLCanvas;
|
||||
class wxScrolledWindow;
|
||||
@ -46,7 +47,7 @@ public:
|
||||
PresetComboBox(wxWindow *parent, Preset::Type preset_type);
|
||||
~PresetComboBox();
|
||||
|
||||
wxButton* edit_btn { nullptr };
|
||||
/*wxButton*/PrusaButton* edit_btn { nullptr };
|
||||
|
||||
enum LabelItemType {
|
||||
LABEL_ITEM_MARKER = 0x4d,
|
||||
@ -58,6 +59,8 @@ public:
|
||||
int get_extruder_idx() const { return extruder_idx; }
|
||||
void check_selection();
|
||||
|
||||
void rescale();
|
||||
|
||||
private:
|
||||
typedef std::size_t Marker;
|
||||
|
||||
@ -83,6 +86,7 @@ public:
|
||||
void update_presets(Slic3r::Preset::Type preset_type);
|
||||
void update_mode_sizer() const;
|
||||
void update_reslice_btn_tooltip() const;
|
||||
void rescale();
|
||||
|
||||
ObjectManipulation* obj_manipul();
|
||||
ObjectList* obj_list();
|
||||
|
@ -15,7 +15,7 @@ void PreferencesDialog::build()
|
||||
{
|
||||
auto app_config = get_app_config();
|
||||
m_optgroup = std::make_shared<ConfigOptionsGroup>(this, _(L("General")));
|
||||
m_optgroup->label_width = 40 * wxGetApp().em_unit(); //400;
|
||||
m_optgroup->label_width = 40; //400;
|
||||
m_optgroup->m_on_change = [this](t_config_option_key opt_key, boost::any value){
|
||||
m_values[opt_key] = boost::any_cast<bool>(value) ? "1" : "0";
|
||||
};
|
||||
@ -110,6 +110,8 @@ void PreferencesDialog::build()
|
||||
auto sizer = new wxBoxSizer(wxVERTICAL);
|
||||
sizer->Add(m_optgroup->sizer, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10);
|
||||
|
||||
SetFont(wxGetApp().normal_font());
|
||||
|
||||
auto buttons = CreateStdDialogButtonSizer(wxOK | wxCANCEL);
|
||||
wxButton* btn = static_cast<wxButton*>(FindWindowById(wxID_OK, this));
|
||||
btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { accept(); });
|
||||
|
@ -115,32 +115,43 @@ void Tab::create_preset_tab()
|
||||
auto color = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
|
||||
|
||||
//buttons
|
||||
wxBitmap bmpMenu;
|
||||
bmpMenu = create_scaled_bitmap(this, "save");
|
||||
m_btn_save_preset = new wxBitmapButton(panel, wxID_ANY, bmpMenu, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE);
|
||||
if (wxMSW) m_btn_save_preset->SetBackgroundColour(color);
|
||||
bmpMenu = create_scaled_bitmap(this, "cross"/*"delete.png"*/);
|
||||
m_btn_delete_preset = new wxBitmapButton(panel, wxID_ANY, bmpMenu, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE);
|
||||
if (wxMSW) m_btn_delete_preset->SetBackgroundColour(color);
|
||||
m_scaled_buttons.reserve(6);
|
||||
m_scaled_buttons.reserve(2);
|
||||
// wxBitmap bmpMenu;
|
||||
// bmpMenu = create_scaled_bitmap(this, "save");
|
||||
// m_btn_save_preset = new wxBitmapButton(panel, wxID_ANY, bmpMenu, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE);
|
||||
// if (wxMSW) m_btn_save_preset->SetBackgroundColour(color);
|
||||
// bmpMenu = create_scaled_bitmap(this, "cross"/*"delete.png"*/);
|
||||
// m_btn_delete_preset = new wxBitmapButton(panel, wxID_ANY, bmpMenu, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE);
|
||||
// if (wxMSW) m_btn_delete_preset->SetBackgroundColour(color);
|
||||
|
||||
add_scaled_button(panel, &m_btn_save_preset, "save");
|
||||
add_scaled_button(panel, &m_btn_delete_preset, "cross");
|
||||
|
||||
m_show_incompatible_presets = false;
|
||||
m_bmp_show_incompatible_presets = create_scaled_bitmap(this, "flag_red");
|
||||
m_bmp_hide_incompatible_presets = create_scaled_bitmap(this, "flag_green");
|
||||
m_btn_hide_incompatible_presets = new wxBitmapButton(panel, wxID_ANY, m_bmp_hide_incompatible_presets, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE);
|
||||
if (wxMSW) m_btn_hide_incompatible_presets->SetBackgroundColour(color);
|
||||
// m_bmp_show_incompatible_presets = create_scaled_bitmap(this, "flag_red");
|
||||
// m_bmp_hide_incompatible_presets = create_scaled_bitmap(this, "flag_green");
|
||||
add_scaled_bitmap(this, m_bmp_show_incompatible_presets, "flag_red");
|
||||
add_scaled_bitmap(this, m_bmp_hide_incompatible_presets, "flag_green");
|
||||
// m_btn_hide_incompatible_presets = new wxBitmapButton(panel, wxID_ANY, m_bmp_hide_incompatible_presets, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE);
|
||||
// if (wxMSW) m_btn_hide_incompatible_presets->SetBackgroundColour(color);
|
||||
add_scaled_button(panel, &m_btn_hide_incompatible_presets, m_bmp_hide_incompatible_presets.name());
|
||||
|
||||
m_btn_save_preset->SetToolTip(_(L("Save current ")) + m_title);
|
||||
m_btn_delete_preset->SetToolTip(_(L("Delete this preset")));
|
||||
m_btn_delete_preset->Disable();
|
||||
|
||||
m_undo_btn = new wxButton(panel, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER);
|
||||
m_undo_to_sys_btn = new wxButton(panel, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER);
|
||||
m_question_btn = new wxButton(panel, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER);
|
||||
if (wxMSW) {
|
||||
m_undo_btn->SetBackgroundColour(color);
|
||||
m_undo_to_sys_btn->SetBackgroundColour(color);
|
||||
m_question_btn->SetBackgroundColour(color);
|
||||
}
|
||||
// m_undo_btn = new wxButton(panel, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER);
|
||||
// m_undo_to_sys_btn = new wxButton(panel, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER);
|
||||
// m_question_btn = new wxButton(panel, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER);
|
||||
|
||||
add_scaled_button(panel, &m_question_btn, "question");
|
||||
|
||||
// if (wxMSW) {
|
||||
// m_undo_btn->SetBackgroundColour(color);
|
||||
// m_undo_to_sys_btn->SetBackgroundColour(color);
|
||||
// m_question_btn->SetBackgroundColour(color);
|
||||
// }
|
||||
|
||||
m_question_btn->SetToolTip(_(L("Hover the cursor over buttons to find more information \n"
|
||||
"or click this button.")));
|
||||
@ -148,22 +159,28 @@ void Tab::create_preset_tab()
|
||||
// Determine the theme color of OS (dark or light)
|
||||
auto luma = wxGetApp().get_colour_approx_luma(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||
// Bitmaps to be shown on the "Revert to system" aka "Lock to system" button next to each input field.
|
||||
m_bmp_value_lock = create_scaled_bitmap(this, luma >= 128 ? "lock_closed" : "lock_closed_white");
|
||||
m_bmp_value_unlock = create_scaled_bitmap(this, "lock_open");
|
||||
// m_bmp_value_lock = create_scaled_bitmap(this, luma >= 128 ? "lock_closed" : "lock_closed_white");
|
||||
// m_bmp_value_unlock = create_scaled_bitmap(this, "lock_open");
|
||||
add_scaled_bitmap(this, m_bmp_value_lock , luma >= 128 ? "lock_closed" : "lock_closed_white");
|
||||
add_scaled_bitmap(this, m_bmp_value_unlock, "lock_open");
|
||||
m_bmp_non_system = &m_bmp_white_bullet;
|
||||
// Bitmaps to be shown on the "Undo user changes" button next to each input field.
|
||||
m_bmp_value_revert = create_scaled_bitmap(this, "undo");
|
||||
m_bmp_white_bullet = create_scaled_bitmap(this, "bullet_white.png");
|
||||
m_bmp_question = create_scaled_bitmap(this, "question");
|
||||
// m_bmp_value_revert = create_scaled_bitmap(this, "undo");
|
||||
// m_bmp_white_bullet = create_scaled_bitmap(this, "bullet_white.png");
|
||||
add_scaled_bitmap(this, m_bmp_value_revert, "undo");
|
||||
add_scaled_bitmap(this, m_bmp_white_bullet, "bullet_white.png");
|
||||
|
||||
fill_icon_descriptions();
|
||||
set_tooltips_text();
|
||||
|
||||
m_undo_btn->SetBitmap(m_bmp_white_bullet);
|
||||
add_scaled_button(panel, &m_undo_btn, m_bmp_white_bullet.name());
|
||||
add_scaled_button(panel, &m_undo_to_sys_btn, m_bmp_white_bullet.name());
|
||||
|
||||
// m_undo_btn->SetBitmap(m_bmp_white_bullet);
|
||||
m_undo_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent) { on_roll_back_value(); }));
|
||||
m_undo_to_sys_btn->SetBitmap(m_bmp_white_bullet);
|
||||
// m_undo_to_sys_btn->SetBitmap(m_bmp_white_bullet);
|
||||
m_undo_to_sys_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent) { on_roll_back_value(true); }));
|
||||
m_question_btn->SetBitmap(m_bmp_question);
|
||||
// m_question_btn->SetBitmap(m_bmp_question);
|
||||
m_question_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent)
|
||||
{
|
||||
auto dlg = new ButtonsDescription(this, &m_icon_descriptions);
|
||||
@ -259,12 +276,32 @@ void Tab::create_preset_tab()
|
||||
toggle_show_hide_incompatible();
|
||||
}));
|
||||
|
||||
// Fill cache for mode bitmaps
|
||||
m_mode_bitmap_cache.reserve(3);
|
||||
m_mode_bitmap_cache.push_back(PrusaBitmap(this, "mode_simple_.png"));
|
||||
m_mode_bitmap_cache.push_back(PrusaBitmap(this, "mode_middle_.png"));
|
||||
m_mode_bitmap_cache.push_back(PrusaBitmap(this, "mode_expert_.png"));
|
||||
|
||||
// Initialize the DynamicPrintConfig by default keys/values.
|
||||
build();
|
||||
rebuild_page_tree();
|
||||
m_complited = true;
|
||||
}
|
||||
|
||||
void Tab::add_scaled_button(wxWindow* parent, PrusaButton** btn, const std::string& icon_name,
|
||||
const wxString& label/* = wxEmptyString*/,
|
||||
long style /*= wxBU_EXACTFIT | wxNO_BORDER*/)
|
||||
{
|
||||
*btn = new PrusaButton(parent, wxID_ANY, icon_name, label, wxDefaultSize, wxDefaultPosition, style);
|
||||
m_scaled_buttons.push_back(*btn);
|
||||
}
|
||||
|
||||
void Tab::add_scaled_bitmap(wxWindow* parent, PrusaBitmap& bmp, const std::string& icon_name)
|
||||
{
|
||||
bmp = PrusaBitmap(parent, icon_name);
|
||||
m_scaled_bitmaps.push_back(&bmp);
|
||||
}
|
||||
|
||||
void Tab::load_initial_data()
|
||||
{
|
||||
m_config = &m_presets->get_edited_preset().config;
|
||||
@ -281,9 +318,9 @@ Slic3r::GUI::PageShp Tab::add_options_page(const wxString& title, const std::str
|
||||
icon_idx = (m_icon_index.find(icon) == m_icon_index.end()) ? -1 : m_icon_index.at(icon);
|
||||
if (icon_idx == -1) {
|
||||
// Add a new icon to the icon list.
|
||||
// wxIcon img_icon(from_u8(Slic3r::var(icon)), wxBITMAP_TYPE_PNG);
|
||||
// m_icons->Add(img_icon);
|
||||
m_icons->Add(create_scaled_bitmap(this, icon));
|
||||
// m_icons->Add(create_scaled_bitmap(this, icon));
|
||||
m_scaled_icons_list.push_back(PrusaBitmap(this, icon));
|
||||
m_icons->Add(m_scaled_icons_list.back().bmp());
|
||||
icon_idx = ++m_icon_count;
|
||||
m_icon_index[icon] = icon_idx;
|
||||
}
|
||||
@ -294,7 +331,7 @@ Slic3r::GUI::PageShp Tab::add_options_page(const wxString& title, const std::str
|
||||
#else
|
||||
auto panel = this;
|
||||
#endif
|
||||
PageShp page(new Page(panel, title, icon_idx));
|
||||
PageShp page(new Page(panel, title, icon_idx, m_mode_bitmap_cache));
|
||||
// page->SetBackgroundStyle(wxBG_STYLE_SYSTEM);
|
||||
#ifdef __WINDOWS__
|
||||
// page->SetDoubleBuffered(true);
|
||||
@ -402,8 +439,8 @@ void Tab::update_changed_ui()
|
||||
{
|
||||
bool is_nonsys_value = false;
|
||||
bool is_modified_value = true;
|
||||
const wxBitmap *sys_icon = &m_bmp_value_lock;
|
||||
const wxBitmap *icon = &m_bmp_value_revert;
|
||||
const /*wxBitmap*/PrusaBitmap *sys_icon = &m_bmp_value_lock;
|
||||
const /*wxBitmap*/PrusaBitmap *icon = &m_bmp_value_revert;
|
||||
|
||||
const wxColour *color = &m_sys_label_clr;
|
||||
|
||||
@ -595,8 +632,8 @@ void Tab::update_changed_tree_ui()
|
||||
|
||||
void Tab::update_undo_buttons()
|
||||
{
|
||||
m_undo_btn->SetBitmap(m_is_modified_values ? m_bmp_value_revert : m_bmp_white_bullet);
|
||||
m_undo_to_sys_btn->SetBitmap(m_is_nonsys_values ? *m_bmp_non_system : m_bmp_value_lock);
|
||||
m_undo_btn-> SetBitmap_(m_is_modified_values ? m_bmp_value_revert: m_bmp_white_bullet);
|
||||
m_undo_to_sys_btn-> SetBitmap_(m_is_nonsys_values ? *m_bmp_non_system : m_bmp_value_lock);
|
||||
|
||||
m_undo_btn->SetToolTip(m_is_modified_values ? m_ttg_value_revert : m_ttg_white_bullet);
|
||||
m_undo_to_sys_btn->SetToolTip(m_is_nonsys_values ? *m_ttg_non_system : m_ttg_value_lock);
|
||||
@ -730,10 +767,36 @@ void Tab::rescale()
|
||||
{
|
||||
m_em_unit = wxGetApp().em_unit();
|
||||
|
||||
m_mode_sizer->rescale();
|
||||
|
||||
m_presets_choice->SetSize(25 * m_em_unit, -1);
|
||||
m_treectrl->SetSize(20 * m_em_unit, -1);
|
||||
m_treectrl->SetMinSize(wxSize(20 * m_em_unit, -1));
|
||||
|
||||
update_tab_ui();
|
||||
|
||||
// rescale buttons and cached bitmaps
|
||||
for (const auto btn : m_scaled_buttons)
|
||||
btn->rescale();
|
||||
for (const auto bmp : m_scaled_bitmaps)
|
||||
bmp->rescale();
|
||||
for (PrusaBitmap& bmp : m_mode_bitmap_cache)
|
||||
bmp.rescale();
|
||||
|
||||
// rescale icons for tree_ctrl
|
||||
for (PrusaBitmap& bmp : m_scaled_icons_list)
|
||||
bmp.rescale();
|
||||
// recreate and set new ImageList for tree_ctrl
|
||||
m_icons->RemoveAll();
|
||||
m_icons = new wxImageList(m_scaled_icons_list.front().bmp().GetWidth(), m_scaled_icons_list.front().bmp().GetHeight());
|
||||
for (PrusaBitmap& bmp : m_scaled_icons_list)
|
||||
m_icons->Add(bmp.bmp());
|
||||
m_treectrl->AssignImageList(m_icons);
|
||||
|
||||
// rescale options_groups
|
||||
for (auto page : m_pages)
|
||||
page->rescale();
|
||||
|
||||
Layout();
|
||||
}
|
||||
|
||||
Field* Tab::get_field(const t_config_option_key& opt_key, int opt_index/* = -1*/) const
|
||||
@ -1131,10 +1194,10 @@ void TabPrint::build()
|
||||
optgroup->append_single_option_line("complete_objects");
|
||||
line = { _(L("Extruder clearance (mm)")), "" };
|
||||
Option option = optgroup->get_option("extruder_clearance_radius");
|
||||
option.opt.width = 60;
|
||||
option.opt.width = 6;
|
||||
line.append_option(option);
|
||||
option = optgroup->get_option("extruder_clearance_height");
|
||||
option.opt.width = 60;
|
||||
option.opt.width = 6;
|
||||
line.append_option(option);
|
||||
optgroup->append_line(line);
|
||||
|
||||
@ -1148,14 +1211,14 @@ void TabPrint::build()
|
||||
optgroup = page->new_optgroup(_(L("Post-processing scripts")), 0);
|
||||
option = optgroup->get_option("post_process");
|
||||
option.opt.full_width = true;
|
||||
option.opt.height = 5 * m_em_unit;//50;
|
||||
option.opt.height = 5;//50;
|
||||
optgroup->append_single_option_line(option);
|
||||
|
||||
page = add_options_page(_(L("Notes")), "note.png");
|
||||
optgroup = page->new_optgroup(_(L("Notes")), 0);
|
||||
option = optgroup->get_option("notes");
|
||||
option.opt.full_width = true;
|
||||
option.opt.height = 25 * m_em_unit;//250;
|
||||
option.opt.height = 25;//250;
|
||||
optgroup->append_single_option_line(option);
|
||||
|
||||
page = add_options_page(_(L("Dependencies")), "wrench.png");
|
||||
@ -1468,7 +1531,7 @@ void TabFilament::build()
|
||||
optgroup->append_single_option_line("bridge_fan_speed");
|
||||
optgroup->append_single_option_line("disable_fan_first_layers");
|
||||
|
||||
optgroup = page->new_optgroup(_(L("Cooling thresholds")), 250);
|
||||
optgroup = page->new_optgroup(_(L("Cooling thresholds")), 25);
|
||||
optgroup->append_single_option_line("fan_below_layer_time");
|
||||
optgroup->append_single_option_line("slowdown_below_layer_time");
|
||||
optgroup->append_single_option_line("min_print_speed");
|
||||
@ -1518,8 +1581,8 @@ void TabFilament::build()
|
||||
};
|
||||
optgroup->append_line(line);
|
||||
|
||||
const int gcode_field_height = 15 * m_em_unit; // 150
|
||||
const int notes_field_height = 25 * m_em_unit; // 250
|
||||
const int gcode_field_height = 15; // 150
|
||||
const int notes_field_height = 25; // 250
|
||||
|
||||
page = add_options_page(_(L("Custom G-code")), "cog");
|
||||
optgroup = page->new_optgroup(_(L("Start G-code")), 0);
|
||||
@ -1616,8 +1679,8 @@ wxSizer* Tab::description_line_widget(wxWindow* parent, ogStaticText* *StaticTex
|
||||
{
|
||||
*StaticText = new ogStaticText(parent, "");
|
||||
|
||||
auto font = (new wxSystemSettings)->GetFont(wxSYS_DEFAULT_GUI_FONT);
|
||||
(*StaticText)->SetFont(font);
|
||||
// auto font = (new wxSystemSettings)->GetFont(wxSYS_DEFAULT_GUI_FONT);
|
||||
(*StaticText)->SetFont(wxGetApp().normal_font());
|
||||
|
||||
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
sizer->Add(*StaticText, 1, wxEXPAND|wxALL, 0);
|
||||
@ -1639,10 +1702,12 @@ void TabPrinter::build_printhost(ConfigOptionsGroup *optgroup)
|
||||
}
|
||||
|
||||
auto printhost_browse = [=](wxWindow* parent) {
|
||||
auto btn = m_printhost_browse_btn = new wxButton(parent, wxID_ANY, _(L(" Browse ")) + dots,
|
||||
wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT);
|
||||
btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
|
||||
btn->SetBitmap(create_scaled_bitmap(this, "zoom.png"));
|
||||
// auto btn = m_printhost_browse_btn = new wxButton(parent, wxID_ANY, _(L(" Browse ")) + dots,
|
||||
// wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT);
|
||||
// btn->SetBitmap(create_scaled_bitmap(this, "zoom.png"));
|
||||
add_scaled_button(parent, &m_printhost_browse_btn, "zoom.png", _(L(" Browse ")) + dots, wxBU_LEFT | wxBU_EXACTFIT);
|
||||
PrusaButton* btn = m_printhost_browse_btn;
|
||||
btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
|
||||
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
sizer->Add(btn);
|
||||
|
||||
@ -1657,11 +1722,13 @@ void TabPrinter::build_printhost(ConfigOptionsGroup *optgroup)
|
||||
return sizer;
|
||||
};
|
||||
|
||||
auto print_host_test = [this](wxWindow* parent) {
|
||||
auto btn = m_print_host_test_btn = new wxButton(parent, wxID_ANY, _(L("Test")),
|
||||
wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT);
|
||||
btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
|
||||
btn->SetBitmap(create_scaled_bitmap(this, "wrench.png"));
|
||||
auto print_host_test = [this](wxWindow* parent) {
|
||||
// auto btn = m_print_host_test_btn = new wxButton(parent, wxID_ANY, _(L("Test")),
|
||||
// wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT);
|
||||
// btn->SetBitmap(create_scaled_bitmap(this, "wrench.png"));
|
||||
add_scaled_button(parent, &m_print_host_test_btn, "wrench_white", _(L("Test")), wxBU_LEFT | wxBU_EXACTFIT);
|
||||
PrusaButton* btn = m_print_host_test_btn;
|
||||
btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
|
||||
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
sizer->Add(btn);
|
||||
|
||||
@ -1774,9 +1841,13 @@ void TabPrinter::build_fff()
|
||||
|
||||
Line line = optgroup->create_single_option_line("bed_shape");//{ _(L("Bed shape")), "" };
|
||||
line.widget = [this](wxWindow* parent) {
|
||||
auto btn = new wxButton(parent, wxID_ANY, _(L(" Set "))+dots, wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT);
|
||||
btn->SetFont(wxGetApp().small_font());
|
||||
btn->SetBitmap(create_scaled_bitmap(this, "printer"));
|
||||
// auto btn = new wxButton(parent, wxID_ANY, _(L(" Set "))+dots, wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT);
|
||||
// btn->SetFont(wxGetApp().small_font());
|
||||
// btn->SetBitmap(create_scaled_bitmap(this, "printer"));
|
||||
|
||||
PrusaButton* btn;
|
||||
add_scaled_button(parent, &btn, "printer_white", _(L(" Set ")) + dots, wxBU_LEFT | wxBU_EXACTFIT);
|
||||
btn->SetFont(wxGetApp().normal_font());
|
||||
|
||||
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
sizer->Add(btn);
|
||||
@ -1903,8 +1974,8 @@ void TabPrinter::build_fff()
|
||||
optgroup->append_single_option_line("use_volumetric_e");
|
||||
optgroup->append_single_option_line("variable_layer_height");
|
||||
|
||||
const int gcode_field_height = 15 * m_em_unit; // 150
|
||||
const int notes_field_height = 25 * m_em_unit; // 250
|
||||
const int gcode_field_height = 15; // 150
|
||||
const int notes_field_height = 25; // 250
|
||||
page = add_options_page(_(L("Custom G-code")), "cog");
|
||||
optgroup = page->new_optgroup(_(L("Start G-code")), 0);
|
||||
option = optgroup->get_option("start_gcode");
|
||||
@ -1975,9 +2046,14 @@ void TabPrinter::build_sla()
|
||||
|
||||
Line line = optgroup->create_single_option_line("bed_shape");//{ _(L("Bed shape")), "" };
|
||||
line.widget = [this](wxWindow* parent) {
|
||||
auto btn = new wxButton(parent, wxID_ANY, _(L(" Set ")) + dots, wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT);
|
||||
btn->SetFont(wxGetApp().small_font());
|
||||
btn->SetBitmap(create_scaled_bitmap(this, "printer"));
|
||||
// auto btn = new wxButton(parent, wxID_ANY, _(L(" Set ")) + dots, wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT);
|
||||
// btn->SetFont(wxGetApp().small_font());
|
||||
// btn->SetBitmap(create_scaled_bitmap(this, "printer"));
|
||||
|
||||
PrusaButton* btn;
|
||||
add_scaled_button(parent, &btn, "printer_white", _(L(" Set ")) + dots, wxBU_LEFT | wxBU_EXACTFIT);
|
||||
btn->SetFont(wxGetApp().normal_font());
|
||||
|
||||
|
||||
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
sizer->Add(btn);
|
||||
@ -2033,7 +2109,7 @@ void TabPrinter::build_sla()
|
||||
optgroup = page->new_optgroup(_(L("Print Host upload")));
|
||||
build_printhost(optgroup.get());
|
||||
|
||||
const int notes_field_height = 25 * m_em_unit; // 250
|
||||
const int notes_field_height = 25; // 250
|
||||
|
||||
page = add_options_page(_(L("Notes")), "note.png");
|
||||
optgroup = page->new_optgroup(_(L("Notes")), 0);
|
||||
@ -2088,12 +2164,12 @@ PageShp TabPrinter::build_kinematics_page()
|
||||
// Legend for OptionsGroups
|
||||
auto optgroup = page->new_optgroup("");
|
||||
optgroup->set_show_modified_btns_val(false);
|
||||
optgroup->label_width = 23 * m_em_unit;// 230;
|
||||
optgroup->label_width = 23;// 230;
|
||||
auto line = Line{ "", "" };
|
||||
|
||||
ConfigOptionDef def;
|
||||
def.type = coString;
|
||||
def.width = 150;
|
||||
def.width = 15;
|
||||
def.gui_type = "legend";
|
||||
def.mode = comAdvanced;
|
||||
def.tooltip = L("Values in this column are for Full Power mode");
|
||||
@ -2887,7 +2963,7 @@ void Tab::toggle_show_hide_incompatible()
|
||||
|
||||
void Tab::update_show_hide_incompatible_button()
|
||||
{
|
||||
m_btn_hide_incompatible_presets->SetBitmap(m_show_incompatible_presets ?
|
||||
m_btn_hide_incompatible_presets->SetBitmap_(m_show_incompatible_presets ?
|
||||
m_bmp_show_incompatible_presets : m_bmp_hide_incompatible_presets);
|
||||
m_btn_hide_incompatible_presets->SetToolTip(m_show_incompatible_presets ?
|
||||
"Both compatible an incompatible presets are shown. Click to hide presets not compatible with the current printer." :
|
||||
@ -2919,10 +2995,11 @@ wxSizer* Tab::compatible_widget_create(wxWindow* parent, PresetDependencies &dep
|
||||
{
|
||||
deps.checkbox = new wxCheckBox(parent, wxID_ANY, _(L("All")));
|
||||
deps.checkbox->SetFont(Slic3r::GUI::wxGetApp().normal_font());
|
||||
deps.btn = new wxButton(parent, wxID_ANY, _(L(" Set "))+dots, wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT);
|
||||
deps.btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
|
||||
// deps.btn = new wxButton(parent, wxID_ANY, _(L(" Set "))+dots, wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT);
|
||||
add_scaled_button(parent, &deps.btn, "printer_white", _(L(" Set ")) + dots, wxBU_LEFT | wxBU_EXACTFIT);
|
||||
deps.btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
|
||||
|
||||
deps.btn->SetBitmap(create_scaled_bitmap(this, "printer"));
|
||||
// deps.btn->SetBitmap(create_scaled_bitmap(this, "printer"));
|
||||
|
||||
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
sizer->Add((deps.checkbox), 0, wxALIGN_CENTER_VERTICAL);
|
||||
@ -3079,6 +3156,12 @@ void Page::update_visibility(ConfigOptionMode mode)
|
||||
m_show = ret_val;
|
||||
}
|
||||
|
||||
void Page::rescale()
|
||||
{
|
||||
for (auto group : m_optgroups)
|
||||
group->rescale();
|
||||
}
|
||||
|
||||
Field* Page::get_field(const t_config_option_key& opt_key, int opt_index /*= -1*/) const
|
||||
{
|
||||
Field* field = nullptr;
|
||||
@ -3102,18 +3185,23 @@ bool Page::set_value(const t_config_option_key& opt_key, const boost::any& value
|
||||
// package Slic3r::GUI::Tab::Page;
|
||||
ConfigOptionsGroupShp Page::new_optgroup(const wxString& title, int noncommon_label_width /*= -1*/)
|
||||
{
|
||||
auto extra_column = [](wxWindow* parent, const Line& line)
|
||||
auto extra_column = [this](wxWindow* parent, const Line& line)
|
||||
{
|
||||
std::string bmp_name;
|
||||
const std::vector<Option>& options = line.get_options();
|
||||
if (options.size() == 0 || options[0].opt.gui_type == "legend")
|
||||
bmp_name = "";// "error.png";
|
||||
else {
|
||||
auto mode = options[0].opt.mode; //we assume that we have one option per line
|
||||
bmp_name = mode == comExpert ? "mode_expert_.png" :
|
||||
mode == comAdvanced ? "mode_middle_.png" : "mode_simple_.png";
|
||||
}
|
||||
auto bmp = new wxStaticBitmap(parent, wxID_ANY, bmp_name.empty() ? wxNullBitmap : create_scaled_bitmap(parent, bmp_name));
|
||||
// if (options.size() == 0 || options[0].opt.gui_type == "legend")
|
||||
// bmp_name = "";
|
||||
// else {
|
||||
// auto mode = options[0].opt.mode; //we assume that we have one option per line
|
||||
// bmp_name = mode == comExpert ? "mode_expert_.png" :
|
||||
// mode == comAdvanced ? "mode_middle_.png" : "mode_simple_.png";
|
||||
// }
|
||||
// auto bmp = new wxStaticBitmap(parent, wxID_ANY, bmp_name.empty() ? wxNullBitmap : create_scaled_bitmap(parent, bmp_name));
|
||||
const wxBitmap& bitmap = options.size() == 0 || options[0].opt.gui_type == "legend" ? wxNullBitmap :
|
||||
m_mode_bitmap_cache[int(options[0].opt.mode)].bmp();
|
||||
auto bmp = new wxStaticBitmap(parent, wxID_ANY, bitmap);
|
||||
bmp->SetClientData((void*)options[0].opt.mode);
|
||||
|
||||
bmp->SetBackgroundStyle(wxBG_STYLE_PAINT);
|
||||
return bmp;
|
||||
};
|
||||
@ -3152,6 +3240,14 @@ ConfigOptionsGroupShp Page::new_optgroup(const wxString& title, int noncommon_la
|
||||
return static_cast<Tab*>(tab)->m_presets->get_selected_preset_parent() != nullptr;
|
||||
};
|
||||
|
||||
optgroup->rescale_extra_column = [this](wxWindow* win) {
|
||||
auto *ctrl = dynamic_cast<wxStaticBitmap*>(win);
|
||||
if (ctrl == nullptr)
|
||||
return;
|
||||
|
||||
ctrl->SetBitmap(m_mode_bitmap_cache[reinterpret_cast<int>(ctrl->GetClientData())].bmp());
|
||||
};
|
||||
|
||||
vsizer()->Add(optgroup->sizer, 0, wxEXPAND | wxALL, 10);
|
||||
m_optgroups.push_back(optgroup);
|
||||
|
||||
@ -3232,7 +3328,7 @@ void TabSLAMaterial::build()
|
||||
optgroup->append_single_option_line("initial_exposure_time");
|
||||
|
||||
optgroup = page->new_optgroup(_(L("Corrections")));
|
||||
optgroup->label_width = 19 * m_em_unit;//190;
|
||||
optgroup->label_width = 19;//190;
|
||||
std::vector<std::string> corrections = {"material_correction"};
|
||||
std::vector<std::string> axes{ "X", "Y", "Z" };
|
||||
for (auto& opt_key : corrections) {
|
||||
@ -3241,7 +3337,7 @@ void TabSLAMaterial::build()
|
||||
for (auto& axis : axes) {
|
||||
auto opt = optgroup->get_option(opt_key, id);
|
||||
opt.opt.label = axis;
|
||||
opt.opt.width = 60;
|
||||
opt.opt.width = 6;
|
||||
line.append_option(opt);
|
||||
++id;
|
||||
}
|
||||
@ -3253,7 +3349,7 @@ void TabSLAMaterial::build()
|
||||
optgroup->label_width = 0;
|
||||
Option option = optgroup->get_option("material_notes");
|
||||
option.opt.full_width = true;
|
||||
option.opt.height = 25 * m_em_unit;//250;
|
||||
option.opt.height = 25;//250;
|
||||
optgroup->append_single_option_line(option);
|
||||
|
||||
page = add_options_page(_(L("Dependencies")), "wrench.png");
|
||||
|
@ -30,14 +30,14 @@
|
||||
|
||||
#include "BedShapeDialog.hpp"
|
||||
#include "Event.hpp"
|
||||
|
||||
class PrusaModeSizer;
|
||||
#include "wxExtensions.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
typedef std::pair<wxBitmap*, std::string> t_icon_description;
|
||||
typedef std::vector<std::pair<wxBitmap*, std::string>> t_icon_descriptions;
|
||||
|
||||
typedef std::pair</*wxBitmap*/PrusaBitmap*, std::string> t_icon_description;
|
||||
typedef std::vector<std::pair</*wxBitmap*/PrusaBitmap*, std::string>> t_icon_descriptions;
|
||||
|
||||
// Single Tab page containing a{ vsizer } of{ optgroups }
|
||||
// package Slic3r::GUI::Tab::Page;
|
||||
@ -50,10 +50,11 @@ class Page : public wxScrolledWindow
|
||||
wxBoxSizer* m_vsizer;
|
||||
bool m_show = true;
|
||||
public:
|
||||
Page(wxWindow* parent, const wxString title, const int iconID) :
|
||||
Page(wxWindow* parent, const wxString title, const int iconID, const std::vector<PrusaBitmap>& mode_bmp_cache) :
|
||||
m_parent(parent),
|
||||
m_title(title),
|
||||
m_iconID(iconID)
|
||||
m_iconID(iconID),
|
||||
m_mode_bitmap_cache(mode_bmp_cache)
|
||||
{
|
||||
Create(m_parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
|
||||
m_vsizer = new wxBoxSizer(wxVERTICAL);
|
||||
@ -67,6 +68,7 @@ public:
|
||||
|
||||
// Delayed layout after resizing the main window.
|
||||
bool layout_valid = false;
|
||||
const std::vector<PrusaBitmap>& m_mode_bitmap_cache;
|
||||
|
||||
public:
|
||||
std::vector <ConfigOptionsGroupShp> m_optgroups;
|
||||
@ -79,6 +81,7 @@ public:
|
||||
void set_config(DynamicPrintConfig* config_in) { m_config = config_in; }
|
||||
void reload_config();
|
||||
void update_visibility(ConfigOptionMode mode);
|
||||
void rescale();
|
||||
Field* get_field(const t_config_option_key& opt_key, int opt_index = -1) const;
|
||||
bool set_value(const t_config_option_key& opt_key, const boost::any& value);
|
||||
ConfigOptionsGroupShp new_optgroup(const wxString& title, int noncommon_label_width = -1);
|
||||
@ -119,9 +122,9 @@ protected:
|
||||
std::string m_name;
|
||||
const wxString m_title;
|
||||
wxBitmapComboBox* m_presets_choice;
|
||||
wxBitmapButton* m_btn_save_preset;
|
||||
wxBitmapButton* m_btn_delete_preset;
|
||||
wxBitmapButton* m_btn_hide_incompatible_presets;
|
||||
/*wxBitmap*/PrusaButton* m_btn_save_preset;
|
||||
/*wxBitmap*/PrusaButton* m_btn_delete_preset;
|
||||
/*wxBitmap*/PrusaButton* m_btn_hide_incompatible_presets;
|
||||
wxBoxSizer* m_hsizer;
|
||||
wxBoxSizer* m_left_sizer;
|
||||
wxTreeCtrl* m_treectrl;
|
||||
@ -132,7 +135,7 @@ protected:
|
||||
struct PresetDependencies {
|
||||
Preset::Type type = Preset::TYPE_INVALID;
|
||||
wxCheckBox *checkbox = nullptr;
|
||||
wxButton *btn = nullptr;
|
||||
/*wxButton*/PrusaButton *btn = nullptr;
|
||||
std::string key_list; // "compatible_printers"
|
||||
std::string key_condition;
|
||||
std::string dialog_title;
|
||||
@ -141,25 +144,27 @@ protected:
|
||||
PresetDependencies m_compatible_printers;
|
||||
PresetDependencies m_compatible_prints;
|
||||
|
||||
wxButton* m_undo_btn;
|
||||
wxButton* m_undo_to_sys_btn;
|
||||
wxButton* m_question_btn;
|
||||
wxImageList* m_preset_icons;
|
||||
/*wxButton*/PrusaButton* m_undo_btn;
|
||||
/*wxButton*/PrusaButton* m_undo_to_sys_btn;
|
||||
/*wxButton*/PrusaButton* m_question_btn;
|
||||
|
||||
// Cached bitmaps.
|
||||
// A "flag" icon to be displayned next to the preset name in the Tab's combo box.
|
||||
wxBitmap m_bmp_show_incompatible_presets;
|
||||
wxBitmap m_bmp_hide_incompatible_presets;
|
||||
/*wxBitmap*/PrusaBitmap m_bmp_show_incompatible_presets;
|
||||
/*wxBitmap*/PrusaBitmap m_bmp_hide_incompatible_presets;
|
||||
// Bitmaps to be shown on the "Revert to system" aka "Lock to system" button next to each input field.
|
||||
wxBitmap m_bmp_value_lock;
|
||||
wxBitmap m_bmp_value_unlock;
|
||||
wxBitmap m_bmp_white_bullet;
|
||||
/*wxBitmap*/PrusaBitmap m_bmp_value_lock;
|
||||
/*wxBitmap*/PrusaBitmap m_bmp_value_unlock;
|
||||
/*wxBitmap*/PrusaBitmap m_bmp_white_bullet;
|
||||
// The following bitmap points to either m_bmp_value_unlock or m_bmp_white_bullet, depending on whether the current preset has a parent preset.
|
||||
wxBitmap *m_bmp_non_system;
|
||||
/*wxBitmap*/PrusaBitmap *m_bmp_non_system;
|
||||
// Bitmaps to be shown on the "Undo user changes" button next to each input field.
|
||||
wxBitmap m_bmp_value_revert;
|
||||
// wxBitmap m_bmp_value_unmodified;
|
||||
wxBitmap m_bmp_question;
|
||||
/*wxBitmap*/PrusaBitmap m_bmp_value_revert;
|
||||
|
||||
std::vector<PrusaButton*> m_scaled_buttons = {};
|
||||
std::vector<PrusaBitmap*> m_scaled_bitmaps = {};
|
||||
std::vector<PrusaBitmap> m_scaled_icons_list = {};
|
||||
std::vector<PrusaBitmap> m_mode_bitmap_cache = {};
|
||||
|
||||
// Colors for ui "decoration"
|
||||
wxColour m_sys_label_clr;
|
||||
@ -236,7 +241,11 @@ public:
|
||||
virtual bool supports_printer_technology(const PrinterTechnology tech) = 0;
|
||||
|
||||
void create_preset_tab();
|
||||
void load_current_preset();
|
||||
void add_scaled_button(wxWindow* parent, PrusaButton** btn, const std::string& icon_name,
|
||||
const wxString& label = wxEmptyString,
|
||||
long style = wxBU_EXACTFIT | wxNO_BORDER);
|
||||
void add_scaled_bitmap(wxWindow* parent, PrusaBitmap& btn, const std::string& icon_name);
|
||||
void load_current_preset();
|
||||
void rebuild_page_tree();
|
||||
void update_page_tree_visibility();
|
||||
// Select a new preset, possibly delete the current one.
|
||||
@ -346,8 +355,8 @@ class TabPrinter : public Tab
|
||||
void build_printhost(ConfigOptionsGroup *optgroup);
|
||||
public:
|
||||
wxButton* m_serial_test_btn = nullptr;
|
||||
wxButton* m_print_host_test_btn = nullptr;
|
||||
wxButton* m_printhost_browse_btn = nullptr;
|
||||
/*wxButton*/PrusaButton* m_print_host_test_btn = nullptr;
|
||||
/*wxButton*/PrusaButton* m_printhost_browse_btn = nullptr;
|
||||
|
||||
size_t m_extruders_count;
|
||||
size_t m_extruders_count_old = 0;
|
||||
|
@ -2394,22 +2394,23 @@ void PrusaLockButton::enter_button(const bool enter)
|
||||
|
||||
PrusaModeButton::PrusaModeButton( wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const std::string& icon_name/* = ""*/,
|
||||
const wxString& mode/* = wxEmptyString*/,
|
||||
const wxBitmap& bmp_on/* = wxNullBitmap*/,
|
||||
const wxSize& size/* = wxDefaultSize*/,
|
||||
const wxPoint& pos/* = wxDefaultPosition*/) :
|
||||
wxButton(parent, id, mode, pos, wxDefaultSize/*size*/, wxBU_EXACTFIT | wxNO_BORDER),
|
||||
m_bmp_on(bmp_on)
|
||||
// wxButton(parent, id, mode, pos, wxDefaultSize/*size*/, wxBU_EXACTFIT | wxNO_BORDER),
|
||||
PrusaButton(parent, id, icon_name, mode, size, pos)
|
||||
// m_bmp_on(bmp_on)
|
||||
{
|
||||
#ifdef __WXMSW__
|
||||
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||
#endif // __WXMSW__
|
||||
m_bmp_off = create_scaled_bitmap(this, "mode_off_sq.png");
|
||||
// #ifdef __WXMSW__
|
||||
// SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||
// #endif // __WXMSW__
|
||||
// m_bmp_off = create_scaled_bitmap(this, "mode_off_sq.png");
|
||||
|
||||
m_tt_focused = wxString::Format(_(L("Switch to the %s mode")), mode);
|
||||
m_tt_selected = wxString::Format(_(L("Current mode is %s")), mode);
|
||||
|
||||
SetBitmap(m_bmp_on);
|
||||
// SetBitmap(m_bmp_on);
|
||||
|
||||
//button events
|
||||
Bind(wxEVT_BUTTON, &PrusaModeButton::OnButton, this);
|
||||
@ -2457,19 +2458,19 @@ PrusaModeSizer::PrusaModeSizer(wxWindow *parent, int hgap/* = 10*/) :
|
||||
{
|
||||
SetFlexibleDirection(wxHORIZONTAL);
|
||||
|
||||
std::vector<std::pair<wxString, wxBitmap>> buttons = {
|
||||
{_(L("Simple")), create_scaled_bitmap(parent, "mode_simple_sq.png")},
|
||||
{_(L("Advanced")), create_scaled_bitmap(parent, "mode_middle_sq.png")},
|
||||
{_(L("Expert")), create_scaled_bitmap(parent, "mode_expert_sq.png")}
|
||||
std::vector < std::pair < wxString, std::string >> buttons = {
|
||||
{_(L("Simple")), /*create_scaled_bitmap(parent, */"mode_simple_sq.png"/*)*/},
|
||||
{_(L("Advanced")), /*create_scaled_bitmap(parent, */"mode_middle_sq.png"/*)*/},
|
||||
{_(L("Expert")), /*create_scaled_bitmap(parent, */"mode_expert_sq.png"/*)*/}
|
||||
};
|
||||
|
||||
mode_btns.reserve(3);
|
||||
for (const auto& button : buttons) {
|
||||
int x, y;
|
||||
parent->GetTextExtent(button.first, &x, &y, nullptr, nullptr, &Slic3r::GUI::wxGetApp().bold_font());
|
||||
const wxSize size = wxSize(x + button.second.GetWidth() + Slic3r::GUI::wxGetApp().em_unit(),
|
||||
y + Slic3r::GUI::wxGetApp().em_unit());
|
||||
mode_btns.push_back(new PrusaModeButton(parent, wxID_ANY, button.first, button.second, size));
|
||||
// int x, y;
|
||||
// parent->GetTextExtent(button.first, &x, &y, nullptr, nullptr, &Slic3r::GUI::wxGetApp().bold_font());
|
||||
// const wxSize size = wxSize(x + button.second.GetWidth() + Slic3r::GUI::wxGetApp().em_unit(),
|
||||
// y + Slic3r::GUI::wxGetApp().em_unit());
|
||||
mode_btns.push_back(new PrusaModeButton(parent, wxID_ANY, button.second, button.first/*, size*/));
|
||||
}
|
||||
|
||||
for (auto btn : mode_btns)
|
||||
@ -2498,6 +2499,12 @@ void PrusaModeSizer::SetMode(const int mode)
|
||||
}
|
||||
|
||||
|
||||
void PrusaModeSizer::rescale()
|
||||
{
|
||||
for (int m = 0; m < mode_btns.size(); m++)
|
||||
mode_btns[m]->rescale();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// PrusaMenu
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -2516,9 +2523,78 @@ void PrusaMenu::DestroySeparators()
|
||||
}
|
||||
|
||||
|
||||
// ************************************** EXPERIMENTS ***************************************
|
||||
// ----------------------------------------------------------------------------
|
||||
// PrusaBitmap
|
||||
// ----------------------------------------------------------------------------
|
||||
PrusaBitmap::PrusaBitmap(wxWindow *parent,
|
||||
const std::string& icon_name/* = ""*/):
|
||||
m_parent(parent), m_icon_name(icon_name)
|
||||
{
|
||||
m_bmp = create_scaled_bitmap(parent, icon_name);
|
||||
}
|
||||
|
||||
|
||||
void PrusaBitmap::rescale()
|
||||
{
|
||||
m_bmp = create_scaled_bitmap(m_parent, m_icon_name);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// PrusaButton
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
PrusaButton::PrusaButton(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const std::string& icon_name/*= ""*/,
|
||||
const wxString& label /* = wxEmptyString*/,
|
||||
const wxSize& size /* = wxDefaultSize*/,
|
||||
const wxPoint& pos /* = wxDefaultPosition*/,
|
||||
long style /*= wxBU_EXACTFIT | wxNO_BORDER*/) :
|
||||
m_current_icon_name(icon_name),
|
||||
m_parent(parent)
|
||||
{
|
||||
const wxBitmap bmp = create_scaled_bitmap(parent, icon_name);
|
||||
Create(parent, id, label, pos, size, style);
|
||||
#ifdef __WXMSW__
|
||||
if (style & wxNO_BORDER)
|
||||
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||
#endif // __WXMSW__
|
||||
|
||||
SetBitmap(bmp);
|
||||
}
|
||||
|
||||
|
||||
PrusaButton::PrusaButton(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const PrusaBitmap& bitmap,
|
||||
const wxString& label /*= wxEmptyString*/,
|
||||
long style /*= wxBU_EXACTFIT | wxNO_BORDER*/) :
|
||||
m_current_icon_name(bitmap.name()),
|
||||
m_parent(parent)
|
||||
{
|
||||
const wxBitmap& bmp = bitmap.bmp();
|
||||
Create(parent, id, label, wxDefaultPosition, wxDefaultSize, style);
|
||||
#ifdef __WXMSW__
|
||||
if (style & wxNO_BORDER)
|
||||
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||
#endif // __WXMSW__
|
||||
|
||||
SetBitmap(bmp);
|
||||
}
|
||||
|
||||
void PrusaButton::SetBitmap_(const PrusaBitmap& bmp)
|
||||
{
|
||||
SetBitmap(bmp.bmp());
|
||||
m_current_icon_name = bmp.name();
|
||||
}
|
||||
|
||||
void PrusaButton::rescale()
|
||||
{
|
||||
const wxBitmap bmp = create_scaled_bitmap(m_parent, m_current_icon_name);
|
||||
|
||||
SetBitmap(bmp);
|
||||
}
|
||||
|
||||
// *****************************************************************************
|
||||
|
||||
|
||||
|
||||
|
@ -882,18 +882,79 @@ private:
|
||||
};
|
||||
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// PrusaBitmap
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class PrusaBitmap
|
||||
{
|
||||
public:
|
||||
PrusaBitmap() {};
|
||||
PrusaBitmap( wxWindow *parent, const std::string& icon_name = "");
|
||||
|
||||
~PrusaBitmap() {}
|
||||
|
||||
void rescale();
|
||||
|
||||
const wxBitmap& bmp() const { return m_bmp; }
|
||||
const std::string& name() const { return m_icon_name; }
|
||||
|
||||
private:
|
||||
wxWindow* m_parent {nullptr};
|
||||
wxBitmap m_bmp;
|
||||
std::string m_icon_name = "";
|
||||
};
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// PrusaButton
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class PrusaButton : public wxButton
|
||||
{
|
||||
public:
|
||||
PrusaButton(){}
|
||||
PrusaButton(
|
||||
wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const std::string& icon_name = "",
|
||||
const wxString& label = wxEmptyString,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
long style = wxBU_EXACTFIT | wxNO_BORDER);
|
||||
|
||||
PrusaButton(
|
||||
wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const PrusaBitmap& bitmap,
|
||||
const wxString& label = wxEmptyString,
|
||||
long style = wxBU_EXACTFIT | wxNO_BORDER);
|
||||
|
||||
~PrusaButton() {}
|
||||
|
||||
void SetBitmap_(const PrusaBitmap& bmp);
|
||||
|
||||
void rescale();
|
||||
|
||||
private:
|
||||
wxWindow* m_parent;
|
||||
std::string m_current_icon_name = "";
|
||||
};
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// PrusaModeButton
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class PrusaModeButton : public wxButton
|
||||
class PrusaModeButton : public PrusaButton/*wxButton*/
|
||||
{
|
||||
public:
|
||||
PrusaModeButton(
|
||||
wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const std::string& icon_name = "",
|
||||
const wxString& mode = wxEmptyString,
|
||||
const wxBitmap& bmp_on = wxNullBitmap,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
const wxPoint& pos = wxDefaultPosition);
|
||||
~PrusaModeButton() {}
|
||||
@ -910,8 +971,8 @@ protected:
|
||||
private:
|
||||
bool m_is_selected = false;
|
||||
|
||||
wxBitmap m_bmp_on;
|
||||
wxBitmap m_bmp_off;
|
||||
// wxBitmap m_bmp_on;
|
||||
// wxBitmap m_bmp_off;
|
||||
wxString m_tt_selected;
|
||||
wxString m_tt_focused;
|
||||
};
|
||||
@ -930,6 +991,8 @@ public:
|
||||
|
||||
void SetMode(const /*ConfigOptionMode*/int mode);
|
||||
|
||||
void rescale();
|
||||
|
||||
private:
|
||||
std::vector<PrusaModeButton*> mode_btns;
|
||||
};
|
||||
@ -958,8 +1021,5 @@ public:
|
||||
};
|
||||
|
||||
|
||||
// ******************************* EXPERIMENTS **********************************************
|
||||
// ******************************************************************************************
|
||||
|
||||
|
||||
#endif // slic3r_GUI_wxExtensions_hpp_
|
||||
|
Loading…
Reference in New Issue
Block a user