mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-12 01:07:57 -06:00
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
22 changed files with 737 additions and 250 deletions
|
@ -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; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue