Fixed re-scaling under MSW for Layers editing

+ Clean code in GUI_ObjectManipulation.cpp
This commit is contained in:
YuSanka 2019-09-17 13:41:44 +02:00
parent c38e537adc
commit 93aa5ac6ce
4 changed files with 65 additions and 20 deletions

View file

@ -227,6 +227,42 @@ void ObjectLayers::msw_rescale()
{
m_bmp_delete.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()
@ -342,5 +378,10 @@ coordf_t LayerRangeEditor::get_value()
return layer_height;
}
void LayerRangeEditor::msw_rescale()
{
SetMinSize(wxSize(8 * wxGetApp().em_unit(), wxDefaultCoord));
}
} //namespace GUI
} //namespace Slic3r

View file

@ -49,6 +49,7 @@ public:
EditorType type() const {return m_type;}
void set_focus_data() const { m_set_focus_data(m_type);}
void msw_rescale();
private:
coordf_t get_value();

View file

@ -104,8 +104,6 @@ void msw_rescale_word_local_combo(wxBitmapComboBox* combo)
combo->Append(_(L("World coordinates")));
combo->Append(_(L("Local coordinates")));
// combo->SetSelection(0);
// combo->SetValue(combo->GetString(0));
wxBitmap empty_bmp(1, combo->GetFont().GetPixelSize().y + 2);
empty_bmp.SetWidth(0);
@ -141,20 +139,10 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) :
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" };
auto manifold_warning_icon = [this](wxWindow* parent) {
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())
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());
});
// return sizer;
return m_fix_throught_netfab_bitmap;
};
// line.append_widget(manifold_warning_icon);
line.near_label_widget = manifold_warning_icon;
def.label = "";
def.gui_type = "legend";

View file

@ -460,6 +460,9 @@ void ObjectDataViewModelNode::init_container()
#endif //__WXGTK__
}
#define LAYER_ROOT_ICON "edit_layers_all"
#define LAYER_ICON "edit_layers_some"
ObjectDataViewModelNode::ObjectDataViewModelNode(ObjectDataViewModelNode* parent, const ItemType type) :
m_parent(parent),
m_type(type),
@ -478,7 +481,7 @@ ObjectDataViewModelNode::ObjectDataViewModelNode(ObjectDataViewModelNode* parent
}
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"));
}
@ -507,7 +510,7 @@ ObjectDataViewModelNode::ObjectDataViewModelNode(ObjectDataViewModelNode* parent
}
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_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();
init_container();
@ -581,6 +584,9 @@ void ObjectDataViewModelNode::msw_rescale()
if (!m_action_icon_name.empty())
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())
update_settings_digest_bitmaps();
}
@ -1766,11 +1772,22 @@ void ObjectDataViewModel::Rescale()
ObjectDataViewModelNode *node = (ObjectDataViewModelNode*)item.GetID();
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());
if (node->m_type & itObject && node->m_bmp.IsOk())
node->m_bmp = *m_warning_bmp;
break;
case itLayerRoot:
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);
}