Overrided OnStateChange() function to CollapsiblePane
This commit is contained in:
parent
4215b2b373
commit
08ccf85a61
@ -179,7 +179,6 @@ sub _init_tabpanel {
|
||||
my $obj_idx = $event->GetInt;
|
||||
|
||||
$self->{plater}->select_object($obj_idx < 0 ? undef: $obj_idx);
|
||||
Wx::MessageBox("Before item_changed_selection", "Slic3r Info", wxOK | wxICON_INFORMATION, $self);
|
||||
$self->{plater}->item_changed_selection($obj_idx);
|
||||
});
|
||||
|
||||
|
@ -858,9 +858,9 @@ wxString from_u8(const std::string &str)
|
||||
wxCollapsiblePane* add_collapsible_pane(wxWindow* parent, wxBoxSizer* sizer_parent, const wxString& name, std::function<wxSizer *(wxWindow *)> content_function)
|
||||
{
|
||||
#ifdef __WXMSW__
|
||||
auto *collpane = new PrusaCollapsiblePane(parent, wxID_ANY, name);
|
||||
auto *collpane = new PrusaCollapsiblePaneMSW(parent, wxID_ANY, name);
|
||||
#else
|
||||
auto *collpane = new wxCollapsiblePane(parent, wxID_ANY, name);
|
||||
auto *collpane = new PrusaCollapsiblePane/*wxCollapsiblePane*/(parent, wxID_ANY, name);
|
||||
#endif // __WXMSW__
|
||||
// add the pane with a zero proportion value to the sizer which contains it
|
||||
sizer_parent->Add(collpane, 0, wxGROW | wxALL, 0);
|
||||
@ -962,9 +962,9 @@ wxBoxSizer* content_edit_object_buttons(wxWindow* win)
|
||||
{
|
||||
auto sizer = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
auto btn_load_part = new wxButton(win, wxID_ANY, /*Load */"part…", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER/*wxBU_LEFT*/);
|
||||
auto btn_load_modifier = new wxButton(win, wxID_ANY, /*Load */"modifier…", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER/*wxBU_LEFT*/);
|
||||
auto btn_load_lambda_modifier = new wxButton(win, wxID_ANY, /*Load */"generic…", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER/*wxBU_LEFT*/);
|
||||
auto btn_load_part = new wxButton(win, wxID_ANY, /*Load */"part"+dots, wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER/*wxBU_LEFT*/);
|
||||
auto btn_load_modifier = new wxButton(win, wxID_ANY, /*Load */"modifier" + dots, wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER/*wxBU_LEFT*/);
|
||||
auto btn_load_lambda_modifier = new wxButton(win, wxID_ANY, /*Load */"generic" + dots, wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER/*wxBU_LEFT*/);
|
||||
auto btn_delete = new wxButton(win, wxID_ANY, "Delete"/*" part"*/, wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER/*wxBU_LEFT*/);
|
||||
auto btn_split = new wxButton(win, wxID_ANY, "Split"/*" part"*/, wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT | wxNO_BORDER/*wxBU_LEFT*/);
|
||||
auto btn_move_up = new wxButton(win, wxID_ANY, "", wxDefaultPosition, wxDefaultSize/*wxSize(30, -1)*/, wxBU_LEFT);
|
||||
@ -1170,17 +1170,17 @@ void add_expert_mode_part(wxWindow* parent, wxBoxSizer* sizer, int event_object_
|
||||
// *** Objects List ***
|
||||
auto collpane = add_collapsible_pane(parent, sizer, "Objects List:", content_objects_list);
|
||||
collpane->Bind(wxEVT_COLLAPSIBLEPANE_CHANGED, ([collpane](wxCommandEvent& e){
|
||||
e.Skip();
|
||||
wxWindowUpdateLocker noUpdates(g_right_panel);
|
||||
// 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);
|
||||
}
|
||||
else
|
||||
m_objects_ctrl->UnselectAll();
|
||||
// else
|
||||
// m_objects_ctrl->UnselectAll();
|
||||
|
||||
g_right_panel->Layout();
|
||||
// e.Skip();
|
||||
// g_right_panel->Layout();
|
||||
}));
|
||||
|
||||
// *** Object/Part Settings ***
|
||||
|
@ -190,10 +190,42 @@ void wxDataViewTreeCtrlComboPopup::OnDataViewTreeCtrlSelection(wxCommandEvent& e
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// *** PrusaCollapsiblePane *** used only #ifdef __WXMSW__
|
||||
// *** PrusaCollapsiblePane ***
|
||||
// ----------------------------------------------------------------------------
|
||||
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();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// *** PrusaCollapsiblePaneMSW *** used only #ifdef __WXMSW__
|
||||
// ----------------------------------------------------------------------------
|
||||
#ifdef __WXMSW__
|
||||
bool PrusaCollapsiblePane::Create(wxWindow *parent, wxWindowID id, const wxString& label,
|
||||
bool PrusaCollapsiblePaneMSW::Create(wxWindow *parent, wxWindowID id, const wxString& label,
|
||||
const wxPoint& pos, const wxSize& size, long style, const wxValidator& val, const wxString& name)
|
||||
{
|
||||
if (!wxControl::Create(parent, id, pos, size, style, val, name))
|
||||
@ -242,7 +274,7 @@ bool PrusaCollapsiblePane::Create(wxWindow *parent, wxWindowID id, const wxStrin
|
||||
return true;
|
||||
}
|
||||
|
||||
void PrusaCollapsiblePane::UpdateBtnBmp()
|
||||
void PrusaCollapsiblePaneMSW::UpdateBtnBmp()
|
||||
{
|
||||
if (IsCollapsed())
|
||||
m_pDisclosureTriangleButton->SetBitmap(m_bmp_close);
|
||||
@ -257,14 +289,14 @@ void PrusaCollapsiblePane::UpdateBtnBmp()
|
||||
Layout();
|
||||
}
|
||||
|
||||
void PrusaCollapsiblePane::SetLabel(const wxString &label)
|
||||
void PrusaCollapsiblePaneMSW::SetLabel(const wxString &label)
|
||||
{
|
||||
m_strLabel = label;
|
||||
m_pDisclosureTriangleButton->SetLabel(m_strLabel);
|
||||
Layout();
|
||||
}
|
||||
|
||||
bool PrusaCollapsiblePane::Layout()
|
||||
bool PrusaCollapsiblePaneMSW::Layout()
|
||||
{
|
||||
if (!m_pDisclosureTriangleButton || !m_pPane || !m_sz)
|
||||
return false; // we need to complete the creation first!
|
||||
@ -289,36 +321,7 @@ bool PrusaCollapsiblePane::Layout()
|
||||
return true;
|
||||
}
|
||||
|
||||
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)
|
||||
void PrusaCollapsiblePaneMSW::Collapse(bool collapse)
|
||||
{
|
||||
// optimization
|
||||
if (IsCollapsed() == collapse)
|
||||
@ -332,7 +335,7 @@ void PrusaCollapsiblePane::Collapse(bool collapse)
|
||||
// update button bitmap
|
||||
UpdateBtnBmp();
|
||||
|
||||
OnStateChange_(GetBestSize());
|
||||
OnStateChange(GetBestSize());
|
||||
}
|
||||
#endif //__WXMSW__
|
||||
|
||||
|
@ -75,14 +75,10 @@ public:
|
||||
|
||||
|
||||
|
||||
// *** PrusaCollapsiblePane *** used only #ifdef __WXMSW__
|
||||
// *** PrusaCollapsiblePane ***
|
||||
// ----------------------------------------------------------------------------
|
||||
#ifdef __WXMSW__
|
||||
class PrusaCollapsiblePane : public wxCollapsiblePane
|
||||
{
|
||||
wxButton* m_pDisclosureTriangleButton = nullptr;
|
||||
wxBitmap m_bmp_close;
|
||||
wxBitmap m_bmp_open;
|
||||
public:
|
||||
PrusaCollapsiblePane() {}
|
||||
PrusaCollapsiblePane(wxWindow *parent,
|
||||
@ -96,9 +92,41 @@ public:
|
||||
{
|
||||
Create(parent, winid, label, pos, size, style, val, name);
|
||||
}
|
||||
|
||||
~PrusaCollapsiblePane() {}
|
||||
|
||||
void OnStateChange(const wxSize& sz); //override/hide of OnStateChange from wxCollapsiblePane
|
||||
virtual bool Show(bool show = true) override {
|
||||
wxCollapsiblePane::Show(show);
|
||||
OnStateChange(GetBestSize());
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// *** PrusaCollapsiblePaneMSW *** used only #ifdef __WXMSW__
|
||||
// ----------------------------------------------------------------------------
|
||||
#ifdef __WXMSW__
|
||||
class PrusaCollapsiblePaneMSW : public PrusaCollapsiblePane//wxCollapsiblePane
|
||||
{
|
||||
wxButton* m_pDisclosureTriangleButton = nullptr;
|
||||
wxBitmap m_bmp_close;
|
||||
wxBitmap m_bmp_open;
|
||||
public:
|
||||
PrusaCollapsiblePaneMSW() {}
|
||||
PrusaCollapsiblePaneMSW( wxWindow *parent,
|
||||
wxWindowID winid,
|
||||
const wxString& label,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxCP_DEFAULT_STYLE,
|
||||
const wxValidator& val = wxDefaultValidator,
|
||||
const wxString& name = wxCollapsiblePaneNameStr)
|
||||
{
|
||||
Create(parent, winid, label, pos, size, style, val, name);
|
||||
}
|
||||
|
||||
~PrusaCollapsiblePaneMSW() {}
|
||||
|
||||
bool Create(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxString& label,
|
||||
@ -112,12 +140,6 @@ public:
|
||||
void SetLabel(const wxString &label) override;
|
||||
bool Layout() override;
|
||||
void Collapse(bool collapse) override;
|
||||
void OnStateChange_(const wxSize& sz); //override of OnStateChange
|
||||
virtual bool Show(bool show=true) override {
|
||||
wxCollapsiblePane::Show(show);
|
||||
OnStateChange_(GetBestSize());
|
||||
return true;
|
||||
}
|
||||
};
|
||||
#endif //__WXMSW__
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user