Filling object settings (continue)
This commit is contained in:
parent
83cec1a640
commit
a877846699
@ -512,10 +512,10 @@ sub new {
|
||||
$scrolled_window_sizer->Add($print_info_sizer, 0, wxEXPAND, 0);
|
||||
|
||||
my $right_sizer = Wx::BoxSizer->new(wxVERTICAL);
|
||||
$right_sizer->SetMinSize([320, 600]);
|
||||
$right_sizer->SetMinSize([320, -1]);
|
||||
$right_sizer->Add($presets, 0, wxEXPAND | wxTOP, 10) if defined $presets;
|
||||
$right_sizer->Add($frequently_changed_parameters_sizer, 0, wxEXPAND | wxTOP, 0) if defined $frequently_changed_parameters_sizer;
|
||||
$right_sizer->Add($expert_mode_part_sizer, 0, wxEXPAND | wxTOP, 0) if defined $expert_mode_part_sizer;
|
||||
$right_sizer->Add($expert_mode_part_sizer, 1, wxEXPAND | wxTOP, 0) if defined $expert_mode_part_sizer;
|
||||
$right_sizer->Add($buttons_sizer, 0, wxEXPAND | wxBOTTOM, 5);
|
||||
$right_sizer->Add($scrolled_window_panel, 1, wxEXPAND | wxALL, 1);
|
||||
# Callback for showing / hiding the print info box.
|
||||
|
@ -120,6 +120,7 @@ wxLocale* g_wxLocale;
|
||||
|
||||
std::vector <std::shared_ptr<ConfigOptionsGroup>> m_optgroups;
|
||||
double m_brim_width = 0.0;
|
||||
size_t m_label_width = 100;
|
||||
wxButton* g_wiping_dialog_button = nullptr;
|
||||
|
||||
//showed/hided controls according to the view mode
|
||||
@ -878,33 +879,66 @@ wxBoxSizer* content_objects_list(wxWindow *win)
|
||||
return objects_sz;
|
||||
}
|
||||
|
||||
wxBoxSizer* content_object_settings(wxWindow *win)
|
||||
Line add_og_to_object_settings(const std::string& option_name, const std::string& sidetext, int def_value=0)
|
||||
{
|
||||
DynamicPrintConfig* config = &g_PresetBundle->prints.get_edited_preset().config;
|
||||
std::shared_ptr<ConfigOptionsGroup> optgroup = std::make_shared<ConfigOptionsGroup>(win, "", config, false, ogSIDE_OPTIONS_VERTICAL);
|
||||
optgroup->label_width = 100;
|
||||
|
||||
Line line = { _(L("Position")), "" };
|
||||
Line line = { _(option_name), "" };
|
||||
ConfigOptionDef def;
|
||||
|
||||
def.label = L("X");
|
||||
def.type = coInt;
|
||||
def.default_value = new ConfigOptionInt(1);
|
||||
def.sidetext = L("mm");
|
||||
def.default_value = new ConfigOptionInt(def_value);
|
||||
def.sidetext = sidetext;
|
||||
def.width = 50;
|
||||
|
||||
Option option = Option(def, "position_X");
|
||||
const std::string lower_name = boost::algorithm::to_lower_copy(option_name);
|
||||
|
||||
Option option = Option(def, lower_name + "_X");
|
||||
option.opt.full_width = true;
|
||||
line.append_option(option);
|
||||
|
||||
def.label = L("Y");
|
||||
option = Option(def, "position_Y");
|
||||
option = Option(def, lower_name + "_Y");
|
||||
line.append_option(option);
|
||||
|
||||
def.label = L("Z");
|
||||
option = Option(def, "position_Z");
|
||||
option = Option(def, lower_name + "_Z");
|
||||
line.append_option(option);
|
||||
return line;
|
||||
}
|
||||
|
||||
optgroup->append_line(line);
|
||||
wxBoxSizer* content_object_settings(wxWindow *win)
|
||||
{
|
||||
DynamicPrintConfig* config = /*&g_PresetBundle->full_config();*/&g_PresetBundle->prints.get_edited_preset().config;
|
||||
std::shared_ptr<ConfigOptionsGroup> optgroup = std::make_shared<ConfigOptionsGroup>(win, "", config);
|
||||
optgroup->label_width = m_label_width;
|
||||
|
||||
ConfigOptionDef def;
|
||||
def.label = L("Name");
|
||||
def.type = coString;
|
||||
def.tooltip = L("Object name");
|
||||
def.full_width = true;
|
||||
def.default_value = new ConfigOptionString{ "BlaBla_object.stl" };
|
||||
optgroup->append_single_option_line(Option(def, "object_name"));
|
||||
|
||||
optgroup->set_flag(ogSIDE_OPTIONS_VERTICAL);
|
||||
|
||||
optgroup->append_line(add_og_to_object_settings(L("Position"), L("mm")));
|
||||
optgroup->append_line(add_og_to_object_settings(L("Rotation"), "°"/*"\u00b0"*/, 1));
|
||||
optgroup->append_line(add_og_to_object_settings(L("Scale"), "%", 2));
|
||||
|
||||
optgroup->set_flag(ogDEFAULT);
|
||||
|
||||
def.label = L("Place on bed");
|
||||
def.type = coBool;
|
||||
def.tooltip = L("Automatic placing of models on printing bed in Y axis");
|
||||
def.gui_type = "";
|
||||
def.sidetext = "";
|
||||
def.default_value = new ConfigOptionBool{ false };
|
||||
optgroup->append_single_option_line(Option(def, "place_on_bed"));
|
||||
|
||||
Option option = optgroup->get_option("extruder");
|
||||
option.opt.default_value = new ConfigOptionInt(1);
|
||||
optgroup->append_single_option_line(option);
|
||||
|
||||
m_optgroups.push_back(optgroup); // ogObjectSettings
|
||||
|
||||
@ -922,7 +956,6 @@ wxBoxSizer* content_part_settings(wxWindow *win)
|
||||
|
||||
void add_expert_mode_part(wxWindow* parent, wxBoxSizer* sizer)
|
||||
{
|
||||
sizer->SetMinSize(-1, 150);
|
||||
auto main_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
auto main_page = new wxScrolledWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
|
||||
main_page->SetSizer(main_sizer);
|
||||
@ -963,7 +996,8 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl
|
||||
DynamicPrintConfig* config = &g_PresetBundle->prints.get_edited_preset().config;
|
||||
std::shared_ptr<ConfigOptionsGroup> optgroup = std::make_shared<ConfigOptionsGroup>(parent, "", config);
|
||||
const wxArrayInt& ar = preset_sizer->GetColWidths();
|
||||
optgroup->label_width = ar.IsEmpty() ? 100 : ar.front()-4; // doesn't work
|
||||
m_label_width = ar.IsEmpty() ? 100 : ar.front()-4;
|
||||
optgroup->label_width = m_label_width;
|
||||
optgroup->m_on_change = [config](t_config_option_key opt_key, boost::any value){
|
||||
TabPrint* tab_print = nullptr;
|
||||
for (size_t i = 0; i < g_wxTabPanel->GetPageCount(); ++i) {
|
||||
|
@ -159,7 +159,8 @@ void OptionsGroup::append_line(const Line& line, wxStaticText** colored_Label/*
|
||||
wxDefaultPosition, wxSize(label_width, -1), staticbox ? 0 : wxALIGN_RIGHT);
|
||||
label->SetFont(label_font);
|
||||
label->Wrap(label_width); // avoid a Linux/GTK bug
|
||||
grid_sizer->Add(label, 0, (staticbox ? 0 : wxALIGN_RIGHT | wxRIGHT) | wxALIGN_CENTER_VERTICAL, 5);
|
||||
grid_sizer->Add(label, 0, (staticbox ? 0 : wxALIGN_RIGHT | wxRIGHT) |
|
||||
(m_flag == ogSIDE_OPTIONS_VERTICAL ? wxTOP : wxALIGN_CENTER_VERTICAL), 5);
|
||||
if (line.label_tooltip.compare("") != 0)
|
||||
label->SetToolTip(line.label_tooltip);
|
||||
}
|
||||
@ -175,7 +176,7 @@ void OptionsGroup::append_line(const Line& line, wxStaticText** colored_Label/*
|
||||
|
||||
// If we're here, we have more than one option or a single option with sidetext
|
||||
// so we need a horizontal sizer to arrange these things
|
||||
auto sizer = new wxBoxSizer((m_flag & ogSIDE_OPTIONS_VERTICAL) != 0 ? wxVERTICAL :wxHORIZONTAL);
|
||||
auto sizer = new wxBoxSizer(m_flag == ogSIDE_OPTIONS_VERTICAL ? wxVERTICAL : wxHORIZONTAL);
|
||||
grid_sizer->Add(sizer, 0, wxEXPAND | (staticbox ? wxALL : wxBOTTOM|wxTOP|wxLEFT), staticbox ? 0 : 1);
|
||||
// If we have a single option with no sidetext just add it directly to the grid sizer
|
||||
if (option_set.size() == 1 && option_set.front().opt.sidetext.size() == 0 &&
|
||||
@ -194,6 +195,7 @@ void OptionsGroup::append_line(const Line& line, wxStaticText** colored_Label/*
|
||||
|
||||
for (auto opt : option_set) {
|
||||
ConfigOptionDef option = opt.opt;
|
||||
wxBoxSizer* sizer_tmp = m_flag == ogSIDE_OPTIONS_VERTICAL ? new wxBoxSizer(wxHORIZONTAL) : sizer;
|
||||
// add label if any
|
||||
if (option.label != "") {
|
||||
wxString str_label = L_str(option.label);
|
||||
@ -203,33 +205,35 @@ void OptionsGroup::append_line(const Line& line, wxStaticText** colored_Label/*
|
||||
// L_str(option.label);
|
||||
label = new wxStaticText(parent(), wxID_ANY, str_label + ":", wxDefaultPosition, wxDefaultSize);
|
||||
label->SetFont(label_font);
|
||||
sizer->Add(label, 0, wxALIGN_CENTER_VERTICAL, 0);
|
||||
sizer_tmp->Add(label, 0, wxALIGN_CENTER_VERTICAL, 0);
|
||||
}
|
||||
|
||||
// add field
|
||||
const Option& opt_ref = opt;
|
||||
auto& field = build_field(opt_ref, label);
|
||||
add_undo_buttuns_to_sizer(sizer, field);
|
||||
add_undo_buttuns_to_sizer(sizer_tmp, field);
|
||||
is_sizer_field(field) ?
|
||||
sizer->Add(field->getSizer(), 0, wxALIGN_CENTER_VERTICAL, 0) :
|
||||
sizer->Add(field->getWindow(), 0, wxALIGN_CENTER_VERTICAL, 0);
|
||||
sizer_tmp->Add(field->getSizer(), 0, wxALIGN_CENTER_VERTICAL, 0) :
|
||||
sizer_tmp->Add(field->getWindow(), 0, wxALIGN_CENTER_VERTICAL, 0);
|
||||
|
||||
// add sidetext if any
|
||||
if (option.sidetext != "") {
|
||||
auto sidetext = new wxStaticText(parent(), wxID_ANY, L_str(option.sidetext), wxDefaultPosition, wxDefaultSize);
|
||||
sidetext->SetFont(sidetext_font);
|
||||
sizer->Add(sidetext, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, 4);
|
||||
sizer_tmp->Add(sidetext, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, 4);
|
||||
}
|
||||
|
||||
// add side widget if any
|
||||
if (opt.side_widget != nullptr) {
|
||||
sizer->Add(opt.side_widget(parent())/*!.target<wxWindow>()*/, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, 1); //! requires verification
|
||||
sizer_tmp->Add(opt.side_widget(parent())/*!.target<wxWindow>()*/, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, 1); //! requires verification
|
||||
}
|
||||
|
||||
if (opt.opt_id != option_set.back().opt_id) //! istead of (opt != option_set.back())
|
||||
if (opt.opt_id != option_set.back().opt_id && m_flag != ogSIDE_OPTIONS_VERTICAL) //! istead of (opt != option_set.back())
|
||||
{
|
||||
sizer->AddSpacer(6);
|
||||
sizer_tmp->AddSpacer(6);
|
||||
}
|
||||
if (m_flag == ogSIDE_OPTIONS_VERTICAL)
|
||||
sizer->Add(sizer_tmp, 1, wxEXPAND|wxALIGN_RIGHT|wxALL, 0);
|
||||
}
|
||||
// add extra sizers if any
|
||||
for (auto extra_widget : line.get_extra_widgets()) {
|
||||
|
@ -131,6 +131,7 @@ public:
|
||||
|
||||
inline void enable() { for (auto& field : m_fields) field.second->enable(); }
|
||||
inline void disable() { for (auto& field : m_fields) field.second->disable(); }
|
||||
void set_flag(ogDrawFlag flag) { m_flag = flag; }
|
||||
|
||||
OptionsGroup(wxWindow* _parent, const wxString& title, bool is_tab_opt=false, ogDrawFlag flag = ogDEFAULT) :
|
||||
m_parent(_parent), title(title), m_is_tab_opt(is_tab_opt), staticbox(title!=""), m_flag(flag) {
|
||||
@ -139,7 +140,7 @@ public:
|
||||
if (label_width != 0) num_columns++;
|
||||
if (extra_column != nullptr) num_columns++;
|
||||
m_grid_sizer = new wxFlexGridSizer(0, num_columns, 0,0);
|
||||
static_cast<wxFlexGridSizer*>(m_grid_sizer)->SetFlexibleDirection(wxHORIZONTAL);
|
||||
static_cast<wxFlexGridSizer*>(m_grid_sizer)->SetFlexibleDirection(wxBOTH/*wxHORIZONTAL*/);
|
||||
static_cast<wxFlexGridSizer*>(m_grid_sizer)->AddGrowableCol(label_width != 0);
|
||||
#ifdef __WXGTK__
|
||||
m_panel = new wxPanel( _parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
|
||||
|
@ -102,9 +102,9 @@ public:
|
||||
this->Bind(wxEVT_COLLAPSIBLEPANE_CHANGED, ([parent, this](wxCommandEvent e){
|
||||
wxWindowUpdateLocker noUpdates_cp(this);
|
||||
wxWindowUpdateLocker noUpdates(parent);
|
||||
parent->GetParent()->Layout();
|
||||
parent->Layout();
|
||||
this->Refresh();
|
||||
parent->GetParent() ? parent->GetParent()->Layout() : //;
|
||||
parent->Layout();
|
||||
// this->Refresh();
|
||||
}));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user