Merge branch 'vb_optgroup_refact'

This commit is contained in:
Vojtech Bubnik 2020-10-01 20:05:31 +02:00
commit ee58ab4e2d
20 changed files with 913 additions and 503 deletions

View file

@ -24,6 +24,9 @@
namespace Slic3r { namespace GUI {
// Thrown if the building of a parameter page is canceled.
class UIBuildCanceled : public std::exception {};
/// Widget type describes a function object that returns a wxWindow (our widget) and accepts a wxWidget (parent window).
using widget_t = std::function<wxSizer*(wxWindow*)>;//!std::function<wxWindow*(wxWindow*)>;
@ -48,7 +51,7 @@ public:
wxString label {wxString("")};
wxString label_tooltip {wxString("")};
size_t full_width {0};
wxSizer* sizer {nullptr};
wxStaticText** full_Label {nullptr};
widget_t widget {nullptr};
std::function<wxWindow*(wxWindow*)> near_label_widget{ nullptr };
@ -119,7 +122,15 @@ public:
return this->stb ? (wxWindow*)this->stb : this->parent();
}
void append_line(const Line& line, wxStaticText** full_Label = nullptr);
void append_line(const Line& line);
// create controls for the option group
void activate_line(Line& line);
// create all controls for the option group from the m_lines
bool activate(std::function<void()> throw_if_canceled = [](){});
// delete all controls from the option group
void clear();
Line create_single_option_line(const Option& option) const;
void append_single_option_line(const Option& option) { append_line(create_single_option_line(option)); }
@ -170,11 +181,7 @@ public:
void clear_fields_except_of(const std::vector<std::string> left_fields);
void hide_labels() {
label_width = 0;
m_grid_sizer->SetCols(m_grid_sizer->GetEffectiveColsCount()-1);
static_cast<wxFlexGridSizer*>(m_grid_sizer)->AddGrowableCol(!extra_column ? 0 : 1);
}
void hide_labels() { label_width = 0; }
OptionsGroup( wxWindow* _parent, const wxString& title, bool is_tab_opt = false,
column_t extra_clmn = nullptr);
@ -188,6 +195,8 @@ protected:
std::vector<wxWindow*> m_extra_column_item_ptrs;
std::vector<wxWindow*> m_near_label_widget_ptrs;
std::vector<Line> m_lines;
/// Field list, contains unique_ptrs of the derived type.
/// using types that need to know what it is beyond the public interface
/// need to cast based on the related ConfigOptionDef.
@ -210,7 +219,7 @@ protected:
const t_field& build_field(const t_config_option_key& id, const ConfigOptionDef& opt, wxStaticText* label = nullptr);
const t_field& build_field(const t_config_option_key& id, wxStaticText* label = nullptr);
const t_field& build_field(const Option& opt, wxStaticText* label = nullptr);
void add_undo_buttuns_to_sizer(wxSizer* sizer, const t_field& field);
void add_undo_buttons_to_sizer(wxSizer* sizer, const t_field& field);
virtual void on_kill_focus(const std::string& opt_key) {};
virtual void on_set_focus(const std::string& opt_key);
@ -259,6 +268,7 @@ public:
// return value shows visibility : false => all options are hidden
void Hide();
void Show(const bool show);
bool is_visible(ConfigOptionMode mode);
bool update_visibility(ConfigOptionMode mode);
void msw_rescale();
void sys_color_changed();