Fixed re-scaling under MSW for Layers editing
+ Clean code in GUI_ObjectManipulation.cpp
This commit is contained in:
parent
c38e537adc
commit
93aa5ac6ce
4 changed files with 65 additions and 20 deletions
|
@ -227,6 +227,42 @@ void ObjectLayers::msw_rescale()
|
||||||
{
|
{
|
||||||
m_bmp_delete.msw_rescale();
|
m_bmp_delete.msw_rescale();
|
||||||
m_bmp_add.msw_rescale();
|
m_bmp_add.msw_rescale();
|
||||||
|
|
||||||
|
m_grid_sizer->SetHGap(wxGetApp().em_unit());
|
||||||
|
|
||||||
|
// rescale edit-boxes
|
||||||
|
const int cells_cnt = m_grid_sizer->GetCols() * m_grid_sizer->GetEffectiveRowsCount();
|
||||||
|
for (int i = 0; i < cells_cnt; i++)
|
||||||
|
{
|
||||||
|
const wxSizerItem* item = m_grid_sizer->GetItem(i);
|
||||||
|
if (item->IsWindow())
|
||||||
|
{
|
||||||
|
LayerRangeEditor* editor = dynamic_cast<LayerRangeEditor*>(item->GetWindow());
|
||||||
|
if (editor != nullptr)
|
||||||
|
editor->msw_rescale();
|
||||||
|
}
|
||||||
|
else if (item->IsSizer()) // case when we have editor with buttons
|
||||||
|
{
|
||||||
|
wxSizerItem* e_item = item->GetSizer()->GetItem(size_t(0)); // editor
|
||||||
|
if (e_item->IsWindow()) {
|
||||||
|
LayerRangeEditor* editor = dynamic_cast<LayerRangeEditor*>(e_item->GetWindow());
|
||||||
|
if (editor != nullptr)
|
||||||
|
editor->msw_rescale();
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<size_t> btns = {2, 3}; // del_btn, add_btn
|
||||||
|
for (auto btn : btns)
|
||||||
|
{
|
||||||
|
wxSizerItem* b_item = item->GetSizer()->GetItem(btn);
|
||||||
|
if (b_item->IsWindow()) {
|
||||||
|
ScalableButton* button = dynamic_cast<ScalableButton*>(b_item->GetWindow());
|
||||||
|
if (button != nullptr)
|
||||||
|
button->msw_rescale();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_grid_sizer->Layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectLayers::reset_selection()
|
void ObjectLayers::reset_selection()
|
||||||
|
@ -342,5 +378,10 @@ coordf_t LayerRangeEditor::get_value()
|
||||||
return layer_height;
|
return layer_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LayerRangeEditor::msw_rescale()
|
||||||
|
{
|
||||||
|
SetMinSize(wxSize(8 * wxGetApp().em_unit(), wxDefaultCoord));
|
||||||
|
}
|
||||||
|
|
||||||
} //namespace GUI
|
} //namespace GUI
|
||||||
} //namespace Slic3r
|
} //namespace Slic3r
|
|
@ -49,6 +49,7 @@ public:
|
||||||
|
|
||||||
EditorType type() const {return m_type;}
|
EditorType type() const {return m_type;}
|
||||||
void set_focus_data() const { m_set_focus_data(m_type);}
|
void set_focus_data() const { m_set_focus_data(m_type);}
|
||||||
|
void msw_rescale();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
coordf_t get_value();
|
coordf_t get_value();
|
||||||
|
|
|
@ -104,8 +104,6 @@ void msw_rescale_word_local_combo(wxBitmapComboBox* combo)
|
||||||
|
|
||||||
combo->Append(_(L("World coordinates")));
|
combo->Append(_(L("World coordinates")));
|
||||||
combo->Append(_(L("Local coordinates")));
|
combo->Append(_(L("Local coordinates")));
|
||||||
// combo->SetSelection(0);
|
|
||||||
// combo->SetValue(combo->GetString(0));
|
|
||||||
|
|
||||||
wxBitmap empty_bmp(1, combo->GetFont().GetPixelSize().y + 2);
|
wxBitmap empty_bmp(1, combo->GetFont().GetPixelSize().y + 2);
|
||||||
empty_bmp.SetWidth(0);
|
empty_bmp.SetWidth(0);
|
||||||
|
@ -141,20 +139,10 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
|
||||||
|
|
||||||
ConfigOptionDef def;
|
ConfigOptionDef def;
|
||||||
|
|
||||||
// Objects(sub-objects) name
|
|
||||||
// def.label = L("Name");
|
|
||||||
// def.gui_type = "legend";
|
|
||||||
// def.tooltip = L("Object name");
|
|
||||||
// def.width = 21 * wxGetApp().em_unit();
|
|
||||||
// def.default_value = new ConfigOptionString{ " " };
|
|
||||||
// m_og->append_single_option_line(Option(def, "object_name"));
|
|
||||||
|
|
||||||
Line line = Line{ "Name", "Object name" };
|
Line line = Line{ "Name", "Object name" };
|
||||||
|
|
||||||
auto manifold_warning_icon = [this](wxWindow* parent) {
|
auto manifold_warning_icon = [this](wxWindow* parent) {
|
||||||
m_fix_throught_netfab_bitmap = new wxStaticBitmap(parent, wxID_ANY, wxNullBitmap);
|
m_fix_throught_netfab_bitmap = new wxStaticBitmap(parent, wxID_ANY, wxNullBitmap);
|
||||||
// auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
|
||||||
// sizer->Add(m_fix_throught_netfab_bitmap);
|
|
||||||
|
|
||||||
if (is_windows10())
|
if (is_windows10())
|
||||||
m_fix_throught_netfab_bitmap->Bind(wxEVT_CONTEXT_MENU, [this](wxCommandEvent &e)
|
m_fix_throught_netfab_bitmap->Bind(wxEVT_CONTEXT_MENU, [this](wxCommandEvent &e)
|
||||||
|
@ -167,11 +155,9 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
|
||||||
update_warning_icon_state(wxGetApp().obj_list()->get_mesh_errors_list());
|
update_warning_icon_state(wxGetApp().obj_list()->get_mesh_errors_list());
|
||||||
});
|
});
|
||||||
|
|
||||||
// return sizer;
|
|
||||||
return m_fix_throught_netfab_bitmap;
|
return m_fix_throught_netfab_bitmap;
|
||||||
};
|
};
|
||||||
|
|
||||||
// line.append_widget(manifold_warning_icon);
|
|
||||||
line.near_label_widget = manifold_warning_icon;
|
line.near_label_widget = manifold_warning_icon;
|
||||||
def.label = "";
|
def.label = "";
|
||||||
def.gui_type = "legend";
|
def.gui_type = "legend";
|
||||||
|
|
|
@ -460,6 +460,9 @@ void ObjectDataViewModelNode::init_container()
|
||||||
#endif //__WXGTK__
|
#endif //__WXGTK__
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define LAYER_ROOT_ICON "edit_layers_all"
|
||||||
|
#define LAYER_ICON "edit_layers_some"
|
||||||
|
|
||||||
ObjectDataViewModelNode::ObjectDataViewModelNode(ObjectDataViewModelNode* parent, const ItemType type) :
|
ObjectDataViewModelNode::ObjectDataViewModelNode(ObjectDataViewModelNode* parent, const ItemType type) :
|
||||||
m_parent(parent),
|
m_parent(parent),
|
||||||
m_type(type),
|
m_type(type),
|
||||||
|
@ -478,7 +481,7 @@ ObjectDataViewModelNode::ObjectDataViewModelNode(ObjectDataViewModelNode* parent
|
||||||
}
|
}
|
||||||
else if (type == itLayerRoot)
|
else if (type == itLayerRoot)
|
||||||
{
|
{
|
||||||
m_bmp = create_scaled_bitmap(nullptr, "edit_layers_all"); // FIXME: pass window ptr
|
m_bmp = create_scaled_bitmap(nullptr, LAYER_ROOT_ICON); // FIXME: pass window ptr
|
||||||
m_name = _(L("Layers"));
|
m_name = _(L("Layers"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -507,7 +510,7 @@ ObjectDataViewModelNode::ObjectDataViewModelNode(ObjectDataViewModelNode* parent
|
||||||
}
|
}
|
||||||
const std::string label_range = (boost::format(" %.2f-%.2f ") % layer_range.first % layer_range.second).str();
|
const std::string label_range = (boost::format(" %.2f-%.2f ") % layer_range.first % layer_range.second).str();
|
||||||
m_name = _(L("Range")) + label_range + "(" + _(L("mm")) + ")";
|
m_name = _(L("Range")) + label_range + "(" + _(L("mm")) + ")";
|
||||||
m_bmp = create_scaled_bitmap(nullptr, "edit_layers_some"); // FIXME: pass window ptr
|
m_bmp = create_scaled_bitmap(nullptr, LAYER_ICON); // FIXME: pass window ptr
|
||||||
|
|
||||||
set_action_icon();
|
set_action_icon();
|
||||||
init_container();
|
init_container();
|
||||||
|
@ -581,6 +584,9 @@ void ObjectDataViewModelNode::msw_rescale()
|
||||||
if (!m_action_icon_name.empty())
|
if (!m_action_icon_name.empty())
|
||||||
m_action_icon = create_scaled_bitmap(nullptr, m_action_icon_name);
|
m_action_icon = create_scaled_bitmap(nullptr, m_action_icon_name);
|
||||||
|
|
||||||
|
if (m_printable != piUndef)
|
||||||
|
m_printable_icon = create_scaled_bitmap(nullptr, m_printable == piPrintable ? "eye_open.png" : "eye_closed.png");
|
||||||
|
|
||||||
if (!m_opt_categories.empty())
|
if (!m_opt_categories.empty())
|
||||||
update_settings_digest_bitmaps();
|
update_settings_digest_bitmaps();
|
||||||
}
|
}
|
||||||
|
@ -1766,11 +1772,22 @@ void ObjectDataViewModel::Rescale()
|
||||||
ObjectDataViewModelNode *node = (ObjectDataViewModelNode*)item.GetID();
|
ObjectDataViewModelNode *node = (ObjectDataViewModelNode*)item.GetID();
|
||||||
node->msw_rescale();
|
node->msw_rescale();
|
||||||
|
|
||||||
if (node->m_type & itVolume)
|
switch (node->m_type)
|
||||||
|
{
|
||||||
|
case itObject:
|
||||||
|
if (node->m_bmp.IsOk()) node->m_bmp = *m_warning_bmp;
|
||||||
|
break;
|
||||||
|
case itVolume:
|
||||||
node->m_bmp = GetVolumeIcon(node->m_volume_type, node->m_bmp.GetWidth() != node->m_bmp.GetHeight());
|
node->m_bmp = GetVolumeIcon(node->m_volume_type, node->m_bmp.GetWidth() != node->m_bmp.GetHeight());
|
||||||
|
break;
|
||||||
if (node->m_type & itObject && node->m_bmp.IsOk())
|
case itLayerRoot:
|
||||||
node->m_bmp = *m_warning_bmp;
|
node->m_bmp = create_scaled_bitmap(nullptr, LAYER_ROOT_ICON); // FIXME: pass window ptr
|
||||||
|
break;
|
||||||
|
case itLayer:
|
||||||
|
node->m_bmp = create_scaled_bitmap(nullptr, LAYER_ICON); // FIXME: pass window ptr
|
||||||
|
break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
|
||||||
ItemChanged(item);
|
ItemChanged(item);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue