Updated Collapsed/Layout for PrusaCollapsiblePane.

Cleaned right_panel
This commit is contained in:
YuSanka 2018-05-28 17:08:48 +02:00
parent d7d0edf4dc
commit c7d7da452e
4 changed files with 86 additions and 82 deletions

View file

@ -230,15 +230,7 @@ sub new {
$self->{right_panel} = Wx::ScrolledWindow->new($self, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
$self->{right_panel}->SetScrollbars(0, 1, 1, 1);
### Scrolled Window for info boxes
my $scrolled_window_sizer = Wx::BoxSizer->new(wxVERTICAL);
$scrolled_window_sizer->SetMinSize([310, -1]);
# my $scrolled_window_panel = Wx::ScrolledWindow->new($self->{right_panel}, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
my $scrolled_window_panel = Wx::Panel->new($self->{right_panel}, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
$scrolled_window_panel->SetSizer($scrolled_window_sizer);
# $scrolled_window_panel->SetScrollbars(1, 1, 1, 1);
$self->{list} = Wx::ListView->new($scrolled_window_panel, -1, wxDefaultPosition, wxDefaultSize,
$self->{list} = Wx::ListView->new($self->{right_panel}, -1, wxDefaultPosition, wxDefaultSize,
wxLC_SINGLE_SEL | wxLC_REPORT | wxBORDER_SUNKEN | wxTAB_TRAVERSAL | wxWANTS_CHARS );
$self->{list}->InsertColumn(0, L("Name"), wxLIST_FORMAT_LEFT, 145);
$self->{list}->InsertColumn(1, L("Copies"), wxLIST_FORMAT_CENTER, 45);
@ -424,7 +416,7 @@ sub new {
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"));
$box->SetFont($Slic3r::GUI::small_bold_font);
$object_info_sizer = Wx::StaticBoxSizer->new($box, wxVERTICAL);
$object_info_sizer->SetMinSize([300,-1]);
@ -443,14 +435,14 @@ 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);
$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"}->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}->Hide;
$self->{"object_info_manifold_warning_icon_show"} = sub {
if ($self->{object_info_manifold_warning_icon}->IsShown() != $_[0]) {
@ -475,7 +467,7 @@ sub new {
my $print_info_sizer;
{
my $box = Wx::StaticBox->new($scrolled_window_panel, -1, L("Sliced Info"));
my $box = Wx::StaticBox->new($self->{right_panel}, -1, L("Sliced Info"));
$box->SetFont($Slic3r::GUI::small_bold_font);
$print_info_sizer = Wx::StaticBoxSizer->new($box, wxVERTICAL);
$print_info_sizer->SetMinSize([300,-1]);
@ -493,11 +485,11 @@ sub new {
);
while (my $field = shift @info) {
my $label = shift @info;
my $text = Wx::StaticText->new($scrolled_window_panel, -1, "$label:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);
my $text = Wx::StaticText->new($self->{right_panel}, -1, "$label:", wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);
$text->SetFont($Slic3r::GUI::small_font);
$grid_sizer->Add($text, 0);
$self->{"print_info_$field"} = Wx::StaticText->new($scrolled_window_panel, -1, "", wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);
$self->{"print_info_$field"} = Wx::StaticText->new($self->{right_panel}, -1, "", wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);
$self->{"print_info_$field"}->SetFont($Slic3r::GUI::small_font);
$grid_sizer->Add($self->{"print_info_$field"}, 0);
}
@ -511,18 +503,22 @@ sub new {
$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_gcode}, 0, wxALIGN_RIGHT, 0);
$scrolled_window_sizer->Add($self->{list}, 1, wxEXPAND, 5);
$scrolled_window_sizer->Add($object_info_sizer, 0, wxEXPAND | wxLEFT, 20);
$scrolled_window_sizer->Add($print_info_sizer, 0, wxEXPAND | wxLEFT, 20);
### Sizer for info boxes
my $info_sizer = Wx::BoxSizer->new(wxVERTICAL);
$info_sizer->SetMinSize([310, -1]);
$info_sizer->Add($self->{list}, 1, wxEXPAND, 5);
$info_sizer->Add($object_info_sizer, 0, wxEXPAND | wxBOTTOM, 5);
$info_sizer->Add($print_info_sizer, 0, wxEXPAND | wxBOTTOM, 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, 0) if defined $expert_mode_part_sizer;
$right_sizer->Add($buttons_sizer, 0, wxEXPAND | wxBOTTOM, 5);
$right_sizer->Add($scrolled_window_panel, 0, wxEXPAND | wxALL, 1);
$right_sizer->Add($info_sizer, 0, wxEXPAND | wxLEFT, 20);
$right_sizer->Add($self->{btn_export_gcode}, 0, wxEXPAND | wxLEFT | wxTOP | wxBOTTOM, 20);
# Callback for showing / hiding the print info box.
$self->{"print_info_box_show"} = sub {
@ -530,18 +526,16 @@ sub new {
# $right_sizer->Show(5, $_[0]);
# $self->Layout
# }
if ($scrolled_window_sizer->IsShown(2) != $_[0]) {
if ($info_sizer->IsShown(2) != $_[0]) {
Slic3r::GUI::set_show_print_info($_[0]);
return if (wxTheApp->{app_config}->get("view_mode") eq "simple");
$scrolled_window_sizer->Show(2, $_[0]);
$scrolled_window_panel->Layout
$info_sizer->Show(2, $_[0]);
$self->{right_panel}->Layout
}
};
# Show the box initially, let it be shown after the slicing is finished.
$self->{"print_info_box_show"}->(0);
$self->{right_panel}->SetSizer($right_sizer);
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);
@ -558,7 +552,7 @@ sub new {
Slic3r::GUI::set_objects_from_perl( $self->{right_panel},
$frequently_changed_parameters_sizer,
$expert_mode_part_sizer,
$scrolled_window_sizer,
$info_sizer,
$self->{btn_export_gcode},
$self->{btn_export_stl},
$self->{btn_reslice},

View file

@ -142,10 +142,11 @@ wxDataViewCtrl *m_objects_ctrl = nullptr;
PrusaCollapsiblePane *m_collpane_settings = nullptr;
wxFont g_small_font{ wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT) };
#ifdef __WXMAC__
g_small_font->SetPointSize(11);
#endif /*__WXMAC__*/
wxFont g_bold_font{ wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).Bold() };
#ifdef __WXMAC__
g_small_font.SetPointSize(11);
g_bold_font.SetPointSize(11);
#endif /*__WXMAC__*/
static void init_label_colours()
{
@ -833,7 +834,6 @@ wxString from_u8(const std::string &str)
PrusaCollapsiblePane* add_prusa_collapsible_pane(wxWindow* parent, wxBoxSizer* sizer_parent, const wxString& name, std::function<wxSizer *(wxWindow *)> content_function)
{
auto *collpane = new PrusaCollapsiblePane(parent, wxID_ANY, name);
collpane->SetTopParent(g_right_panel);
// add the pane with a zero proportion value to the sizer which contains it
sizer_parent->Add(collpane, 0, wxGROW | wxALL, 0);
@ -844,14 +844,14 @@ PrusaCollapsiblePane* add_prusa_collapsible_pane(wxWindow* parent, wxBoxSizer* s
wxSizer *sizer_pane = new wxBoxSizer(wxVERTICAL);
sizer_pane->Add(sizer, 1, wxGROW | wxEXPAND | wxBOTTOM, 2);
win->SetSizer(sizer_pane);
sizer_pane->SetSizeHints(win);
// sizer_pane->SetSizeHints(win);
return collpane;
}
wxBoxSizer* content_objects_list(wxWindow *win)
{
m_objects_ctrl = new wxDataViewCtrl(win, wxID_ANY, wxDefaultPosition, wxDefaultSize);
m_objects_ctrl->SetBestFittingSize(wxSize(-1, 150)); // TODO - Set correct height according to the opened/closed objects
m_objects_ctrl->SetInitialSize(wxSize(-1, 150)); // TODO - Set correct height according to the opened/closed objects
auto objects_sz = new wxBoxSizer(wxVERTICAL);
objects_sz->Add(m_objects_ctrl, 1, wxGROW | wxLEFT/*ALL*/, 20/*5*/);
@ -883,18 +883,17 @@ wxBoxSizer* content_objects_list(wxWindow *win)
wxDATAVIEW_COL_SORTABLE | wxDATAVIEW_COL_RESIZABLE);
m_objects_ctrl->AppendColumn(column02);
m_objects_ctrl->Bind(wxEVT_DATAVIEW_SELECTION_CHANGED, [objects_model](wxCommandEvent& evt)
m_objects_ctrl->Bind(wxEVT_DATAVIEW_SELECTION_CHANGED, [objects_model](wxEvent& evt)
{
wxWindowUpdateLocker noUpdates(g_right_panel);
auto item = m_objects_ctrl->GetSelection();
if (!item) return;
// m_objects_ctrl->SetSize(m_objects_ctrl->GetBestSize()); // TODO override GetBestSize(), than use it
auto show_obj_sizer = objects_model->GetParent(item) == wxDataViewItem(0);
m_sizer_object_buttons->Show(show_obj_sizer);
m_sizer_part_buttons->Show(!show_obj_sizer);
m_collpane_settings->SetLabelText((show_obj_sizer ? _(L("Object Settings")) : _(L("Part Settings"))) + ":");
m_collpane_settings->Show(true);
g_right_panel->Layout();
m_collpane_settings->show_it(true);
});
return objects_sz;
@ -921,15 +920,13 @@ wxBoxSizer* content_edit_object_buttons(wxWindow* win)
btn_move_up->SetBitmap(wxBitmap(from_u8(Slic3r::var("bullet_arrow_up.png")), wxBITMAP_TYPE_PNG));
btn_move_down->SetBitmap(wxBitmap(from_u8(Slic3r::var("bullet_arrow_down.png")), wxBITMAP_TYPE_PNG));
m_sizer_object_buttons = new /*wxFlex*/wxGridSizer(1, 3, 0, 0);
// static_cast<wxFlexGridSizer*>(m_sizer_object_buttons)->SetFlexibleDirection(wxBOTH);
m_sizer_object_buttons = new wxGridSizer(1, 3, 0, 0);
m_sizer_object_buttons->Add(btn_load_part, 0, wxEXPAND);
m_sizer_object_buttons->Add(btn_load_modifier, 0, wxEXPAND);
m_sizer_object_buttons->Add(btn_load_lambda_modifier, 0, wxEXPAND);
m_sizer_object_buttons->Show(false);
m_sizer_part_buttons = new /*wxFlex*/wxGridSizer(1, 3, 0, 0);
// m_sizer_part_buttons->SetFlexibleDirection(wxBOTH);
m_sizer_part_buttons = new wxGridSizer(1, 3, 0, 0);
m_sizer_part_buttons->Add(btn_delete, 0, wxEXPAND);
m_sizer_part_buttons->Add(btn_split, 0, wxEXPAND);
{
@ -948,8 +945,8 @@ wxBoxSizer* content_edit_object_buttons(wxWindow* win)
btn_move_up->SetFont(Slic3r::GUI::small_font());
btn_move_down->SetFont(Slic3r::GUI::small_font());
sizer->Add(m_sizer_object_buttons, 0, wxEXPAND|wxLEFT, 20/*wxALIGN_CENTER_HORIZONTAL*/);
sizer->Add(m_sizer_part_buttons, 0, wxEXPAND|wxLEFT, 20/*wxALIGN_CENTER_HORIZONTAL*/);
sizer->Add(m_sizer_object_buttons, 0, wxEXPAND|wxLEFT, 20);
sizer->Add(m_sizer_part_buttons, 0, wxEXPAND|wxLEFT, 20);
return sizer;
}
@ -1021,31 +1018,29 @@ wxBoxSizer* content_settings(wxWindow *win)
void add_expert_mode_part(wxWindow* parent, wxBoxSizer* sizer)
{
auto main_sizer = new wxBoxSizer(wxVERTICAL);
auto main_page = new wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
main_page->SetSizer(main_sizer);
sizer->Add(main_page, 1, wxEXPAND | wxALL, 1);
wxWindowUpdateLocker noUpdates(parent);
// Experiments with new UI
// *** Objects List ***
auto collpane = add_prusa_collapsible_pane(main_page, main_sizer, "Objects List:", content_objects_list);
collpane->Bind(wxEVT_COLLAPSIBLEPANE_CHANGED, ([collpane](wxCommandEvent e){
auto collpane = add_prusa_collapsible_pane(parent, sizer, "Objects List:", content_objects_list);
collpane->Bind(wxEVT_COLLAPSIBLEPANE_CHANGED, ([collpane](wxCommandEvent& e){
e.Skip();
wxWindowUpdateLocker noUpdates(g_right_panel);
if (collpane->IsCollapsed()) {
m_sizer_object_buttons->Show(false);
m_sizer_part_buttons->Show(false);
m_collpane_settings->Show(false);
m_collpane_settings->show_it(false);
}
else
m_objects_ctrl->UnselectAll();
g_right_panel->Layout();
}));
// *** Object/Part Settings ***
m_collpane_settings = add_prusa_collapsible_pane(main_page, main_sizer, "Settings:", content_settings);
m_collpane_settings->Show(false);
m_collpane_settings = add_prusa_collapsible_pane(parent, sizer, "Settings:", content_settings);
m_collpane_settings->Hide(); // ? TODO why doesn't work?
// More experiments with UI
// auto listctrl = new wxDataViewListCtrl(main_page, wxID_ANY, wxDefaultPosition, wxSize(-1, 100));

View file

@ -257,6 +257,36 @@ void PrusaCollapsiblePane::UpdateBtnBmp()
Layout();
}
void PrusaCollapsiblePane::OnStateChange_(const wxSize& sz)
{
SetSize(sz);
if (this->HasFlag(wxCP_NO_TLW_RESIZE))
{
// the user asked to explicitly handle the resizing itself...
return;
}
auto top = GetParent(); //right_panel
if (!top)
return;
wxSizer *sizer = top->GetSizer();
if (!sizer)
return;
const wxSize newBestSize = sizer->ComputeFittingClientSize(top);
top->SetMinClientSize(newBestSize);
wxWindowUpdateLocker noUpdates_p(top->GetParent());
// we shouldn't attempt to resize a maximized window, whatever happens
// if (!top->IsMaximized())
// top->SetClientSize(newBestSize);
top->GetParent()->Layout();
top->Refresh();
}
void PrusaCollapsiblePane::Collapse(bool collapse)
{
// optimization
@ -268,10 +298,20 @@ void PrusaCollapsiblePane::Collapse(bool collapse)
// update our state
m_pPane->Show(!collapse);
// update button label
#if defined( __WXMAC__ ) && !defined(__WXUNIVERSAL__)
m_pButton->SetOpen(!collapse);
#else
#ifdef __WXMSW__
// update button bitmap
UpdateBtnBmp();
#else
// NB: this must be done after updating our "state"
m_pButton->SetLabel(GetBtnLabel());
#endif //__WXMSW__
#endif
OnStateChange(GetBestSize());
OnStateChange_(GetBestSize());
}
void PrusaCollapsiblePane::SetLabel(const wxString &label)

View file

@ -84,7 +84,6 @@ class PrusaCollapsiblePane : public wxCollapsiblePane
wxBitmap m_bmp_close;
wxBitmap m_bmp_open;
#endif //__WXMSW__
wxWindow* m_top_parent = nullptr;
public:
PrusaCollapsiblePane() {}
PrusaCollapsiblePane( wxWindow *parent,
@ -101,35 +100,10 @@ public:
#else
Create(parent, winid, label);
#endif //__WXMSW__
this->Bind(wxEVT_COLLAPSIBLEPANE_CHANGED, ([parent, this](wxCommandEvent e){
wxWindowUpdateLocker noUpdates_cp(this);
wxWindowUpdateLocker noUpdates(parent);
parent->Layout();
this->Refresh();
if (m_top_parent)
{
m_top_parent->GetSizer()->Layout();
}
else{
wxGetTopLevelParent(this)->Layout();
}
// if (parent->GetParent()){
// parent->GetParent()->Layout();
// parent->Refresh();
// }
// else{
// parent->Layout();
// this->Refresh();}
}));
}
~PrusaCollapsiblePane() {}
void SetTopParent(wxWindow *parent) { m_top_parent = parent; }
#ifdef __WXMSW__
bool Create(wxWindow *parent,
wxWindowID id,
@ -141,11 +115,12 @@ public:
const wxString& name);
void UpdateBtnBmp();
void Collapse(bool collapse) override;
void SetLabel(const wxString &label) override;
bool Layout() override;
#endif //__WXMSW__
void Collapse(bool collapse) override;
void OnStateChange_(const wxSize& sz); //override of OnStateChange
void show_it(bool show) { Show(show); OnStateChange_(GetBestSize()); }
};