Fixed controls layout on right panel.

+ Split ObjectManipulation class to ObjectManipulation and ObjectSettings
+ fixed typo-bug in GetItemByVolumeId
This commit is contained in:
YuSanka 2018-11-09 18:39:07 +01:00
parent 5b34e54ce9
commit 7f4a8bccd5
12 changed files with 366 additions and 212 deletions

View File

@ -486,7 +486,7 @@ void GUI_App::update_mode()
ConfigMenuIDs mode = wxGetApp().get_view_mode();
obj_list()->get_sizer()->Show(mode == ConfigMenuModeExpert);
sidebar().show_info_sizers(mode == ConfigMenuModeExpert);
sidebar().show_info_sizer(mode == ConfigMenuModeExpert);
sidebar().show_buttons(mode == ConfigMenuModeExpert);
obj_manipul()->show_object_name(mode == ConfigMenuModeSimple);
obj_list()->update_manipulation_sizer(mode == ConfigMenuModeSimple);
@ -658,6 +658,11 @@ ObjectManipulation* GUI_App::obj_manipul()
return sidebar().obj_manipul();
}
ObjectSettings* GUI_App::obj_settings()
{
return sidebar().obj_settings();
}
ObjectList* GUI_App::obj_list()
{
return sidebar().obj_list();

View File

@ -130,6 +130,7 @@ public:
Sidebar& sidebar();
ObjectManipulation* obj_manipul();
ObjectSettings* obj_settings();
ObjectList* obj_list();
Plater* plater();
wxGLCanvas* canvas3D();

View File

@ -527,8 +527,12 @@ void ObjectList::get_settings_choice(wxMenu *menu, int id, bool is_part)
// part_selection_changed();
#endif //no __WXOSX__
}
else
wxGetApp().obj_manipul()->update_settings_list();
else {
auto panel = wxGetApp().sidebar().scrolled_panel();
panel->Freeze();
wxGetApp().obj_settings()->UpdateAndShow(true);//obj_manipul()->update_settings_list();
panel->Thaw();
}
}
void ObjectList::menu_item_add_generic(wxMenuItem* &menu, int id, const int type) {
@ -998,30 +1002,35 @@ void ObjectList::parts_changed(int obj_idx)
void ObjectList::part_selection_changed()
{
int obj_idx = -1;
ConfigOptionsGroup* og = wxGetApp().obj_manipul()->get_og();
m_config = nullptr;
wxString object_name = wxEmptyString;
wxString og_name = wxEmptyString;
if (multiple_selection())
og->set_name(" " + _(L("Group manipulation")) + " ");
bool update_and_show_manipulations = false;
bool update_and_show_settings = false;
bool show_info_sizer = false;
if (multiple_selection()) {
og_name = _(L("Group manipulation"));
update_and_show_manipulations = true;
}
else
{
const auto item = GetSelection();
if (item)
{
const bool is_settings_item = m_objects_model->IsSettingsItem(item);
bool is_part = false;
wxString og_name = wxEmptyString;
if (m_objects_model->GetParent(item) == wxDataViewItem(0)) {
obj_idx = m_objects_model->GetIdByItem(item);
og_name = _(L("Object manipulation"));
m_config = &(*m_objects)[obj_idx]->config;
update_and_show_manipulations = true;
show_info_sizer = true;
}
else {
auto parent = m_objects_model->GetParent(item);
// Take ID of the parent object to "inform" perl-side which object have to be selected on the scene
obj_idx = m_objects_model->GetIdByItem(parent);
if (is_settings_item) {
if (m_objects_model->GetItemType(item) == itSettings) {
if (m_objects_model->GetParent(parent) == wxDataViewItem(0)) {
og_name = _(L("Object Settings to modify"));
m_config = &(*m_objects)[obj_idx]->config;
@ -1034,31 +1043,44 @@ void ObjectList::part_selection_changed()
const auto volume_id = m_objects_model->GetVolumeIdByItem(parent);
m_config = &(*m_objects)[obj_idx]->volumes[volume_id]->config;
}
update_and_show_settings = true;
}
else if (m_objects_model->GetItemType(item) == itVolume) {
og_name = _(L("Part manipulation"));
is_part = true;
const auto volume_id = m_objects_model->GetVolumeIdByItem(item);
m_config = &(*m_objects)[obj_idx]->volumes[volume_id]->config;
update_and_show_manipulations = true;
}
else if (m_objects_model->GetItemType(item) == itInstance) {
og_name = _(L("Instance manipulation"));
update_and_show_manipulations = true;
}
}
og->set_name(" " + og_name + " ");
object_name = m_objects_model->GetName(item);
if (m_default_config) delete m_default_config;
m_default_config = DynamicPrintConfig::new_from_defaults_keys(get_options(is_part));
}
}
og->set_value("object_name", object_name);
wxGetApp().obj_manipul()->update_settings_list();
m_selected_object_id = obj_idx;
wxGetApp().obj_manipul()->update_settings_value(_3DScene::get_canvas(wxGetApp().canvas3D())->get_selection());
if (update_and_show_manipulations) {
wxGetApp().obj_manipul()->get_og()->set_name(" " + og_name + " ");
wxGetApp().obj_manipul()->get_og()->set_value("object_name", m_objects_model->GetName(GetSelection()));
}
if (update_and_show_settings)
wxGetApp().obj_settings()->get_og()->set_name(" " + og_name + " ");
auto panel = wxGetApp().sidebar().scrolled_panel();
panel->Freeze();
wxGetApp().obj_manipul() ->UpdateAndShow(update_and_show_manipulations);
wxGetApp().obj_settings()->UpdateAndShow(update_and_show_settings);
show_info_sizer ? wxGetApp().sidebar().update_info_sizer() : wxGetApp().sidebar().show_info_sizer(false);
panel->Thaw();
}
void ObjectList::update_manipulation_sizer(const bool is_simple_mode)

View File

@ -14,17 +14,6 @@ namespace Slic3r
namespace GUI
{
OG_Settings::OG_Settings(wxWindow* parent, const bool staticbox)
{
wxString title = staticbox ? " " : ""; // temporary workaround - #ys_FIXME
m_og = std::make_shared<ConfigOptionsGroup>(parent, title);
}
wxSizer* OG_Settings::get_sizer()
{
return m_og->sizer;
}
ObjectManipulation::ObjectManipulation(wxWindow* parent):
OG_Settings(parent, true)
{
@ -139,11 +128,32 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent):
def.sidetext = "";
def.default_value = new ConfigOptionBool{ false };
m_og->append_single_option_line(Option(def, "place_on_bed"));
}
m_settings_list_sizer = new wxBoxSizer(wxVERTICAL);
m_og->sizer->Add(m_settings_list_sizer, 1, wxEXPAND | wxLEFT, 5);
void ObjectManipulation::Show(const bool show)
{
if (show == IsShown())
return;
m_og->disable();
m_og->Show(show);
if (show && wxGetApp().get_view_mode() != ConfigMenuModeSimple) {
m_og->get_grid_sizer()->Show(size_t(0), false);
m_og->get_grid_sizer()->Show(size_t(1), false);
}
}
bool ObjectManipulation::IsShown()
{
return m_og->get_grid_sizer()->IsShown(2);
}
void ObjectManipulation::UpdateAndShow(const bool show)
{
if (show)
update_settings_value(_3DScene::get_canvas(wxGetApp().canvas3D())->get_selection());
OG_Settings::UpdateAndShow(show);
}
int ObjectManipulation::ol_selection()
@ -151,121 +161,6 @@ int ObjectManipulation::ol_selection()
return wxGetApp().obj_list()->get_selected_obj_idx();
}
void ObjectManipulation::update_settings_list()
{
#ifdef __WXGTK__
auto parent = m_og->get_parent();
#else
auto parent = m_og->parent();
#endif /* __WXGTK__ */
// There is a bug related to Ubuntu overlay scrollbars, see https://github.com/prusa3d/Slic3r/issues/898 and https://github.com/prusa3d/Slic3r/issues/952.
// The issue apparently manifests when Show()ing a window with overlay scrollbars while the UI is frozen. For this reason,
// we will Thaw the UI prematurely on Linux. This means destroing the no_updates object prematurely.
#ifdef __linux__
std::unique_ptr<wxWindowUpdateLocker> no_updates(new wxWindowUpdateLocker(parent));
#else
wxWindowUpdateLocker noUpdates(parent);
#endif
m_settings_list_sizer->Clear(true);
bool show_manipulations = true;
auto objects_ctrl = wxGetApp().obj_list();
auto objects_model = wxGetApp().obj_list()->m_objects_model;
auto config = wxGetApp().obj_list()->m_config;
const auto item = objects_ctrl->GetSelection();
if (!objects_ctrl->multiple_selection() &&
config && objects_model->IsSettingsItem(item))
{
auto extra_column = [config](wxWindow* parent, const Line& line)
{
auto opt_key = (line.get_options())[0].opt_id; //we assume that we have one option per line
auto btn = new wxBitmapButton(parent, wxID_ANY, wxBitmap(from_u8(var("colorchange_delete_on.png")), wxBITMAP_TYPE_PNG),
wxDefaultPosition, wxDefaultSize, wxBORDER_NONE);
#ifdef __WXMSW__
btn->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
#endif // __WXMSW__
btn->Bind(wxEVT_BUTTON, [opt_key, config](wxEvent &event) {
config->erase(opt_key);
wxTheApp->CallAfter([]() { wxGetApp().obj_manipul()->update_settings_list(); });
});
return btn;
};
std::map<std::string, std::vector<std::string>> cat_options;
auto opt_keys = config->keys();
m_og_settings.resize(0);
std::vector<std::string> categories;
if (!(opt_keys.size() == 1 && opt_keys[0] == "extruder"))// return;
{
auto extruders_cnt = wxGetApp().preset_bundle->printers.get_selected_preset().printer_technology() == ptSLA ? 1 :
wxGetApp().preset_bundle->printers.get_edited_preset().config.option<ConfigOptionFloats>("nozzle_diameter")->values.size();
for (auto& opt_key : opt_keys) {
auto category = config->def()->get(opt_key)->category;
if (category.empty() ||
(category == "Extruders" && extruders_cnt == 1)) continue;
std::vector< std::string > new_category;
auto& cat_opt = cat_options.find(category) == cat_options.end() ? new_category : cat_options.at(category);
cat_opt.push_back(opt_key);
if (cat_opt.size() == 1)
cat_options[category] = cat_opt;
}
for (auto& cat : cat_options) {
if (cat.second.size() == 1 && cat.second[0] == "extruder")
continue;
auto optgroup = std::make_shared<ConfigOptionsGroup>(parent, cat.first, config, false, extra_column);
optgroup->label_width = 150;
optgroup->sidetext_width = 70;
optgroup->m_on_change = [](const t_config_option_key& opt_id, const boost::any& value) {
wxGetApp().obj_list()->part_settings_changed(); };
for (auto& opt : cat.second)
{
if (opt == "extruder")
continue;
Option option = optgroup->get_option(opt);
option.opt.width = 70;
optgroup->append_single_option_line(option);
}
optgroup->reload_config();
m_settings_list_sizer->Add(optgroup->sizer, 0, wxEXPAND | wxALL, 0);
m_og_settings.push_back(optgroup);
categories.push_back(cat.first);
}
}
if (m_og_settings.empty()) {
objects_ctrl->Select(objects_model->Delete(item));
wxGetApp().obj_list()->part_selection_changed();
}
else {
if (!categories.empty())
objects_model->UpdateSettingsDigest(item, categories);
show_manipulations = false;
}
}
show_manipulation_og(show_manipulations);
wxGetApp().sidebar().show_info_sizers(show_manipulations && item && objects_model->GetParent(item) == wxDataViewItem(0));
#ifdef __linux__
no_updates.reset(nullptr);
#endif
parent->Layout();
parent->GetParent()->Layout();
}
void ObjectManipulation::update_settings_value(const GLCanvas3D::Selection& selection)
{
#if ENABLE_MODELVOLUME_TRANSFORM
@ -479,14 +374,6 @@ void ObjectManipulation::show_object_name(bool show)
grid_sizer->Show(static_cast<size_t>(1), show);
}
void ObjectManipulation::show_manipulation_og(const bool show)
{
wxGridSizer* grid_sizer = m_og->get_grid_sizer();
if (show == grid_sizer->IsShown(2))
return;
for (size_t id = 2; id < 12; id++)
grid_sizer->Show(id, show);
}
} //namespace GUI
} //namespace Slic3r

View File

@ -3,28 +3,12 @@
#include <memory>
#include <wx/panel.h>
#include "Preset.hpp"
#include "GUI_ObjectSettings.hpp"
#include "GLCanvas3D.hpp"
class wxBoxSizer;
namespace Slic3r {
namespace GUI {
class ConfigOptionsGroup;
class OG_Settings
{
protected:
std::shared_ptr<ConfigOptionsGroup> m_og;
public:
OG_Settings(wxWindow* parent, const bool staticbox);
~OG_Settings() {}
wxSizer* get_sizer();
ConfigOptionsGroup* get_og() { return m_og.get(); }
};
class ObjectManipulation : public OG_Settings
@ -32,17 +16,16 @@ class ObjectManipulation : public OG_Settings
bool m_is_percent_scale = false; // true -> percentage scale unit
// false -> uniform scale unit
bool m_is_uniform_scale = false; // It indicates if scale is uniform
// sizer for extra Object/Part's settings
wxBoxSizer* m_settings_list_sizer{ nullptr };
// option groups for settings
std::vector <std::shared_ptr<ConfigOptionsGroup>> m_og_settings;
public:
ObjectManipulation(wxWindow* parent);
~ObjectManipulation() {}
void Show(const bool show) override;
bool IsShown() override;
void UpdateAndShow(const bool show) override;
int ol_selection();
void update_settings_list();
void update_settings_value(const GLCanvas3D::Selection& selection);
void reset_settings_value();
@ -66,7 +49,7 @@ public:
void set_uniform_scaling(const bool uniform_scale) { m_is_uniform_scale = uniform_scale; }
void show_object_name(bool show);
void show_manipulation_og(const bool show);
};
}}

View File

@ -0,0 +1,159 @@
#include "GUI_ObjectSettings.hpp"
#include "GUI_ObjectList.hpp"
#include "OptionsGroup.hpp"
#include "wxExtensions.hpp"
#include "PresetBundle.hpp"
#include "Model.hpp"
#include <boost/algorithm/string.hpp>
namespace Slic3r
{
namespace GUI
{
OG_Settings::OG_Settings(wxWindow* parent, const bool staticbox) :
m_parent(parent)
{
wxString title = staticbox ? " " : ""; // temporary workaround - #ys_FIXME
m_og = std::make_shared<ConfigOptionsGroup>(parent, title);
}
bool OG_Settings::IsShown()
{
return m_og->sizer->IsEmpty() ? false : m_og->sizer->IsShown(size_t(0));
}
void OG_Settings::Show(const bool show)
{
m_og->Show(show);
}
void OG_Settings::Hide()
{
Show(false);
}
void OG_Settings::UpdateAndShow(const bool show)
{
Show(show);
m_parent->Layout();
}
wxSizer* OG_Settings::get_sizer()
{
return m_og->sizer;
}
ObjectSettings::ObjectSettings(wxWindow* parent) :
OG_Settings(parent, true)
{
m_og->set_name(_(L("Additional Settings")));
m_settings_list_sizer = new wxBoxSizer(wxVERTICAL);
m_og->sizer->Add(m_settings_list_sizer, 1, wxEXPAND | wxLEFT, 5);
}
void ObjectSettings::update_settings_list()
{
m_settings_list_sizer->Clear(true);
auto objects_ctrl = wxGetApp().obj_list();
auto objects_model = wxGetApp().obj_list()->m_objects_model;
auto config = wxGetApp().obj_list()->m_config;
const auto item = objects_ctrl->GetSelection();
if (item && !objects_ctrl->multiple_selection() &&
config && objects_model->IsSettingsItem(item))
{
auto extra_column = [config, this](wxWindow* parent, const Line& line)
{
auto opt_key = (line.get_options())[0].opt_id; //we assume that we have one option per line
auto btn = new wxBitmapButton(parent, wxID_ANY, wxBitmap(from_u8(var("colorchange_delete_on.png")), wxBITMAP_TYPE_PNG),
wxDefaultPosition, wxDefaultSize, wxBORDER_NONE);
#ifdef __WXMSW__
btn->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
#endif // __WXMSW__
btn->Bind(wxEVT_BUTTON, [opt_key, config, this](wxEvent &event) {
config->erase(opt_key);
wxTheApp->CallAfter([this]() {
update_settings_list();
m_parent->Layout();
});
});
return btn;
};
std::map<std::string, std::vector<std::string>> cat_options;
auto opt_keys = config->keys();
m_og_settings.resize(0);
std::vector<std::string> categories;
if (!(opt_keys.size() == 1 && opt_keys[0] == "extruder"))// return;
{
auto extruders_cnt = wxGetApp().preset_bundle->printers.get_selected_preset().printer_technology() == ptSLA ? 1 :
wxGetApp().preset_bundle->printers.get_edited_preset().config.option<ConfigOptionFloats>("nozzle_diameter")->values.size();
for (auto& opt_key : opt_keys) {
auto category = config->def()->get(opt_key)->category;
if (category.empty() ||
(category == "Extruders" && extruders_cnt == 1)) continue;
std::vector< std::string > new_category;
auto& cat_opt = cat_options.find(category) == cat_options.end() ? new_category : cat_options.at(category);
cat_opt.push_back(opt_key);
if (cat_opt.size() == 1)
cat_options[category] = cat_opt;
}
for (auto& cat : cat_options) {
if (cat.second.size() == 1 && cat.second[0] == "extruder")
continue;
auto optgroup = std::make_shared<ConfigOptionsGroup>(m_parent, cat.first, config, false, extra_column);
optgroup->label_width = 150;
optgroup->sidetext_width = 70;
optgroup->m_on_change = [](const t_config_option_key& opt_id, const boost::any& value) {
wxGetApp().obj_list()->part_settings_changed(); };
for (auto& opt : cat.second)
{
if (opt == "extruder")
continue;
Option option = optgroup->get_option(opt);
option.opt.width = 70;
optgroup->append_single_option_line(option);
}
optgroup->reload_config();
m_settings_list_sizer->Add(optgroup->sizer, 0, wxEXPAND | wxALL, 0);
m_og_settings.push_back(optgroup);
categories.push_back(cat.first);
}
}
if (m_og_settings.empty()) {
objects_ctrl->select_item(objects_model->Delete(item));
}
else {
if (!categories.empty())
objects_model->UpdateSettingsDigest(item, categories);
}
}
}
void ObjectSettings::UpdateAndShow(const bool show)
{
if (show)
update_settings_list();
OG_Settings::UpdateAndShow(show);
}
} //namespace GUI
} //namespace Slic3r

View File

@ -0,0 +1,49 @@
#ifndef slic3r_GUI_ObjectSettings_hpp_
#define slic3r_GUI_ObjectSettings_hpp_
#include <memory>
#include <wx/panel.h>
class wxBoxSizer;
namespace Slic3r {
namespace GUI {
class ConfigOptionsGroup;
class OG_Settings
{
protected:
std::shared_ptr<ConfigOptionsGroup> m_og;
wxWindow* m_parent;
public:
OG_Settings(wxWindow* parent, const bool staticbox);
~OG_Settings() {}
virtual bool IsShown();
virtual void Show(const bool show);
virtual void Hide();
virtual void UpdateAndShow(const bool show);
wxSizer* get_sizer();
ConfigOptionsGroup* get_og() { return m_og.get(); }
};
class ObjectSettings : public OG_Settings
{
// sizer for extra Object/Part's settings
wxBoxSizer* m_settings_list_sizer{ nullptr };
// option groups for settings
std::vector <std::shared_ptr<ConfigOptionsGroup>> m_og_settings;
public:
ObjectSettings(wxWindow* parent);
~ObjectSettings() {}
void update_settings_list();
void UpdateAndShow(const bool show) override;
};
}}
#endif // slic3r_GUI_ObjectSettings_hpp_

