mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-28 13:52:02 +08:00
Config layer: Refactored handling of open enums
This commit is contained in:
parent
8dad25efc4
commit
827fb8356e
@ -335,12 +335,9 @@ void ConfigDef::finalize()
|
|||||||
if (def.type == coEnum) {
|
if (def.type == coEnum) {
|
||||||
assert(def.enum_def);
|
assert(def.enum_def);
|
||||||
assert(def.enum_def->is_valid_closed_enum());
|
assert(def.enum_def->is_valid_closed_enum());
|
||||||
assert(def.gui_type != ConfigOptionDef::GUIType::i_enum_open &&
|
assert(! def.is_gui_type_enum_open());
|
||||||
def.gui_type != ConfigOptionDef::GUIType::f_enum_open &&
|
|
||||||
def.gui_type != ConfigOptionDef::GUIType::select_open);
|
|
||||||
def.enum_def->finalize_closed_enum();
|
def.enum_def->finalize_closed_enum();
|
||||||
} else if (def.gui_type == ConfigOptionDef::GUIType::i_enum_open || def.gui_type == ConfigOptionDef::GUIType::f_enum_open ||
|
} else if (def.is_gui_type_enum_open()) {
|
||||||
def.gui_type == ConfigOptionDef::GUIType::select_open) {
|
|
||||||
assert(def.enum_def);
|
assert(def.enum_def);
|
||||||
assert(def.enum_def->is_valid_open_enum());
|
assert(def.enum_def->is_valid_open_enum());
|
||||||
assert(def.gui_type != ConfigOptionDef::GUIType::i_enum_open || def.type == coInt || def.type == coInts);
|
assert(def.gui_type != ConfigOptionDef::GUIType::i_enum_open || def.type == coInt || def.type == coInts);
|
||||||
@ -427,7 +424,7 @@ std::ostream& ConfigDef::print_cli_help(std::ostream& out, bool show_defaults, s
|
|||||||
descr += " (";
|
descr += " (";
|
||||||
if (!def.sidetext.empty()) {
|
if (!def.sidetext.empty()) {
|
||||||
descr += def.sidetext + ", ";
|
descr += def.sidetext + ", ";
|
||||||
} else if (def.enum_def->has_values()) {
|
} else if (def.enum_def && def.enum_def->has_values()) {
|
||||||
descr += boost::algorithm::join(def.enum_def->values(), ", ") + "; ";
|
descr += boost::algorithm::join(def.enum_def->values(), ", ") + "; ";
|
||||||
}
|
}
|
||||||
descr += "default: " + def.default_value->serialize() + ")";
|
descr += "default: " + def.default_value->serialize() + ")";
|
||||||
|
@ -1836,6 +1836,8 @@ public:
|
|||||||
// Close parameter, string value could be one of the list values.
|
// Close parameter, string value could be one of the list values.
|
||||||
select_close,
|
select_close,
|
||||||
};
|
};
|
||||||
|
static bool is_gui_type_enum_open(const GUIType gui_type)
|
||||||
|
{ return gui_type == ConfigOptionDef::GUIType::i_enum_open || gui_type == ConfigOptionDef::GUIType::f_enum_open || gui_type == ConfigOptionDef::GUIType::select_open; }
|
||||||
|
|
||||||
// Identifier of this option. It is stored here so that it is accessible through the by_serialization_key_ordinal map.
|
// Identifier of this option. It is stored here so that it is accessible through the by_serialization_key_ordinal map.
|
||||||
t_config_option_key opt_key;
|
t_config_option_key opt_key;
|
||||||
@ -1923,6 +1925,7 @@ public:
|
|||||||
// Special values - "i_enum_open", "f_enum_open" to provide combo box for int or float selection,
|
// Special values - "i_enum_open", "f_enum_open" to provide combo box for int or float selection,
|
||||||
// "select_open" - to open a selection dialog (currently only a serial port selection).
|
// "select_open" - to open a selection dialog (currently only a serial port selection).
|
||||||
GUIType gui_type { GUIType::undefined };
|
GUIType gui_type { GUIType::undefined };
|
||||||
|
bool is_gui_type_enum_open() const { return is_gui_type_enum_open(this->gui_type); }
|
||||||
// Usually empty. Otherwise "serialized" or "show_value"
|
// Usually empty. Otherwise "serialized" or "show_value"
|
||||||
// The flags may be combined.
|
// The flags may be combined.
|
||||||
// "serialized" - vector valued option is entered in a single edit field. Values are separated by a semicolon.
|
// "serialized" - vector valued option is entered in a single edit field. Values are separated by a semicolon.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user