Big Refactoring: - deleted/renamed all _Prusa_ prefixes,

- cleaned code from commented parts
 - rescale() -> msw_rescale()
This commit is contained in:
YuSanka 2019-04-25 01:45:00 +02:00
parent be60f0a53c
commit 065448e9e5
32 changed files with 726 additions and 1139 deletions

View file

@ -45,9 +45,8 @@ AboutDialog::AboutDialog()
main_sizer->Add(hsizer, 0, wxEXPAND | wxALL, 20);
// logo
m_logo_bitmap = PrusaBitmap(this, "Slic3r_192px.png", 192);
m_logo_bitmap = ScalableBitmap(this, "Slic3r_192px.png", 192);
m_logo = new wxStaticBitmap(this, wxID_ANY, m_logo_bitmap.bmp());
// auto *logo = new wxStaticBitmap(this, wxID_ANY, create_scaled_bitmap(this, "Slic3r_192px.png", 192));
hsizer->Add(m_logo, 1, wxALIGN_CENTER_VERTICAL);
wxBoxSizer* vsizer = new wxBoxSizer(wxVERTICAL);
@ -56,8 +55,7 @@ AboutDialog::AboutDialog()
// title
{
wxStaticText* title = new wxStaticText(this, wxID_ANY, SLIC3R_APP_NAME, wxDefaultPosition, wxDefaultSize);
wxFont title_font = GUI::wxGetApp().bold_font();// wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
// title_font.SetWeight(wxFONTWEIGHT_BOLD);
wxFont title_font = GUI::wxGetApp().bold_font();
title_font.SetFamily(wxFONTFAMILY_ROMAN);
title_font.SetPointSize(24);
title->SetFont(title_font);
@ -68,9 +66,9 @@ AboutDialog::AboutDialog()
{
auto version_string = _(L("Version"))+ " " + std::string(SLIC3R_VERSION);
wxStaticText* version = new wxStaticText(this, wxID_ANY, version_string.c_str(), wxDefaultPosition, wxDefaultSize);
wxFont version_font = GetFont();//wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
wxFont version_font = GetFont();
#ifdef __WXMSW__
version_font.SetPointSize(/*9*/version_font.GetPointSize()-1);
version_font.SetPointSize(version_font.GetPointSize()-1);
#else
version_font.SetPointSize(11);
#endif
@ -82,7 +80,7 @@ AboutDialog::AboutDialog()
m_html = new wxHtmlWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO/*NEVER*/);
{
m_html->SetMinSize(wxSize(-1, 16 * wxGetApp().em_unit()));
wxFont font = GetFont();//GUI::wxGetApp().normal_font(); // wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
wxFont font = GetFont();
const auto text_clr = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
auto text_clr_str = wxString::Format(wxT("#%02X%02X%02X"), text_clr.Red(), text_clr.Green(), text_clr.Blue());
auto bgr_clr_str = wxString::Format(wxT("#%02X%02X%02X"), bgr_clr.Red(), bgr_clr.Green(), bgr_clr.Blue());
@ -125,7 +123,7 @@ AboutDialog::AboutDialog()
void AboutDialog::on_dpi_changed(const wxRect &suggested_rect)
{
m_logo_bitmap.rescale();
m_logo_bitmap.msw_rescale();
m_logo->SetBitmap(m_logo_bitmap.bmp());
const wxFont& font = GetFont();

View file

@ -25,7 +25,7 @@ private:
class AboutDialog : public DPIDialog
{
PrusaBitmap m_logo_bitmap;
ScalableBitmap m_logo_bitmap;
wxHtmlWindow* m_html;
wxStaticBitmap* m_logo;
public:

View file

@ -43,7 +43,7 @@ void BedShapeDialog::on_dpi_changed(const wxRect &suggested_rect)
m_panel->m_shape_options_book->SetMinSize(wxSize(25 * em, -1));
for (auto og : m_panel->m_optgroups)
og->rescale();
og->msw_rescale();
const wxSize& size = wxSize(50 * em, -1);

View file

@ -4,12 +4,12 @@
#include <wx/dialog.h>
#include <vector>
class PrusaBitmap;
class ScalableBitmap;
namespace Slic3r {
namespace GUI {
using t_icon_descriptions = std::vector<std::pair</*wxBitmap*/PrusaBitmap*, std::string>>;
using t_icon_descriptions = std::vector<std::pair<ScalableBitmap*, std::string>>;
class ButtonsDescription : public wxDialog
{
@ -17,8 +17,6 @@ class ButtonsDescription : public wxDialog
public:
ButtonsDescription(wxWindow* parent, t_icon_descriptions* icon_descriptions);
~ButtonsDescription() {}
};
} // GUI

View file

@ -648,10 +648,10 @@ ConfigWizardIndex::ConfigWizardIndex(wxWindow *parent)
, bullet_blue(GUI::from_u8(Slic3r::var("bullet_blue.png")), wxBITMAP_TYPE_PNG)
, bullet_white(GUI::from_u8(Slic3r::var("bullet_white.png")), wxBITMAP_TYPE_PNG)
*/
, bg(PrusaBitmap(parent, "Slic3r_192px_transparent.png", 192))
, bullet_black(PrusaBitmap(parent, "bullet_black.png"))
, bullet_blue(PrusaBitmap(parent, "bullet_blue.png"))
, bullet_white(PrusaBitmap(parent, "bullet_white.png"))
, bg(ScalableBitmap(parent, "Slic3r_192px_transparent.png", 192))
, bullet_black(ScalableBitmap(parent, "bullet_black.png"))
, bullet_blue(ScalableBitmap(parent, "bullet_blue.png"))
, bullet_white(ScalableBitmap(parent, "bullet_white.png"))
, item_active(0)
, item_hover(-1)
, last_page((size_t)-1)
@ -839,15 +839,15 @@ void ConfigWizardIndex::on_mouse_move(wxMouseEvent &evt)
evt.Skip();
}
void ConfigWizardIndex::rescale()
void ConfigWizardIndex::msw_rescale()
{
bg.rescale();
bg.msw_rescale();
SetMinSize(bg.bmp().GetSize());
logo->SetBitmap(bg.bmp());
bullet_black.rescale();
bullet_blue.rescale();
bullet_white.rescale();
bullet_black.msw_rescale();
bullet_blue.msw_rescale();
bullet_white.msw_rescale();
Refresh();
}
@ -1174,7 +1174,7 @@ const wxString& ConfigWizard::name(const bool from_menu/* = false*/)
void ConfigWizard::on_dpi_changed(const wxRect &suggested_rect)
{
p->index->rescale();
p->index->msw_rescale();
Refresh();
}

View file

@ -210,7 +210,7 @@ public:
void go_to(ConfigWizardPage *page);
void clear();
void rescale();
void msw_rescale();
int em() const { return em_w; }
private:
@ -231,10 +231,10 @@ private:
const wxBitmap bullet_blue;
const wxBitmap bullet_white;
*/
PrusaBitmap bg;
PrusaBitmap bullet_black;
PrusaBitmap bullet_blue;
PrusaBitmap bullet_white;
ScalableBitmap bg;
ScalableBitmap bullet_black;
ScalableBitmap bullet_blue;
ScalableBitmap bullet_white;
wxStaticBitmap* logo;
std::vector<Item> items;

View file

@ -33,22 +33,12 @@ 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 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 = new RevertButton(m_parent, "bullet_white.png");
m_Undo_to_sys_btn = new RevertButton(m_parent, "bullet_white.png");
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 = create_scaled_bitmap(m_parent, "bullet_white.png" );
// set_undo_bitmap(&bmp);
// set_undo_to_sys_bitmap(&bmp);
switch (m_opt.type)
{
case coPercents:
@ -360,9 +350,9 @@ boost::any& TextCtrl::get_value()
return m_value;
}
void TextCtrl::rescale()
void TextCtrl::msw_rescale()
{
Field::rescale();
Field::msw_rescale();
auto size = wxSize(wxDefaultSize);
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);
@ -523,9 +513,9 @@ void SpinCtrl::propagate_value()
on_change_field();
}
void SpinCtrl::rescale()
void SpinCtrl::msw_rescale()
{
Field::rescale();
Field::msw_rescale();
wxSpinCtrl* field = dynamic_cast<wxSpinCtrl*>(window);
field->SetMinSize(wxSize(-1, int(1.9f*field->GetFont().GetPixelSize().y)));
@ -843,9 +833,9 @@ boost::any& Choice::get_value()
return m_value;
}
void Choice::rescale()
void Choice::msw_rescale()
{
Field::rescale();
Field::msw_rescale();
wxBitmapComboBox* field = dynamic_cast<wxBitmapComboBox*>(window);
@ -967,9 +957,9 @@ void PointCtrl::BUILD()
y_textctrl->SetToolTip(get_tooltip_text(X+", "+Y));
}
void PointCtrl::rescale()
void PointCtrl::msw_rescale()
{
Field::rescale();
Field::msw_rescale();
const wxSize field_size(4 * m_em_unit, -1);
@ -1037,9 +1027,9 @@ void StaticText::BUILD()
temp->SetToolTip(get_tooltip_text(legend));
}
void StaticText::rescale()
void StaticText::msw_rescale()
{
Field::rescale();
Field::msw_rescale();
auto size = wxSize(wxDefaultSize);
if (m_opt.height >= 0) size.SetHeight(m_opt.height*m_em_unit);

View file

@ -37,7 +37,7 @@ using t_back_to_init = std::function<void(const std::string&)>;
wxString double_to_string(double const value, const int max_precision = 4);
class RevertButton : public /*wxButton*/PrusaButton
class RevertButton : public ScalableButton
{
bool hidden = false; // never show button if it's hidden ones
public:
@ -54,7 +54,7 @@ public:
wxWindow *parent,
const std::string& icon_name = ""
) :
PrusaButton(parent, wxID_ANY, icon_name) {}
ScalableButton(parent, wxID_ANY, icon_name) {}
// overridden from wxWindow base class
virtual bool
@ -160,7 +160,7 @@ public:
return std::move(p); //!p;
}
bool set_undo_bitmap(const /*wxBitmap*/PrusaBitmap *bmp) {
bool set_undo_bitmap(const ScalableBitmap *bmp) {
if (m_undo_bitmap != bmp) {
m_undo_bitmap = bmp;
m_Undo_btn->SetBitmap_(*bmp);
@ -169,7 +169,7 @@ public:
return false;
}
bool set_undo_to_sys_bitmap(const /*wxBitmap*/PrusaBitmap *bmp) {
bool set_undo_to_sys_bitmap(const ScalableBitmap *bmp) {
if (m_undo_to_sys_bitmap != bmp) {
m_undo_to_sys_bitmap = bmp;
m_Undo_to_sys_btn->SetBitmap_(*bmp);
@ -217,9 +217,9 @@ public:
m_side_text = side_text;
}
virtual void rescale() {
m_Undo_to_sys_btn->rescale();
m_Undo_btn->rescale();
virtual void msw_rescale() {
m_Undo_to_sys_btn->msw_rescale();
m_Undo_btn->msw_rescale();
// update em_unit value
m_em_unit = em_unit(m_parent);
@ -228,11 +228,11 @@ public:
protected:
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*/PrusaBitmap* m_undo_bitmap = nullptr;
const ScalableBitmap* m_undo_bitmap = nullptr;
const wxString* m_undo_tooltip = 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*/PrusaBitmap* m_undo_to_sys_bitmap = nullptr;
const ScalableBitmap* m_undo_to_sys_bitmap = nullptr;
const wxString* m_undo_to_sys_tooltip = nullptr;
wxStaticText* m_Label = nullptr;
@ -290,7 +290,7 @@ public:
boost::any& get_value() override;
void rescale() override;
void msw_rescale() override;
virtual void enable();
virtual void disable();
@ -355,7 +355,7 @@ public:
return m_value = tmp_value;
}
void rescale() override;
void msw_rescale() override;
void enable() override { dynamic_cast<wxSpinCtrl*>(window)->Enable(); }
void disable() override { dynamic_cast<wxSpinCtrl*>(window)->Disable(); }
@ -384,7 +384,7 @@ public:
void set_values(const std::vector<std::string> &values);
boost::any& get_value() override;
void rescale() override;
void msw_rescale() override;
void enable() override { dynamic_cast<wxBitmapComboBox*>(window)->Enable(); };
void disable() override{ dynamic_cast<wxBitmapComboBox*>(window)->Disable(); };
@ -437,7 +437,7 @@ public:
void set_value(const boost::any& value, bool change_event = false);
boost::any& get_value() override;
void rescale() override;
void msw_rescale() override;
void enable() override {
x_textctrl->Enable();
@ -471,7 +471,7 @@ public:
boost::any& get_value()override { return m_value; }
void rescale() override;
void msw_rescale() override;
void enable() override { dynamic_cast<wxStaticText*>(window)->Enable(); };
void disable() override{ dynamic_cast<wxStaticText*>(window)->Disable(); };

View file

@ -3188,7 +3188,7 @@ double GLCanvas3D::get_size_proportional_to_max_bed_size(double factor) const
return factor * m_bed.get_bounding_box().max_size();
}
void GLCanvas3D::rescale()
void GLCanvas3D::msw_rescale()
{
m_warning_texture.rescale(*this);
}

View file

@ -594,7 +594,7 @@ public:
double get_size_proportional_to_max_bed_size(double factor) const;
void rescale();
void msw_rescale();
private:
bool _is_shown_on_screen() const;

View file

@ -163,7 +163,7 @@ void ObjectList::create_objects_ctrl()
m_sizer = new wxBoxSizer(wxVERTICAL);
m_sizer->Add(this, 1, wxGROW);
m_objects_model = new PrusaObjectDataViewModel;
m_objects_model = new ObjectDataViewModel;
AssociateModel(m_objects_model);
m_objects_model->SetAssociatedControl(this);
#if wxUSE_DRAG_AND_DROP && wxUSE_UNICODE
@ -173,7 +173,7 @@ void ObjectList::create_objects_ctrl()
// column 0(Icon+Text) of the view control:
// And Icon can be consisting of several bitmaps
AppendColumn(new wxDataViewColumn(_(L("Name")), new PrusaBitmapTextRenderer(),
AppendColumn(new wxDataViewColumn(_(L("Name")), new BitmapTextRenderer(),
0, 20*wxGetApp().em_unit()/*200*/, wxALIGN_LEFT, wxDATAVIEW_COL_RESIZABLE));
// column 1 of the view control:
@ -395,22 +395,10 @@ void ObjectList::update_name_in_model(const wxDataViewItem& item) const
void ObjectList::init_icons()
{
// m_bmp_modifiermesh = create_scaled_bitmap(nullptr, "add_modifier");
// m_bmp_solidmesh = create_scaled_bitmap(nullptr, "add_part");
// m_bmp_support_enforcer = create_scaled_bitmap(nullptr, "support_enforcer");
// m_bmp_support_blocker = create_scaled_bitmap(nullptr, "support_blocker");
//
//
// m_bmp_vector.reserve(4); // bitmaps for different types of parts
// m_bmp_vector.push_back(&m_bmp_solidmesh);
// m_bmp_vector.push_back(&m_bmp_modifiermesh);
// m_bmp_vector.push_back(&m_bmp_support_enforcer);
// m_bmp_vector.push_back(&m_bmp_support_blocker);
m_bmp_modifiermesh = PrusaBitmap(nullptr, "add_modifier"); // Add part
m_bmp_solidmesh = PrusaBitmap(nullptr, "add_part"); // Add modifier
m_bmp_support_enforcer = PrusaBitmap(nullptr, "support_enforcer");// Add support enforcer
m_bmp_support_blocker = PrusaBitmap(nullptr, "support_blocker"); // Add support blocker
m_bmp_modifiermesh = ScalableBitmap(nullptr, "add_modifier"); // Add part
m_bmp_solidmesh = ScalableBitmap(nullptr, "add_part"); // Add modifier
m_bmp_support_enforcer = ScalableBitmap(nullptr, "support_enforcer");// Add support enforcer
m_bmp_support_blocker = ScalableBitmap(nullptr, "support_blocker"); // Add support blocker
m_bmp_vector.reserve(4); // bitmaps for different types of parts
m_bmp_vector.push_back(&m_bmp_solidmesh.bmp());
@ -423,34 +411,34 @@ void ObjectList::init_icons()
m_objects_model->SetVolumeBitmaps(m_bmp_vector);
// init icon for manifold warning
m_bmp_manifold_warning = /*create_scaled_bitmap*/PrusaBitmap(nullptr, "exclamation");
m_bmp_manifold_warning = ScalableBitmap(nullptr, "exclamation");
// init bitmap for "Split to sub-objects" context menu
m_bmp_split = /*create_scaled_bitmap*/PrusaBitmap(nullptr, "split_parts_SMALL");
m_bmp_split = ScalableBitmap(nullptr, "split_parts_SMALL");
// init bitmap for "Add Settings" context menu
m_bmp_cog = /*create_scaled_bitmap*/PrusaBitmap(nullptr, "cog");
m_bmp_cog = ScalableBitmap(nullptr, "cog");
}
void ObjectList::rescale_icons()
{
m_bmp_vector.clear();
m_bmp_vector.reserve(4); // bitmaps for different types of parts
for (PrusaBitmap* bitmap : std::vector<PrusaBitmap*> {
for (ScalableBitmap* bitmap : std::vector<ScalableBitmap*> {
&m_bmp_modifiermesh, // Add part
&m_bmp_solidmesh, // Add modifier
&m_bmp_support_enforcer, // Add support enforcer
&m_bmp_support_blocker }) // Add support blocker
{
bitmap->rescale();
bitmap->msw_rescale();
m_bmp_vector.push_back(& bitmap->bmp());
}
// Set volumes default bitmaps for the model
m_objects_model->SetVolumeBitmaps(m_bmp_vector);
m_bmp_manifold_warning.rescale();
m_bmp_split.rescale();
m_bmp_cog.rescale();
m_bmp_manifold_warning.msw_rescale();
m_bmp_split.msw_rescale();
m_bmp_cog.msw_rescale();
// Update CATEGORY_ICON according to new scale
@ -1057,7 +1045,7 @@ wxMenuItem* ObjectList::append_menu_item_split(wxMenu* menu)
wxMenuItem* ObjectList::append_menu_item_settings(wxMenu* menu_)
{
PrusaMenu* menu = dynamic_cast<PrusaMenu*>(menu_);
MenuWithSeparators* menu = dynamic_cast<MenuWithSeparators*>(menu_);
const wxString menu_name = _(L("Add settings"));
// Delete old items from settings popupmenu
@ -1105,7 +1093,7 @@ wxMenuItem* ObjectList::append_menu_item_settings(wxMenu* menu_)
if (printer_technology() == ptFFF ||
menu->GetMenuItems().size() > 0 && !menu->GetMenuItems().back()->IsSeparator())
menu->m_separator_frst = menu->AppendSeparator();
menu->SetFirstSeparator();
// Add frequently settings
create_freq_settings_popupmenu(menu);
@ -1113,7 +1101,7 @@ wxMenuItem* ObjectList::append_menu_item_settings(wxMenu* menu_)
if (mode == comAdvanced)
return nullptr;
menu->m_separator_scnd = menu->AppendSeparator();
menu->SetSecondSeparator();
// Add full settings list
auto menu_item = new wxMenuItem(menu, wxID_ANY, menu_name);
@ -1864,7 +1852,7 @@ void ObjectList::add_object_to_list(size_t obj_idx)
stats.facets_added + stats.facets_reversed + stats.backwards_edges;
if (errors > 0) {
wxVariant variant;
variant << PrusaDataViewBitmapText(item_name, m_bmp_manifold_warning.bmp());
variant << DataViewBitmapText(item_name, m_bmp_manifold_warning.bmp());
m_objects_model->SetValue(variant, item, 0);
}
@ -2664,7 +2652,7 @@ void ObjectList::rename_item()
wxVariant valueOld;
m_objects_model->GetValue(valueOld, item, 0);
PrusaDataViewBitmapText bmpText;
DataViewBitmapText bmpText;
bmpText << valueOld;
// But replace the text with the value entered by user.
@ -2712,12 +2700,12 @@ void ObjectList::update_item_error_icon(const int obj_idx, const int vol_idx) co
if (errors == 0) {
// delete Error_icon if all errors are fixed
wxVariant variant;
variant << PrusaDataViewBitmapText(from_u8(model_object->name), wxNullBitmap);
variant << DataViewBitmapText(from_u8(model_object->name), wxNullBitmap);
m_objects_model->SetValue(variant, item, 0);
}
}
void ObjectList::rescale()
void ObjectList::msw_rescale()
{
// update min size !!! A width of control shouldn't be a wxDefaultCoord
SetMinSize(wxSize(1, 15 * wxGetApp().em_unit()));
@ -2748,7 +2736,7 @@ void ObjectList::OnEditingDone(wxDataViewEvent &event)
if (event.GetColumn() != 0)
return;
const auto renderer = dynamic_cast<PrusaBitmapTextRenderer*>(GetColumn(0)->GetRenderer());
const auto renderer = dynamic_cast<BitmapTextRenderer*>(GetColumn(0)->GetRenderer());
if (renderer->WasCanceled())
show_error(this, _(L("The supplied name is not valid;")) + "\n" +

View file

@ -13,8 +13,8 @@
class wxBoxSizer;
class wxMenuItem;
class PrusaObjectDataViewModel;
class PrusaMenu;
class ObjectDataViewModel;
class MenuWithSeparators;
namespace Slic3r {
class ConfigOptionsGroup;
@ -108,24 +108,24 @@ class ObjectList : public wxDataViewCtrl
wxBoxSizer *m_sizer {nullptr};
wxWindow *m_parent {nullptr};
/*wxBitmap*/PrusaBitmap m_bmp_modifiermesh;
/*wxBitmap*/PrusaBitmap m_bmp_solidmesh;
/*wxBitmap*/PrusaBitmap m_bmp_support_enforcer;
/*wxBitmap*/PrusaBitmap m_bmp_support_blocker;
/*wxBitmap*/PrusaBitmap m_bmp_manifold_warning;
/*wxBitmap*/PrusaBitmap m_bmp_cog;
/*wxBitmap*/PrusaBitmap m_bmp_split;
ScalableBitmap m_bmp_modifiermesh;
ScalableBitmap m_bmp_solidmesh;
ScalableBitmap m_bmp_support_enforcer;
ScalableBitmap m_bmp_support_blocker;
ScalableBitmap m_bmp_manifold_warning;
ScalableBitmap m_bmp_cog;
ScalableBitmap m_bmp_split;
PrusaMenu m_menu_object;
PrusaMenu m_menu_part;
PrusaMenu m_menu_sla_object;
PrusaMenu m_menu_instance;
MenuWithSeparators m_menu_object;
MenuWithSeparators m_menu_part;
MenuWithSeparators m_menu_sla_object;
MenuWithSeparators m_menu_instance;
wxMenuItem* m_menu_item_split { nullptr };
wxMenuItem* m_menu_item_split_part { nullptr };
wxMenuItem* m_menu_item_settings { nullptr };
wxMenuItem* m_menu_item_split_instances { nullptr };
std::vector<wxBitmap* /*const wxBitmap&*/> m_bmp_vector;
std::vector<wxBitmap*> m_bmp_vector;
int m_selected_object_id = -1;
bool m_prevent_list_events = false; // We use this flag to avoid circular event handling Select()
@ -139,9 +139,6 @@ class ObjectList : public wxDataViewCtrl
// update_settings_items - updating canvas selection is undesirable,
// because it would turn off the gizmos (mainly a problem for the SLA gizmo)
// bool m_parts_changed = false;
// bool m_part_settings_changed = false;
int m_selected_row = 0;
wxDataViewItem m_last_selected_item {nullptr};
@ -157,7 +154,7 @@ public:
std::map<std::string, wxBitmap> CATEGORY_ICON;
PrusaObjectDataViewModel *m_objects_model{ nullptr };
ObjectDataViewModel *m_objects_model{ nullptr };
DynamicPrintConfig *m_config {nullptr};
std::vector<ModelObject*> *m_objects{ nullptr };
@ -289,7 +286,7 @@ public:
void paste_volumes_into_list(int obj_idx, const ModelVolumePtrs& volumes);
void paste_objects_into_list(const std::vector<size_t>& object_idxs);
void rescale();
void msw_rescale();
private:
void OnChar(wxKeyEvent& event);

View file

@ -78,7 +78,7 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
// Add "uniform scaling" button in front of "Scale" option
if (option_name == "Scale") {
line.near_label_widget = [this](wxWindow* parent) {
auto btn = new PrusaLockButton(parent, wxID_ANY);
auto btn = new LockButton(parent, wxID_ANY);
btn->Bind(wxEVT_BUTTON, [btn, this](wxCommandEvent &event){
event.Skip();
wxTheApp->CallAfter([btn, this]() { set_uniform_scaling(btn->IsLocked()); });
@ -119,10 +119,10 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
// call back for a rescale of button "Set uniform scale"
m_og->rescale_near_label_widget = [this](wxWindow* win) {
auto *ctrl = dynamic_cast<PrusaLockButton*>(win);
auto *ctrl = dynamic_cast<LockButton*>(win);
if (ctrl == nullptr)
return;
ctrl->rescale();
ctrl->msw_rescale();
};
}

View file

@ -7,7 +7,7 @@
#include "GLCanvas3D.hpp"
class wxStaticText;
class PrusaLockButton;
class LockButton;
namespace Slic3r {
namespace GUI {
@ -76,7 +76,7 @@ class ObjectManipulation : public OG_Settings
Vec3d m_new_size;
bool m_new_enabled;
bool m_uniform_scale {true};
PrusaLockButton* m_lock_bnt{ nullptr };
LockButton* m_lock_bnt{ nullptr };
#ifndef __APPLE__
// Currently focused option name (empty if none)

View file

@ -60,7 +60,7 @@ 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");
m_bmp_delete = ScalableBitmap(parent, "cross");
}
void ObjectSettings::update_settings_list()
@ -79,12 +79,8 @@ 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);
auto btn = new PrusaButton(parent, wxID_ANY, m_bmp_delete);
//#ifdef __WXMSW__
// btn->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
//#endif // __WXMSW__
auto btn = new ScalableButton(parent, wxID_ANY, m_bmp_delete);
btn->Bind(wxEVT_BUTTON, [opt_key, config, this](wxEvent &event) {
config->erase(opt_key);
wxGetApp().obj_list()->changed_object();
@ -145,7 +141,7 @@ void ObjectSettings::update_settings_list()
// call back for rescaling of the extracolumn control
optgroup->rescale_extra_column_item = [this](wxWindow* win) {
auto *ctrl = dynamic_cast<PrusaButton*>(win);
auto *ctrl = dynamic_cast<ScalableButton*>(win);
if (ctrl == nullptr)
return;
ctrl->SetBitmap_(m_bmp_delete);
@ -175,12 +171,12 @@ void ObjectSettings::UpdateAndShow(const bool show)
OG_Settings::UpdateAndShow(show);
}
void ObjectSettings::rescale()
void ObjectSettings::msw_rescale()
{
m_bmp_delete.rescale();
m_bmp_delete.msw_rescale();
for (auto group : m_og_settings)
group->rescale();
group->msw_rescale();
}
} //namespace GUI

View file

@ -38,7 +38,7 @@ class ObjectSettings : public OG_Settings
// option groups for settings
std::vector <std::shared_ptr<ConfigOptionsGroup>> m_og_settings;
PrusaBitmap m_bmp_delete;
ScalableBitmap m_bmp_delete;
public:
ObjectSettings(wxWindow* parent);
@ -46,7 +46,7 @@ public:
void update_settings_list();
void UpdateAndShow(const bool show) override;
void rescale();
void msw_rescale();
};
}}

View file

@ -396,13 +396,13 @@ void Preview::refresh_print()
load_print(true);
}
void Preview::rescale()
void Preview::msw_rescale()
{
// rescale slider
if (m_slider) m_slider->rescale();
if (m_slider) m_slider->msw_rescale();
// rescale warning legend on the canvas
get_canvas3d()->rescale();
get_canvas3d()->msw_rescale();
// rescale legend
refresh_print();
@ -519,7 +519,7 @@ void Preview::on_checkbox_shells(wxCommandEvent& evt)
void Preview::create_double_slider()
{
m_slider = new PrusaDoubleSlider(this, wxID_ANY, 0, 0, 0, 100);
m_slider = new DoubleSlider(this, wxID_ANY, 0, 0, 0, 100);
m_double_slider_sizer->Add(m_slider, 0, wxEXPAND, 0);
// sizer, m_canvas_widget

View file

@ -13,7 +13,7 @@ class wxStaticText;
class wxChoice;
class wxComboCtrl;
class wxCheckBox;
class PrusaDoubleSlider;
class DoubleSlider;
namespace Slic3r {
@ -99,7 +99,7 @@ class Preview : public wxPanel
bool m_loaded;
bool m_enabled;
PrusaDoubleSlider* m_slider {nullptr};
DoubleSlider* m_slider {nullptr};
public:
Preview(wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar, Model* model, DynamicPrintConfig* config,
@ -120,7 +120,7 @@ public:
void reload_print(bool keep_volumes = false);
void refresh_print();
void rescale();
void msw_rescale();
private:
bool init(wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar, Model* model);

View file

@ -15,21 +15,21 @@ KBShortcutsDialog::KBShortcutsDialog()
{
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
main_sizer = new wxBoxSizer(wxVERTICAL);
auto main_sizer = new wxBoxSizer(wxVERTICAL);
// logo
m_logo_bmp = PrusaBitmap(this, "Slic3r_32px.png", 32);
m_logo_bmp = ScalableBitmap(this, "Slic3r_32px.png", 32);
// fonts
const wxFont& font = wxGetApp().normal_font();
const wxFont& bold_font = wxGetApp().bold_font();
SetFont(font);
wxFont head_font = bold_font;// wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).Bold();
wxFont head_font = bold_font;
#ifdef __WXOSX__
head_font.SetPointSize(14);
#else
head_font.SetPointSize(/*12*/bold_font.GetPointSize() + 2);
head_font.SetPointSize(bold_font.GetPointSize() + 2);
#endif // __WXOSX__
fill_shortcuts();
@ -191,7 +191,7 @@ void KBShortcutsDialog::fill_shortcuts()
void KBShortcutsDialog::on_dpi_changed(const wxRect &suggested_rect)
{
m_logo_bmp.rescale();
m_logo_bmp.msw_rescale();
for (wxStaticBitmap* bmp : m_head_bitmaps)
bmp->SetBitmap(m_logo_bmp.bmp());

View file

@ -11,7 +11,7 @@
namespace Slic3r {
namespace GUI {
class KBShortcutsDialog : public DPIDialog/*wxDialog*/
class KBShortcutsDialog : public DPIDialog
{
enum PLACED_SIZER_ID
{
@ -26,8 +26,7 @@ class KBShortcutsDialog : public DPIDialog/*wxDialog*/
wxString text_info {wxEmptyString};
ShortcutsVec m_full_shortcuts;
wxSizer* main_sizer;
PrusaBitmap m_logo_bmp;
ScalableBitmap m_logo_bmp;
std::vector<wxStaticBitmap*> m_head_bitmaps;
public:

View file

@ -270,11 +270,11 @@ void MainFrame::on_dpi_changed(const wxRect &suggested_rect)
wxGetApp().preset_bundle->load_default_preset_bitmaps(this);
// update Plater
wxGetApp().plater()->rescale();
wxGetApp().plater()->msw_rescale();
// update Tabs
for (auto tab : wxGetApp().tabs_list)
tab->rescale();
tab->msw_rescale();
/* To correct window rendering (especially redraw of a status bar)
* we should imitate window resizing.

View file

@ -484,7 +484,7 @@ bool ConfigOptionsGroup::update_visibility(ConfigOptionMode mode) {
return true;
}
void ConfigOptionsGroup::rescale()
void ConfigOptionsGroup::msw_rescale()
{
// update bitmaps for extra column items (like "mode markers" or buttons on settings panel)
if (rescale_extra_column_item)
@ -498,7 +498,7 @@ void ConfigOptionsGroup::rescale()
// update undo buttons : rescale bitmaps
for (const auto& field : m_fields)
field.second->rescale();
field.second->msw_rescale();
const int em = em_unit(parent());

View file

@ -266,7 +266,7 @@ public:
void Hide();
void Show(const bool show);
bool update_visibility(ConfigOptionMode mode);
void rescale();
void msw_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);

View file

@ -111,7 +111,7 @@ public:
bool showing_manifold_warning_icon;
void show_sizer(bool show);
void rescale();
void msw_rescale();
};
ObjectInfo::ObjectInfo(wxWindow *parent) :
@ -161,7 +161,7 @@ void ObjectInfo::show_sizer(bool show)
manifold_warning_icon->Show(showing_manifold_warning_icon && show);
}
void ObjectInfo::rescale()
void ObjectInfo::msw_rescale()
{
manifold_warning_icon->SetBitmap(create_scaled_bitmap(nullptr, "exclamation"));
}
@ -288,12 +288,7 @@ 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 PrusaButton(parent, wxID_ANY, "cog");
edit_btn = new ScalableButton(parent, wxID_ANY, "cog");
edit_btn->SetToolTip(_(L("Click to edit preset")));
edit_btn->Bind(wxEVT_BUTTON, ([preset_type, this](wxCommandEvent)
@ -339,10 +334,10 @@ void PresetComboBox::check_selection()
this->last_selected = GetSelection();
}
void PresetComboBox::rescale()
void PresetComboBox::msw_rescale()
{
m_em_unit = wxGetApp().em_unit();
edit_btn->rescale();
edit_btn->msw_rescale();
}
// Frequently changed parameters
@ -580,7 +575,7 @@ struct Sidebar::priv
wxScrolledWindow *scrolled;
wxPanel* presets_panel; // Used for MSW better layouts
PrusaModeSizer *mode_sizer;
ModeSizer *mode_sizer;
wxFlexGridSizer *sizer_presets;
PresetComboBox *combo_print;
std::vector<PresetComboBox*> combos_filament;
@ -639,7 +634,7 @@ Sidebar::Sidebar(Plater *parent)
p->scrolled->SetSizer(scrolled_sizer);
// Sizer with buttons for mode changing
p->mode_sizer = new PrusaModeSizer(p->scrolled, 2 * wxGetApp().em_unit());
p->mode_sizer = new ModeSizer(p->scrolled, 2 * wxGetApp().em_unit());
// The preset chooser
p->sizer_presets = new wxFlexGridSizer(10, 1, 1, 2);
@ -854,23 +849,6 @@ void Sidebar::update_presets(Preset::Type preset_type)
case Preset::TYPE_PRINTER:
{
// wxWindowUpdateLocker noUpdates_scrolled(p->scrolled);
// // Update the print choosers to only contain the compatible presets, update the dirty flags.
// if (print_tech == ptFFF)
// preset_bundle.prints.update_platter_ui(p->combo_print);
// else {
// preset_bundle.sla_prints.update_platter_ui(p->combo_sla_print);
// preset_bundle.sla_materials.update_platter_ui(p->combo_sla_material);
// }
// // Update the printer choosers, update the dirty flags.
// preset_bundle.printers.update_platter_ui(p->combo_printer);
// // Update the filament choosers to only contain the compatible presets, update the color preview,
// // update the dirty flags.
// if (print_tech == ptFFF) {
// for (size_t i = 0; i < p->combos_filament.size(); ++ i)
// preset_bundle.update_platter_filament_ui(i, p->combos_filament[i], wxGetApp().em_unit());
// }
update_all_preset_comboboxes();
p->show_preset_comboboxes();
break;
@ -896,33 +874,33 @@ void Sidebar::update_reslice_btn_tooltip() const
p->btn_reslice->SetToolTip(tooltip);
}
void Sidebar::rescale()
void Sidebar::msw_rescale()
{
SetMinSize(wxSize(40 * wxGetApp().em_unit(), -1));
p->mode_sizer->rescale();
p->mode_sizer->msw_rescale();
// Rescale preset comboboxes in respect to the current em_unit ...
for (PresetComboBox* combo : std::vector<PresetComboBox*> { p->combo_print,
p->combo_sla_print,
p->combo_sla_material,
p->combo_printer } )
combo->rescale();
combo->msw_rescale();
for (PresetComboBox* combo : p->combos_filament)
combo->rescale();
combo->msw_rescale();
// ... then refill them and set min size to correct layout of the sidebar
update_all_preset_comboboxes();
p->frequently_changed_parameters->get_og(true)->rescale();
p->frequently_changed_parameters->get_og(false)->rescale();
p->frequently_changed_parameters->get_og(true)->msw_rescale();
p->frequently_changed_parameters->get_og(false)->msw_rescale();
p->object_list->rescale();
p->object_list->msw_rescale();
p->object_manipulation->get_og()->rescale();
p->object_settings->rescale();
p->object_manipulation->get_og()->msw_rescale();
p->object_settings->msw_rescale();
p->object_info->rescale();
p->object_info->msw_rescale();
p->scrolled->Layout();
}
@ -1198,11 +1176,11 @@ struct Plater::priv
MainFrame *main_frame;
// Object popup menu
PrusaMenu object_menu;
MenuWithSeparators object_menu;
// Part popup menu
PrusaMenu part_menu;
MenuWithSeparators part_menu;
// SLA-Object popup menu
PrusaMenu sla_object_menu;
MenuWithSeparators sla_object_menu;
// Removed/Prepended Items according to the view mode
std::vector<wxMenuItem*> items_increase;
@ -3850,13 +3828,13 @@ bool Plater::can_paste_from_clipboard() const
return true;
}
void Plater::rescale()
void Plater::msw_rescale()
{
p->preview->rescale();
p->preview->msw_rescale();
p->view3D->get_canvas3d()->rescale();
p->view3D->get_canvas3d()->msw_rescale();
p->sidebar->rescale();
p->sidebar->msw_rescale();
Layout();
GetParent()->Layout();

View file

@ -14,7 +14,7 @@
#include "GLTexture.hpp"
class wxButton;
class PrusaButton;
class ScalableButton;
class wxBoxSizer;
class wxGLCanvas;
class wxScrolledWindow;
@ -47,7 +47,7 @@ public:
PresetComboBox(wxWindow *parent, Preset::Type preset_type);
~PresetComboBox();
/*wxButton*/PrusaButton* edit_btn { nullptr };
ScalableButton* edit_btn { nullptr };
enum LabelItemType {
LABEL_ITEM_MARKER = 0x4d,
@ -60,7 +60,7 @@ public:
int em_unit() const { return m_em_unit; }
void check_selection();
void rescale();
void msw_rescale();
private:
typedef std::size_t Marker;
@ -88,7 +88,7 @@ public:
void update_presets(Slic3r::Preset::Type preset_type);
void update_mode_sizer() const;
void update_reslice_btn_tooltip() const;
void rescale();
void msw_rescale();
ObjectManipulation* obj_manipul();
ObjectList* obj_list();
@ -206,7 +206,7 @@ public:
bool can_copy() const;
bool can_paste() const;
void rescale();
void msw_rescale();
private:
struct priv;

View file

@ -144,7 +144,7 @@ void PreferencesDialog::accept()
void PreferencesDialog::on_dpi_changed(const wxRect &suggested_rect)
{
m_optgroup->rescale();
m_optgroup->msw_rescale();
const int& em = em_unit();
const wxSize& size = wxSize(50 * em, 29 * em);

View file

@ -54,8 +54,7 @@ SysInfoDialog::SysInfoDialog()
main_sizer->Add(hsizer, 1, wxEXPAND | wxALL, 10);
// logo
m_logo_bmp = PrusaBitmap(this, "Slic3r_192px.png", 192);
// auto *logo = new wxStaticBitmap(this, wxID_ANY, create_scaled_bitmap(this, "Slic3r_192px.png", 192));
m_logo_bmp = ScalableBitmap(this, "Slic3r_192px.png", 192);
m_logo = new wxStaticBitmap(this, wxID_ANY, m_logo_bmp.bmp());
hsizer->Add(m_logo, 0, wxALIGN_CENTER_VERTICAL);
@ -65,8 +64,7 @@ SysInfoDialog::SysInfoDialog()
// title
{
wxStaticText* title = new wxStaticText(this, wxID_ANY, SLIC3R_APP_NAME, wxDefaultPosition, wxDefaultSize);
wxFont title_font = wxGetApp().bold_font();//wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
// title_font.SetWeight(wxFONTWEIGHT_BOLD);
wxFont title_font = wxGetApp().bold_font();
title_font.SetFamily(wxFONTFAMILY_ROMAN);
title_font.SetPointSize(22);
title->SetFont(title_font);
@ -74,7 +72,7 @@ SysInfoDialog::SysInfoDialog()
}
// main_info_text
wxFont font = wxGetApp().normal_font();//wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
wxFont font = wxGetApp().normal_font();
const auto text_clr = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
auto text_clr_str = wxString::Format(wxT("#%02X%02X%02X"), text_clr.Red(), text_clr.Green(), text_clr.Blue());
auto bgr_clr_str = wxString::Format(wxT("#%02X%02X%02X"), bgr_clr.Red(), bgr_clr.Green(), bgr_clr.Blue());
@ -136,7 +134,7 @@ SysInfoDialog::SysInfoDialog()
void SysInfoDialog::on_dpi_changed(const wxRect &suggested_rect)
{
m_logo_bmp.rescale();
m_logo_bmp.msw_rescale();
m_logo->SetBitmap(m_logo_bmp.bmp());
wxFont font = GetFont();

View file

@ -12,8 +12,7 @@ namespace GUI {
class SysInfoDialog : public DPIDialog
{
wxString text_info {wxEmptyString};
PrusaBitmap m_logo_bmp;
ScalableBitmap m_logo_bmp;
wxStaticBitmap* m_logo;
wxHtmlWindow* m_opengl_info_html;
wxHtmlWindow* m_html;

View file

@ -117,61 +117,34 @@ void Tab::create_preset_tab()
//buttons
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");
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);
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.")));
// 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");
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, luma >= 128 ? "dot" : "dot_white"/*"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, luma >= 128 ? "dot" : "dot_white"/*"bullet_white.png"*/);
add_scaled_bitmap(this, m_bmp_white_bullet, luma >= 128 ? "dot" : "dot_white");
fill_icon_descriptions();
set_tooltips_text();
@ -179,11 +152,8 @@ void Tab::create_preset_tab()
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->Bind(wxEVT_BUTTON, ([this](wxCommandEvent) { on_roll_back_value(true); }));
// m_question_btn->SetBitmap(m_bmp_question);
m_question_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent)
{
auto dlg = new ButtonsDescription(this, &m_icon_descriptions);
@ -203,7 +173,7 @@ void Tab::create_preset_tab()
m_default_text_clr = wxGetApp().get_label_clr_default();
// Sizer with buttons for mode changing
m_mode_sizer = new PrusaModeSizer(panel);
m_mode_sizer = new ModeSizer(panel);
const float scale_factor = wxGetApp().em_unit()*0.1;// GetContentScaleFactor();
m_hsizer = new wxBoxSizer(wxHORIZONTAL);
@ -281,9 +251,9 @@ void Tab::create_preset_tab()
// 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"));
m_mode_bitmap_cache.push_back(ScalableBitmap(this, "mode_simple_.png"));
m_mode_bitmap_cache.push_back(ScalableBitmap(this, "mode_middle_.png"));
m_mode_bitmap_cache.push_back(ScalableBitmap(this, "mode_expert_.png"));
// Initialize the DynamicPrintConfig by default keys/values.
build();
@ -291,17 +261,21 @@ void Tab::create_preset_tab()
m_complited = true;
}
void Tab::add_scaled_button(wxWindow* parent, PrusaButton** btn, const std::string& icon_name,
void Tab::add_scaled_button(wxWindow* parent,
ScalableButton** 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);
*btn = new ScalableButton(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)
void Tab::add_scaled_bitmap(wxWindow* parent,
ScalableBitmap& bmp,
const std::string& icon_name)
{
bmp = PrusaBitmap(parent, icon_name);
bmp = ScalableBitmap(parent, icon_name);
m_scaled_bitmaps.push_back(&bmp);
}
@ -321,8 +295,7 @@ 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.
// m_icons->Add(create_scaled_bitmap(this, icon));
m_scaled_icons_list.push_back(PrusaBitmap(this, icon));
m_scaled_icons_list.push_back(ScalableBitmap(this, icon));
m_icons->Add(m_scaled_icons_list.back().bmp());
icon_idx = ++m_icon_count;
m_icon_index[icon] = icon_idx;
@ -442,8 +415,8 @@ void Tab::update_changed_ui()
{
bool is_nonsys_value = false;
bool is_modified_value = true;
const /*wxBitmap*/PrusaBitmap *sys_icon = &m_bmp_value_lock;
const /*wxBitmap*/PrusaBitmap *icon = &m_bmp_value_revert;
const ScalableBitmap *sys_icon = &m_bmp_value_lock;
const ScalableBitmap *icon = &m_bmp_value_revert;
const wxColour *color = &m_sys_label_clr;
@ -766,11 +739,11 @@ void Tab::update_visibility()
update_changed_tree_ui();
}
void Tab::rescale()
void Tab::msw_rescale()
{
m_em_unit = wxGetApp().em_unit();
m_mode_sizer->rescale();
m_mode_sizer->msw_rescale();
m_presets_choice->SetSize(35 * m_em_unit, -1);
m_treectrl->SetMinSize(wxSize(20 * m_em_unit, -1));
@ -779,25 +752,25 @@ void Tab::rescale()
// rescale buttons and cached bitmaps
for (const auto btn : m_scaled_buttons)
btn->rescale();
btn->msw_rescale();
for (const auto bmp : m_scaled_bitmaps)
bmp->rescale();
for (PrusaBitmap& bmp : m_mode_bitmap_cache)
bmp.rescale();
bmp->msw_rescale();
for (ScalableBitmap& bmp : m_mode_bitmap_cache)
bmp.msw_rescale();
// rescale icons for tree_ctrl
for (PrusaBitmap& bmp : m_scaled_icons_list)
bmp.rescale();
for (ScalableBitmap& bmp : m_scaled_icons_list)
bmp.msw_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)
for (ScalableBitmap& 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();
page->msw_rescale();
Layout();
}
@ -1705,12 +1678,8 @@ 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, "browse"));
add_scaled_button(parent, &m_printhost_browse_btn, "browse", _(L(" Browse ")) + dots, wxBU_LEFT | wxBU_EXACTFIT);
PrusaButton* btn = m_printhost_browse_btn;
ScalableButton* btn = m_printhost_browse_btn;
btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
auto sizer = new wxBoxSizer(wxHORIZONTAL);
@ -1728,12 +1697,8 @@ void TabPrinter::build_printhost(ConfigOptionsGroup *optgroup)
};
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, "test"));
add_scaled_button(parent, &m_print_host_test_btn, "test", _(L("Test")), wxBU_LEFT | wxBU_EXACTFIT);
PrusaButton* btn = m_print_host_test_btn;
ScalableButton* btn = m_print_host_test_btn;
btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
auto sizer = new wxBoxSizer(wxHORIZONTAL);
sizer->Add(btn);
@ -1849,11 +1814,7 @@ 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"));
PrusaButton* btn;
ScalableButton* btn;
add_scaled_button(parent, &btn, "printer_white", _(L(" Set ")) + dots, wxBU_LEFT | wxBU_EXACTFIT);
btn->SetFont(wxGetApp().normal_font());
@ -2054,11 +2015,7 @@ 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"));
PrusaButton* btn;
ScalableButton* btn;
add_scaled_button(parent, &btn, "printer_white", _(L(" Set ")) + dots, wxBU_LEFT | wxBU_EXACTFIT);
btn->SetFont(wxGetApp().normal_font());
@ -2157,7 +2114,6 @@ void TabPrinter::extruders_count_changed(size_t extruders_count)
* of unregular pages of a Printer Settings
*/
build_unregular_pages();
// reload_config(); // #ys_FIXME_delete_after_testing : This function is called from build_extruder_pages() now
if (is_count_changed) {
on_value_change("extruders_count", extruders_count);
@ -3029,12 +2985,9 @@ 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);
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"));
auto sizer = new wxBoxSizer(wxHORIZONTAL);
sizer->Add((deps.checkbox), 0, wxALIGN_CENTER_VERTICAL);
sizer->Add((deps.btn), 0, wxALIGN_CENTER_VERTICAL);
@ -3190,10 +3143,10 @@ void Page::update_visibility(ConfigOptionMode mode)
m_show = ret_val;
}
void Page::rescale()
void Page::msw_rescale()
{
for (auto group : m_optgroups)
group->rescale();
group->msw_rescale();
}
Field* Page::get_field(const t_config_option_key& opt_key, int opt_index /*= -1*/) const
@ -3223,14 +3176,6 @@ ConfigOptionsGroupShp Page::new_optgroup(const wxString& title, int noncommon_la
{
std::string bmp_name;
const std::vector<Option>& options = line.get_options();
// 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));
int mode_id = int(options[0].opt.mode);
const wxBitmap& bitmap = options.size() == 0 || options[0].opt.gui_type == "legend" ? wxNullBitmap :
m_mode_bitmap_cache[mode_id].bmp();
@ -3280,7 +3225,7 @@ ConfigOptionsGroupShp Page::new_optgroup(const wxString& title, int noncommon_la
if (ctrl == nullptr)
return;
ctrl->SetBitmap(reinterpret_cast<PrusaBitmap*>(ctrl->GetClientData())->bmp());
ctrl->SetBitmap(reinterpret_cast<ScalableBitmap*>(ctrl->GetClientData())->bmp());
};
vsizer()->Add(optgroup->sizer, 0, wxEXPAND | wxALL, 10);

View file

@ -36,8 +36,8 @@ namespace Slic3r {
namespace GUI {
typedef std::pair</*wxBitmap*/PrusaBitmap*, std::string> t_icon_description;
typedef std::vector<std::pair</*wxBitmap*/PrusaBitmap*, std::string>> t_icon_descriptions;
typedef std::pair<ScalableBitmap*, std::string> t_icon_description;
typedef std::vector<std::pair<ScalableBitmap*, std::string>> t_icon_descriptions;
// Single Tab page containing a{ vsizer } of{ optgroups }
// package Slic3r::GUI::Tab::Page;
@ -50,7 +50,7 @@ class Page : public wxScrolledWindow
wxBoxSizer* m_vsizer;
bool m_show = true;
public:
Page(wxWindow* parent, const wxString title, const int iconID, const std::vector<PrusaBitmap>& mode_bmp_cache) :
Page(wxWindow* parent, const wxString title, const int iconID, const std::vector<ScalableBitmap>& mode_bmp_cache) :
m_parent(parent),
m_title(title),
m_iconID(iconID),
@ -68,7 +68,7 @@ public:
// Delayed layout after resizing the main window.
bool layout_valid = false;
const std::vector<PrusaBitmap>& m_mode_bitmap_cache;
const std::vector<ScalableBitmap>& m_mode_bitmap_cache;
public:
std::vector <ConfigOptionsGroupShp> m_optgroups;
@ -81,7 +81,7 @@ public:
void set_config(DynamicPrintConfig* config_in) { m_config = config_in; }
void reload_config();
void update_visibility(ConfigOptionMode mode);
void rescale();
void msw_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);
@ -122,20 +122,20 @@ protected:
std::string m_name;
const wxString m_title;
wxBitmapComboBox* m_presets_choice;
/*wxBitmap*/PrusaButton* m_btn_save_preset;
/*wxBitmap*/PrusaButton* m_btn_delete_preset;
/*wxBitmap*/PrusaButton* m_btn_hide_incompatible_presets;
ScalableButton* m_btn_save_preset;
ScalableButton* m_btn_delete_preset;
ScalableButton* m_btn_hide_incompatible_presets;
wxBoxSizer* m_hsizer;
wxBoxSizer* m_left_sizer;
wxTreeCtrl* m_treectrl;
wxImageList* m_icons;
PrusaModeSizer* m_mode_sizer;
ModeSizer* m_mode_sizer;
struct PresetDependencies {
Preset::Type type = Preset::TYPE_INVALID;
wxCheckBox *checkbox = nullptr;
/*wxButton*/PrusaButton *btn = nullptr;
ScalableButton *btn = nullptr;
std::string key_list; // "compatible_printers"
std::string key_condition;
std::string dialog_title;
@ -144,27 +144,27 @@ protected:
PresetDependencies m_compatible_printers;
PresetDependencies m_compatible_prints;
/*wxButton*/PrusaButton* m_undo_btn;
/*wxButton*/PrusaButton* m_undo_to_sys_btn;
/*wxButton*/PrusaButton* m_question_btn;
ScalableButton* m_undo_btn;
ScalableButton* m_undo_to_sys_btn;
ScalableButton* m_question_btn;
// Cached bitmaps.
// A "flag" icon to be displayned next to the preset name in the Tab's combo box.
/*wxBitmap*/PrusaBitmap m_bmp_show_incompatible_presets;
/*wxBitmap*/PrusaBitmap m_bmp_hide_incompatible_presets;
ScalableBitmap m_bmp_show_incompatible_presets;
ScalableBitmap 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*/PrusaBitmap m_bmp_value_lock;
/*wxBitmap*/PrusaBitmap m_bmp_value_unlock;
/*wxBitmap*/PrusaBitmap m_bmp_white_bullet;
ScalableBitmap m_bmp_value_lock;
ScalableBitmap m_bmp_value_unlock;
ScalableBitmap 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*/PrusaBitmap *m_bmp_non_system;
ScalableBitmap *m_bmp_non_system;
// Bitmaps to be shown on the "Undo user changes" button next to each input field.
/*wxBitmap*/PrusaBitmap m_bmp_value_revert;
ScalableBitmap 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 = {};
std::vector<ScalableButton*> m_scaled_buttons = {};
std::vector<ScalableBitmap*> m_scaled_bitmaps = {};
std::vector<ScalableBitmap> m_scaled_icons_list = {};
std::vector<ScalableBitmap> m_mode_bitmap_cache = {};
// Colors for ui "decoration"
wxColour m_sys_label_clr;
@ -241,10 +241,10 @@ public:
virtual bool supports_printer_technology(const PrinterTechnology tech) = 0;
void create_preset_tab();
void add_scaled_button(wxWindow* parent, PrusaButton** btn, const std::string& icon_name,
void add_scaled_button(wxWindow* parent, ScalableButton** 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 add_scaled_bitmap(wxWindow* parent, ScalableBitmap& btn, const std::string& icon_name);
void load_current_preset();
void rebuild_page_tree();
void update_page_tree_visibility();
@ -283,7 +283,7 @@ public:
virtual void reload_config();
void update_mode();
void update_visibility();
void rescale();
void msw_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);
wxSizer* description_line_widget(wxWindow* parent, ogStaticText** StaticText);
@ -355,8 +355,8 @@ class TabPrinter : public Tab
void build_printhost(ConfigOptionsGroup *optgroup);
public:
wxButton* m_serial_test_btn = nullptr;
/*wxButton*/PrusaButton* m_print_host_test_btn = nullptr;
/*wxButton*/PrusaButton* m_printhost_browse_btn = nullptr;
ScalableButton* m_print_host_test_btn = nullptr;
ScalableButton* m_printhost_browse_btn = nullptr;
size_t m_extruders_count;
size_t m_extruders_count_old = 0;

File diff suppressed because it is too large Load diff

View file

@ -96,91 +96,20 @@ public:
};
// *** PrusaCollapsiblePane ***
// ----------------------------------------------------------------------------
class PrusaCollapsiblePane : public wxCollapsiblePane
// DataViewBitmapText: helper class used by PrusaBitmapTextRenderer
// ----------------------------------------------------------------------------
class DataViewBitmapText : public wxObject
{
public:
PrusaCollapsiblePane() {}
PrusaCollapsiblePane(wxWindow *parent,
wxWindowID winid,
const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxCP_DEFAULT_STYLE,
const wxValidator& val = wxDefaultValidator,
const wxString& name = wxCollapsiblePaneNameStr)
{
Create(parent, winid, label, pos, size, style, val, name);
}
~PrusaCollapsiblePane() {}
void OnStateChange(const wxSize& sz); //override/hide of OnStateChange from wxCollapsiblePane
virtual bool Show(bool show = true) override {
wxCollapsiblePane::Show(show);
OnStateChange(GetBestSize());
return true;
}
};
// *** PrusaCollapsiblePaneMSW *** used only #ifdef __WXMSW__
// ----------------------------------------------------------------------------
#ifdef __WXMSW__
class PrusaCollapsiblePaneMSW : public PrusaCollapsiblePane//wxCollapsiblePane
{
wxButton* m_pDisclosureTriangleButton = nullptr;
wxBitmap m_bmp_close;
wxBitmap m_bmp_open;
wxString m_strLabel;
public:
PrusaCollapsiblePaneMSW() {}
PrusaCollapsiblePaneMSW( wxWindow *parent,
wxWindowID winid,
const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxCP_DEFAULT_STYLE,
const wxValidator& val = wxDefaultValidator,
const wxString& name = wxCollapsiblePaneNameStr)
{
Create(parent, winid, label, pos, size, style, val, name);
}
~PrusaCollapsiblePaneMSW() {}
bool Create(wxWindow *parent,
wxWindowID id,
const wxString& label,
const wxPoint& pos,
const wxSize& size,
long style,
const wxValidator& val,
const wxString& name);
void UpdateBtnBmp();
void SetLabel(const wxString &label) override;
bool Layout() override;
void Collapse(bool collapse) override;
};
#endif //__WXMSW__
// *****************************************************************************
// ----------------------------------------------------------------------------
// PrusaDataViewBitmapText: helper class used by PrusaBitmapTextRenderer
// ----------------------------------------------------------------------------
class PrusaDataViewBitmapText : public wxObject
{
public:
PrusaDataViewBitmapText(const wxString &text = wxEmptyString,
DataViewBitmapText( const wxString &text = wxEmptyString,
const wxBitmap& bmp = wxNullBitmap) :
m_text(text), m_bmp(bmp)
m_text(text),
m_bmp(bmp)
{ }
PrusaDataViewBitmapText(const PrusaDataViewBitmapText &other)
DataViewBitmapText(const DataViewBitmapText &other)
: wxObject(),
m_text(other.m_text),
m_bmp(other.m_bmp)
@ -191,15 +120,15 @@ public:
void SetBitmap(const wxBitmap &bmp) { m_bmp = bmp; }
const wxBitmap &GetBitmap() const { return m_bmp; }
bool IsSameAs(const PrusaDataViewBitmapText& other) const {
bool IsSameAs(const DataViewBitmapText& other) const {
return m_text == other.m_text && m_bmp.IsSameAs(other.m_bmp);
}
bool operator==(const PrusaDataViewBitmapText& other) const {
bool operator==(const DataViewBitmapText& other) const {
return IsSameAs(other);
}
bool operator!=(const PrusaDataViewBitmapText& other) const {
bool operator!=(const DataViewBitmapText& other) const {
return !IsSameAs(other);
}
@ -207,13 +136,13 @@ private:
wxString m_text;
wxBitmap m_bmp;
wxDECLARE_DYNAMIC_CLASS(PrusaDataViewBitmapText);
wxDECLARE_DYNAMIC_CLASS(DataViewBitmapText);
};
DECLARE_VARIANT_OBJECT(PrusaDataViewBitmapText)
DECLARE_VARIANT_OBJECT(DataViewBitmapText)
// ----------------------------------------------------------------------------
// PrusaObjectDataViewModelNode: a node inside PrusaObjectDataViewModel
// ObjectDataViewModelNode: a node inside PrusaObjectDataViewModel
// ----------------------------------------------------------------------------
enum ItemType {
@ -225,49 +154,58 @@ enum ItemType {
itSettings = 16
};
class PrusaObjectDataViewModelNode;
WX_DEFINE_ARRAY_PTR(PrusaObjectDataViewModelNode*, MyObjectTreeModelNodePtrArray);
class ObjectDataViewModelNode;
WX_DEFINE_ARRAY_PTR(ObjectDataViewModelNode*, MyObjectTreeModelNodePtrArray);
class PrusaObjectDataViewModelNode
class ObjectDataViewModelNode
{
PrusaObjectDataViewModelNode* m_parent;
ObjectDataViewModelNode* m_parent;
MyObjectTreeModelNodePtrArray m_children;
wxBitmap m_empty_bmp;
size_t m_volumes_cnt = 0;
std::vector< std::string > m_opt_categories;
wxString m_name;
wxBitmap& m_bmp = m_empty_bmp;
ItemType m_type;
int m_idx = -1;
bool m_container = false;
wxString m_extruder = "default";
wxBitmap m_action_icon;
std::string m_action_icon_name = "";
Slic3r::ModelVolumeType m_volume_type;
public:
PrusaObjectDataViewModelNode(const wxString &name,
const wxString& extruder) {
m_parent = NULL;
m_name = name;
m_type = itObject;
ObjectDataViewModelNode(const wxString &name,
const wxString& extruder):
m_parent(NULL),
m_name(name),
m_type(itObject),
m_extruder(extruder)
{
#ifdef __WXGTK__
// it's necessary on GTK because of control have to know if this item will be container
// in another case you couldn't to add subitem for this item
// it will be produce "segmentation fault"
m_container = true;
#endif //__WXGTK__
m_extruder = extruder;
// set_object_action_icon();
set_action_icon();
}
PrusaObjectDataViewModelNode( PrusaObjectDataViewModelNode* parent,
ObjectDataViewModelNode(ObjectDataViewModelNode* parent,
const wxString& sub_obj_name,
const wxBitmap& bmp,
const wxString& extruder,
const int idx = -1 ) {
m_parent = parent;
m_name = sub_obj_name;
const int idx = -1 ) :
m_parent (parent),
m_name (sub_obj_name),
m_type (itVolume),
m_idx (idx),
m_extruder (extruder)
{
m_bmp = bmp;
m_type = itVolume;
m_idx = idx;
m_extruder = extruder;
#ifdef __WXGTK__
// it's necessary on GTK because of control have to know if this item will be container
// in another case you couldn't to add subitem for this item
@ -275,11 +213,11 @@ public:
m_container = true;
#endif //__WXGTK__
// set_part_action_icon();
set_action_icon();
}
PrusaObjectDataViewModelNode( PrusaObjectDataViewModelNode* parent, const ItemType type) :
ObjectDataViewModelNode(ObjectDataViewModelNode* parent,
const ItemType type) :
m_parent(parent),
m_type(type),
m_extruder(wxEmptyString)
@ -296,36 +234,28 @@ public:
else if (type == itInstance) {
m_idx = parent->GetChildCount();
m_name = wxString::Format("Instance_%d", m_idx+1);
// set_part_action_icon();
set_action_icon();
}
}
~PrusaObjectDataViewModelNode()
~ObjectDataViewModelNode()
{
// free all our children nodes
size_t count = m_children.GetCount();
for (size_t i = 0; i < count; i++)
{
PrusaObjectDataViewModelNode *child = m_children[i];
ObjectDataViewModelNode *child = m_children[i];
delete child;
}
}
wxString m_name;
wxBitmap& m_bmp = m_empty_bmp;
ItemType m_type;
int m_idx = -1;
bool m_container = false;
wxString m_extruder = "default";
wxBitmap m_action_icon;
bool IsContainer() const
{
return m_container;
}
PrusaObjectDataViewModelNode* GetParent()
ObjectDataViewModelNode* GetParent()
{
return m_parent;
}
@ -333,17 +263,17 @@ public:
{
return m_children;
}
PrusaObjectDataViewModelNode* GetNthChild(unsigned int n)
ObjectDataViewModelNode* GetNthChild(unsigned int n)
{
return m_children.Item(n);
}
void Insert(PrusaObjectDataViewModelNode* child, unsigned int n)
void Insert(ObjectDataViewModelNode* child, unsigned int n)
{
if (!m_container)
m_container = true;
m_children.Insert(child, n);
}
void Append(PrusaObjectDataViewModelNode* child)
void Append(ObjectDataViewModelNode* child)
{
if (!m_container)
m_container = true;
@ -373,7 +303,7 @@ public:
switch (col)
{
case 0:{
PrusaDataViewBitmapText data;
DataViewBitmapText data;
data << variant;
m_bmp = data.GetBitmap();
m_name = data.GetText();
@ -411,7 +341,7 @@ public:
}
// use this function only for childrens
void AssignAllVal(PrusaObjectDataViewModelNode& from_node)
void AssignAllVal(ObjectDataViewModelNode& from_node)
{
// ! Don't overwrite other values because of equality of this values for all children --
m_name = from_node.m_name;
@ -427,8 +357,8 @@ public:
scnd_id < 0 || scnd_id >= GetChildCount())
return false;
PrusaObjectDataViewModelNode new_scnd = *GetNthChild(frst_id);
PrusaObjectDataViewModelNode new_frst = *GetNthChild(scnd_id);
ObjectDataViewModelNode new_scnd = *GetNthChild(frst_id);
ObjectDataViewModelNode new_frst = *GetNthChild(scnd_id);
new_scnd.m_idx = m_children.Item(scnd_id)->m_idx;
new_frst.m_idx = m_children.Item(frst_id)->m_idx;
@ -439,38 +369,36 @@ public:
}
// Set action icons for node
// void set_object_action_icon();
// void set_part_action_icon();
void set_action_icon();
void update_settings_digest_bitmaps();
bool update_settings_digest(const std::vector<std::string>& categories);
int volume_type() const { return int(m_volume_type); }
void rescale();
void msw_rescale();
private:
friend class PrusaObjectDataViewModel;
friend class ObjectDataViewModel;
};
// ----------------------------------------------------------------------------
// PrusaObjectDataViewModel
// ObjectDataViewModel
// ----------------------------------------------------------------------------
// custom message the model sends to associated control to notify a last volume deleted from the object:
wxDECLARE_EVENT(wxCUSTOMEVT_LAST_VOLUME_IS_DELETED, wxCommandEvent);
class PrusaObjectDataViewModel :public wxDataViewModel
class ObjectDataViewModel :public wxDataViewModel
{
std::vector<PrusaObjectDataViewModelNode*> m_objects;
std::vector<ObjectDataViewModelNode*> m_objects;
std::vector<wxBitmap*> m_volume_bmps;
wxDataViewCtrl* m_ctrl{ nullptr };
public:
PrusaObjectDataViewModel();
~PrusaObjectDataViewModel();
ObjectDataViewModel();
~ObjectDataViewModel();
wxDataViewItem Add(const wxString &name, const int extruder);
wxDataViewItem AddVolumeChild(const wxDataViewItem &parent_item,
wxDataViewItem AddVolumeChild( const wxDataViewItem &parent_item,
const wxString &name,
const Slic3r::ModelVolumeType volume_type,
const int extruder = 0,
@ -505,18 +433,20 @@ public:
virtual unsigned int GetColumnCount() const override { return 3;}
virtual wxString GetColumnType(unsigned int col) const override{ return wxT("string"); }
virtual void GetValue(wxVariant &variant,
const wxDataViewItem &item, unsigned int col) const override;
virtual bool SetValue(const wxVariant &variant,
const wxDataViewItem &item, unsigned int col) override;
bool SetValue(const wxVariant &variant, const int item_idx, unsigned int col);
virtual void GetValue( wxVariant &variant,
const wxDataViewItem &item,
unsigned int col) const override;
virtual bool SetValue( const wxVariant &variant,
const wxDataViewItem &item,
unsigned int col) override;
bool SetValue( const wxVariant &variant,
const int item_idx,
unsigned int col);
// wxDataViewItem MoveChildUp(const wxDataViewItem &item);
// wxDataViewItem MoveChildDown(const wxDataViewItem &item);
// For parent move child from cur_volume_id place to new_volume_id
// Remaining items will moved up/down accordingly
wxDataViewItem ReorganizeChildren(int cur_volume_id,
int new_volume_id,
wxDataViewItem ReorganizeChildren( const int cur_volume_id,
const int new_volume_id,
const wxDataViewItem &parent);
virtual bool IsEnabled(const wxDataViewItem &item, unsigned int col) const override;
@ -533,11 +463,13 @@ public:
virtual bool HasContainerColumns(const wxDataViewItem& WXUNUSED(item)) const override { return true; }
ItemType GetItemType(const wxDataViewItem &item) const ;
wxDataViewItem GetItemByType(const wxDataViewItem &parent_item, ItemType type) const;
wxDataViewItem GetItemByType( const wxDataViewItem &parent_item,
ItemType type) const;
wxDataViewItem GetSettingsItem(const wxDataViewItem &item) const;
wxDataViewItem GetInstanceRootItem(const wxDataViewItem &item) const;
bool IsSettingsItem(const wxDataViewItem &item) const;
void UpdateSettingsDigest(const wxDataViewItem &item, const std::vector<std::string>& categories);
void UpdateSettingsDigest( const wxDataViewItem &item,
const std::vector<std::string>& categories);
void SetVolumeBitmaps(const std::vector<wxBitmap*>& volume_bmps) { m_volume_bmps = volume_bmps; }
void SetVolumeType(const wxDataViewItem &item, const Slic3r::ModelVolumeType type);
@ -548,16 +480,16 @@ public:
};
// ----------------------------------------------------------------------------
// PrusaBitmapTextRenderer
// BitmapTextRenderer
// ----------------------------------------------------------------------------
#if ENABLE_NONCUSTOM_DATA_VIEW_RENDERING
class PrusaBitmapTextRenderer : public wxDataViewRenderer
class BitmapTextRenderer : public wxDataViewRenderer
#else
class PrusaBitmapTextRenderer : public wxDataViewCustomRenderer
class BitmapTextRenderer : public wxDataViewCustomRenderer
#endif //ENABLE_NONCUSTOM_DATA_VIEW_RENDERING
{
public:
PrusaBitmapTextRenderer(wxDataViewCellMode mode =
BitmapTextRenderer(wxDataViewCellMode mode =
#ifdef __WXOSX__
wxDATAVIEW_CELL_INERT
#else
@ -568,7 +500,7 @@ public:
#if ENABLE_NONCUSTOM_DATA_VIEW_RENDERING
);
#else
) : wxDataViewCustomRenderer(wxT("PrusaDataViewBitmapText"), mode, align) {}
) : wxDataViewCustomRenderer(wxT("DataViewBitmapText"), mode, align) {}
#endif //ENABLE_NONCUSTOM_DATA_VIEW_RENDERING
bool SetValue(const wxVariant &value);
@ -596,7 +528,7 @@ public:
bool WasCanceled() const { return m_was_unusable_symbol; }
private:
PrusaDataViewBitmapText m_value;
DataViewBitmapText m_value;
bool m_was_unusable_symbol {false};
};
@ -694,21 +626,21 @@ private:
// ----------------------------------------------------------------------------
// PrusaBitmap
// ScalableBitmap
// ----------------------------------------------------------------------------
class PrusaBitmap
class ScalableBitmap
{
public:
PrusaBitmap() {};
PrusaBitmap(wxWindow *parent,
ScalableBitmap() {};
ScalableBitmap( wxWindow *parent,
const std::string& icon_name = "",
const int px_cnt = 16,
const bool is_horizontal = false);
~PrusaBitmap() {}
~ScalableBitmap() {}
void rescale();
void msw_rescale();
const wxBitmap& bmp() const { return m_bmp; }
wxBitmap& bmp() { return m_bmp; }
@ -724,7 +656,7 @@ private:
// ----------------------------------------------------------------------------
// PrusaDoubleSlider
// DoubleSlider
// ----------------------------------------------------------------------------
// custom message the slider sends to its parent to notify a tick-change:
@ -741,10 +673,10 @@ enum TicksAction{
taDel
};
class PrusaDoubleSlider : public wxControl
class DoubleSlider : public wxControl
{
public:
PrusaDoubleSlider(
DoubleSlider(
wxWindow *parent,
wxWindowID id,
int lowerValue,
@ -756,9 +688,9 @@ public:
long style = wxSL_VERTICAL,
const wxValidator& val = wxDefaultValidator,
const wxString& name = wxEmptyString);
~PrusaDoubleSlider() {}
~DoubleSlider() {}
void rescale();
void msw_rescale();
int GetMinValue() const { return m_min_value; }
int GetMaxValue() const { return m_max_value; }
@ -852,16 +784,16 @@ private:
int m_max_value;
int m_lower_value;
int m_higher_value;
/*wxBitmap*/PrusaBitmap m_bmp_thumb_higher;
/*wxBitmap*/PrusaBitmap m_bmp_thumb_lower;
/*wxBitmap*/PrusaBitmap m_bmp_add_tick_on;
/*wxBitmap*/PrusaBitmap m_bmp_add_tick_off;
/*wxBitmap*/PrusaBitmap m_bmp_del_tick_on;
/*wxBitmap*/PrusaBitmap m_bmp_del_tick_off;
/*wxBitmap*/PrusaBitmap m_bmp_one_layer_lock_on;
/*wxBitmap*/PrusaBitmap m_bmp_one_layer_lock_off;
/*wxBitmap*/PrusaBitmap m_bmp_one_layer_unlock_on;
/*wxBitmap*/PrusaBitmap m_bmp_one_layer_unlock_off;
ScalableBitmap m_bmp_thumb_higher;
ScalableBitmap m_bmp_thumb_lower;
ScalableBitmap m_bmp_add_tick_on;
ScalableBitmap m_bmp_add_tick_off;
ScalableBitmap m_bmp_del_tick_on;
ScalableBitmap m_bmp_del_tick_off;
ScalableBitmap m_bmp_one_layer_lock_on;
ScalableBitmap m_bmp_one_layer_lock_off;
ScalableBitmap m_bmp_one_layer_unlock_on;
ScalableBitmap m_bmp_one_layer_unlock_off;
SelectedSlider m_selection;
bool m_is_left_down = false;
bool m_is_right_down = false;
@ -892,26 +824,26 @@ private:
wxPen GREY_PEN;
wxPen LIGHT_GREY_PEN;
std::vector<wxPen*> line_pens;
std::vector<wxPen*> segm_pens;
std::vector<wxPen*> m_line_pens;
std::vector<wxPen*> m_segm_pens;
std::set<int> m_ticks;
std::vector<std::pair<int,double>> m_values;
};
// ----------------------------------------------------------------------------
// PrusaLockButton
// LockButton
// ----------------------------------------------------------------------------
class PrusaLockButton : public wxButton
class LockButton : public wxButton
{
public:
PrusaLockButton(
LockButton(
wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize);
~PrusaLockButton() {}
~LockButton() {}
void OnButton(wxCommandEvent& event);
void OnEnterBtn(wxMouseEvent& event) { enter_button(true); event.Skip(); }
@ -920,7 +852,7 @@ public:
bool IsLocked() const { return m_is_pushed; }
void SetLock(bool lock);
void rescale();
void msw_rescale();
protected:
void enter_button(const bool enter);
@ -928,23 +860,23 @@ protected:
private:
bool m_is_pushed = false;
/*wxBitmap*/PrusaBitmap m_bmp_lock_on;
/*wxBitmap*/PrusaBitmap m_bmp_lock_off;
/*wxBitmap*/PrusaBitmap m_bmp_unlock_on;
/*wxBitmap*/PrusaBitmap m_bmp_unlock_off;
ScalableBitmap m_bmp_lock_on;
ScalableBitmap m_bmp_lock_off;
ScalableBitmap m_bmp_unlock_on;
ScalableBitmap m_bmp_unlock_off;
};
// ----------------------------------------------------------------------------
// PrusaButton
// ScalableButton
// ----------------------------------------------------------------------------
class PrusaButton : public wxButton
class ScalableButton : public wxButton
{
public:
PrusaButton(){}
PrusaButton(
wxWindow *parent,
ScalableButton(){}
ScalableButton(
wxWindow * parent,
wxWindowID id,
const std::string& icon_name = "",
const wxString& label = wxEmptyString,
@ -952,18 +884,18 @@ public:
const wxPoint& pos = wxDefaultPosition,
long style = wxBU_EXACTFIT | wxNO_BORDER);
PrusaButton(
wxWindow *parent,
ScalableButton(
wxWindow * parent,
wxWindowID id,
const PrusaBitmap& bitmap,
const ScalableBitmap& bitmap,
const wxString& label = wxEmptyString,
long style = wxBU_EXACTFIT | wxNO_BORDER);
~PrusaButton() {}
~ScalableButton() {}
void SetBitmap_(const PrusaBitmap& bmp);
void SetBitmap_(const ScalableBitmap& bmp);
void rescale();
void msw_rescale();
private:
wxWindow* m_parent;
@ -972,20 +904,20 @@ private:
// ----------------------------------------------------------------------------
// PrusaModeButton
// ModeButton
// ----------------------------------------------------------------------------
class PrusaModeButton : public PrusaButton/*wxButton*/
class ModeButton : public ScalableButton
{
public:
PrusaModeButton(
wxWindow *parent,
ModeButton(
wxWindow* parent,
wxWindowID id,
const std::string& icon_name = "",
const wxString& mode = wxEmptyString,
const wxSize& size = wxDefaultSize,
const wxPoint& pos = wxDefaultPosition);
~PrusaModeButton() {}
~ModeButton() {}
void OnButton(wxCommandEvent& event);
void OnEnterBtn(wxMouseEvent& event) { focus_button(true); event.Skip(); }
@ -999,8 +931,6 @@ protected:
private:
bool m_is_selected = false;
// wxBitmap m_bmp_on;
// wxBitmap m_bmp_off;
wxString m_tt_selected;
wxString m_tt_focused;
};
@ -1008,42 +938,45 @@ private:
// ----------------------------------------------------------------------------
// PrusaModeSizer
// ModeSizer
// ----------------------------------------------------------------------------
class PrusaModeSizer : public wxFlexGridSizer
class ModeSizer : public wxFlexGridSizer
{
public:
PrusaModeSizer( wxWindow *parent, int hgap = 10);
~PrusaModeSizer() {}
ModeSizer( wxWindow *parent, int hgap = 10);
~ModeSizer() {}
void SetMode(const /*ConfigOptionMode*/int mode);
void rescale();
void msw_rescale();
private:
std::vector<PrusaModeButton*> mode_btns;
std::vector<ModeButton*> m_mode_btns;
};
// ----------------------------------------------------------------------------
// PrusaMenu
// MenuWithSeparators
// ----------------------------------------------------------------------------
class PrusaMenu : public wxMenu
class MenuWithSeparators : public wxMenu
{
public:
PrusaMenu(const wxString& title, long style = 0)
MenuWithSeparators(const wxString& title, long style = 0)
: wxMenu(title, style) {}
PrusaMenu(long style = 0)
MenuWithSeparators(long style = 0)
: wxMenu(style) {}
~PrusaMenu() {}
~MenuWithSeparators() {}
void DestroySeparators();
void SetFirstSeparator();
void SetSecondSeparator();
private:
wxMenuItem* m_separator_frst { nullptr }; // use like separator before settings item
wxMenuItem* m_separator_scnd { nullptr }; // use like separator between settings items
};