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;
|
my $obj_idx = $event->GetInt;
|
||||||
|
|
||||||
$self->{plater}->select_object($obj_idx < 0 ? undef: $obj_idx);
|
$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);
|
$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)
|
wxCollapsiblePane* add_collapsible_pane(wxWindow* parent, wxBoxSizer* sizer_parent, const wxString& name, std::function<wxSizer *(wxWindow *)> content_function)
|
||||||
{
|
{
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
auto *collpane = new PrusaCollapsiblePane(parent, wxID_ANY, name);
|
auto *collpane = new PrusaCollapsiblePaneMSW(parent, wxID_ANY, name);
|
||||||
#else
|
#else
|
||||||
auto *collpane = new wxCollapsiblePane(parent, wxID_ANY, name);
|
auto *collpane = new PrusaCollapsiblePane/*wxCollapsiblePane*/(parent, wxID_ANY, name);
|
||||||
#endif // __WXMSW__
|
#endif // __WXMSW__
|
||||||
// add the pane with a zero proportion value to the sizer which contains it
|
// add the pane with a zero proportion value to the sizer which contains it
|
||||||
sizer_parent->Add(collpane, 0, wxGROW | wxALL, 0);
|
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 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_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…", 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…", 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_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_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);
|
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 ***
|
// *** Objects List ***
|
||||||
auto collpane = add_collapsible_pane(parent, sizer, "Objects List:", content_objects_list);
|
auto collpane = add_collapsible_pane(parent, sizer, "Objects List:", content_objects_list);
|
||||||
collpane->Bind(wxEVT_COLLAPSIBLEPANE_CHANGED, ([collpane](wxCommandEvent& e){
|
collpane->Bind(wxEVT_COLLAPSIBLEPANE_CHANGED, ([collpane](wxCommandEvent& e){
|
||||||
e.Skip();
|
// wxWindowUpdateLocker noUpdates(g_right_panel);
|
||||||
wxWindowUpdateLocker noUpdates(g_right_panel);
|
|
||||||
if (collpane->IsCollapsed()) {
|
if (collpane->IsCollapsed()) {
|
||||||
m_sizer_object_buttons->Show(false);
|
m_sizer_object_buttons->Show(false);
|
||||||
m_sizer_part_buttons->Show(false);
|
m_sizer_part_buttons->Show(false);
|
||||||
m_collpane_settings->Show(false);
|
m_collpane_settings->Show(false);
|
||||||
}
|
}
|
||||||
else
|
// else
|
||||||
m_objects_ctrl->UnselectAll();
|
// m_objects_ctrl->UnselectAll();
|
||||||
|
|
||||||
g_right_panel->Layout();
|
// e.Skip();
|
||||||
|
// g_right_panel->Layout();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// *** Object/Part Settings ***
|
// *** 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__
|
#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)
|
const wxPoint& pos, const wxSize& size, long style, const wxValidator& val, const wxString& name)
|
||||||
{
|
{
|
||||||
if (!wxControl::Create(parent, id, pos, size, style, val, 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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrusaCollapsiblePane::UpdateBtnBmp()
|
void PrusaCollapsiblePaneMSW::UpdateBtnBmp()
|
||||||
{
|
{
|
||||||
if (IsCollapsed())
|
if (IsCollapsed())
|
||||||
m_pDisclosureTriangleButton->SetBitmap(m_bmp_close);
|
m_pDisclosureTriangleButton->SetBitmap(m_bmp_close);
|
||||||
@ -257,14 +289,14 @@ void PrusaCollapsiblePane::UpdateBtnBmp()
|
|||||||
Layout();
|
Layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrusaCollapsiblePane::SetLabel(const wxString &label)
|
void PrusaCollapsiblePaneMSW::SetLabel(const wxString &label)
|
||||||
{
|
{
|
||||||
m_strLabel = label;
|
m_strLabel = label;
|
||||||
m_pDisclosureTriangleButton->SetLabel(m_strLabel);
|
m_pDisclosureTriangleButton->SetLabel(m_strLabel);
|
||||||
Layout();
|
Layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PrusaCollapsiblePane::Layout()
|
bool PrusaCollapsiblePaneMSW::Layout()
|
||||||
{
|
{
|
||||||
if (!m_pDisclosureTriangleButton || !m_pPane || !m_sz)
|
if (!m_pDisclosureTriangleButton || !m_pPane || !m_sz)
|
||||||
return false; // we need to complete the creation first!
|
return false; // we need to complete the creation first!
|
||||||
@ -289,36 +321,7 @@ bool PrusaCollapsiblePane::Layout()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrusaCollapsiblePane::OnStateChange_(const wxSize& sz)
|
void PrusaCollapsiblePaneMSW::Collapse(bool collapse)
|
||||||
{
|
|
||||||
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
|
// optimization
|
||||||
if (IsCollapsed() == collapse)
|
if (IsCollapsed() == collapse)
|
||||||
@ -332,7 +335,7 @@ void PrusaCollapsiblePane::Collapse(bool collapse)
|
|||||||
// update button bitmap
|
// update button bitmap
|
||||||
UpdateBtnBmp();
|
UpdateBtnBmp();
|
||||||
|
|
||||||
OnStateChange_(GetBestSize());
|
OnStateChange(GetBestSize());
|
||||||
}
|
}
|
||||||
#endif //__WXMSW__
|
#endif //__WXMSW__
|
||||||
|
|
||||||
|
@ -75,17 +75,45 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// *** PrusaCollapsiblePane *** used only #ifdef __WXMSW__
|
// *** PrusaCollapsiblePane ***
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
class PrusaCollapsiblePane : public wxCollapsiblePane
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PrusaCollapsiblePane() {}
|
||||||
|
PrusaCollapsiblePane(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);
|
||||||
|
}
|
||||||
|
~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__
|
#ifdef __WXMSW__
|
||||||
class PrusaCollapsiblePane : public wxCollapsiblePane
|
class PrusaCollapsiblePaneMSW : public PrusaCollapsiblePane//wxCollapsiblePane
|
||||||
{
|
{
|
||||||
wxButton* m_pDisclosureTriangleButton = nullptr;
|
wxButton* m_pDisclosureTriangleButton = nullptr;
|
||||||
wxBitmap m_bmp_close;
|
wxBitmap m_bmp_close;
|
||||||
wxBitmap m_bmp_open;
|
wxBitmap m_bmp_open;
|
||||||
public:
|
public:
|
||||||
PrusaCollapsiblePane() {}
|
PrusaCollapsiblePaneMSW() {}
|
||||||
PrusaCollapsiblePane( wxWindow *parent,
|
PrusaCollapsiblePaneMSW( wxWindow *parent,
|
||||||
wxWindowID winid,
|
wxWindowID winid,
|
||||||
const wxString& label,
|
const wxString& label,
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
@ -97,7 +125,7 @@ public:
|
|||||||
Create(parent, winid, label, pos, size, style, val, name);
|
Create(parent, winid, label, pos, size, style, val, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
~PrusaCollapsiblePane() {}
|
~PrusaCollapsiblePaneMSW() {}
|
||||||
|
|
||||||
bool Create(wxWindow *parent,
|
bool Create(wxWindow *parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
@ -112,12 +140,6 @@ public:
|
|||||||
void SetLabel(const wxString &label) override;
|
void SetLabel(const wxString &label) override;
|
||||||
bool Layout() override;
|
bool Layout() override;
|
||||||
void Collapse(bool collapse) 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__
|
#endif //__WXMSW__
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user