Some modifications:
- Added no_controller to create_preset_tab(). - Small changes in Tab"Setting" constructor.
This commit is contained in:
parent
fced9a85ec
commit
4d234e90ae
@ -162,9 +162,9 @@ sub _init_tabpanel {
|
||||
EVT_COMMAND($self, -1, $VALUE_CHANGE_EVENT, sub {
|
||||
my ($self, $event) = @_;
|
||||
my $str = $event->GetString;
|
||||
my ($opt_key, $title) = ($str =~ /(.*) (.*)/);
|
||||
my ($opt_key, $name) = ($str =~ /(.*) (.*)/);
|
||||
#print "VALUE_CHANGE_EVENT: ", $opt_key, "\n";
|
||||
my $tab = Slic3r::GUI::get_preset_tab($title);
|
||||
my $tab = Slic3r::GUI::get_preset_tab($name);
|
||||
my $config = $tab->get_config;
|
||||
if ($self->{plater}) {
|
||||
$self->{plater}->on_config_change($config); # propagate config change events to the plater
|
||||
@ -180,11 +180,9 @@ sub _init_tabpanel {
|
||||
# or when the preset's "modified" status changes.
|
||||
EVT_COMMAND($self, -1, $PRESETS_CHANGED_EVENT, sub {
|
||||
my ($self, $event) = @_;
|
||||
my $title = $event->GetString;
|
||||
my $tab_name = lc($title);
|
||||
#print "PRESETS_CHANGED_EVENT: ", $tab_name , "\n";
|
||||
my $tab_name = $event->GetString;
|
||||
|
||||
my $tab = Slic3r::GUI::get_preset_tab($title);
|
||||
my $tab = Slic3r::GUI::get_preset_tab($tab_name);
|
||||
if ($self->{plater}) {
|
||||
# Update preset combo boxes (Print settings, Filament, Printer) from their respective tabs.
|
||||
my $presets = $tab->get_presets;
|
||||
@ -205,10 +203,10 @@ sub _init_tabpanel {
|
||||
$self->{plater}->on_config_change($tab->get_config);
|
||||
}
|
||||
});
|
||||
Slic3r::GUI::create_preset_tabs(wxTheApp->{preset_bundle}, wxTheApp->{app_config}, $VALUE_CHANGE_EVENT, $PRESETS_CHANGED_EVENT);
|
||||
$self->{options_tabs2}{print} = Slic3r::GUI::get_preset_tab("Print");
|
||||
$self->{options_tabs2}{filament} = Slic3r::GUI::get_preset_tab("Filament");
|
||||
$self->{options_tabs2}{printer} = Slic3r::GUI::get_preset_tab("Printer");
|
||||
Slic3r::GUI::create_preset_tabs(wxTheApp->{preset_bundle}, wxTheApp->{app_config}, $self->{no_controller}, $VALUE_CHANGE_EVENT, $PRESETS_CHANGED_EVENT);
|
||||
$self->{options_tabs2}{print} = Slic3r::GUI::get_preset_tab("print");
|
||||
$self->{options_tabs2}{filament} = Slic3r::GUI::get_preset_tab("filament");
|
||||
$self->{options_tabs2}{printer} = Slic3r::GUI::get_preset_tab("printer");
|
||||
|
||||
if ($self->{plater}) {
|
||||
$self->{plater}->on_select_preset(sub {
|
||||
|
@ -186,15 +186,16 @@ void add_debug_menu(wxMenuBar *menu)
|
||||
#endif
|
||||
}
|
||||
|
||||
void create_preset_tabs(PresetBundle *preset_bundle, AppConfig *app_config, int event_value_change, int event_presets_changed)
|
||||
void create_preset_tabs(PresetBundle *preset_bundle, AppConfig *app_config,
|
||||
bool no_controller, int event_value_change, int event_presets_changed)
|
||||
{
|
||||
add_created_tab(new TabPrint (g_wxTabPanel, "Print"), preset_bundle, app_config);
|
||||
add_created_tab(new TabFilament(g_wxTabPanel, "Filament"), preset_bundle, app_config);
|
||||
add_created_tab(new TabPrinter (g_wxTabPanel, "Printer"), preset_bundle, app_config);
|
||||
add_created_tab(new TabPrint (g_wxTabPanel), preset_bundle, app_config, no_controller);
|
||||
add_created_tab(new TabFilament(g_wxTabPanel), preset_bundle, app_config, no_controller);
|
||||
add_created_tab(new TabPrinter (g_wxTabPanel), preset_bundle, app_config, no_controller);
|
||||
g_wxTabPanel->Bind(wxEVT_NOTEBOOK_PAGE_CHANGED, ([](wxCommandEvent e){
|
||||
Tab* panel = (Tab*)g_wxTabPanel->GetCurrentPage();
|
||||
if (panel->GetName().compare("Print")==0 ||
|
||||
panel->GetName().compare("Filament") == 0)
|
||||
if (panel->GetName().compare("Print Settings")==0 ||
|
||||
panel->GetName().compare("Filament Settings") == 0)
|
||||
panel->OnActivate();
|
||||
}), g_wxTabPanel->GetId() );
|
||||
for (size_t i = 0; i < g_wxTabPanel->GetPageCount(); ++ i) {
|
||||
@ -212,7 +213,7 @@ TabIface* get_preset_tab_iface(char *name)
|
||||
Tab *tab = dynamic_cast<Tab*>(g_wxTabPanel->GetPage(i));
|
||||
if (! tab)
|
||||
continue;
|
||||
if (tab->title().ToStdString() == name) {
|
||||
if (tab->name() == name) {
|
||||
return new TabIface(tab);
|
||||
}
|
||||
}
|
||||
@ -297,15 +298,14 @@ void change_opt_value(DynamicPrintConfig& config, t_config_option_key opt_key, b
|
||||
}
|
||||
}
|
||||
|
||||
void add_created_tab(Tab* panel, PresetBundle *preset_bundle, AppConfig *app_config)
|
||||
void add_created_tab(Tab* panel, PresetBundle *preset_bundle, AppConfig *app_config, bool no_controller)
|
||||
{
|
||||
panel->m_no_controller = app_config->get("no_controller").empty();
|
||||
panel->m_no_controller = no_controller;
|
||||
panel->m_show_btn_incompatible_presets = app_config->get("show_incompatible_presets").empty();
|
||||
panel->create_preset_tab(preset_bundle);
|
||||
|
||||
// Load the currently selected preset into the GUI, update the preset selection box.
|
||||
panel->load_current_preset();
|
||||
|
||||
g_wxTabPanel->AddPage(panel, panel->title());
|
||||
}
|
||||
|
||||
|
@ -36,11 +36,12 @@ void set_tab_panel(wxNotebook *tab_panel);
|
||||
|
||||
void add_debug_menu(wxMenuBar *menu);
|
||||
// Create a new preset tab (print, filament and printer),
|
||||
void create_preset_tabs(PresetBundle *preset_bundle, AppConfig *app_config, int event_value_change, int event_presets_changed);
|
||||
void create_preset_tabs(PresetBundle *preset_bundle, AppConfig *app_config,
|
||||
bool no_controller, int event_value_change, int event_presets_changed);
|
||||
TabIface* get_preset_tab_iface(char *name);
|
||||
|
||||
// add it at the end of the tab panel.
|
||||
void add_created_tab(Tab* panel, PresetBundle *preset_bundle, AppConfig *app_config);
|
||||
void add_created_tab(Tab* panel, PresetBundle *preset_bundle, AppConfig *app_config, bool no_controller);
|
||||
// Change option value in config
|
||||
void change_opt_value(DynamicPrintConfig& config, t_config_option_key opt_key, boost::any value);
|
||||
|
||||
|
@ -276,14 +276,13 @@ void Tab::on_value_change(std::string opt_key, boost::any value)
|
||||
{
|
||||
if (m_event_value_change > 0) {
|
||||
wxCommandEvent event(m_event_value_change);
|
||||
std::string str_out = opt_key + " " + m_title;
|
||||
std::string str_out = opt_key + " " + m_name;
|
||||
event.SetString(str_out);
|
||||
if (opt_key == "extruders_count")
|
||||
{
|
||||
int val = boost::any_cast<size_t>(value);
|
||||
event.SetInt(val);
|
||||
}
|
||||
|
||||
g_wxMainFrame->ProcessWindowEvent(event);
|
||||
}
|
||||
update();
|
||||
@ -298,7 +297,7 @@ void Tab::on_presets_changed(/*std::vector<std::string> reload_dependent_tabs*/)
|
||||
{
|
||||
if (m_event_presets_changed > 0) {
|
||||
wxCommandEvent event(m_event_presets_changed);
|
||||
event.SetString(m_title);
|
||||
event.SetString(m_name);
|
||||
g_wxMainFrame->ProcessWindowEvent(event);
|
||||
}
|
||||
}
|
||||
|
@ -76,6 +76,7 @@ class Tab: public wxPanel
|
||||
{
|
||||
wxNotebook* m_parent;
|
||||
protected:
|
||||
std::string m_name;
|
||||
const wxString m_title;
|
||||
wxBitmapComboBox* m_presets_choice;
|
||||
wxBitmapButton* m_btn_save_preset;
|
||||
@ -108,18 +109,18 @@ public:
|
||||
bool m_show_btn_incompatible_presets;
|
||||
PresetCollection* m_presets;
|
||||
DynamicPrintConfig* m_config;
|
||||
// t_change m_on_value_change{ nullptr };
|
||||
// std::function<void()> m_on_presets_changed{ nullptr };
|
||||
|
||||
public:
|
||||
Tab() {}
|
||||
Tab(wxNotebook* parent, const char *title) : m_parent(parent), m_title(title) {
|
||||
Tab(wxNotebook* parent, const char *title, const char* name) :
|
||||
m_parent(parent), m_title(title), m_name(name) {
|
||||
Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBK_LEFT | wxTAB_TRAVERSAL);
|
||||
}
|
||||
~Tab(){}
|
||||
|
||||
wxWindow* parent() const { return m_parent; }
|
||||
wxString title() const { return m_title; }
|
||||
std::string name() const { return m_name; }
|
||||
|
||||
// Set the events to the callbacks posted to the main frame window (currently implemented in Perl).
|
||||
void set_event_value_change(wxEventType evt) { m_event_value_change = evt; }
|
||||
@ -161,8 +162,7 @@ public:
|
||||
bool current_preset_is_dirty();
|
||||
DynamicPrintConfig* get_config() { return m_config; }
|
||||
PresetCollection* get_presets() { return m_presets; }
|
||||
std::vector<std::string> get_dependent_tabs() {
|
||||
return m_reload_dependent_tabs; }
|
||||
std::vector<std::string> get_dependent_tabs() { return m_reload_dependent_tabs; }
|
||||
|
||||
void on_value_change(std::string opt_key, boost::any value);
|
||||
|
||||
@ -175,7 +175,7 @@ class TabPrint : public Tab
|
||||
{
|
||||
public:
|
||||
TabPrint() {}
|
||||
TabPrint(wxNotebook* parent, const char *title) : Tab(parent, title) {}
|
||||
TabPrint(wxNotebook* parent) : Tab(parent, "Print Settings", "print") {}
|
||||
~TabPrint(){}
|
||||
|
||||
ogStaticText* m_recommended_thin_wall_thickness_description_line;
|
||||
@ -194,7 +194,7 @@ class TabFilament : public Tab
|
||||
ogStaticText* m_cooling_description_line;
|
||||
public:
|
||||
TabFilament() {}
|
||||
TabFilament(wxNotebook* parent, const char *title) : Tab(parent, title) {}
|
||||
TabFilament(wxNotebook* parent) : Tab(parent, "Filament Settings", "filament") {}
|
||||
~TabFilament(){}
|
||||
|
||||
void build() override;
|
||||
@ -215,7 +215,7 @@ public:
|
||||
|
||||
public:
|
||||
TabPrinter() {}
|
||||
TabPrinter(wxNotebook* parent, const char *title) : Tab(parent, title) {}
|
||||
TabPrinter(wxNotebook* parent) : Tab(parent, "Printer Settings", "printer") {}
|
||||
~TabPrinter(){}
|
||||
|
||||
void build() override;
|
||||
|
@ -7,7 +7,7 @@ void TabIface::load_current_preset() { m_tab->load_current_preset(); }
|
||||
void TabIface::update_tab_ui() { m_tab->update_tab_ui(); }
|
||||
void TabIface::update_ui_from_settings() { m_tab->update_ui_from_settings();}
|
||||
void TabIface::select_preset(char* name) { m_tab->select_preset(name);}
|
||||
char* TabIface::title() { return (char*)m_tab->title().ToStdString()/*ToUTF8()*/.data();}
|
||||
char* TabIface::title() { return (char*)m_tab->title().ToStdString().data();}
|
||||
void TabIface::load_config(DynamicPrintConfig* config) { m_tab->load_config(*config);}
|
||||
bool TabIface::current_preset_is_dirty() { return m_tab->current_preset_is_dirty();}
|
||||
DynamicPrintConfig* TabIface::get_config() { return m_tab->get_config();}
|
||||
|
@ -35,8 +35,8 @@ void set_tab_panel(SV *ui)
|
||||
void add_debug_menu(SV *ui)
|
||||
%code%{ Slic3r::GUI::add_debug_menu((wxMenuBar*)wxPli_sv_2_object(aTHX_ ui, "Wx::MenuBar")); %};
|
||||
|
||||
void create_preset_tabs(PresetBundle *preset_bundle, AppConfig *app_config, int event_value_change, int event_presets_changed)
|
||||
%code%{ Slic3r::GUI::create_preset_tabs(preset_bundle, app_config, event_value_change, event_presets_changed); %};
|
||||
void create_preset_tabs(PresetBundle *preset_bundle, AppConfig *app_config, bool no_controller, int event_value_change, int event_presets_changed)
|
||||
%code%{ Slic3r::GUI::create_preset_tabs(preset_bundle, app_config, no_controller, event_value_change, event_presets_changed); %};
|
||||
|
||||
Ref<TabIface> get_preset_tab(char *name)
|
||||
%code%{ RETVAL=Slic3r::GUI::get_preset_tab_iface(name); %};
|
||||
|
Loading…
Reference in New Issue
Block a user