Bitmaps: Pass wxWindow context in a few more places

This commit is contained in:
Vojtech Kral 2019-04-09 17:40:14 +02:00
parent d399ebacc9
commit 81f4ce5f2e
5 changed files with 25 additions and 25 deletions

View file

@ -61,7 +61,7 @@ DPIFrame(NULL, wxID_ANY, SLIC3R_BUILD, wxDefaultPosition, wxDefaultSize, wxDEFAU
/* Load default preset bitmaps before a tabpanel initialization, /* Load default preset bitmaps before a tabpanel initialization,
* but after filling of an em_unit value * but after filling of an em_unit value
*/ */
wxGetApp().preset_bundle->load_default_preset_bitmaps(); wxGetApp().preset_bundle->load_default_preset_bitmaps(this);
// initialize tabpanel and menubar // initialize tabpanel and menubar
init_tabpanel(); init_tabpanel();

View file

@ -799,16 +799,14 @@ bool PresetCollection::delete_current_preset()
return true; return true;
} }
void PresetCollection::load_bitmap_default(const std::string &file_name) void PresetCollection::load_bitmap_default(wxWindow *window, const std::string &file_name)
{ {
// FIXME: pass window ptr for proper scaling *m_bitmap_main_frame = create_scaled_bitmap(window, file_name);
*m_bitmap_main_frame = create_scaled_bitmap(nullptr, file_name);
} }
void PresetCollection::load_bitmap_add(const std::string &file_name) void PresetCollection::load_bitmap_add(wxWindow *window, const std::string &file_name)
{ {
// FIXME: pass window ptr for proper scaling *m_bitmap_add = create_scaled_bitmap(window, file_name);
*m_bitmap_add = create_scaled_bitmap(nullptr, file_name);
} }
const Preset* PresetCollection::get_selected_preset_parent() const const Preset* PresetCollection::get_selected_preset_parent() const

View file

@ -15,6 +15,7 @@ class wxBitmapComboBox;
class wxChoice; class wxChoice;
class wxItemContainer; class wxItemContainer;
class wxString; class wxString;
class wxWindow;
namespace Slic3r { namespace Slic3r {
@ -276,10 +277,10 @@ public:
bool delete_current_preset(); bool delete_current_preset();
// Load default bitmap to be placed at the wxBitmapComboBox of a MainFrame. // Load default bitmap to be placed at the wxBitmapComboBox of a MainFrame.
void load_bitmap_default(const std::string &file_name); void load_bitmap_default(wxWindow *window, const std::string &file_name);
// Load "add new printer" bitmap to be placed at the wxBitmapComboBox of a MainFrame. // Load "add new printer" bitmap to be placed at the wxBitmapComboBox of a MainFrame.
void load_bitmap_add(const std::string &file_name); void load_bitmap_add(wxWindow *window, const std::string &file_name);
// Compatible & incompatible marks, to be placed at the wxBitmapComboBox items. // Compatible & incompatible marks, to be placed at the wxBitmapComboBox items.
void set_bitmap_compatible (const wxBitmap *bmp) { m_bitmap_compatible = bmp; } void set_bitmap_compatible (const wxBitmap *bmp) { m_bitmap_compatible = bmp; }

View file

@ -396,13 +396,12 @@ void PresetBundle::export_selections(AppConfig &config)
config.set("presets", "printer", printers.get_selected_preset_name()); config.set("presets", "printer", printers.get_selected_preset_name());
} }
void PresetBundle::load_compatible_bitmaps() void PresetBundle::load_compatible_bitmaps(wxWindow *window)
{ {
// FIXME: pass window ptr for proper scaling *m_bitmapCompatible = create_scaled_bitmap(window, "flag-green-icon.png");
*m_bitmapCompatible = create_scaled_bitmap(nullptr, "flag-green-icon.png"); *m_bitmapIncompatible = create_scaled_bitmap(window, "flag-red-icon.png");
*m_bitmapIncompatible = create_scaled_bitmap(nullptr, "flag-red-icon.png"); *m_bitmapLock = create_scaled_bitmap(window, "sys_lock.png");
*m_bitmapLock = create_scaled_bitmap(nullptr, "sys_lock.png"); *m_bitmapLockOpen = create_scaled_bitmap(window, "sys_unlock.png");
*m_bitmapLockOpen = create_scaled_bitmap(nullptr, "sys_unlock.png");
prints .set_bitmap_compatible(m_bitmapCompatible); prints .set_bitmap_compatible(m_bitmapCompatible);
filaments .set_bitmap_compatible(m_bitmapCompatible); filaments .set_bitmap_compatible(m_bitmapCompatible);
@ -1428,15 +1427,15 @@ bool PresetBundle::parse_color(const std::string &scolor, unsigned char *rgb_out
return true; return true;
} }
void PresetBundle::load_default_preset_bitmaps() void PresetBundle::load_default_preset_bitmaps(wxWindow *window)
{ {
this->prints.load_bitmap_default("cog"); this->prints.load_bitmap_default(window, "cog");
this->sla_prints.load_bitmap_default("cog"); this->sla_prints.load_bitmap_default(window, "cog");
this->filaments.load_bitmap_default("spool.png"); this->filaments.load_bitmap_default(window, "spool.png");
this->sla_materials.load_bitmap_default("package_green.png"); this->sla_materials.load_bitmap_default(window, "package_green.png");
this->printers.load_bitmap_default("printer"); this->printers.load_bitmap_default(window, "printer");
this->printers.load_bitmap_add("add.png"); this->printers.load_bitmap_add(window, "add.png");
this->load_compatible_bitmaps(); this->load_compatible_bitmaps(window);
} }
void PresetBundle::update_platter_filament_ui(unsigned int idx_extruder, GUI::PresetComboBox *ui) void PresetBundle::update_platter_filament_ui(unsigned int idx_extruder, GUI::PresetComboBox *ui)

View file

@ -7,6 +7,8 @@
#include <set> #include <set>
#include <boost/filesystem/path.hpp> #include <boost/filesystem/path.hpp>
class wxWindow;
namespace Slic3r { namespace Slic3r {
namespace GUI { namespace GUI {
@ -127,7 +129,7 @@ public:
static bool parse_color(const std::string &scolor, unsigned char *rgb_out); static bool parse_color(const std::string &scolor, unsigned char *rgb_out);
void load_default_preset_bitmaps(); void load_default_preset_bitmaps(wxWindow *window);
private: private:
std::string load_system_presets(); std::string load_system_presets();
@ -148,7 +150,7 @@ private:
// If it is not an external config, then the config will be stored into the user profile directory. // If it is not an external config, then the config will be stored into the user profile directory.
void load_config_file_config(const std::string &name_or_path, bool is_external, DynamicPrintConfig &&config); void load_config_file_config(const std::string &name_or_path, bool is_external, DynamicPrintConfig &&config);
void load_config_file_config_bundle(const std::string &path, const boost::property_tree::ptree &tree); void load_config_file_config_bundle(const std::string &path, const boost::property_tree::ptree &tree);
void load_compatible_bitmaps(); void load_compatible_bitmaps(wxWindow *window);
DynamicPrintConfig full_fff_config() const; DynamicPrintConfig full_fff_config() const;
DynamicPrintConfig full_sla_config() const; DynamicPrintConfig full_sla_config() const;