View File

@ -387,6 +387,20 @@ void ConfigOptionsGroup::reload_config() {
}
void ConfigOptionsGroup::Hide()
{
Show(false);
}
void ConfigOptionsGroup::Show(const bool show)
{
sizer->ShowItems(show);
#ifdef __WXGTK__
m_panel->Show(show);
m_grid_sizer->Show(show);
#endif /* __WXGTK__ */
}
bool ConfigOptionsGroup::update_visibility(ConfigOptionMode mode) {
if (m_options_mode.empty())
return true;
@ -394,11 +408,7 @@ bool ConfigOptionsGroup::update_visibility(ConfigOptionMode mode) {
m_options_mode.size() == 1)
return m_options_mode[0] <= mode;
sizer->ShowItems(true);
#ifdef __WXGTK__
m_panel->Show(true);
m_grid_sizer->Show(true);
#endif /* __WXGTK__ */
Show(true);
int coef = 0;
int hidden_row_cnt = 0;

View File

@ -247,6 +247,8 @@ public:
void on_kill_focus() override{ reload_config();}
void reload_config();
// return value shows visibility : false => all options are hidden
void Hide();
void Show(const bool show);
bool update_visibility(ConfigOptionMode mode);
boost::any config_value(const std::string& opt_key, int opt_index, bool deserialize);
// return option value from config

View File

@ -430,6 +430,7 @@ struct Sidebar::priv
FreqChangedParams *frequently_changed_parameters;
ObjectList *object_list;
ObjectManipulation *object_manipulation;
ObjectSettings *object_settings;
ObjectInfo *object_info;
SlicedInfo *sliced_info;
@ -447,18 +448,24 @@ void Sidebar::priv::show_preset_comboboxes()
{
const bool showSLA = wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() == ptSLA;
wxWindowUpdateLocker noUpdates(wxGetApp().mainframe);
wxWindowUpdateLocker noUpdates_scrolled(scrolled);
// scrolled->Freeze();
for (size_t i = 0; i < 4; ++i) {
if (sizer_presets->IsShown(i) == showSLA)
sizer_presets->Show(i, !showSLA);
}
for (size_t i = 0; i < 4; ++i)
sizer_presets->Show(i, !showSLA);
for (size_t i = 4; i < 6; ++i) {
if (sizer_presets->IsShown(i) != showSLA)
sizer_presets->Show(i, showSLA);
}
sizer_presets->Show(4, showSLA);
sizer_presets->Show(5, showSLA);
if (frequently_changed_parameters->IsShown() == showSLA)
frequently_changed_parameters->Show(!showSLA);
frequently_changed_parameters->Show(!showSLA);
wxGetApp().plater()->Layout();
wxGetApp().mainframe->Layout();
scrolled->Layout();
// scrolled->Thaw();
}
@ -467,7 +474,12 @@ void Sidebar::priv::show_preset_comboboxes()
Sidebar::Sidebar(Plater *parent)
: wxPanel(parent), p(new priv(parent))
{
p->scrolled = new wxScrolledWindow(this);
p->scrolled = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, wxSize(400, -1));
p->scrolled->SetScrollbars(0, 1, 1, 1);
// Sizer in the scrolled area
auto *scrolled_sizer = new wxBoxSizer(wxVERTICAL);
p->scrolled->SetSizer(scrolled_sizer);
// The preset chooser
p->sizer_presets = new wxFlexGridSizer(4, 2, 1, 2);
@ -513,10 +525,16 @@ Sidebar::Sidebar(Plater *parent)
p->object_list = new ObjectList(p->scrolled);
p->sizer_params->Add(p->object_list->get_sizer(), 1, wxEXPAND | wxTOP, 20);
// Frequently Object Settings
// Object Manipulations
p->object_manipulation = new ObjectManipulation(p->scrolled);
p->object_manipulation->Hide();
p->sizer_params->Add(p->object_manipulation->get_sizer(), 0, wxEXPAND | wxLEFT | wxTOP, 20);
// Frequently Object Settings
p->object_settings = new ObjectSettings(p->scrolled);
p->object_settings->Hide();
p->sizer_params->Add(p->object_settings->get_sizer(), 0, wxEXPAND | wxLEFT | wxTOP, 20);
// Buttons in the scrolled area
wxBitmap arrow_up(GUI::from_u8(Slic3r::var("brick_go.png")), wxBITMAP_TYPE_PNG);
p->btn_send_gcode = new wxButton(p->scrolled, wxID_ANY, _(L("Send to printer")));
@ -530,10 +548,6 @@ Sidebar::Sidebar(Plater *parent)
p->sliced_info = new SlicedInfo(p->scrolled);
// Sizer in the scrolled area
auto *scrolled_sizer = new wxBoxSizer(wxVERTICAL);
scrolled_sizer->SetMinSize(320, -1);
p->scrolled->SetSizer(scrolled_sizer);
p->scrolled->SetScrollbars(0, 1, 1, 1);
scrolled_sizer->Add(p->sizer_presets, 0, wxEXPAND | wxLEFT, 2);
scrolled_sizer->Add(p->sizer_params, 1, wxEXPAND);
scrolled_sizer->Add(p->object_info, 0, wxEXPAND | wxTOP | wxLEFT, 20);
@ -650,6 +664,16 @@ ObjectList* Sidebar::obj_list()
return p->object_list;
}
ObjectSettings* Sidebar::obj_settings()
{
return p->object_settings;
}
wxScrolledWindow* Sidebar::scrolled_panel()
{
return p->scrolled;
}
ConfigOptionsGroup* Sidebar::og_freq_chng_params()
{
return p->frequently_changed_parameters->get_og();
@ -665,22 +689,24 @@ void Sidebar::update_objects_list_extruder_column(int extruders_count)
p->object_list->update_objects_list_extruder_column(extruders_count);
}
void Sidebar::show_info_sizers(const bool show)
void Sidebar::show_info_sizer(const bool show)
{
p->object_info->show_sizer(show);
p->scrolled->Layout();
}
void Sidebar::show_info_sizer()
void Sidebar::update_info_sizer()
{
wxWindowUpdateLocker freeze_guard(p->plater);
wxWindowUpdateLocker freeze_guard(p->scrolled);
int obj_idx = p->plater->get_selected_object_idx();
if (obj_idx < 0) {
if (/*obj_idx < 0 || */!p->plater->is_single_full_object_selection()) {
p->object_info->Show(false);
p->scrolled->Layout();
return;
}
int obj_idx = p->plater->get_selected_object_idx();
const ModelObject* model_object = (*wxGetApp().model_objects())[obj_idx];
const ModelInstance* model_instance = !model_object->instances.empty() ? model_object->instances.front() : nullptr;
@ -717,12 +743,11 @@ void Sidebar::show_info_sizer()
p->object_info->show_sizer(true);
p->scrolled->Layout();
p->plater->Layout();
}
void Sidebar::show_sliced_info_sizer(const bool show)
{
wxWindowUpdateLocker freeze_guard(p->plater);
wxWindowUpdateLocker freeze_guard(p->scrolled);
p->sliced_info->Show(show);
if (show) {
@ -752,7 +777,6 @@ void Sidebar::show_sliced_info_sizer(const bool show)
}
p->scrolled->Layout();
p->plater->Layout();
}
void Sidebar::show_buttons(const bool show)
@ -1388,7 +1412,7 @@ void Plater::priv::selection_changed()
// forces a frame render to update the view (to avoid a missed update if, for example, the context menu appears)
_3DScene::render(canvas3D);
sidebar->show_info_sizer();
sidebar->update_info_sizer();
}
void Plater::priv::object_list_changed()
@ -2172,6 +2196,9 @@ void Plater::on_extruders_change(int num_extruders)
{
auto& choices = sidebar().combos_filament();
wxWindowUpdateLocker noUpdates_scrolled_panel(sidebar().scrolled_panel());
// sidebar().scrolled_panel()->Freeze();
int i = choices.size();
while ( i < num_extruders )
{
@ -2187,8 +2214,8 @@ void Plater::on_extruders_change(int num_extruders)
// remove unused choices if any
sidebar().remove_unused_filament_combos(num_extruders);
sidebar().Layout();
GetParent()->Layout();
sidebar().scrolled_panel()->Layout();
// sidebar().scrolled_panel()->Thaw();
}
void Plater::on_config_change(const DynamicPrintConfig &config)
@ -2251,6 +2278,11 @@ int Plater::get_selected_object_idx()
return p->get_selected_object_idx();
}
bool Plater::is_single_full_object_selection()
{
return p->get_selection().is_single_full_object();
}
wxGLCanvas* Plater::canvas3D()
{
return p->canvas3D;

View File

@ -13,6 +13,7 @@
class wxButton;
class wxBoxSizer;
class wxGLCanvas;
class wxScrolledWindow;
namespace Slic3r {
@ -23,6 +24,7 @@ namespace GUI {
class MainFrame;
class ConfigOptionsGroup;
class ObjectManipulation;
class ObjectSettings;
class ObjectList;
using t_optgroups = std::vector <std::shared_ptr<ConfigOptionsGroup>>;
@ -72,12 +74,14 @@ public:
ObjectManipulation* obj_manipul();
ObjectList* obj_list();
ObjectSettings* obj_settings();
wxScrolledWindow* scrolled_panel();
ConfigOptionsGroup* og_freq_chng_params();
wxButton* get_wiping_dialog_button();
void update_objects_list_extruder_column(int extruders_count);
void show_info_sizers(const bool show);
void show_info_sizer();
void show_info_sizer(const bool show);
void update_info_sizer();
void show_sliced_info_sizer(const bool show);
void show_buttons(const bool show);
void show_button(ButtonAction but_action, bool show);
@ -131,7 +135,7 @@ public:
void on_config_change(const DynamicPrintConfig &config);
int get_selected_object_idx();
bool is_single_full_object_selection();
wxGLCanvas* canvas3D();
private:
struct priv;

View File

@ -778,7 +778,7 @@ wxDataViewItem PrusaObjectDataViewModel::GetItemByVolumeId(int obj_idx, int volu
}
for (size_t i = 0; i < parent->GetChildCount(); i++)
if (parent->GetNthChild(i)->m_idx == volume_idx && parent->GetNthChild(0)->GetType() & itVolume)
if (parent->GetNthChild(i)->m_idx == volume_idx && parent->GetNthChild(i)->GetType() & itVolume)
return wxDataViewItem(parent->GetNthChild(i));
return wxDataViewItem(0);