Fixed an icon scaling in the ObjectList under OSX
This commit is contained in:
parent
cf7d7bd40f
commit
635def1648
3 changed files with 59 additions and 43 deletions
|
@ -90,20 +90,20 @@ ObjectList::ObjectList(wxWindow* parent) :
|
||||||
// see note in PresetBundle::load_compatible_bitmaps()
|
// see note in PresetBundle::load_compatible_bitmaps()
|
||||||
|
|
||||||
// ptFFF
|
// ptFFF
|
||||||
CATEGORY_ICON[L("Layers and Perimeters")] = create_scaled_bitmap(nullptr, "layers");
|
CATEGORY_ICON[L("Layers and Perimeters")] = create_scaled_bitmap(this, "layers");
|
||||||
CATEGORY_ICON[L("Infill")] = create_scaled_bitmap(nullptr, "infill");
|
CATEGORY_ICON[L("Infill")] = create_scaled_bitmap(this, "infill");
|
||||||
CATEGORY_ICON[L("Support material")] = create_scaled_bitmap(nullptr, "support");
|
CATEGORY_ICON[L("Support material")] = create_scaled_bitmap(this, "support");
|
||||||
CATEGORY_ICON[L("Speed")] = create_scaled_bitmap(nullptr, "time");
|
CATEGORY_ICON[L("Speed")] = create_scaled_bitmap(this, "time");
|
||||||
CATEGORY_ICON[L("Extruders")] = create_scaled_bitmap(nullptr, "funnel");
|
CATEGORY_ICON[L("Extruders")] = create_scaled_bitmap(this, "funnel");
|
||||||
CATEGORY_ICON[L("Extrusion Width")] = create_scaled_bitmap(nullptr, "funnel");
|
CATEGORY_ICON[L("Extrusion Width")] = create_scaled_bitmap(this, "funnel");
|
||||||
CATEGORY_ICON[L("Wipe options")] = create_scaled_bitmap(nullptr, "funnel");
|
CATEGORY_ICON[L("Wipe options")] = create_scaled_bitmap(this, "funnel");
|
||||||
// CATEGORY_ICON[L("Skirt and brim")] = create_scaled_bitmap(nullptr, "skirt+brim");
|
// CATEGORY_ICON[L("Skirt and brim")] = create_scaled_bitmap(this, "skirt+brim");
|
||||||
// CATEGORY_ICON[L("Speed > Acceleration")] = create_scaled_bitmap(nullptr, "time");
|
// CATEGORY_ICON[L("Speed > Acceleration")] = create_scaled_bitmap(this, "time");
|
||||||
CATEGORY_ICON[L("Advanced")] = create_scaled_bitmap(nullptr, "wrench");
|
CATEGORY_ICON[L("Advanced")] = create_scaled_bitmap(this, "wrench");
|
||||||
// ptSLA
|
// ptSLA
|
||||||
CATEGORY_ICON[L("Supports")] = create_scaled_bitmap(nullptr, "support"/*"sla_supports"*/);
|
CATEGORY_ICON[L("Supports")] = create_scaled_bitmap(this, "support"/*"sla_supports"*/);
|
||||||
CATEGORY_ICON[L("Pad")] = create_scaled_bitmap(nullptr, "pad");
|
CATEGORY_ICON[L("Pad")] = create_scaled_bitmap(this, "pad");
|
||||||
CATEGORY_ICON[L("Hollowing")] = create_scaled_bitmap(nullptr, "hollowing");
|
CATEGORY_ICON[L("Hollowing")] = create_scaled_bitmap(this, "hollowing");
|
||||||
}
|
}
|
||||||
|
|
||||||
// create control
|
// create control
|
||||||
|
@ -265,7 +265,7 @@ void ObjectList::create_objects_ctrl()
|
||||||
|
|
||||||
// column ItemName(Icon+Text) of the view control:
|
// column ItemName(Icon+Text) of the view control:
|
||||||
// And Icon can be consisting of several bitmaps
|
// And Icon can be consisting of several bitmaps
|
||||||
AppendColumn(new wxDataViewColumn(_(L("Name")), new BitmapTextRenderer(),
|
AppendColumn(new wxDataViewColumn(_(L("Name")), new BitmapTextRenderer(this),
|
||||||
colName, 20*em, wxALIGN_LEFT, wxDATAVIEW_COL_RESIZABLE));
|
colName, 20*em, wxALIGN_LEFT, wxDATAVIEW_COL_RESIZABLE));
|
||||||
|
|
||||||
// column PrintableProperty (Icon) of the view control:
|
// column PrintableProperty (Icon) of the view control:
|
||||||
|
@ -559,10 +559,10 @@ void ObjectList::update_name_in_model(const wxDataViewItem& item) const
|
||||||
|
|
||||||
void ObjectList::init_icons()
|
void ObjectList::init_icons()
|
||||||
{
|
{
|
||||||
m_bmp_solidmesh = ScalableBitmap(nullptr, ADD_VOLUME_MENU_ITEMS[int(ModelVolumeType::MODEL_PART) ].second);
|
m_bmp_solidmesh = ScalableBitmap(this, ADD_VOLUME_MENU_ITEMS[int(ModelVolumeType::MODEL_PART) ].second);
|
||||||
m_bmp_modifiermesh = ScalableBitmap(nullptr, ADD_VOLUME_MENU_ITEMS[int(ModelVolumeType::PARAMETER_MODIFIER)].second);
|
m_bmp_modifiermesh = ScalableBitmap(this, ADD_VOLUME_MENU_ITEMS[int(ModelVolumeType::PARAMETER_MODIFIER)].second);
|
||||||
m_bmp_support_enforcer = ScalableBitmap(nullptr, ADD_VOLUME_MENU_ITEMS[int(ModelVolumeType::SUPPORT_ENFORCER) ].second);
|
m_bmp_support_enforcer = ScalableBitmap(this, ADD_VOLUME_MENU_ITEMS[int(ModelVolumeType::SUPPORT_ENFORCER) ].second);
|
||||||
m_bmp_support_blocker = ScalableBitmap(nullptr, ADD_VOLUME_MENU_ITEMS[int(ModelVolumeType::SUPPORT_BLOCKER) ].second);
|
m_bmp_support_blocker = ScalableBitmap(this, ADD_VOLUME_MENU_ITEMS[int(ModelVolumeType::SUPPORT_BLOCKER) ].second);
|
||||||
|
|
||||||
m_bmp_vector.reserve(4); // bitmaps for different types of parts
|
m_bmp_vector.reserve(4); // bitmaps for different types of parts
|
||||||
m_bmp_vector.push_back(&m_bmp_solidmesh.bmp());
|
m_bmp_vector.push_back(&m_bmp_solidmesh.bmp());
|
||||||
|
@ -575,12 +575,12 @@ void ObjectList::init_icons()
|
||||||
m_objects_model->SetVolumeBitmaps(m_bmp_vector);
|
m_objects_model->SetVolumeBitmaps(m_bmp_vector);
|
||||||
|
|
||||||
// init icon for manifold warning
|
// init icon for manifold warning
|
||||||
m_bmp_manifold_warning = ScalableBitmap(nullptr, "exclamation");
|
m_bmp_manifold_warning = ScalableBitmap(this, "exclamation");
|
||||||
// Set warning bitmap for the model
|
// Set warning bitmap for the model
|
||||||
m_objects_model->SetWarningBitmap(&m_bmp_manifold_warning.bmp());
|
m_objects_model->SetWarningBitmap(&m_bmp_manifold_warning.bmp());
|
||||||
|
|
||||||
// init bitmap for "Add Settings" context menu
|
// init bitmap for "Add Settings" context menu
|
||||||
m_bmp_cog = ScalableBitmap(nullptr, "cog");
|
m_bmp_cog = ScalableBitmap(this, "cog");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectList::msw_rescale_icons()
|
void ObjectList::msw_rescale_icons()
|
||||||
|
@ -1741,7 +1741,8 @@ void ObjectList::create_instance_popupmenu(wxMenu*menu)
|
||||||
void ObjectList::create_default_popupmenu(wxMenu*menu)
|
void ObjectList::create_default_popupmenu(wxMenu*menu)
|
||||||
{
|
{
|
||||||
wxMenu* sub_menu = append_submenu_add_generic(menu, ModelVolumeType::INVALID);
|
wxMenu* sub_menu = append_submenu_add_generic(menu, ModelVolumeType::INVALID);
|
||||||
append_submenu(menu, sub_menu, wxID_ANY, _(L("Add Shape")), "", "add_part");
|
append_submenu(menu, sub_menu, wxID_ANY, _(L("Add Shape")), "", "add_part",
|
||||||
|
[](){return true;}, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMenu* ObjectList::create_settings_popupmenu(wxMenu *parent_menu)
|
wxMenu* ObjectList::create_settings_popupmenu(wxMenu *parent_menu)
|
||||||
|
|
|
@ -584,7 +584,8 @@ void ObjectDataViewModelNode::init_container()
|
||||||
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),
|
||||||
m_extruder(wxEmptyString)
|
m_extruder(wxEmptyString),
|
||||||
|
m_ctrl(parent->m_ctrl)
|
||||||
{
|
{
|
||||||
if (type == itSettings)
|
if (type == itSettings)
|
||||||
m_name = "Settings to modified";
|
m_name = "Settings to modified";
|
||||||
|
@ -599,7 +600,7 @@ ObjectDataViewModelNode::ObjectDataViewModelNode(ObjectDataViewModelNode* parent
|
||||||
}
|
}
|
||||||
else if (type == itLayerRoot)
|
else if (type == itLayerRoot)
|
||||||
{
|
{
|
||||||
m_bmp = create_scaled_bitmap(nullptr, LAYER_ROOT_ICON); // FIXME: pass window ptr
|
m_bmp = create_scaled_bitmap(m_ctrl, LAYER_ROOT_ICON); // FIXME: pass window ptr
|
||||||
m_name = _(L("Layers"));
|
m_name = _(L("Layers"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -615,7 +616,8 @@ ObjectDataViewModelNode::ObjectDataViewModelNode(ObjectDataViewModelNode* parent
|
||||||
m_type(itLayer),
|
m_type(itLayer),
|
||||||
m_idx(idx),
|
m_idx(idx),
|
||||||
m_layer_range(layer_range),
|
m_layer_range(layer_range),
|
||||||
m_extruder(extruder)
|
m_extruder(extruder),
|
||||||
|
m_ctrl(parent->m_ctrl)
|
||||||
{
|
{
|
||||||
const int children_cnt = parent->GetChildCount();
|
const int children_cnt = parent->GetChildCount();
|
||||||
if (idx < 0)
|
if (idx < 0)
|
||||||
|
@ -628,7 +630,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, LAYER_ICON); // FIXME: pass window ptr
|
m_bmp = create_scaled_bitmap(m_ctrl, LAYER_ICON); // FIXME: pass window ptr
|
||||||
|
|
||||||
set_action_and_extruder_icons();
|
set_action_and_extruder_icons();
|
||||||
init_container();
|
init_container();
|
||||||
|
@ -647,7 +649,7 @@ void ObjectDataViewModelNode::set_action_and_extruder_icons()
|
||||||
{
|
{
|
||||||
m_action_icon_name = m_type & itObject ? "advanced_plus" :
|
m_action_icon_name = m_type & itObject ? "advanced_plus" :
|
||||||
m_type & (itVolume | itLayer) ? "cog" : /*m_type & itInstance*/ "set_separate_obj";
|
m_type & (itVolume | itLayer) ? "cog" : /*m_type & itInstance*/ "set_separate_obj";
|
||||||
m_action_icon = create_scaled_bitmap(nullptr, m_action_icon_name); // FIXME: pass window ptr
|
m_action_icon = create_scaled_bitmap(m_ctrl, m_action_icon_name); // FIXME: pass window ptr
|
||||||
|
|
||||||
if (m_type & itInstance)
|
if (m_type & itInstance)
|
||||||
return; // don't set colored bitmap for Instance
|
return; // don't set colored bitmap for Instance
|
||||||
|
@ -662,7 +664,7 @@ void ObjectDataViewModelNode::set_printable_icon(PrintIndicator printable)
|
||||||
{
|
{
|
||||||
m_printable = printable;
|
m_printable = printable;
|
||||||
m_printable_icon = m_printable == piUndef ? m_empty_bmp :
|
m_printable_icon = m_printable == piUndef ? m_empty_bmp :
|
||||||
create_scaled_bitmap(nullptr, m_printable == piPrintable ? "eye_open.png" : "eye_closed.png");
|
create_scaled_bitmap(m_ctrl, m_printable == piPrintable ? "eye_open.png" : "eye_closed.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectDataViewModelNode::update_settings_digest_bitmaps()
|
void ObjectDataViewModelNode::update_settings_digest_bitmaps()
|
||||||
|
@ -707,10 +709,10 @@ bool ObjectDataViewModelNode::update_settings_digest(const std::vector<std::stri
|
||||||
void ObjectDataViewModelNode::msw_rescale()
|
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(m_ctrl, m_action_icon_name);
|
||||||
|
|
||||||
if (m_printable != piUndef)
|
if (m_printable != piUndef)
|
||||||
m_printable_icon = create_scaled_bitmap(nullptr, m_printable == piPrintable ? "eye_open.png" : "eye_closed.png");
|
m_printable_icon = create_scaled_bitmap(m_ctrl, 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();
|
||||||
|
@ -791,7 +793,7 @@ wxDataViewItem ObjectDataViewModel::Add(const wxString &name,
|
||||||
const bool has_errors/* = false*/)
|
const bool has_errors/* = false*/)
|
||||||
{
|
{
|
||||||
const wxString extruder_str = extruder == 0 ? _(L("default")) : wxString::Format("%d", extruder);
|
const wxString extruder_str = extruder == 0 ? _(L("default")) : wxString::Format("%d", extruder);
|
||||||
auto root = new ObjectDataViewModelNode(name, extruder_str);
|
auto root = new ObjectDataViewModelNode(name, extruder_str, m_ctrl);
|
||||||
// Add error icon if detected auto-repaire
|
// Add error icon if detected auto-repaire
|
||||||
if (has_errors)
|
if (has_errors)
|
||||||
root->m_bmp = *m_warning_bmp;
|
root->m_bmp = *m_warning_bmp;
|
||||||
|
@ -1987,10 +1989,9 @@ void ObjectDataViewModel::Rescale()
|
||||||
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;
|
break;
|
||||||
case itLayerRoot:
|
case itLayerRoot:
|
||||||
node->m_bmp = create_scaled_bitmap(nullptr, LAYER_ROOT_ICON); // FIXME: pass window ptr
|
node->m_bmp = create_scaled_bitmap(m_ctrl, LAYER_ROOT_ICON);
|
||||||
break;
|
|
||||||
case itLayer:
|
case itLayer:
|
||||||
node->m_bmp = create_scaled_bitmap(nullptr, LAYER_ICON); // FIXME: pass window ptr
|
node->m_bmp = create_scaled_bitmap(m_ctrl, LAYER_ICON);
|
||||||
break;
|
break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
@ -2092,8 +2093,11 @@ bool BitmapTextRenderer::Render(wxRect rect, wxDC *dc, int state)
|
||||||
const wxBitmap& icon = m_value.GetBitmap();
|
const wxBitmap& icon = m_value.GetBitmap();
|
||||||
if (icon.IsOk())
|
if (icon.IsOk())
|
||||||
{
|
{
|
||||||
dc->DrawBitmap(icon, rect.x, rect.y + (rect.height - icon.GetHeight()) / 2);
|
float sf = (float)1.0 / get_svg_scale_factor(m_parent);
|
||||||
xoffset = icon.GetWidth() + 4;
|
wxSize icon_sz = icon.GetSize() * sf;
|
||||||
|
|
||||||
|
dc->DrawBitmap(icon, rect.x, rect.y + (rect.height - icon_sz.y) / 2);
|
||||||
|
xoffset = icon_sz.x + 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderText(m_value.GetText(), xoffset, rect, dc, state);
|
RenderText(m_value.GetText(), xoffset, rect, dc, state);
|
||||||
|
|
|
@ -228,13 +228,18 @@ class ObjectDataViewModelNode
|
||||||
std::string m_action_icon_name = "";
|
std::string m_action_icon_name = "";
|
||||||
Slic3r::ModelVolumeType m_volume_type;
|
Slic3r::ModelVolumeType m_volume_type;
|
||||||
|
|
||||||
|
// pointer to control (is needed to create scaled bitmaps)
|
||||||
|
wxDataViewCtrl* m_ctrl{ nullptr };
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ObjectDataViewModelNode(const wxString &name,
|
ObjectDataViewModelNode(const wxString& name,
|
||||||
const wxString& extruder):
|
const wxString& extruder,
|
||||||
|
wxDataViewCtrl* ctrl):
|
||||||
m_parent(NULL),
|
m_parent(NULL),
|
||||||
m_name(name),
|
m_name(name),
|
||||||
m_type(itObject),
|
m_type(itObject),
|
||||||
m_extruder(extruder)
|
m_extruder(extruder),
|
||||||
|
m_ctrl(ctrl)
|
||||||
{
|
{
|
||||||
set_action_and_extruder_icons();
|
set_action_and_extruder_icons();
|
||||||
init_container();
|
init_container();
|
||||||
|
@ -249,7 +254,8 @@ public:
|
||||||
m_name (sub_obj_name),
|
m_name (sub_obj_name),
|
||||||
m_type (itVolume),
|
m_type (itVolume),
|
||||||
m_idx (idx),
|
m_idx (idx),
|
||||||
m_extruder (extruder)
|
m_extruder (extruder),
|
||||||
|
m_ctrl (parent->m_ctrl)
|
||||||
{
|
{
|
||||||
m_bmp = bmp;
|
m_bmp = bmp;
|
||||||
set_action_and_extruder_icons();
|
set_action_and_extruder_icons();
|
||||||
|
@ -538,7 +544,8 @@ class BitmapTextRenderer : public wxDataViewCustomRenderer
|
||||||
#endif //ENABLE_NONCUSTOM_DATA_VIEW_RENDERING
|
#endif //ENABLE_NONCUSTOM_DATA_VIEW_RENDERING
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BitmapTextRenderer(wxDataViewCellMode mode =
|
BitmapTextRenderer( wxWindow* parent,
|
||||||
|
wxDataViewCellMode mode =
|
||||||
#ifdef __WXOSX__
|
#ifdef __WXOSX__
|
||||||
wxDATAVIEW_CELL_INERT
|
wxDATAVIEW_CELL_INERT
|
||||||
#else
|
#else
|
||||||
|
@ -549,7 +556,10 @@ public:
|
||||||
#if ENABLE_NONCUSTOM_DATA_VIEW_RENDERING
|
#if ENABLE_NONCUSTOM_DATA_VIEW_RENDERING
|
||||||
);
|
);
|
||||||
#else
|
#else
|
||||||
) : wxDataViewCustomRenderer(wxT("DataViewBitmapText"), mode, align) {}
|
) :
|
||||||
|
wxDataViewCustomRenderer(wxT("DataViewBitmapText"), mode, align),
|
||||||
|
m_parent(parent)
|
||||||
|
{}
|
||||||
#endif //ENABLE_NONCUSTOM_DATA_VIEW_RENDERING
|
#endif //ENABLE_NONCUSTOM_DATA_VIEW_RENDERING
|
||||||
|
|
||||||
bool SetValue(const wxVariant &value);
|
bool SetValue(const wxVariant &value);
|
||||||
|
@ -577,8 +587,9 @@ public:
|
||||||
bool WasCanceled() const { return m_was_unusable_symbol; }
|
bool WasCanceled() const { return m_was_unusable_symbol; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DataViewBitmapText m_value;
|
DataViewBitmapText m_value;
|
||||||
bool m_was_unusable_symbol {false};
|
bool m_was_unusable_symbol {false};
|
||||||
|
wxWindow* m_parent {nullptr};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue