mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 16:57:53 -06:00
To fix blurred icons under OSX there is implemented PresetBitmapComboBox, derived from wxBitmapComboBox,
which now will be used for preset choosers on sidebar a preset tabs. + for BitmapCache class added m_scale used for correct scaling of SVG images on Retina displays + some code clearing from unused functions or function's parameters
This commit is contained in:
parent
378321231f
commit
1472ad9b14
17 changed files with 319 additions and 177 deletions
|
@ -53,9 +53,8 @@ class wxBitmapComboBox;
|
|||
void edit_tooltip(wxString& tooltip);
|
||||
void msw_buttons_rescale(wxDialog* dlg, const int em_unit, const std::vector<int>& btn_ids);
|
||||
int em_unit(wxWindow* win);
|
||||
float get_svg_scale_factor(wxWindow* win);
|
||||
|
||||
wxBitmap create_scaled_bitmap(wxWindow *win, const std::string& bmp_name,
|
||||
wxBitmap create_scaled_bitmap(const std::string& bmp_name, wxWindow *win = nullptr,
|
||||
const int px_cnt = 16, const bool grayscale = false);
|
||||
|
||||
std::vector<wxBitmap*> get_extruder_color_icons(bool thin_icon = false);
|
||||
|
@ -102,6 +101,37 @@ public:
|
|||
void OnListBoxSelection(wxCommandEvent& evt);
|
||||
};
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
// *** PresetBitmapComboBox ***
|
||||
|
||||
// BitmapComboBox used to presets list on Sidebar and Tabs
|
||||
class PresetBitmapComboBox: public wxBitmapComboBox
|
||||
{
|
||||
public:
|
||||
PresetBitmapComboBox(wxWindow* parent, const wxSize& size = wxDefaultSize);
|
||||
~PresetBitmapComboBox() {}
|
||||
|
||||
#ifdef __APPLE__
|
||||
protected:
|
||||
/* For PresetBitmapComboBox we use bitmaps that are created from images that are already scaled appropriately for Retina
|
||||
* (Contrary to the intuition, the `scale` argument for Bitmap's constructor doesn't mean
|
||||
* "please scale this to such and such" but rather
|
||||
* "the wxImage is already sized for backing scale such and such". )
|
||||
* Unfortunately, the constructor changes the size of wxBitmap too.
|
||||
* Thus We need to use unscaled size value for bitmaps that we use
|
||||
* to avoid scaled size of control items.
|
||||
* For this purpose control drawing methods and
|
||||
* control size calculation methods (virtual) are overridden.
|
||||
**/
|
||||
virtual bool OnAddBitmap(const wxBitmap& bitmap) override;
|
||||
virtual void OnDrawItem(wxDC& dc, const wxRect& rect, int item, int flags) const override;
|
||||
#endif
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// *** wxDataViewTreeCtrlComboBox ***
|
||||
|
||||
|
@ -228,18 +258,13 @@ class ObjectDataViewModelNode
|
|||
std::string m_action_icon_name = "";
|
||||
Slic3r::ModelVolumeType m_volume_type;
|
||||
|
||||
// pointer to control (is needed to create scaled bitmaps)
|
||||
wxDataViewCtrl* m_ctrl{ nullptr };
|
||||
|
||||
public:
|
||||
ObjectDataViewModelNode(const wxString& name,
|
||||
const wxString& extruder,
|
||||
wxDataViewCtrl* ctrl):
|
||||
const wxString& extruder):
|
||||
m_parent(NULL),
|
||||
m_name(name),
|
||||
m_type(itObject),
|
||||
m_extruder(extruder),
|
||||
m_ctrl(ctrl)
|
||||
m_extruder(extruder)
|
||||
{
|
||||
set_action_and_extruder_icons();
|
||||
init_container();
|
||||
|
@ -254,8 +279,7 @@ public:
|
|||
m_name (sub_obj_name),
|
||||
m_type (itVolume),
|
||||
m_idx (idx),
|
||||
m_extruder (extruder),
|
||||
m_ctrl (parent->m_ctrl)
|
||||
m_extruder (extruder)
|
||||
{
|
||||
m_bmp = bmp;
|
||||
set_action_and_extruder_icons();
|
||||
|
@ -734,6 +758,10 @@ public:
|
|||
|
||||
~ScalableBitmap() {}
|
||||
|
||||
wxSize GetBmpSize() const;
|
||||
int GetBmpWidth() const;
|
||||
int GetBmpHeight() const;
|
||||
|
||||
void msw_rescale();
|
||||
|
||||
const wxBitmap& bmp() const { return m_bmp; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue