mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-12 21:39:07 +08:00
Tab panel initializes.
This commit is contained in:
parent
cc17b2e279
commit
19bc2eabdc
@ -1,6 +1,4 @@
|
||||
#include "MainFrame.hpp"
|
||||
#include "Plater.hpp"
|
||||
#include "Controller.hpp"
|
||||
|
||||
namespace Slic3r { namespace GUI {
|
||||
|
||||
@ -11,7 +9,7 @@ MainFrame::MainFrame(const wxString& title, const wxPoint& pos, const wxSize& si
|
||||
: MainFrame(title, pos, size, nullptr) {}
|
||||
MainFrame::MainFrame(const wxString& title, const wxPoint& pos, const wxSize& size, std::shared_ptr<Settings> config)
|
||||
: wxFrame(NULL, wxID_ANY, title, pos, size), loaded(false),
|
||||
tabpanel(nullptr), controller(nullptr), plater(nullptr), gui_config(config)
|
||||
tabpanel(nullptr), controller(nullptr), plater(nullptr), gui_config(config), preset_editor_tabs(std::map<wxWindowID, PresetEditor*>())
|
||||
{
|
||||
// Set icon to either the .ico if windows or png for everything else.
|
||||
|
||||
@ -40,7 +38,34 @@ MainFrame::MainFrame(const wxString& title, const wxPoint& pos, const wxSize& si
|
||||
this->Show();
|
||||
this->Layout();
|
||||
}
|
||||
|
||||
/*
|
||||
# declare events
|
||||
EVT_CLOSE($self, sub {
|
||||
my (undef, $event) = @_;
|
||||
|
||||
if ($event->CanVeto) {
|
||||
if (!$self->{plater}->prompt_unsaved_changes) {
|
||||
$event->Veto;
|
||||
return;
|
||||
}
|
||||
|
||||
if ($self->{controller} && $self->{controller}->printing) {
|
||||
my $confirm = Wx::MessageDialog->new($self, "You are currently printing. Do you want to stop printing and continue anyway?",
|
||||
'Unfinished Print', wxICON_QUESTION | wxYES_NO | wxNO_DEFAULT);
|
||||
if ($confirm->ShowModal == wxID_NO) {
|
||||
$event->Veto;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# save window size
|
||||
wxTheApp->save_window_pos($self, "main_frame");
|
||||
|
||||
# propagate event
|
||||
$event->Skip;
|
||||
});
|
||||
*/
|
||||
}
|
||||
|
||||
/// Private initialization function for the main frame tab panel.
|
||||
@ -51,9 +76,8 @@ void MainFrame::init_tabpanel()
|
||||
|
||||
panel->Bind(wxEVT_AUINOTEBOOK_PAGE_CHANGED, ([=](wxAuiNotebookEvent& e)
|
||||
{
|
||||
auto panel = this->tabpanel->GetPage(this->tabpanel->GetSelection());
|
||||
auto tabpanel = this->tabpanel;
|
||||
// todo: trigger processing for activation(?)
|
||||
// TODO: trigger processing for activation event
|
||||
if (tabpanel->GetSelection() > 1) {
|
||||
tabpanel->SetWindowStyle(tabpanel->GetWindowStyleFlag() | wxAUI_NB_CLOSE_ON_ACTIVE_TAB);
|
||||
} else if (this->gui_config->show_host == false && tabpanel->GetSelection() == 1) {
|
||||
@ -63,40 +87,20 @@ void MainFrame::init_tabpanel()
|
||||
}
|
||||
}), panel->GetId());
|
||||
|
||||
panel->Bind(wxEVT_AUINOTEBOOK_PAGE_CLOSE, ([=](wxAuiNotebookEvent& e)
|
||||
{
|
||||
if (typeid(panel) == typeid(Slic3r::GUI::PresetEditor)) {
|
||||
wxDELETE(this->preset_editor_tabs[panel->GetId()]);
|
||||
}
|
||||
wxTheApp->CallAfter([=] { this->tabpanel->SetSelection(0); });
|
||||
}), panel->GetId());
|
||||
|
||||
this->plater = new Slic3r::GUI::Plater(panel, _("Plater"));
|
||||
this->controller = new Slic3r::GUI::Controller(panel, _("Controller"));
|
||||
|
||||
/*
|
||||
sub _init_tabpanel {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{tabpanel} = my $panel = Wx::AuiNotebook->new($self, -1, wxDefaultPosition, wxDefaultSize, wxAUI_NB_TOP);
|
||||
EVT_AUINOTEBOOK_PAGE_CHANGED($self, $self->{tabpanel}, sub {
|
||||
my $panel = $self->{tabpanel}->GetPage($self->{tabpanel}->GetSelection);
|
||||
$panel->OnActivate if $panel->can('OnActivate');
|
||||
if ($self->{tabpanel}->GetSelection > 1) {
|
||||
$self->{tabpanel}->SetWindowStyle($self->{tabpanel}->GetWindowStyleFlag | wxAUI_NB_CLOSE_ON_ACTIVE_TAB);
|
||||
} elsif(($Slic3r::GUI::Settings->{_}{show_host} == 0) && ($self->{tabpanel}->GetSelection == 1)){
|
||||
$self->{tabpanel}->SetWindowStyle($self->{tabpanel}->GetWindowStyleFlag | wxAUI_NB_CLOSE_ON_ACTIVE_TAB);
|
||||
} else {
|
||||
$self->{tabpanel}->SetWindowStyle($self->{tabpanel}->GetWindowStyleFlag & ~wxAUI_NB_CLOSE_ON_ACTIVE_TAB);
|
||||
}
|
||||
});
|
||||
EVT_AUINOTEBOOK_PAGE_CLOSE($self, $self->{tabpanel}, sub {
|
||||
my $panel = $self->{tabpanel}->GetPage($self->{tabpanel}->GetSelection);
|
||||
if ($panel->isa('Slic3r::GUI::PresetEditor')) {
|
||||
delete $self->{preset_editor_tabs}{$panel->name};
|
||||
}
|
||||
wxTheApp->CallAfter(sub {
|
||||
$self->{tabpanel}->SetSelection(0);
|
||||
});
|
||||
});
|
||||
|
||||
$panel->AddPage($self->{plater} = Slic3r::GUI::Plater->new($panel), "Plater");
|
||||
$panel->AddPage($self->{controller} = Slic3r::GUI::Controller->new($panel), "Controller")
|
||||
if ($Slic3r::GUI::Settings->{_}{show_host});
|
||||
*/
|
||||
|
||||
panel->AddPage(this->plater, this->plater->GetName());
|
||||
if (this->gui_config->show_host) panel->AddPage(this->controller, this->controller->GetName());
|
||||
|
||||
}
|
||||
|
||||
void MainFrame::init_menubar()
|
||||
|
@ -9,9 +9,12 @@
|
||||
#include <wx/tooltip.h>
|
||||
|
||||
#include <memory>
|
||||
#include <map>
|
||||
|
||||
|
||||
#include "Controller.hpp"
|
||||
#include "Plater.hpp"
|
||||
#include "PresetEditor.hpp"
|
||||
#include "Settings.hpp"
|
||||
|
||||
namespace Slic3r { namespace GUI {
|
||||
@ -39,6 +42,7 @@ private:
|
||||
|
||||
|
||||
std::shared_ptr<Settings> gui_config;
|
||||
std::map<wxWindowID, PresetEditor*> preset_editor_tabs;
|
||||
|
||||
};
|
||||
|
||||
|
11
src/GUI/PresetEditor.hpp
Normal file
11
src/GUI/PresetEditor.hpp
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef PRESETEDITOR_HPP
|
||||
#define PRESETEDITOR_HPP
|
||||
|
||||
namespace Slic3r { namespace GUI {
|
||||
|
||||
class PresetEditor : public wxPanel {
|
||||
|
||||
};
|
||||
|
||||
}} // namespace Slic3r::GUI
|
||||
#endif // PRESETEDITOR_HPP
|
@ -44,6 +44,8 @@ main(int argc, char **argv)
|
||||
std::shared_ptr<GUI::Settings> gui_config = std::make_shared<GUI::Settings>();
|
||||
|
||||
GUI::App *gui = new GUI::App(gui_config);
|
||||
|
||||
gui_config->show_host = true;
|
||||
|
||||
GUI::App::SetInstance(gui);
|
||||
wxEntry(argc, argv);
|
||||
|
Loading…
x
Reference in New Issue
Block a user