Completed settings hiding according to view mode
This commit is contained in:
parent
f47949504e
commit
70f4ca3f5b
@ -97,6 +97,7 @@ void PrintConfigDef::init_fff_params()
|
||||
def->multiline = true;
|
||||
def->full_width = true;
|
||||
def->height = 50;
|
||||
def->mode = comExpert;
|
||||
def->default_value = new ConfigOptionString("");
|
||||
|
||||
def = this->add("between_objects_gcode", coString);
|
||||
@ -106,6 +107,7 @@ void PrintConfigDef::init_fff_params()
|
||||
def->multiline = true;
|
||||
def->full_width = true;
|
||||
def->height = 120;
|
||||
def->mode = comExpert;
|
||||
def->default_value = new ConfigOptionString("");
|
||||
|
||||
def = this->add("bottom_solid_layers", coInt);
|
||||
@ -314,6 +316,7 @@ void PrintConfigDef::init_fff_params()
|
||||
def->multiline = true;
|
||||
def->full_width = true;
|
||||
def->height = 120;
|
||||
def->mode = comExpert;
|
||||
def->default_value = new ConfigOptionString("M104 S0 ; turn off temperature\nG28 X0 ; home X axis\nM84 ; disable motors\n");
|
||||
|
||||
def = this->add("end_filament_gcode", coStrings);
|
||||
@ -325,6 +328,7 @@ void PrintConfigDef::init_fff_params()
|
||||
def->multiline = true;
|
||||
def->full_width = true;
|
||||
def->height = 120;
|
||||
def->mode = comExpert;
|
||||
def->default_value = new ConfigOptionStrings { "; Filament-specific end gcode \n;END gcode for filament\n" };
|
||||
|
||||
def = this->add("ensure_vertical_shell_thickness", coBool);
|
||||
@ -519,6 +523,7 @@ void PrintConfigDef::init_fff_params()
|
||||
def->multiline = true;
|
||||
def->full_width = true;
|
||||
def->height = 130;
|
||||
def->mode = comMiddle;
|
||||
def->default_value = new ConfigOptionStrings { "" };
|
||||
|
||||
def = this->add("filament_max_volumetric_speed", coFloats);
|
||||
@ -1012,6 +1017,7 @@ void PrintConfigDef::init_fff_params()
|
||||
def->multiline = true;
|
||||
def->full_width = true;
|
||||
def->height = 50;
|
||||
def->mode = comExpert;
|
||||
def->default_value = new ConfigOptionString("");
|
||||
|
||||
def = this->add("remaining_times", coBool);
|
||||
@ -1238,6 +1244,7 @@ void PrintConfigDef::init_fff_params()
|
||||
def->multiline = true;
|
||||
def->full_width = true;
|
||||
def->height = 130;
|
||||
def->mode = comMiddle;
|
||||
def->default_value = new ConfigOptionString("");
|
||||
|
||||
def = this->add("nozzle_diameter", coFloats);
|
||||
@ -1422,6 +1429,7 @@ void PrintConfigDef::init_fff_params()
|
||||
def->multiline = true;
|
||||
def->full_width = true;
|
||||
def->height = 130;
|
||||
def->mode = comMiddle;
|
||||
def->default_value = new ConfigOptionString("");
|
||||
|
||||
def = this->add("printer_vendor", coString);
|
||||
@ -1787,6 +1795,7 @@ void PrintConfigDef::init_fff_params()
|
||||
def->multiline = true;
|
||||
def->full_width = true;
|
||||
def->height = 120;
|
||||
def->mode = comExpert;
|
||||
def->default_value = new ConfigOptionString("G28 ; home all axes\nG1 Z5 F5000 ; lift nozzle\n");
|
||||
|
||||
def = this->add("start_filament_gcode", coStrings);
|
||||
@ -1803,6 +1812,7 @@ void PrintConfigDef::init_fff_params()
|
||||
def->multiline = true;
|
||||
def->full_width = true;
|
||||
def->height = 120;
|
||||
def->mode = comExpert;
|
||||
def->default_value = new ConfigOptionStrings { "; Filament gcode\n" };
|
||||
|
||||
def = this->add("single_extruder_multi_material", coBool);
|
||||
@ -2075,6 +2085,7 @@ void PrintConfigDef::init_fff_params()
|
||||
def->multiline = true;
|
||||
def->full_width = true;
|
||||
def->height = 50;
|
||||
def->mode = comExpert;
|
||||
def->default_value = new ConfigOptionString("");
|
||||
|
||||
def = this->add("top_infill_extrusion_width", coFloatOrPercent);
|
||||
@ -2406,6 +2417,7 @@ void PrintConfigDef::init_sla_params()
|
||||
def->multiline = true;
|
||||
def->full_width = true;
|
||||
def->height = 130;
|
||||
def->mode = comMiddle;
|
||||
def->default_value = new ConfigOptionString("");
|
||||
|
||||
def = this->add("default_sla_material_profile", coString);
|
||||
|
@ -54,10 +54,13 @@ public:
|
||||
virtual bool
|
||||
AcceptsFocusFromKeyboard() const { return false; }
|
||||
|
||||
void set_as_hidden() {
|
||||
Hide();
|
||||
hidden = true;
|
||||
}
|
||||
|
||||
virtual bool Show(bool show = true) override {
|
||||
if (!show)
|
||||
hidden = true;
|
||||
return wxButton::Show(!hidden);
|
||||
return wxButton::Show(hidden ? false : show);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -97,8 +97,8 @@ const t_field& OptionsGroup::build_field(const t_config_option_key& id, const Co
|
||||
void OptionsGroup::add_undo_buttuns_to_sizer(wxSizer* sizer, const t_field& field)
|
||||
{
|
||||
if (!m_show_modified_btns) {
|
||||
field->m_Undo_btn->Hide();
|
||||
field->m_Undo_to_sys_btn->Hide();
|
||||
field->m_Undo_btn->set_as_hidden();
|
||||
field->m_Undo_to_sys_btn->set_as_hidden();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -123,6 +123,10 @@ void OptionsGroup::append_line(const Line& line, wxStaticText** colored_Label/*
|
||||
for (auto opt : option_set)
|
||||
m_options.emplace(opt.opt_id, opt);
|
||||
|
||||
// add mode value for current line to m_options_mode
|
||||
if (!option_set.empty())
|
||||
m_options_mode.push_back(option_set[0].opt.mode);
|
||||
|
||||
// if we have a single option with no label, no sidetext just add it directly to sizer
|
||||
if (option_set.size() == 1 && label_width == 0 && option_set.front().opt.full_width &&
|
||||
option_set.front().opt.sidetext.size() == 0 && option_set.front().side_widget == nullptr &&
|
||||
@ -383,16 +387,17 @@ void ConfigOptionsGroup::reload_config(){
|
||||
|
||||
}
|
||||
|
||||
void ConfigOptionsGroup::update_visibility(ConfigOptionMode mode) {
|
||||
int rows = m_grid_sizer->GetEffectiveRowsCount();
|
||||
if (rows != m_options.size())
|
||||
return;
|
||||
bool ConfigOptionsGroup::update_visibility(ConfigOptionMode mode) {
|
||||
if (m_grid_sizer->GetEffectiveRowsCount() != m_options_mode.size() &&
|
||||
m_options_mode.size() == 1)
|
||||
return m_options_mode[0] <= mode;
|
||||
|
||||
sizer->ShowItems(true);
|
||||
|
||||
int coef = 0;
|
||||
const int cols = m_grid_sizer->GetCols();
|
||||
for (std::map<t_config_option_key, Option>::iterator it = m_options.begin(); it != m_options.end(); ++it) {
|
||||
const bool show = it->second.opt.mode <= mode;
|
||||
for (auto opt_mode : m_options_mode) {
|
||||
const bool show = opt_mode <= mode;
|
||||
if (!show) {
|
||||
for (int i = 0; i < cols; ++i)
|
||||
m_grid_sizer->Show(coef + i, show);
|
||||
@ -400,8 +405,11 @@ void ConfigOptionsGroup::update_visibility(ConfigOptionMode mode) {
|
||||
coef+= cols;
|
||||
}
|
||||
|
||||
if (!sizer->IsShown(m_grid_sizer))
|
||||
if (!sizer->IsShown(m_grid_sizer)) {
|
||||
sizer->ShowItems(false);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
boost::any ConfigOptionsGroup::config_value(const std::string& opt_key, int opt_index, bool deserialize){
|
||||
|
@ -182,6 +182,7 @@ public:
|
||||
protected:
|
||||
std::map<t_config_option_key, Option> m_options;
|
||||
wxWindow* m_parent {nullptr};
|
||||
std::vector<ConfigOptionMode> m_options_mode;
|
||||
|
||||
/// Field list, contains unique_ptrs of the derived type.
|
||||
/// using types that need to know what it is beyond the public interface
|
||||
@ -245,7 +246,8 @@ public:
|
||||
void back_to_config_value(const DynamicPrintConfig& config, const std::string& opt_key);
|
||||
void on_kill_focus() override{ reload_config();}
|
||||
void reload_config();
|
||||
void update_visibility(ConfigOptionMode mode);
|
||||
// return value shows visibility : false => all options are hidden
|
||||
bool update_visibility(ConfigOptionMode mode);
|
||||
boost::any config_value(const std::string& opt_key, int opt_index, bool deserialize);
|
||||
// return option value from config
|
||||
boost::any get_config_value(const DynamicPrintConfig& config, const std::string& opt_key, int opt_index = -1);
|
||||
|
@ -635,9 +635,15 @@ void Tab::reload_config(){
|
||||
void Tab::update_visibility(ConfigOptionMode mode)
|
||||
{
|
||||
Freeze();
|
||||
|
||||
for (auto page : m_pages)
|
||||
page->update_visibility(mode);
|
||||
Thaw();
|
||||
update_page_tree_visibility();
|
||||
|
||||
m_hsizer->Layout();
|
||||
Refresh();
|
||||
|
||||
Thaw();
|
||||
}
|
||||
|
||||
Field* Tab::get_field(const t_config_option_key& opt_key, int opt_index/* = -1*/) const
|
||||
@ -2264,6 +2270,33 @@ void Tab::rebuild_page_tree(bool tree_sel_change_event /*= false*/)
|
||||
Thaw();
|
||||
}
|
||||
|
||||
void Tab::update_page_tree_visibility()
|
||||
{
|
||||
const auto sel_item = m_treectrl->GetSelection();
|
||||
const auto selected = sel_item ? m_treectrl->GetItemText(sel_item) : "";
|
||||
const auto rootItem = m_treectrl->GetRootItem();
|
||||
|
||||
auto have_selection = 0;
|
||||
m_treectrl->DeleteChildren(rootItem);
|
||||
for (auto p : m_pages)
|
||||
{
|
||||
if (!p->get_show())
|
||||
continue;
|
||||
auto itemId = m_treectrl->AppendItem(rootItem, p->title(), p->iconID());
|
||||
m_treectrl->SetItemTextColour(itemId, p->get_item_colour());
|
||||
if (p->title() == selected) {
|
||||
m_treectrl->SelectItem(itemId);
|
||||
have_selection = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!have_selection) {
|
||||
// this is triggered on first load, so we don't disable the sel change event
|
||||
m_treectrl->SelectItem(m_treectrl->GetFirstVisibleItem());//! (treectrl->GetFirstChild(rootItem));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Called by the UI combo box when the user switches profiles.
|
||||
// Select a preset by a name.If !defined(name), then the default preset is selected.
|
||||
// If the current profile is modified, user is asked to save the changes.
|
||||
@ -2692,8 +2725,11 @@ void Page::reload_config()
|
||||
|
||||
void Page::update_visibility(ConfigOptionMode mode)
|
||||
{
|
||||
for (auto group : m_optgroups)
|
||||
group->update_visibility(mode);
|
||||
bool ret_val = false;
|
||||
for (auto group : m_optgroups)
|
||||
ret_val = group->update_visibility(mode) || ret_val;
|
||||
|
||||
m_show = ret_val;
|
||||
}
|
||||
|
||||
Field* Page::get_field(const t_config_option_key& opt_key, int opt_index /*= -1*/) const
|
||||
|
@ -47,6 +47,7 @@ class Page : public wxScrolledWindow
|
||||
wxString m_title;
|
||||
size_t m_iconID;
|
||||
wxBoxSizer* m_vsizer;
|
||||
bool m_show = true;
|
||||
public:
|
||||
Page(wxWindow* parent, const wxString title, const int iconID) :
|
||||
m_parent(parent),
|
||||
@ -89,6 +90,7 @@ public:
|
||||
const wxColour get_item_colour() {
|
||||
return *m_item_color;
|
||||
}
|
||||
bool get_show() const { return m_show; }
|
||||
|
||||
protected:
|
||||
// Color of TreeCtrlItem. The wxColour will be updated only if the new wxColour pointer differs from the currently rendered one.
|
||||
@ -215,6 +217,7 @@ public:
|
||||
void create_preset_tab();
|
||||
void load_current_preset();
|
||||
void rebuild_page_tree(bool tree_sel_change_event = false);
|
||||
void update_page_tree_visibility();
|
||||
void select_preset(std::string preset_name = "");
|
||||
bool may_discard_current_dirty_preset(PresetCollection* presets = nullptr, const std::string& new_printer_name = "");
|
||||
wxSizer* compatible_printers_widget(wxWindow* parent, wxCheckBox** checkbox, wxButton** btn);
|
||||
|
Loading…
Reference in New Issue
Block a user