diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 1a769a87e..4548fd391 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -109,10 +109,11 @@ sub new { # callback to enable/disable action buttons my $enable_action_buttons = sub { my ($enable) = @_; - $self->{btn_export_gcode}->Enable($enable); - $self->{btn_reslice}->Enable($enable); - $self->{btn_print}->Enable($enable); - $self->{btn_send_gcode}->Enable($enable); + Slic3r::GUI::enable_action_buttons($enable); +# $self->{btn_export_gcode}->Enable($enable); +# $self->{btn_reslice}->Enable($enable); +# $self->{btn_print}->Enable($enable); +# $self->{btn_send_gcode}->Enable($enable); }; # callback to react to gizmo scale @@ -363,26 +364,35 @@ sub new { # } ### Panel for right column -# $self->{right_panel} = Wx::Panel->new($self, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); - $self->{right_panel} = Wx::ScrolledWindow->new($self, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); - $self->{right_panel}->SetScrollbars(0, 1, 1, 1); + $self->{right_panel} = Wx::Panel->new($self, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); +# $self->{right_panel} = Wx::ScrolledWindow->new($self, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); +# $self->{right_panel}->SetScrollbars(0, 1, 1, 1); + + ### Scrolled Window for panel without "Export G-code" and "Slice now" buttons + my $scrolled_window_sizer = $self->{scrolled_window_sizer} = Wx::BoxSizer->new(wxVERTICAL); + $scrolled_window_sizer->SetMinSize([320, -1]); + my $scrolled_window_panel = $self->{scrolled_window_panel} = Wx::ScrolledWindow->new($self->{right_panel}, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); + $scrolled_window_panel->SetSizer($scrolled_window_sizer); + $scrolled_window_panel->SetScrollbars(0, 1, 1, 1); # right pane buttons $self->{btn_export_gcode} = Wx::Button->new($self->{right_panel}, -1, L("Export G-code…"), wxDefaultPosition, [-1, 30], wxNO_BORDER);#, wxBU_LEFT); - $self->{btn_reslice} = Wx::Button->new($self->{right_panel}, -1, L("Slice now"), wxDefaultPosition, [-1, 30], wxBU_LEFT); - $self->{btn_print} = Wx::Button->new($self->{right_panel}, -1, L("Print…"), wxDefaultPosition, [-1, 30], wxBU_LEFT); - $self->{btn_send_gcode} = Wx::Button->new($self->{right_panel}, -1, L("Send to printer"), wxDefaultPosition, [-1, 30], wxBU_LEFT); - $self->{btn_export_stl} = Wx::Button->new($self->{right_panel}, -1, L("Export STL…"), wxDefaultPosition, [-1, 30], wxBU_LEFT); + $self->{btn_reslice} = Wx::Button->new($self->{right_panel}, -1, L("Slice now"), wxDefaultPosition, [-1, 30], wxNO_BORDER);#, wxBU_LEFT); +# $self->{btn_print} = Wx::Button->new($self->{right_panel}, -1, L("Print…"), wxDefaultPosition, [-1, 30], wxBU_LEFT); +# $self->{btn_send_gcode} = Wx::Button->new($self->{right_panel}, -1, L("Send to printer"), wxDefaultPosition, [-1, 30], wxBU_LEFT); + $self->{btn_print} = Wx::Button->new($scrolled_window_panel, -1, L("Print…"), wxDefaultPosition, [-1, 30], wxBU_LEFT); + $self->{btn_send_gcode} = Wx::Button->new($scrolled_window_panel, -1, L("Send to printer"), wxDefaultPosition, [-1, 30], wxBU_LEFT); + #$self->{btn_export_stl} = Wx::Button->new($self->{right_panel}, -1, L("Export STL…"), wxDefaultPosition, [-1, 30], wxBU_LEFT); #$self->{btn_export_gcode}->SetFont($Slic3r::GUI::small_font); #$self->{btn_export_stl}->SetFont($Slic3r::GUI::small_font); $self->{btn_print}->Hide; $self->{btn_send_gcode}->Hide; # export_gcode cog_go.png +#! reslice reslice.png my %icons = qw( print arrow_up.png send_gcode arrow_up.png - reslice reslice.png export_stl brick_go.png ); for (grep $self->{"btn_$_"}, keys %icons) { @@ -499,9 +509,11 @@ sub new { # $self->{preset_choosers}{$group}[$idx] $self->{preset_choosers} = {}; for my $group (qw(print filament sla_material printer)) { - my $text = Wx::StaticText->new($self->{right_panel}, -1, "$group_labels{$group}:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT); +# my $text = Wx::StaticText->new($self->{right_panel}, -1, "$group_labels{$group}:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT); + my $text = Wx::StaticText->new($scrolled_window_panel, -1, "$group_labels{$group}:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT); $text->SetFont($Slic3r::GUI::small_font); - my $choice = Wx::BitmapComboBox->new($self->{right_panel}, -1, "", wxDefaultPosition, wxDefaultSize, [], wxCB_READONLY); +# my $choice = Wx::BitmapComboBox->new($self->{right_panel}, -1, "", wxDefaultPosition, wxDefaultSize, [], wxCB_READONLY); + my $choice = Wx::BitmapComboBox->new($scrolled_window_panel, -1, "", wxDefaultPosition, wxDefaultSize, [], wxCB_READONLY); if ($group eq 'filament') { EVT_LEFT_DOWN($choice, sub { $self->filament_color_box_lmouse_down(0, @_); } ); } @@ -520,26 +532,13 @@ sub new { } my $frequently_changed_parameters_sizer = $self->{frequently_changed_parameters_sizer} = Wx::BoxSizer->new(wxVERTICAL); - Slic3r::GUI::add_frequently_changed_parameters($self->{right_panel}, $frequently_changed_parameters_sizer, $presets); - - my $expert_mode_part_sizer = Wx::BoxSizer->new(wxVERTICAL); - Slic3r::GUI::add_expert_mode_part( $self->{right_panel}, $expert_mode_part_sizer, - $self->{model}, - $self->{event_object_selection_changed}, - $self->{event_object_settings_changed}, - $self->{event_remove_object}, - $self->{event_update_scene}); -# if ($expert_mode_part_sizer->IsShown(2)==1) -# { -# $expert_mode_part_sizer->Layout; -# $expert_mode_part_sizer->Show(2, 0); # ? Why doesn't work -# $self->{right_panel}->Layout; -# } +#! Slic3r::GUI::add_frequently_changed_parameters($self->{right_panel}, $frequently_changed_parameters_sizer, $presets); + Slic3r::GUI::add_frequently_changed_parameters($self->{scrolled_window_panel}, $frequently_changed_parameters_sizer, $presets); my $object_info_sizer; { -# my $box = Wx::StaticBox->new($scrolled_window_panel, -1, L("Info")); - my $box = Wx::StaticBox->new($self->{right_panel}, -1, L("Info")); + my $box = Wx::StaticBox->new($scrolled_window_panel, -1, L("Info")); +# my $box = Wx::StaticBox->new($self->{right_panel}, -1, L("Info")); $box->SetFont($Slic3r::GUI::small_bold_font); $object_info_sizer = Wx::StaticBoxSizer->new($box, wxVERTICAL); $object_info_sizer->SetMinSize([300,-1]); @@ -559,17 +558,17 @@ sub new { ); while (my $field = shift @info) { my $label = shift @info; -# my $text = Wx::StaticText->new($scrolled_window_panel, -1, "$label:", wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT); - my $text = Wx::StaticText->new($self->{right_panel}, -1, "$label:", wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT); + my $text = Wx::StaticText->new($scrolled_window_panel, -1, "$label:", wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT); +# my $text = Wx::StaticText->new($self->{right_panel}, -1, "$label:", wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT); $text->SetFont($Slic3r::GUI::small_font); #!$grid_sizer->Add($text, 0); -# $self->{"object_info_$field"} = Wx::StaticText->new($scrolled_window_panel, -1, "", wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT); - $self->{"object_info_$field"} = Wx::StaticText->new($self->{right_panel}, -1, "", wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT); + $self->{"object_info_$field"} = Wx::StaticText->new($scrolled_window_panel, -1, "", wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT); +# $self->{"object_info_$field"} = Wx::StaticText->new($self->{right_panel}, -1, "", wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT); $self->{"object_info_$field"}->SetFont($Slic3r::GUI::small_font); if ($field eq 'manifold') { -# $self->{object_info_manifold_warning_icon} = Wx::StaticBitmap->new($scrolled_window_panel, -1, Wx::Bitmap->new(Slic3r::var("error.png"), wxBITMAP_TYPE_PNG)); - $self->{object_info_manifold_warning_icon} = Wx::StaticBitmap->new($self->{right_panel}, -1, Wx::Bitmap->new(Slic3r::var("error.png"), wxBITMAP_TYPE_PNG)); + $self->{object_info_manifold_warning_icon} = Wx::StaticBitmap->new($scrolled_window_panel, -1, Wx::Bitmap->new(Slic3r::var("error.png"), wxBITMAP_TYPE_PNG)); +# $self->{object_info_manifold_warning_icon} = Wx::StaticBitmap->new($self->{right_panel}, -1, Wx::Bitmap->new(Slic3r::var("error.png"), wxBITMAP_TYPE_PNG)); #$self->{object_info_manifold_warning_icon}->Hide; $self->{"object_info_manifold_warning_icon_show"} = sub { if ($self->{object_info_manifold_warning_icon}->IsShown() != $_[0]) { @@ -595,18 +594,19 @@ sub new { } } - my $print_info_sizer = $self->{print_info_sizer} = Wx::StaticBoxSizer->new( -# Wx::StaticBox->new($scrolled_window_panel, -1, L("Sliced Info")), wxVERTICAL); - Wx::StaticBox->new($self->{right_panel}, -1, L("Sliced Info")), wxVERTICAL); + my $print_info_box = Wx::StaticBox->new($scrolled_window_panel, -1, L("Sliced Info")); + $print_info_box->SetFont($Slic3r::GUI::small_bold_font); + my $print_info_sizer = $self->{print_info_sizer} = Wx::StaticBoxSizer->new($print_info_box, wxVERTICAL); +# Wx::StaticBox->new($self->{right_panel}, -1, L("Sliced Info")), wxVERTICAL); $print_info_sizer->SetMinSize([300,-1]); my $buttons_sizer = Wx::BoxSizer->new(wxHORIZONTAL); $self->{buttons_sizer} = $buttons_sizer; $buttons_sizer->AddStretchSpacer(1); - $buttons_sizer->Add($self->{btn_export_stl}, 0, wxALIGN_RIGHT, 0); - $buttons_sizer->Add($self->{btn_reslice}, 0, wxALIGN_RIGHT, 0); - $buttons_sizer->Add($self->{btn_print}, 0, wxALIGN_RIGHT, 0); - $buttons_sizer->Add($self->{btn_send_gcode}, 0, wxALIGN_RIGHT, 0); +# $buttons_sizer->Add($self->{btn_export_stl}, 0, wxALIGN_RIGHT, 0); +#! $buttons_sizer->Add($self->{btn_reslice}, 0, wxALIGN_RIGHT, 0); + $buttons_sizer->Add($self->{btn_print}, 0, wxALIGN_RIGHT | wxBOTTOM | wxTOP, 5); + $buttons_sizer->Add($self->{btn_send_gcode}, 0, wxALIGN_RIGHT | wxBOTTOM | wxTOP, 5); # $scrolled_window_sizer->Add($self->{list}, 1, wxEXPAND, 5); # $scrolled_window_sizer->Add($object_info_sizer, 0, wxEXPAND, 0); @@ -616,24 +616,39 @@ sub new { ### Sizer for info boxes my $info_sizer = $self->{info_sizer} = Wx::BoxSizer->new(wxVERTICAL); $info_sizer->SetMinSize([318, -1]); - $info_sizer->Add($object_info_sizer, 0, wxEXPAND | wxBOTTOM, 5); - $info_sizer->Add($print_info_sizer, 0, wxEXPAND | wxBOTTOM, 5); + $info_sizer->Add($object_info_sizer, 0, wxEXPAND | wxTOP, 20); + $info_sizer->Add($print_info_sizer, 0, wxEXPAND | wxTOP, 20); + + $scrolled_window_sizer->Add($presets, 0, wxEXPAND | wxLEFT, 2) if defined $presets; + $scrolled_window_sizer->Add($frequently_changed_parameters_sizer, 1, wxEXPAND | wxLEFT, 0) if defined $frequently_changed_parameters_sizer; + $scrolled_window_sizer->Add($buttons_sizer, 0, wxEXPAND, 0); + $scrolled_window_sizer->Add($info_sizer, 0, wxEXPAND | wxLEFT, 20); + # Show the box initially, let it be shown after the slicing is finished. + $self->print_info_box_show(0); + + ### Sizer for "Export G-code" & "Slice now" buttons + my $btns_sizer = Wx::BoxSizer->new(wxVERTICAL); + $btns_sizer->SetMinSize([318, -1]); + $btns_sizer->Add($self->{btn_reslice}, 0, wxEXPAND, 0); + $btns_sizer->Add($self->{btn_export_gcode}, 0, wxEXPAND | wxTOP, 5); my $right_sizer = Wx::BoxSizer->new(wxVERTICAL); $self->{right_panel}->SetSizer($right_sizer); $right_sizer->SetMinSize([320, -1]); - $right_sizer->Add($presets, 0, wxEXPAND | wxTOP, 10) if defined $presets; - $right_sizer->Add($frequently_changed_parameters_sizer, 1, wxEXPAND | wxTOP, 0) if defined $frequently_changed_parameters_sizer; - $right_sizer->Add($expert_mode_part_sizer, 0, wxEXPAND | wxTOP, 10) if defined $expert_mode_part_sizer; - $right_sizer->Add($buttons_sizer, 0, wxEXPAND | wxBOTTOM | wxTOP, 10); - $right_sizer->Add($info_sizer, 0, wxEXPAND | wxLEFT, 20); +#! $right_sizer->Add($presets, 0, wxEXPAND | wxTOP, 10) if defined $presets; +#! $right_sizer->Add($frequently_changed_parameters_sizer, 1, wxEXPAND | wxTOP, 0) if defined $frequently_changed_parameters_sizer; +#! $right_sizer->Add($buttons_sizer, 0, wxEXPAND | wxBOTTOM | wxTOP, 10); +#! $right_sizer->Add($info_sizer, 0, wxEXPAND | wxLEFT, 20); # Show the box initially, let it be shown after the slicing is finished. - $self->print_info_box_show(0); - $right_sizer->Add($self->{btn_export_gcode}, 0, wxEXPAND | wxLEFT | wxTOP | wxBOTTOM, 20); +#! $self->print_info_box_show(0); + $right_sizer->Add($scrolled_window_panel, 1, wxEXPAND | wxTOP, 5); +# $right_sizer->Add($self->{btn_reslice}, 0, wxEXPAND | wxLEFT | wxTOP, 20); +# $right_sizer->Add($self->{btn_export_gcode}, 0, wxEXPAND | wxLEFT | wxTOP, 20); + $right_sizer->Add($btns_sizer, 0, wxEXPAND | wxLEFT | wxTOP, 20); my $hsizer = Wx::BoxSizer->new(wxHORIZONTAL); $hsizer->Add($self->{preview_notebook}, 1, wxEXPAND | wxTOP, 1); - $hsizer->Add($self->{right_panel}, 0, wxEXPAND | wxLEFT | wxRIGHT, 3); + $hsizer->Add($self->{right_panel}, 0, wxEXPAND | wxLEFT | wxRIGHT, 0);#3); my $sizer = Wx::BoxSizer->new(wxVERTICAL); # $sizer->Add($self->{htoolbar}, 0, wxEXPAND, 0) if $self->{htoolbar}; @@ -644,16 +659,21 @@ sub new { $self->SetSizer($sizer); # Send sizers/buttons to C++ - Slic3r::GUI::set_objects_from_perl( $self->{right_panel}, - $frequently_changed_parameters_sizer, - $expert_mode_part_sizer, - $info_sizer, - $self->{btn_export_gcode}, - $self->{btn_export_stl}, - $self->{btn_reslice}, - $self->{btn_print}, - $self->{btn_send_gcode}, - $self->{object_info_manifold_warning_icon} ); + Slic3r::GUI::set_objects_from_perl( $self->{scrolled_window_panel}, + $frequently_changed_parameters_sizer, + $info_sizer, + $self->{btn_export_gcode}, + # $self->{btn_export_stl}, + $self->{btn_reslice}, + $self->{btn_print}, + $self->{btn_send_gcode}, + $self->{object_info_manifold_warning_icon} ); + + Slic3r::GUI::set_model_events_from_perl( $self->{model}, + $self->{event_object_selection_changed}, + $self->{event_object_settings_changed}, + $self->{event_remove_object}, + $self->{event_update_scene}); } # Last correct selected item for each preset @@ -1724,14 +1744,16 @@ sub print_info_box_show { # my $scrolled_window_panel = $self->{scrolled_window_panel}; # my $scrolled_window_sizer = $self->{scrolled_window_sizer}; # return if (!$show && ($scrolled_window_sizer->IsShown(2) == $show)); - my $panel = $self->{right_panel}; + my $panel = $self->{scrolled_window_panel};#$self->{right_panel}; my $sizer = $self->{info_sizer}; - return if (!$sizer || !$show && ($sizer->IsShown(1) == $show)); +# return if (!$sizer || !$show && ($sizer->IsShown(1) == $show)); + return if (!$sizer); Slic3r::GUI::set_show_print_info($show); - return if (wxTheApp->{app_config}->get("view_mode") eq "simple"); +# return if (wxTheApp->{app_config}->get("view_mode") eq "simple"); - if ($show) { +# if ($show) + { my $print_info_sizer = $self->{print_info_sizer}; $print_info_sizer->Clear(1); my $grid_sizer = Wx::FlexGridSizer->new(2, 2, 5, 5); @@ -1769,7 +1791,7 @@ sub print_info_box_show { # $scrolled_window_sizer->Show(2, $show); # $scrolled_window_panel->Layout; - $sizer->Show(1, $show); + $sizer->Show(1, $show && wxTheApp->{app_config}->get("view_mode") ne "simple"); $self->Layout; $panel->Refresh; @@ -2011,7 +2033,8 @@ sub on_extruders_change { my @presets = $choices->[0]->GetStrings; # initialize new choice - my $choice = Wx::BitmapComboBox->new($self->{right_panel}, -1, "", wxDefaultPosition, wxDefaultSize, [@presets], wxCB_READONLY); +# my $choice = Wx::BitmapComboBox->new($self->{right_panel}, -1, "", wxDefaultPosition, wxDefaultSize, [@presets], wxCB_READONLY); + my $choice = Wx::BitmapComboBox->new($self->{scrolled_window_panel}, -1, "", wxDefaultPosition, wxDefaultSize, [@presets], wxCB_READONLY); my $extruder_idx = scalar @$choices; EVT_LEFT_DOWN($choice, sub { $self->filament_color_box_lmouse_down($extruder_idx, @_); } ); push @$choices, $choice; diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index 34865fa63..315a4bada 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -135,14 +135,9 @@ wxButton* g_wiping_dialog_button = nullptr; //showed/hided controls according to the view mode wxWindow *g_right_panel = nullptr; wxBoxSizer *g_frequently_changed_parameters_sizer = nullptr; -wxBoxSizer *g_expert_mode_part_sizer = nullptr; -wxBoxSizer *g_scrolled_window_sizer = nullptr; +wxBoxSizer *g_info_sizer = nullptr; wxBoxSizer *g_object_list_sizer = nullptr; -wxButton *g_btn_export_gcode = nullptr; -wxButton *g_btn_export_stl = nullptr; -wxButton *g_btn_reslice = nullptr; -wxButton *g_btn_print = nullptr; -wxButton *g_btn_send_gcode = nullptr; +std::vector g_buttons; wxStaticBitmap *g_manifold_warning_icon = nullptr; bool g_show_print_info = false; bool g_show_manifold_warning_icon = false; @@ -221,22 +216,36 @@ void set_preset_updater(PresetUpdater *updater) g_PresetUpdater = updater; } -void set_objects_from_perl( wxWindow* parent, wxBoxSizer *frequently_changed_parameters_sizer, - wxBoxSizer *expert_mode_part_sizer, wxBoxSizer *scrolled_window_sizer, +enum ActionButtons +{ + abExportGCode, + abReslice, + abPrint, + abSendGCode, +}; + +void set_objects_from_perl( wxWindow* parent, + wxBoxSizer *frequently_changed_parameters_sizer, + wxBoxSizer *info_sizer, wxButton *btn_export_gcode, - wxButton *btn_export_stl, wxButton *btn_reslice, - wxButton *btn_print, wxButton *btn_send_gcode, + wxButton *btn_reslice, + wxButton *btn_print, + wxButton *btn_send_gcode, wxStaticBitmap *manifold_warning_icon) { - g_right_panel = parent; + g_right_panel = parent->GetParent(); g_frequently_changed_parameters_sizer = frequently_changed_parameters_sizer; - g_expert_mode_part_sizer = expert_mode_part_sizer; - g_scrolled_window_sizer = scrolled_window_sizer; - g_btn_export_gcode = btn_export_gcode; - g_btn_export_stl = btn_export_stl; - g_btn_reslice = btn_reslice; - g_btn_print = btn_print; - g_btn_send_gcode = btn_send_gcode; + g_info_sizer = info_sizer; + + g_buttons.push_back(btn_export_gcode); + g_buttons.push_back(btn_reslice); + g_buttons.push_back(btn_print); + g_buttons.push_back(btn_send_gcode); + + // Update font style for buttons + for (auto btn : g_buttons) + btn->SetFont(bold_font()); + g_manifold_warning_icon = manifold_warning_icon; } @@ -930,12 +939,11 @@ wxString from_u8(const std::string &str) return wxString::FromUTF8(str.c_str()); } -void add_expert_mode_part( wxWindow* parent, wxBoxSizer* sizer, - Model &model, - int event_object_selection_changed, - int event_object_settings_changed, - int event_remove_object, - int event_update_scene) +void set_model_events_from_perl(Model &model, + int event_object_selection_changed, + int event_object_settings_changed, + int event_remove_object, + int event_update_scene) { set_event_object_selection_changed(event_object_selection_changed); set_event_object_settings_changed(event_object_settings_changed); @@ -1072,7 +1080,7 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl }; optgroup->append_line(line); - sizer->Add(optgroup->sizer, 0, wxEXPAND | wxBOTTOM, 2); + sizer->Add(optgroup->sizer, 0, wxEXPAND | wxBOTTOM | wxLEFT, 2); m_optgroups.push_back(optgroup);// ogFrequentlyChangingParameters @@ -1099,15 +1107,14 @@ void show_frequently_changed_parameters(bool show) void show_buttons(bool show) { - g_btn_export_stl->Show(show); - g_btn_reslice->Show(show); + g_buttons[abReslice]->Show(show); for (size_t i = 0; i < g_wxTabPanel->GetPageCount(); ++i) { TabPrinter *tab = dynamic_cast(g_wxTabPanel->GetPage(i)); if (!tab) continue; if (g_PresetBundle->printers.get_selected_preset().printer_technology() == ptFFF) { - g_btn_print->Show(show && !tab->m_config->opt_string("serial_port").empty()); - g_btn_send_gcode->Show(show && !tab->m_config->opt_string("print_host").empty()); + g_buttons[abPrint]->Show(show && !tab->m_config->opt_string("serial_port").empty()); + g_buttons[abSendGCode]->Show(show && !tab->m_config->opt_string("print_host").empty()); } break; } @@ -1115,8 +1122,8 @@ void show_buttons(bool show) void show_info_sizer(bool show) { - g_scrolled_window_sizer->Show(static_cast(0), show); - g_scrolled_window_sizer->Show(1, show && g_show_print_info); + g_info_sizer->Show(static_cast(0), show); + g_info_sizer->Show(1, show && g_show_print_info); g_manifold_warning_icon->Show(show && g_show_manifold_warning_icon); } @@ -1129,20 +1136,10 @@ void show_object_name(bool show) void update_mode() { - wxWindowUpdateLocker noUpdates(g_right_panel); - - // TODO There is a not the best place of it! - //*** Update style of the "Export G-code" button**** - if (g_btn_export_gcode->GetFont() != bold_font()){ - g_btn_export_gcode->SetBackgroundColour(wxColour(252, 77, 1)); - g_btn_export_gcode->SetFont(bold_font()); - } - // *********************************** + wxWindowUpdateLocker noUpdates(g_right_panel->GetParent()); ConfigMenuIDs mode = get_view_mode(); -// show_frequently_changed_parameters(mode >= ConfigMenuModeRegular); -// g_expert_mode_part_sizer->Show(mode == ConfigMenuModeExpert); g_object_list_sizer->Show(mode == ConfigMenuModeExpert); show_info_sizer(mode == ConfigMenuModeExpert); show_buttons(mode == ConfigMenuModeExpert); @@ -1153,7 +1150,7 @@ void update_mode() // show_collpane_settings(mode == ConfigMenuModeExpert); // ************************* g_right_panel->Layout(); - g_right_panel->GetParent()->GetParent()->Layout(); + g_right_panel->GetParent()->Layout(); } bool is_expert_mode(){ @@ -1229,6 +1226,20 @@ void get_current_screen_size(unsigned &width, unsigned &height) height = disp_size.GetHeight(); } +void enable_action_buttons(bool enable) +{ + if (g_buttons.empty()) + return; + + // Update background colour for buttons + const wxColour bgrd_color = enable ? wxColour(255, 96, 0) : wxColour(204, 204, 204); + + for (auto btn : g_buttons) { + btn->Enable(enable); + btn->SetBackgroundColour(bgrd_color); + } +} + void about() { AboutDialog dlg; diff --git a/xs/src/slic3r/GUI/GUI.hpp b/xs/src/slic3r/GUI/GUI.hpp index 22ea3edb0..ceb004f8c 100644 --- a/xs/src/slic3r/GUI/GUI.hpp +++ b/xs/src/slic3r/GUI/GUI.hpp @@ -102,10 +102,8 @@ void set_preset_bundle(PresetBundle *preset_bundle); void set_preset_updater(PresetUpdater *updater); void set_objects_from_perl( wxWindow* parent, wxBoxSizer *frequently_changed_parameters_sizer, - wxBoxSizer *expert_mode_part_sizer, - wxBoxSizer *scrolled_window_sizer, + wxBoxSizer *info_sizer, wxButton *btn_export_gcode, - wxButton *btn_export_stl, wxButton *btn_reslice, wxButton *btn_print, wxButton *btn_send_gcode, @@ -202,12 +200,11 @@ wxString L_str(const std::string &str); // Return wxString from std::string in UTF8 wxString from_u8(const std::string &str); -void add_expert_mode_part( wxWindow* parent, wxBoxSizer* sizer, - Model &model, - int event_object_selection_changed, - int event_object_settings_changed, - int event_remove_object, - int event_update_scene); +void set_model_events_from_perl(Model &model, + int event_object_selection_changed, + int event_object_settings_changed, + int event_remove_object, + int event_update_scene); void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFlexGridSizer* preset_sizer); // Update view mode according to selected menu void update_mode(); @@ -226,6 +223,9 @@ int get_export_option(wxFileDialog* dlg); // Returns the dimensions of the screen on which the main frame is displayed void get_current_screen_size(unsigned &width, unsigned &height); +// Update buttons view according to enable/disable +void enable_action_buttons(bool enable); + // Display an About dialog extern void about(); // Ask the destop to open the datadir using the default file explorer. diff --git a/xs/xsp/GUI.xsp b/xs/xsp/GUI.xsp index 3e967bb86..7b0aadab5 100644 --- a/xs/xsp/GUI.xsp +++ b/xs/xsp/GUI.xsp @@ -87,26 +87,21 @@ void add_frequently_changed_parameters(SV *ui_parent, SV *ui_sizer, SV *ui_p_siz (wxBoxSizer*)wxPli_sv_2_object(aTHX_ ui_sizer, "Wx::BoxSizer"), (wxFlexGridSizer*)wxPli_sv_2_object(aTHX_ ui_p_sizer, "Wx::FlexGridSizer")); %}; -void add_expert_mode_part( SV *ui_parent, SV *ui_sizer, - Model *model, - int event_object_selection_changed, - int event_object_settings_changed, - int event_remove_object, - int event_update_scene) - %code%{ Slic3r::GUI::add_expert_mode_part( (wxWindow*)wxPli_sv_2_object(aTHX_ ui_parent, "Wx::Window"), - (wxBoxSizer*)wxPli_sv_2_object(aTHX_ ui_sizer, "Wx::BoxSizer"), - *model, - event_object_selection_changed, - event_object_settings_changed, - event_remove_object, - event_update_scene); %}; +void set_model_events_from_perl(Model *model, + int event_object_selection_changed, + int event_object_settings_changed, + int event_remove_object, + int event_update_scene) + %code%{ Slic3r::GUI::set_model_events_from_perl(*model, + event_object_selection_changed, + event_object_settings_changed, + event_remove_object, + event_update_scene); %}; void set_objects_from_perl( SV *ui_parent, SV *frequently_changed_parameters_sizer, - SV *expert_mode_part_sizer, - SV *scrolled_window_sizer, + SV *info_sizer, SV *btn_export_gcode, - SV *btn_export_stl, SV *btn_reslice, SV *btn_print, SV *btn_send_gcode, @@ -114,10 +109,8 @@ void set_objects_from_perl( SV *ui_parent, %code%{ Slic3r::GUI::set_objects_from_perl( (wxWindow *)wxPli_sv_2_object(aTHX_ ui_parent, "Wx::Window"), (wxBoxSizer *)wxPli_sv_2_object(aTHX_ frequently_changed_parameters_sizer, "Wx::BoxSizer"), - (wxBoxSizer *)wxPli_sv_2_object(aTHX_ expert_mode_part_sizer, "Wx::BoxSizer"), - (wxBoxSizer *)wxPli_sv_2_object(aTHX_ scrolled_window_sizer, "Wx::BoxSizer"), + (wxBoxSizer *)wxPli_sv_2_object(aTHX_ info_sizer, "Wx::BoxSizer"), (wxButton *)wxPli_sv_2_object(aTHX_ btn_export_gcode, "Wx::Button"), - (wxButton *)wxPli_sv_2_object(aTHX_ btn_export_stl, "Wx::Button"), (wxButton *)wxPli_sv_2_object(aTHX_ btn_reslice, "Wx::Button"), (wxButton *)wxPli_sv_2_object(aTHX_ btn_print, "Wx::Button"), (wxButton *)wxPli_sv_2_object(aTHX_ btn_send_gcode, "Wx::Button"), @@ -190,4 +183,6 @@ void update_double_slider(bool force_sliders_full_range) void reset_double_slider() %code%{ Slic3r::GUI::reset_double_slider(); %}; +void enable_action_buttons(bool enable) + %code%{ Slic3r::GUI::enable_action_buttons(enable); %};