Fix layout from OG_custom

This commit is contained in:
supermerill 2020-11-06 02:10:10 +01:00
parent bd36042523
commit 4da0a6efe1
10 changed files with 309 additions and 254 deletions

View File

@ -2,12 +2,6 @@
<!-- Generator: Adobe Illustrator 23.0.6, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.0" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 16 16" enable-background="new 0 0 16 16" xml:space="preserve">
<path id="undo_1_" fill="#2172eb" d="M1.95,7.01h10.24L8.86,2.51c-0.31-0.42-0.22-1.01,0.2-1.32c0.42-0.31,1.01-0.22,1.32,0.2
l4.44,6.01c0,0.01,0.01,0.01,0.01,0.02c0.01,0.01,0.02,0.03,0.03,0.04c0.01,0.02,0.03,0.05,0.04,0.07c0.01,0.02,0.02,0.03,0.03,0.05
c0.01,0.01,0.01,0.03,0.02,0.04c0.01,0.02,0.02,0.05,0.02,0.07c0.01,0.02,0.01,0.04,0.02,0.06c0,0.01,0,0.03,0.01,0.04
c0,0.02,0.01,0.05,0.01,0.07c0,0.02,0.01,0.05,0.01,0.07c0,0.01,0,0.01,0,0.02c0,0.01,0,0.01,0,0.02c0,0.02,0,0.05-0.01,0.07
c0,0.02,0,0.05-0.01,0.07c0,0.01,0,0.03-0.01,0.04c0,0.02-0.01,0.04-0.02,0.06c-0.01,0.02-0.01,0.05-0.02,0.07
c-0.01,0.01-0.01,0.03-0.02,0.04c-0.01,0.02-0.02,0.04-0.03,0.05c-0.01,0.02-0.02,0.04-0.04,0.07c-0.01,0.01-0.02,0.03-0.03,0.04
c0,0.01-0.01,0.01-0.01,0.02l-4.54,6.05c-0.19,0.25-0.47,0.38-0.76,0.38c-0.2,0-0.4-0.06-0.57-0.19c-0.42-0.31-0.5-0.91-0.19-1.32
l3.41-4.54H1.95C1.42,8.91,1,8.48,1,7.96C1,7.44,1.42,7.01,1.95,7.01z"/>
<path id="background_white_1_" fill="#ffffff" d="M 1.337373,6.1250997 10.523316,6.0815623 7.9003335,2.4654392 C 7.2747405,1.5361462 7.7643506,0.69105937 8.4771954,0.27549438 9.1410379,-0.11150384 10.22409,0.04292985 10.822715,0.78475227 l 4.522254,6.09993063 c 0,0.019477 0.01088,0.019477 0.01088,0.038952 0.01089,0.019477 0.02176,0.05843 0.03266,0.077906 0.01089,0.038952 0.03266,0.097382 0.04354,0.1363348 0.01089,0.038952 0.02176,0.05843 0.03266,0.097382 0.01088,0.019477 0.01088,0.05843 0.02176,0.077906 0.01089,0.038952 0.02176,0.097382 0.02176,0.1363349 0.01089,0.038952 0.01089,0.077906 0.02176,0.1168593 0,0.019477 0,0.05843 0.01088,0.077906 0,0.038952 0.01089,0.097382 0.01089,0.136335 0,0.038952 0.01088,0.097382 0.01088,0.136335 v 0.038952 0.038952 c 0,0.038952 0,0.097382 -0.01088,0.1363349 0,0.038953 0,0.097382 -0.01089,0.1363351 0,0.019477 0,0.05843 -0.01088,0.077906 0,0.038952 -0.01089,0.077906 -0.02176,0.1168593 -0.01088,0.038952 -0.01088,0.097382 -0.02176,0.1363349 -0.01089,0.019477 -0.01089,0.05843 -0.02176,0.077906 -0.01089,0.038952 -0.02176,0.077906 -0.03266,0.097382 -0.01089,0.038952 -0.02176,0.077905 -0.04354,0.1363346 -0.01088,0.019482 -0.02176,0.058434 -0.03266,0.077905 0,0.019482 -0.01088,0.019482 -0.01088,0.038952 l -4.680073,6.3030093 c -0.473459,0.546777 -1.6420466,0.6907 -2.4054079,0.163238 C 7.4961268,14.965873 7.5883336,13.730833 7.8785692,13.341506 L 10.414473,9.7236666 1.337373,9.767204 C 0.76052572,9.8256383 0.30340136,8.9881443 0.30340136,7.9753665 c 0,-1.0127776 0.45712436,-1.8502668 1.03397164,-1.8502668 z" />
<path id="arraow_red_1_" fill="#ff0000" d="M1.95,7.01h10.24L8.86,2.51c-0.31-0.42-0.22-1.01,0.2-1.32c0.42-0.31,1.01-0.22,1.32,0.2 l4.44,6.01c0,0.01,0.01,0.01,0.01,0.02c0.01,0.01,0.02,0.03,0.03,0.04c0.01,0.02,0.03,0.05,0.04,0.07c0.01,0.02,0.02,0.03,0.03,0.05 c0.01,0.01,0.01,0.03,0.02,0.04c0.01,0.02,0.02,0.05,0.02,0.07c0.01,0.02,0.01,0.04,0.02,0.06c0,0.01,0,0.03,0.01,0.04 c0,0.02,0.01,0.05,0.01,0.07c0,0.02,0.01,0.05,0.01,0.07c0,0.01,0,0.01,0,0.02c0,0.01,0,0.01,0,0.02c0,0.02,0,0.05-0.01,0.07 c0,0.02,0,0.05-0.01,0.07c0,0.01,0,0.03-0.01,0.04c0,0.02-0.01,0.04-0.02,0.06c-0.01,0.02-0.01,0.05-0.02,0.07 c-0.01,0.01-0.01,0.03-0.02,0.04c-0.01,0.02-0.02,0.04-0.03,0.05c-0.01,0.02-0.02,0.04-0.04,0.07c-0.01,0.01-0.02,0.03-0.03,0.04 c0,0.01-0.01,0.01-0.01,0.02l-4.54,6.05c-0.19,0.25-0.47,0.38-0.76,0.38c-0.2,0-0.4-0.06-0.57-0.19c-0.42-0.31-0.5-0.91-0.19-1.32 l3.41-4.54H1.95C1.42,8.91,1,8.48,1,7.96C1,7.44,1.42,7.01,1.95,7.01z" />
</svg>

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@ -44,7 +44,7 @@ each parameter is separated by ':'
* full_label: to override the label by the "full one".
* full_width: to tell to create a field that span the full width.
* sidetext$STR: the suffix at the right of the widget (like 'mm').
* sidetext_width$INT: the suffix label length (override the group one). 0 for auto.
* sidetext_width$INT: the suffix label length (override the group one). -& for auto.
* simple|advanced|expert: add one of these to modify the mode in which this setting appear.
* width$INT: change the width of the field. Shouod work on most type of settings.
* height$INT: change the height of the field. Don't works with every type of setting.

View File

@ -39,10 +39,10 @@ group:Quality
setting:width$5:thin_walls_overlap
setting:thin_walls_merge
end_line
group:Overhangs
group:label_width$12:Overhangs
line:threshold for
setting:label$bridge speed and fan:width$5:overhangs_width_speed
setting:label$bridge flow:width$5:overhangs_width
setting:label$Bridge speed and fan:width$5:overhangs_width_speed
setting:label$Bridge flow:width$5:overhangs_width
end_line
line:Extrusion direction
setting:sidetext_width$1:overhangs_reverse
@ -80,12 +80,12 @@ group:Filtering
setting:resolution
setting:model_precision
setting:slice_closing_radius
group:label_width$8:Modifying slices
group:Modifying slices
line:Curve smoothing
setting:width$6:curve_smoothing_precision
setting:width$6:curve_smoothing_angle_convex
setting:width$6:curve_smoothing_angle_concave
setting:width$6:curve_smoothing_cutoff_dist
setting:label_width$6:width$6:curve_smoothing_cutoff_dist
end_line
setting:hole_to_polyhole
line:XY compensation
@ -118,36 +118,36 @@ group:Reducing printing time
setting:infill_every_layers
setting:infill_only_where_needed
line:Supporting dense layer
setting:infill_dense
setting:sidetext_width$0:infill_dense
setting:infill_dense_algo
end_line
group:sidetext_width$3:Advanced
setting:solid_infill_every_layers
setting:solid_infill_below_area
line:Angle
setting:label_width$6:width$5:fill_angle
setting:label_width$8:width$5:fill_angle
setting:label_width$6:width$5:bridge_angle
setting:label_width$6:width$5:label$increment:fill_angle_increment
end_line
line:Anchor solid infill by X mm
setting:label_width$6:width$5:external_infill_margin
setting:label_width$8:width$5:external_infill_margin
setting:label_width$6:width$5:bridged_infill_margin
end_line
setting:only_retract_when_crossing_perimeters
setting:infill_first
group:Advanced Infill options
line:Ironing infill tuning
setting:label_width$9:width$5:fill_smooth_distribution
setting:label$Spacing between ironing lines:width$5:sidetext_width$7:fill_smooth_width
setting:label_width$8:width$5:fill_smooth_distribution
setting:label_width$26:label$Spacing between ironing lines:width$5:sidetext_width$7:fill_smooth_width
end_line
group:Ironing post-process (This will go on top of infills and perimeters)
line:Enable ironing post-process
setting:label$_:ironing
setting:label$_:sidetext_width$0:ironing
setting:label$On:ironing_type
end_line
line:Tuning ironing
setting:ironing_flowrate
setting:ironing_spacing
setting:label_width$8:width$5:ironing_flowrate
setting:label_width$26:width$5:ironing_spacing
end_line
page:Skirt & Brim:skirt+brim

View File

@ -764,7 +764,7 @@ void PrintConfigDef::init_fff_params()
def->full_label = L("Default infill margin");
def->category = OptionCategory::infill;
def->tooltip = L("This parameter grows the top/bottom/solid layers by the specified MM to anchor them into the part. Put 0 to deactivate it. Can be a % of the width of the perimeters.");
def->sidetext = L("mm");
def->sidetext = L("mm/%");
def->ratio_over = "perimeter_extrusion_width";
def->min = 0;
def->mode = comExpert;
@ -775,7 +775,7 @@ void PrintConfigDef::init_fff_params()
def->full_label = L("Bridge margin");
def->category = OptionCategory::infill;
def->tooltip = L("This parameter grows the bridged solid infill layers by the specified MM to anchor them into the part. Put 0 to deactivate it. Can be a % of the width of the external perimeter.");
def->sidetext = L("mm");
def->sidetext = L("mm/%");
def->ratio_over = "external_perimeter_extrusion_width";
def->min = 0;
def->mode = comExpert;
@ -897,15 +897,15 @@ void PrintConfigDef::init_fff_params()
def->set_default_value(new ConfigOptionBool(false));
def = this->add("external_perimeters_nothole", coBool);
def->label = L("only for outter side");
def->full_label = L("ext peri first for outter side");
def->label = L("Only for outer side");
def->full_label = L("ext peri first for outer side");
def->category = OptionCategory::perimeter;
def->tooltip = L("Only do the vase trick on the external side. Useful when the thikness is too low.");
def->mode = comExpert;
def->set_default_value(new ConfigOptionBool(true));
def = this->add("external_perimeters_hole", coBool);
def->label = L("only for inner side");
def->label = L("Only for inner side");
def->full_label = L("ext peri first for inner side");
def->category = OptionCategory::perimeter;
def->tooltip = L("Only do the vase trick on the external side. Useful when you only want to remode seam from screw hole.");
@ -1389,6 +1389,7 @@ void PrintConfigDef::init_fff_params()
def = this->add("filament_density", coFloats);
def->label = L("Density");
def->category = OptionCategory::filament;
def->tooltip = L("Enter your filament density here. This is only for statistical information. "
"A decent way is to weigh a known length of filament and compute the ratio "
"of the length to volume. Better is to calculate the volume directly through displacement.");
@ -1607,7 +1608,7 @@ void PrintConfigDef::init_fff_params()
def->ratio_over = "top_infill_extrusion_width";
def->min = 0;
def->mode = comExpert;
def->sidetext = L("% or mm");
def->sidetext = L("mm/%");
def->set_default_value(new ConfigOptionFloatOrPercent(50, true));
def = this->add("fill_smooth_distribution", coPercent);
@ -3850,8 +3851,8 @@ void PrintConfigDef::init_fff_params()
def->set_default_value(new ConfigOptionFloat(10.));
def = this->add("xy_size_compensation", coFloat);
def->label = L("Outter");
def->full_label = L("Outter XY size compensation");
def->label = L("outer");
def->full_label = L("outer XY size compensation");
def->category = OptionCategory::slicing;
def->tooltip = L("The object will be grown/shrunk in the XY plane by the configured value "
"(negative = inwards, positive = outwards). This might be useful for fine-tuning sizes."

View File

@ -68,7 +68,7 @@ Field::~Field()
wxWindow* win = getWindow();
win->Destroy();
win = nullptr;
}
}
}
void Field::PostInitialize()
@ -79,8 +79,8 @@ void Field::PostInitialize()
{
case coPercents:
case coFloats:
case coStrings:
case coBools:
case coStrings:
case coBools:
case coPoints:
case coInts: {
auto tag_pos = m_opt_id.find("#");
@ -220,7 +220,7 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true
wxString label = m_opt.full_label.empty() ? _(m_opt.label) : _(m_opt.full_label);
show_error(m_parent, from_u8((boost::format(_utf8(L("%s doesn't support percentage"))) % label).str()));
set_value(double_to_string(m_opt.min), true);
m_value = m_opt.min;
m_value = double(m_opt.min);
break;
}
double val;
@ -284,28 +284,29 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true
if (m_opt.min > val) val = m_opt.min;
set_value(double_to_string(val), true);
} else if (((m_opt.sidetext.rfind("mm/s") != std::string::npos && val > m_opt.max) ||
(m_opt.sidetext.rfind("mm ") != std::string::npos && val > 1)) &&
(m_value.empty() || std::string(str.ToUTF8().data()) != boost::any_cast<std::string>(m_value)))
{
if (!check_value) {
m_value.clear();
break;
}
const std::string sidetext = m_opt.sidetext.rfind("mm/s") != std::string::npos ? "mm/s" : "mm";
const wxString stVal = double_to_string(val, 2);
const wxString msg_text = from_u8((boost::format(_utf8(L("Do you mean %s%% instead of %s %s?\n"
"Select YES if you want to change this value to %s%%, \n"
"or NO if you are sure that %s %s is a correct value."))) % stVal % stVal % sidetext % stVal % stVal % sidetext).str());
wxMessageDialog dialog(m_parent, msg_text, _(L("Parameter validation")) + ": " + m_opt_id, wxICON_WARNING | wxYES | wxNO);
if (dialog.ShowModal() == wxID_YES) {
set_value(from_u8((boost::format("%s%%") % stVal).str()), false/*true*/);
str += "%%";
} else
set_value(stVal, false); // it's no needed but can be helpful, when inputted value contained "," instead of "."
(m_opt.sidetext.rfind("mm ") != std::string::npos && val > 1)) &&
(m_value.empty() || std::string(str.ToUTF8().data()) != boost::any_cast<std::string>(m_value)))
{
if (!check_value) {
m_value.clear();
break;
}
const std::string sidetext = m_opt.sidetext.rfind("mm/s") != std::string::npos ? "mm/s" : "mm";
const wxString stVal = double_to_string(val, 2);
const wxString msg_text = from_u8((boost::format(_utf8(L("Do you mean %s%% instead of %s %s?\n"
"Select YES if you want to change this value to %s%%, \n"
"or NO if you are sure that %s %s is a correct value."))) % stVal % stVal % sidetext % stVal % stVal % sidetext).str());
wxMessageDialog dialog(m_parent, msg_text, _(L("Parameter validation")) + ": " + m_opt_id , wxICON_WARNING | wxYES | wxNO);
if (dialog.ShowModal() == wxID_YES) {
set_value(from_u8((boost::format("%s%%") % stVal).str()), false/*true*/);
str += "%%";
}
else
set_value(stVal, false); // it's no needed but can be helpful, when inputted value contained "," instead of "."
}
}
}
m_value = std::string(str.ToUTF8().data());
break; }
@ -318,7 +319,7 @@ void Field::msw_rescale()
{
// update em_unit value
m_em_unit = em_unit(m_parent);
}
}
void Field::sys_color_changed()
{
@ -564,7 +565,7 @@ void TextCtrl::msw_rescale()
if (parent_is_custom_ctrl)
field->SetSize(size);
else
field->SetMinSize(size);
field->SetMinSize(size);
}
}
@ -620,9 +621,8 @@ void CheckBox::set_value(const boost::any& value, bool change_event)
m_last_meaningful_value = value;
dynamic_cast<wxCheckBox*>(window)->SetValue(m_is_na_val ? false : boost::any_cast<unsigned char>(value) != 0);
}
else{
else
dynamic_cast<wxCheckBox*>(window)->SetValue(boost::any_cast<bool>(value));
}
m_disable_change_event = false;
}
@ -692,7 +692,7 @@ void SpinCtrl::BUILD() {
break;
}
const double min_val = m_opt.min == INT_MIN
const int min_val = m_opt.min == INT_MIN
#ifdef __WXOSX__
// We will forcibly set the input value for SpinControl, since the value
// inserted from the keyboard is not updated under OSX.
@ -701,8 +701,8 @@ void SpinCtrl::BUILD() {
// less then min_val.
|| m_opt.min > 0
#endif
? 0. : m_opt.min;
const double max_val = m_opt.max < 2147483647 ? m_opt.max : 2147483647.;
? 0 : m_opt.min;
const int max_val = m_opt.max < 2147483647 ? m_opt.max : 2147483647;
auto temp = new wxSpinCtrl(m_parent, wxID_ANY, text_value, wxDefaultPosition, size,
0|wxTE_PROCESS_ENTER, min_val, max_val, default_value);
@ -804,7 +804,7 @@ void SpinCtrl::msw_rescale()
if (parent_is_custom_ctrl)
field->SetSize(wxSize(def_width() * m_em_unit, lround(opt_height * m_em_unit)));
else
field->SetMinSize(wxSize(def_width() * m_em_unit, int(1.9f*field->GetFont().GetPixelSize().y)));
field->SetMinSize(wxSize(def_width() * m_em_unit, int(1.9f*field->GetFont().GetPixelSize().y)));
}
#ifdef __WXOSX__
@ -1027,10 +1027,10 @@ void Choice::set_value(const boost::any& value, bool change_event)
case coString:
case coStrings: {
wxString text_value;
if (m_opt.type == coInt)
text_value = wxString::Format(_T("%i"), int(boost::any_cast<int>(value)));
if (m_opt.type == coInt)
text_value = wxString::Format(_T("%i"), int(boost::any_cast<int>(value)));
else
text_value = boost::any_cast<wxString>(value);
text_value = boost::any_cast<wxString>(value);
size_t idx = 0;
for (auto el : m_opt.enum_values)
{
@ -1045,11 +1045,11 @@ void Choice::set_value(const boost::any& value, bool change_event)
field->SetValue(text_value);
}
else
field->SetSelection(idx);
break;
}
case coEnum: {
int val = boost::any_cast<int>(value);
field->SetSelection(idx);
break;
}
case coEnum: {
int val = boost::any_cast<int>(value);
if (m_opt_id == "top_fill_pattern" || m_opt_id == "bottom_fill_pattern" || m_opt_id == "solid_fill_pattern"
|| m_opt_id == "fill_pattern" || m_opt_id == "support_material_interface_pattern" || m_opt_id == "brim_ears_pattern")
val = idx_from_enum_value<InfillPattern>(val);
@ -1142,6 +1142,7 @@ void Choice::set_values(const wxArrayString &values)
m_disable_change_event = false;
}
boost::any& Choice::get_value()
{
choice_ctrl* field = dynamic_cast<choice_ctrl*>(window);
@ -1154,7 +1155,7 @@ boost::any& Choice::get_value()
if (m_opt_id == rp_option)
return m_value = boost::any(ret_str);
if (m_opt.type == coEnum)
if (m_opt.type == coEnum)
{
int ret_enum = field->GetSelection();
if (m_opt_id == "top_fill_pattern" || m_opt_id == "bottom_fill_pattern" || m_opt_id == "solid_fill_pattern"
@ -1267,11 +1268,11 @@ void Choice::msw_rescale()
void ColourPicker::BUILD()
{
auto size = wxSize(def_width() * m_em_unit, wxDefaultCoord);
if (m_opt.height >= 0) size.SetHeight(m_opt.height * m_em_unit);
if (m_opt.width >= 0) size.SetWidth(m_opt.width * m_em_unit);
auto size = wxSize(def_width() * m_em_unit, wxDefaultCoord);
if (m_opt.height >= 0) size.SetHeight(m_opt.height*m_em_unit);
if (m_opt.width >= 0) size.SetWidth(m_opt.width*m_em_unit);
// Validate the color
// Validate the color
wxColour clr = wxTransparentColour;
if (m_opt.type == coStrings)
clr = wxColour{wxString{ m_opt.get_default_value<ConfigOptionStrings>()->get_at(m_opt_idx) }};
@ -1358,7 +1359,7 @@ void ColourPicker::msw_rescale()
if (parent_is_custom_ctrl)
field->SetSize(size);
else
field->SetMinSize(size);
field->SetMinSize(size);
if (field->GetColour() == wxTransparentColour)
set_undef_value(field);
@ -1423,9 +1424,9 @@ void PointCtrl::msw_rescale()
y_textctrl->SetSize(field_size);
}
else {
x_textctrl->SetMinSize(field_size);
y_textctrl->SetMinSize(field_size);
}
x_textctrl->SetMinSize(field_size);
y_textctrl->SetMinSize(field_size);
}
}
bool PointCtrl::value_was_changed(wxTextCtrl* win)

View File

@ -82,7 +82,7 @@ void OG_CustomCtrl::init_ctrl_lines()
wxCoord height;
// if we have a single option with no label, no sidetext just add it directly to sizer
if (option_set.size() == 1 && opt_group->label_width == 0 && option_set.front().opt.full_width &&
if (option_set.size() == 1 && opt_group->title_width == 0 && option_set.front().opt.full_width &&
option_set.front().opt.label.empty() &&
option_set.front().opt.sidetext.size() == 0 && option_set.front().side_widget == nullptr &&
line.get_extra_widgets().size() == 0)
@ -90,10 +90,10 @@ void OG_CustomCtrl::init_ctrl_lines()
height = m_bmp_blinking_sz.GetHeight() + m_v_gap;
ctrl_lines.emplace_back(CtrlLine(height, this, line, true));
}
else if (opt_group->label_width != 0 && !line.label.IsEmpty())
else if (opt_group->title_width != 0 && !line.label.IsEmpty())
{
wxSize label_sz = GetTextExtent(line.label);
height = label_sz.y * (label_sz.GetWidth() > int(opt_group->label_width * m_em_unit) ? 2 : 1) + m_v_gap;
height = label_sz.y * (label_sz.GetWidth() > int(opt_group->title_width * m_em_unit) ? 2 : 1) + m_v_gap;
ctrl_lines.emplace_back(CtrlLine(height, this, line));
}
else
@ -135,8 +135,8 @@ wxPoint OG_CustomCtrl::get_pos(const Line& line, Field* field_in/* = nullptr*/)
}
wxString label = line.label;
if (opt_group->label_width != 0 && !label.IsEmpty())
h_pos += opt_group->label_width * m_em_unit + m_h_gap;
if (opt_group->title_width != 0 && !label.IsEmpty())
h_pos += opt_group->title_width * m_em_unit + m_h_gap;
int blinking_button_width = m_bmp_blinking_sz.GetWidth() + m_h_gap;
@ -155,29 +155,50 @@ wxPoint OG_CustomCtrl::get_pos(const Line& line, Field* field_in/* = nullptr*/)
option_set.front().opt.label.empty() &&
option_set.front().side_widget == nullptr && line.get_extra_widgets().size() == 0)
{
h_pos += 3 * blinking_button_width;
h_pos += 2 * blinking_button_width;
Field* field = opt_group->get_field(option_set.front().opt_id);
correct_line_height(ctrl_line.height, field->getWindow());
break;
}
for (auto opt : option_set) {
for (size_t i = 0; i < option_set.size(); ++i) {
if (i >= ctrl_line.is_visible.size() || !ctrl_line.is_visible[i])
continue;
const Option& opt = option_set[i];
Field* field = opt_group->get_field(opt.opt_id);
correct_line_height(ctrl_line.height, field->getWindow());
ConfigOptionDef option = opt.opt;
// add label if any
if (!option.label.empty()) {
std::string opt_label = (option.label.empty() || option.label.back() != '_') ? option.label : option.label.substr(0, option.label.size() - 1);
//! To correct translation by context have to use wxGETTEXT_IN_CONTEXT macro from wxWidget 3.1.1
label = (option.label == L_CONTEXT("Top", "Layers") || option.label == L_CONTEXT("Bottom", "Layers")) ?
_CTX(option.label, "Layers") : _(option.label);
label += ":";
label = (opt_label == L_CONTEXT("Top", "Layers") || opt_label == L_CONTEXT("Bottom", "Layers")) ?
_CTX(opt_label, "Layers") : _(opt_label);
bool no_dots = label.empty() || option.label.back() == '_';
if (!no_dots)
label += ":";
wxPaintDC dc(this);
dc.SetFont(m_font);
h_pos += dc.GetMultiLineTextExtent(label).x + m_h_gap;
if (!label.empty()) {
wxPaintDC dc(this);
dc.SetFont(m_font);
if (option.label_width >= 0) {
if (option.label_width != 0) {
h_pos += option.label_width * m_em_unit;
} else {
h_pos += dc.GetMultiLineTextExtent(label).x;
}
} else {
if (opt_group->label_width > 0) {
h_pos += opt_group->label_width * m_em_unit;
} else {
h_pos += dc.GetMultiLineTextExtent(label).x;
}
}
h_pos += m_h_gap;
}
}
h_pos += 3 * blinking_button_width;
h_pos += 2 * blinking_button_width;
if (field == field_in)
break;
@ -187,15 +208,15 @@ wxPoint OG_CustomCtrl::get_pos(const Line& line, Field* field_in/* = nullptr*/)
break;
// add sidetext if any
if (!option.sidetext.empty() || opt_group->sidetext_width > 0)
h_pos += opt_group->sidetext_width * m_em_unit + m_h_gap;
if ((!option.sidetext.empty() || opt_group->sidetext_width > 0 || option.sidetext_width > 0) && option.sidetext_width != 0)
h_pos += (option.sidetext_width > 0 ? option.sidetext_width : opt_group->sidetext_width)* m_em_unit + m_h_gap;
if (opt.opt_id != option_set.back().opt_id) //! istead of (opt != option_set.back())
h_pos += lround(0.6 * m_em_unit);
}
break;
}
if (ctrl_line.is_visible)
if (ctrl_line.is_line_visible)
v_pos += ctrl_line.height;
}
@ -220,7 +241,7 @@ void OG_CustomCtrl::OnPaint(wxPaintEvent&)
wxCoord v_pos = 0;
for (CtrlLine& line : ctrl_lines) {
if (!line.is_visible)
if (!line.is_line_visible)
continue;
line.render(dc, v_pos);
v_pos += line.height;
@ -315,7 +336,7 @@ bool OG_CustomCtrl::update_visibility(ConfigOptionMode mode)
size_t invisible_lines = 0;
for (CtrlLine& line : ctrl_lines) {
line.update_visibility(mode);
if (line.is_visible)
if (line.is_line_visible)
v_pos += (wxCoord)line.height;
else
invisible_lines++;
@ -338,14 +359,15 @@ void OG_CustomCtrl::correct_widgets_position(wxSizer* widget, const Line& line,
auto children = widget->GetChildren();
wxPoint line_pos = get_pos(line, field);
int line_height = get_height(line);
for (auto child : children)
if (child->IsWindow()) {
for (auto child : children) {
if (child->IsWindow() && child->IsShown()) {
wxPoint pos = line_pos;
wxSize sz = child->GetWindow()->GetSize();
pos.y += std::max(0, int(0.5 * (line_height - sz.y)));
child->GetWindow()->SetPosition(pos);
line_pos.x += sz.x + m_h_gap;
}
}
};
void OG_CustomCtrl::msw_rescale()
@ -361,7 +383,7 @@ void OG_CustomCtrl::msw_rescale()
wxCoord v_pos = 0;
for (CtrlLine& line : ctrl_lines) {
line.msw_rescale();
if (line.is_visible) {
if (line.is_line_visible) {
v_pos += (wxCoord)line.height;
}
}
@ -393,7 +415,7 @@ OG_CustomCtrl::CtrlLine::CtrlLine( wxCoord height,
void OG_CustomCtrl::CtrlLine::correct_items_positions()
{
if (draw_just_act_buttons || !is_visible)
if (draw_just_act_buttons || !is_line_visible)
return;
if (og_line.near_label_widget_win)
@ -421,9 +443,9 @@ void OG_CustomCtrl::CtrlLine::msw_rescale()
if (draw_just_act_buttons)
height = get_bitmap_size(create_scaled_bitmap("empty")).GetHeight();
if (ctrl->opt_group->label_width != 0 && !og_line.label.IsEmpty()) {
if (ctrl->opt_group->title_width != 0 && !og_line.label.IsEmpty()) {
wxSize label_sz = ctrl->GetTextExtent(og_line.label);
height = label_sz.y * (label_sz.GetWidth() > int(ctrl->opt_group->label_width * ctrl->m_em_unit) ? 2 : 1) + ctrl->m_v_gap;
height = label_sz.y * (label_sz.GetWidth() > int(ctrl->opt_group->title_width * ctrl->m_em_unit) ? 2 : 1) + ctrl->m_v_gap;
}
if (og_line.get_options().front().opt.full_width) {
@ -439,21 +461,26 @@ void OG_CustomCtrl::CtrlLine::update_visibility(ConfigOptionMode mode)
{
const std::vector<Option>& option_set = og_line.get_options();
const ConfigOptionMode& line_mode = option_set.front().opt.mode;
is_visible = line_mode <= mode;
ConfigOptionMode line_mode = option_set.front().opt.mode;
for (const Option& opt : option_set)
if (opt.opt.mode < line_mode)
line_mode = opt.opt.mode;
is_line_visible = line_mode <= mode;
if (draw_just_act_buttons)
return;
if (og_line.near_label_widget_win)
og_line.near_label_widget_win->Show(is_visible);
og_line.near_label_widget_win->Show(is_line_visible);
if (og_line.widget_sizer)
og_line.widget_sizer->ShowItems(is_visible);
og_line.widget_sizer->ShowItems(is_line_visible);
if (og_line.extra_widget_sizer)
og_line.extra_widget_sizer->ShowItems(is_visible);
og_line.extra_widget_sizer->ShowItems(is_line_visible);
for (auto opt : option_set) {
is_visible.clear();
for (const Option& opt : option_set) {
Field* field = ctrl->opt_group->get_field(opt.opt_id);
is_visible.push_back(opt.opt.mode <= mode);
if (!field)
continue;
@ -461,10 +488,11 @@ void OG_CustomCtrl::CtrlLine::update_visibility(ConfigOptionMode mode)
auto children = field->getSizer()->GetChildren();
for (auto child : children)
if (child->IsWindow())
child->GetWindow()->Show(is_visible);
child->GetWindow()->Show(is_visible.back());
field->getSizer()->Show(is_visible.back());
}
else if (field->getWindow())
field->getWindow()->Show(is_visible);
field->getWindow()->Show(is_visible.back());
}
correct_items_positions();
@ -487,12 +515,13 @@ void OG_CustomCtrl::CtrlLine::render(wxDC& dc, wxCoord v_pos)
const std::vector<Option>& option_set = og_line.get_options();
wxString label = og_line.label;
bool is_url_string = false;
if (ctrl->opt_group->label_width != 0 && !label.IsEmpty()) {
if (ctrl->opt_group->title_width != 0 && !og_line.label.IsEmpty()) {
const wxColour* text_clr = (option_set.size() == 1 && field ? field->label_color() : og_line.full_Label_color);
is_url_string = !og_line.label_path.IsEmpty();
h_pos = draw_text(dc, wxPoint(h_pos, v_pos), label + ":", text_clr, ctrl->opt_group->label_width * ctrl->m_em_unit, is_url_string);
wxString opt_label = (og_line.label.empty() || og_line.label.Last() != '_') ? og_line.label : og_line.label.substr(0, og_line.label.size() - 1);
bool no_dots = og_line.label.empty() || og_line.label.Last() == '_';
h_pos = draw_text(dc, wxPoint(h_pos, v_pos), (no_dots ? opt_label : opt_label + ':'), text_clr, ctrl->opt_group->title_width * ctrl->m_em_unit, is_url_string);
}
// If there's a widget, build it and set result to the correct position.
@ -515,21 +544,39 @@ void OG_CustomCtrl::CtrlLine::render(wxDC& dc, wxCoord v_pos)
}
size_t bmp_rect_id = 0;
for (const Option& opt : option_set) {
for (size_t i = 0; i < option_set.size(); ++i) {
if (i >= is_visible.size() || !is_visible[i])
continue;
const Option& opt = option_set[i];
field = ctrl->opt_group->get_field(opt.opt_id);
ConfigOptionDef option = opt.opt;
// add label if any
if (!option.label.empty()) {
std::string opt_label = (option.label.empty() || option.label.back() != '_') ? option.label : option.label.substr(0, option.label.size() - 1);
//! To correct translation by context have to use wxGETTEXT_IN_CONTEXT macro from wxWidget 3.1.1
label = (option.label == L_CONTEXT("Top", "Layers") || option.label == L_CONTEXT("Bottom", "Layers")) ?
_CTX(option.label, "Layers") : _(option.label);
label += ":";
wxString label = (opt_label == L_CONTEXT("Top", "Layers") || opt_label == L_CONTEXT("Bottom", "Layers")) ?
_CTX(opt_label, "Layers") : _(opt_label);
bool no_dots = label.empty() || option.label.back() == '_';
if (!no_dots)
label += ":";
if (!label.empty()) {
int width = ctrl->opt_group->sublabel_width * ctrl->m_em_unit;
if (option.label_width >= 0) {
if (option.label_width != 0) {
width = option.label_width * ctrl->m_em_unit;
}
} else {
if (ctrl->opt_group->label_width > 0) {
width = ctrl->opt_group->label_width * ctrl->m_em_unit;
}
}
if (is_url_string)
is_url_string = false;
else if(opt == option_set.front())
is_url_string = !og_line.label_path.IsEmpty();
h_pos = draw_text(dc, wxPoint(h_pos, v_pos), label, field ? field->label_color() : nullptr, ctrl->opt_group->sublabel_width * ctrl->m_em_unit, is_url_string);
if (is_url_string)
is_url_string = false;
else if (opt == option_set.front())
is_url_string = !og_line.label_path.IsEmpty();
h_pos = draw_text(dc, wxPoint(h_pos, v_pos), label, field ? field->label_color() : nullptr, width, is_url_string, true);
}
}
if (field && field->undo_to_sys_bitmap()) {
@ -550,8 +597,8 @@ void OG_CustomCtrl::CtrlLine::render(wxDC& dc, wxCoord v_pos)
break;
// add sidetext if any
if (!option.sidetext.empty() || ctrl->opt_group->sidetext_width > 0)
h_pos = draw_text(dc, wxPoint(h_pos, v_pos), _(option.sidetext), nullptr, ctrl->opt_group->sidetext_width * ctrl->m_em_unit);
if ( (!option.sidetext.empty() || ctrl->opt_group->sidetext_width > 0 || option.sidetext_width > 0 ) && option.sidetext_width != 0)
h_pos = draw_text(dc, wxPoint(h_pos, v_pos), _(option.sidetext), nullptr, (option.sidetext_width > 0 ? option.sidetext_width : ctrl->opt_group->sidetext_width ) * ctrl->m_em_unit);
if (opt.opt_id != option_set.back().opt_id) //! istead of (opt != option_set.back())
h_pos += lround(0.6 * ctrl->m_em_unit);
@ -571,7 +618,7 @@ wxCoord OG_CustomCtrl::CtrlLine::draw_mode_bmp(wxDC& dc, wxCoord v_pos)
return get_bitmap_size(bmp).GetWidth() + ctrl->m_h_gap;
}
wxCoord OG_CustomCtrl::CtrlLine::draw_text(wxDC& dc, wxPoint pos, const wxString& text, const wxColour* color, int width, bool is_url/* = false*/)
wxCoord OG_CustomCtrl::CtrlLine::draw_text(wxDC& dc, wxPoint pos, const wxString& text, const wxColour* color, int width, bool is_url/* = false*/, bool align_right/* = false*/)
{
wxString multiline_text;
if (width > 0 && dc.GetTextExtent(text).x > width) {
@ -604,8 +651,11 @@ wxCoord OG_CustomCtrl::CtrlLine::draw_text(wxDC& dc, wxPoint pos, const wxStr
dc.GetMultiLineTextExtent(out_text, &text_width, &text_height);
pos.y = pos.y + lround((height - text_height) / 2);
wxPoint draw_pos = pos;
if (align_right && width > 0)
draw_pos.x += width - text_width;
if (width > 0 && is_url)
rect_label = wxRect(pos, wxSize(text_width, text_height));
rect_label = wxRect(draw_pos, wxSize(text_width, text_height));
wxColour old_clr = dc.GetTextForeground();
wxFont old_font = dc.GetFont();
@ -617,7 +667,7 @@ wxCoord OG_CustomCtrl::CtrlLine::draw_text(wxDC& dc, wxPoint pos, const wxStr
dc.SetFont(old_font.Bold().Underlined());
#endif
dc.SetTextForeground(color ? *color : wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
dc.DrawText(out_text, pos);
dc.DrawText(out_text, draw_pos);
dc.SetTextForeground(old_clr);
dc.SetFont(old_font);
@ -634,9 +684,10 @@ wxPoint OG_CustomCtrl::CtrlLine::draw_blinking_bmp(wxDC& dc, wxPoint pos, bool i
wxCoord h_pos = pos.x;
wxCoord v_pos = pos.y + lround((height - get_bitmap_size(bmp_blinking).GetHeight()) / 2);
int bmp_dim = get_bitmap_size(bmp_blinking).GetWidth();
dc.DrawBitmap(bmp_blinking, h_pos, v_pos);
int bmp_dim = get_bitmap_size(bmp_blinking).GetWidth();
h_pos += bmp_dim + ctrl->m_h_gap;
return wxPoint(h_pos, v_pos);
@ -644,23 +695,28 @@ wxPoint OG_CustomCtrl::CtrlLine::draw_blinking_bmp(wxDC& dc, wxPoint pos, bool i
wxCoord OG_CustomCtrl::CtrlLine::draw_act_bmps(wxDC& dc, wxPoint pos, const wxBitmap& bmp_undo_to_sys, const wxBitmap& bmp_undo, bool is_blinking, size_t rect_id)
{
pos = draw_blinking_bmp(dc, pos, is_blinking, rect_id);
wxCoord h_pos = pos.x;
wxCoord v_pos = pos.y;
dc.DrawBitmap(bmp_undo_to_sys, h_pos, v_pos);
dc.DrawBitmap(bmp_undo_to_sys, h_pos, v_pos + 5);
int bmp_dim = get_bitmap_size(bmp_undo_to_sys).GetWidth();
rects_undo_to_sys_icon[rect_id] = wxRect(h_pos, v_pos, bmp_dim, bmp_dim);
h_pos += bmp_dim + ctrl->m_h_gap;
dc.DrawBitmap(bmp_undo, h_pos, v_pos);
dc.DrawBitmap(bmp_undo, h_pos, v_pos + 5);
bmp_dim = get_bitmap_size(bmp_undo).GetWidth();
rects_undo_icon[rect_id] = wxRect(h_pos, v_pos, bmp_dim, bmp_dim);
if(is_blinking)
draw_blinking_bmp(dc, wxPoint(h_pos, v_pos), is_blinking, rect_id);
h_pos += bmp_dim + ctrl->m_h_gap;
if (is_blinking)
draw_blinking_bmp(dc, wxPoint(h_pos, v_pos), is_blinking, rect_id);
return h_pos;
}

View File

@ -39,7 +39,8 @@ class OG_CustomCtrl :public wxPanel
const Line& og_line;
bool draw_just_act_buttons { false };
bool is_visible { true };
std::vector<bool> is_visible;
bool is_line_visible { true };
bool is_focused { false };
CtrlLine( wxCoord height,
@ -54,7 +55,7 @@ class OG_CustomCtrl :public wxPanel
void render(wxDC& dc, wxCoord v_pos);
wxCoord draw_mode_bmp(wxDC& dc, wxCoord v_pos);
wxCoord draw_text (wxDC& dc, wxPoint pos, const wxString& text, const wxColour* color, int width, bool is_url = false);
wxCoord draw_text (wxDC& dc, wxPoint pos, const wxString& text, const wxColour* color, int width, bool is_url = false, bool align_right = false);
wxPoint draw_blinking_bmp(wxDC& dc, wxPoint pos, bool is_blinking, size_t rect_id = 0);
wxCoord draw_act_bmps(wxDC& dc, wxPoint pos, const wxBitmap& bmp_undo_to_sys, const wxBitmap& bmp_undo, bool is_blinking, size_t rect_id = 0);
bool launch_browser() const;

View File

@ -88,7 +88,7 @@ const t_field& OptionsGroup::build_field(const t_config_option_key& id, const Co
this->on_set_focus(opt_id);
};
field->m_parent = parent();
field->m_back_to_initial_value = [this](std::string opt_id) {
if (!m_disabled)
this->back_to_initial_value(opt_id);
@ -146,7 +146,7 @@ void OptionsGroup::show_field(const t_config_option_key& opt_key, bool show/* =
}
else if (show_row(item, row_shift))
return;
}
}
row_shift += cols;
}
}
@ -166,11 +166,11 @@ void OptionsGroup::append_line(const Line& line)
m_options.emplace(opt.opt_id, opt);
// add mode value for current line to m_options_mode
m_options_mode.emplace_back();
m_line_sizer.emplace_back();
if (!option_set.empty()) {
m_options_mode.back()[option_set[0].opt.mode].push_back(-1);
}
if (!option_set.empty()){
m_line_sizer.emplace_back();
m_options_mode.emplace_back();
m_options_mode.back()[option_set[0].opt.mode].push_back(-1);
}
}
void OptionsGroup::activate_line(Line& line)
@ -233,38 +233,38 @@ void OptionsGroup::activate_line(Line& line)
if (custom_ctrl)
m_use_custom_ctrl_as_parent = true;
// if we have an extra column, build it
if (extra_column && !m_show_modified_btns)
{
m_extra_column_item_ptrs.push_back(extra_column(this->ctrl_parent(), line));
grid_sizer->Add(m_extra_column_item_ptrs.back(), 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 3);
}
// if we have an extra column, build it
if (extra_column && !m_show_modified_btns)
{
m_extra_column_item_ptrs.push_back(extra_column(this->ctrl_parent(), line));
grid_sizer->Add(m_extra_column_item_ptrs.back(), 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 3);
}
// Build a label if we have it
wxStaticText* label=nullptr;
wxStaticText* label=nullptr;
if (title_width != 0) {
if (custom_ctrl) {
if (line.near_label_widget)
line.near_label_widget_win = line.near_label_widget(this->ctrl_parent());
}
else {
if (! line.near_label_widget || ! line.label.IsEmpty()) {
// Only create the label if it is going to be displayed.
long label_style = staticbox ? 0 : wxALIGN_RIGHT;
if (!line.near_label_widget || !line.label.IsEmpty()) {
// Only create the label if it is going to be displayed.
long label_style = staticbox ? 0 : wxALIGN_RIGHT;
#ifdef __WXGTK__
// workaround for correct text align of the StaticBox on Linux
// flags wxALIGN_RIGHT and wxALIGN_CENTRE don't work when Ellipsize flags are _not_ given.
// Text is properly aligned only when Ellipsize is checked.
label_style |= staticbox ? 0 : wxST_ELLIPSIZE_END;
// workaround for correct text align of the StaticBox on Linux
// flags wxALIGN_RIGHT and wxALIGN_CENTRE don't work when Ellipsize flags are _not_ given.
// Text is properly aligned only when Ellipsize is checked.
label_style |= staticbox ? 0 : wxST_ELLIPSIZE_END;
#endif /* __WXGTK__ */
label = new wxStaticText(this->ctrl_parent(), wxID_ANY, line.label + (line.label.IsEmpty() ? "" : ": "),
wxDefaultPosition, wxSize(title_width * wxGetApp().em_unit(), -1), label_style);
label->SetBackgroundStyle(wxBG_STYLE_PAINT);
label->SetFont(wxGetApp().normal_font());
label->Wrap(title_width*wxGetApp().em_unit()); // avoid a Linux/GTK bug
}
if (!line.near_label_widget)
grid_sizer->Add(label, 0, (staticbox ? 0 : wxALIGN_RIGHT | wxRIGHT) | wxALIGN_CENTER_VERTICAL, line.label.IsEmpty() ? 0 : 5);
label = new wxStaticText(this->ctrl_parent(), wxID_ANY, line.label + (line.label.IsEmpty() ? "" : ": "),
wxDefaultPosition, wxSize(title_width * wxGetApp().em_unit(), -1), label_style);
label->SetBackgroundStyle(wxBG_STYLE_PAINT);
label->SetFont(wxGetApp().normal_font());
label->Wrap(title_width * wxGetApp().em_unit()); // avoid a Linux/GTK bug
}
if (!line.near_label_widget)
grid_sizer->Add(label, 0, (staticbox ? 0 : wxALIGN_RIGHT | wxRIGHT) | wxALIGN_CENTER_VERTICAL, line.label.IsEmpty() ? 0 : 5);
else if (!line.label.IsEmpty()) {
// If we're here, we have some widget near the label
// so we need a horizontal sizer to arrange these things
@ -272,9 +272,9 @@ void OptionsGroup::activate_line(Line& line)
grid_sizer->Add(sizer, 0, wxEXPAND | (staticbox ? wxALL : wxBOTTOM | wxTOP | wxLEFT), staticbox ? 0 : 1);
sizer->Add(label, 0, (staticbox ? 0 : wxALIGN_RIGHT | wxRIGHT) | wxALIGN_CENTER_VERTICAL, 5);
}
if (label != nullptr && line.label_tooltip != "")
label->SetToolTip(line.label_tooltip);
}
if (label != nullptr && line.label_tooltip != "")
label->SetToolTip(line.label_tooltip);
}
}
// If there's a widget, build it and add the result to the sizer.
@ -283,7 +283,7 @@ void OptionsGroup::activate_line(Line& line)
if (custom_ctrl)
line.widget_sizer = wgt;
else
grid_sizer->Add(wgt, 0, wxEXPAND | wxBOTTOM | wxTOP, (wxOSX || line.label.IsEmpty()) ? 0 : 5);
grid_sizer->Add(wgt, 0, wxEXPAND | wxBOTTOM | wxTOP, (wxOSX || line.label.IsEmpty()) ? 0 : 5);
return;
}
@ -291,7 +291,7 @@ void OptionsGroup::activate_line(Line& line)
// so we need a horizontal sizer to arrange these things
auto sizer = new wxBoxSizer(wxHORIZONTAL);
if (!custom_ctrl)
grid_sizer->Add(sizer, 0, wxEXPAND | (staticbox ? wxALL : wxBOTTOM | wxTOP | wxLEFT), staticbox ? 0 : 1);
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 &&
option_set.front().opt.label.empty() &&
@ -306,7 +306,7 @@ void OptionsGroup::activate_line(Line& line)
else {
if (is_window_field(field))
sizer->Add(field->getWindow(), option.opt.full_width ? 1 : 0,
wxBOTTOM | wxTOP | (option.opt.full_width ? wxEXPAND : wxALIGN_CENTER_VERTICAL), (wxOSX || !staticbox) ? 0 : 2);
wxBOTTOM | wxTOP | (option.opt.full_width ? wxEXPAND : wxALIGN_CENTER_VERTICAL), (wxOSX || !staticbox) ? 0 : 2);
if (is_sizer_field(field))
sizer->Add(field->getSizer(), 1, option.opt.full_width ? wxEXPAND : wxALIGN_CENTER_VERTICAL, 0);
}
@ -315,83 +315,86 @@ void OptionsGroup::activate_line(Line& line)
m_line_sizer.back() = sizer;
wxSizer* sizer_tmp = sizer;
for (auto opt : option_set) {
for (auto opt : option_set) {
ConfigOptionDef option = opt.opt;
// add label if any
if (!option.label.empty() && !custom_ctrl) {
//! To correct translation by context have to use wxGETTEXT_IN_CONTEXT macro from wxWidget 3.1.1
std::string opt_label = (option.label.at(option.label.size() - 1) != '_') ? option.label : option.label.substr(0, option.label.size() - 1);
std::string opt_label = (option.label.empty() || option.label.back() != '_') ? option.label : option.label.substr(0, option.label.size() - 1);
wxString str_label = (opt_label == L_CONTEXT("Top", "Layers") || opt_label == L_CONTEXT("Bottom", "Layers")) ?
_CTX(opt_label, "Layers") :
_(opt_label);
bool no_dots = str_label.empty() || option.label.back() == '_';
label = new wxStaticText(this->ctrl_parent(), wxID_ANY,
(str_label.empty() ? "" : (str_label + ":")), wxDefaultPosition, //wxDefaultSize);
(no_dots ? "" : (str_label + ":")), wxDefaultPosition, //wxDefaultSize);
(option.label_width >= 0) ? ((option.label_width != 0) ? wxSize(option.label_width*wxGetApp().em_unit(), -1) : wxDefaultSize) :
((label_width > 0) ? wxSize(label_width * wxGetApp().em_unit(), -1) : (wxDefaultSize))
, wxALIGN_RIGHT);
label->SetBackgroundStyle(wxBG_STYLE_PAINT);
label->SetFont(wxGetApp().normal_font());
label->SetBackgroundStyle(wxBG_STYLE_PAINT);
label->SetFont(wxGetApp().normal_font());
if (option.label_width > 0 || label_width >0) {
label->Wrap((option.label_width > 0 ? option.label_width : label_width)* wxGetApp().em_unit()); // avoid a Linux/GTK bug
}
m_options_mode.back()[opt.opt.mode].push_back(sizer_tmp->GetItemCount());
sizer_tmp->Add(label, 0, wxALIGN_CENTER_VERTICAL, 0);
}
// add field
const Option& opt_ref = opt;
auto& field = build_field(opt_ref);
if (!custom_ctrl) {
if (option_set.size() == 1 && option_set.front().opt.full_width)
{
const auto v_sizer = new wxBoxSizer(wxVERTICAL);
m_options_mode.back()[opt.opt.mode].push_back(sizer_tmp->GetItemCount());
sizer_tmp->Add(v_sizer, 1, wxEXPAND);
is_sizer_field(field) ?
v_sizer->Add(field->getSizer(), 0, wxEXPAND) :
v_sizer->Add(field->getWindow(), 0, wxEXPAND);
break;
sizer_tmp->Add(label, 0, wxALIGN_CENTER_VERTICAL, 0);
}
m_options_mode.back()[opt.opt.mode].push_back(sizer_tmp->GetItemCount());
is_sizer_field(field) ?
sizer_tmp->Add(field->getSizer(), 0, wxALIGN_CENTER_VERTICAL, 0) :
sizer_tmp->Add(field->getWindow(), 0, wxALIGN_CENTER_VERTICAL, 0);
// add field
const Option& opt_ref = opt;
auto& field = build_field(opt_ref);
if (!custom_ctrl) {
if (option_set.size() == 1 && option_set.front().opt.full_width)
{
const auto v_sizer = new wxBoxSizer(wxVERTICAL);
m_options_mode.back()[opt.opt.mode].push_back(sizer_tmp->GetItemCount());
sizer_tmp->Add(v_sizer, 1, wxEXPAND);
is_sizer_field(field) ?
v_sizer->Add(field->getSizer(), 0, wxEXPAND) :
v_sizer->Add(field->getWindow(), 0, wxEXPAND);
break;
}
// add sidetext if any
if (!option.sidetext.empty() || sidetext_width > 0) {
wxString textstring;
if(!option.sidetext.empty())
if (option.sidetext.at(option.sidetext.size() - 1) != '_') {
textstring = _(option.sidetext);
} else {
textstring = option.sidetext.substr(0, option.sidetext.size() - 1);
}
wxSize wxsize{ -1,-1 };
if (option.sidetext_width >= 0) {
if (option.sidetext_width != 0)
wxsize = wxSize{ option.sidetext_width * wxGetApp().em_unit(), -1 };
} else if (sidetext_width > 0)
wxsize = wxSize{ sidetext_width * wxGetApp().em_unit(),-1 };
wxStaticText *sidetext = new wxStaticText( this->ctrl_parent(), wxID_ANY, textstring,
wxDefaultPosition, wxsize
/*wxDefaultSize*/, wxALIGN_LEFT);
sidetext->SetBackgroundStyle(wxBG_STYLE_PAINT);
sidetext->SetFont(wxGetApp().normal_font());
m_options_mode.back()[opt.opt.mode].push_back(sizer_tmp->GetItemCount());
sizer_tmp->Add(sidetext, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, 4);
}
m_options_mode.back()[opt.opt.mode].push_back(sizer_tmp->GetItemCount());
is_sizer_field(field) ?
sizer_tmp->Add(field->getSizer(), 0, wxALIGN_CENTER_VERTICAL, 0) :
sizer_tmp->Add(field->getWindow(), 0, wxALIGN_CENTER_VERTICAL, 0);
// add side widget if any
if (opt.side_widget != nullptr) {
m_options_mode.back()[opt.opt.mode].push_back(sizer_tmp->GetItemCount());
sizer_tmp->Add(opt.side_widget(this->ctrl_parent())/*!.target<wxWindow>()*/, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, 1); //! requires verification
}
// add sidetext if any
if ((!option.sidetext.empty() || sidetext_width > 0) && option.sidetext_width != 0){
wxString textstring;
if(!option.sidetext.empty())
if (option.sidetext.at(option.sidetext.size() - 1) != '_') {
textstring = _(option.sidetext);
} else {
textstring = option.sidetext.substr(0, option.sidetext.size() - 1);
}
wxSize wxsize{ -1,-1 };
if (option.sidetext_width >= 0) {
if (option.sidetext_width != 0)
wxsize = wxSize{ option.sidetext_width * wxGetApp().em_unit(), -1 };
} else if (sidetext_width > 0)
wxsize = wxSize{ sidetext_width * wxGetApp().em_unit(),-1 };
wxStaticText *sidetext = new wxStaticText( this->ctrl_parent(), wxID_ANY, textstring,
wxDefaultPosition, wxsize
/*wxDefaultSize*/, wxALIGN_LEFT);
sidetext->SetBackgroundStyle(wxBG_STYLE_PAINT);
sidetext->SetFont(wxGetApp().normal_font());
m_options_mode.back()[opt.opt.mode].push_back(sizer_tmp->GetItemCount());
sizer_tmp->Add(sidetext, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, 4);
if (opt.opt_id != option_set.back().opt_id) //! istead of (opt != option_set.back())
m_options_mode.back()[opt.opt.mode].push_back(sizer_tmp->GetItemCount());
sizer_tmp->AddSpacer(6);
}
}
// add side widget if any
if (opt.side_widget != nullptr) {
m_options_mode.back()[opt.opt.mode].push_back(sizer_tmp->GetItemCount());
sizer_tmp->Add(opt.side_widget(this->ctrl_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())
m_options_mode.back()[opt.opt.mode].push_back(sizer_tmp->GetItemCount());
sizer_tmp->AddSpacer(6);
}
}
// add extra sizers if any
@ -563,9 +566,9 @@ void ConfigOptionsGroup::on_change_OG(const t_config_option_key& opt_id, const b
return;
}
auto itOption = it->second;
auto itOption = it->second;
const std::string &opt_key = itOption.first;
int opt_index = itOption.second;
int opt_index = itOption.second;
this->change_opt_value(opt_key, value, opt_index == -1 ? 0 : opt_index);
}
@ -600,7 +603,7 @@ void ConfigOptionsGroup::back_to_config_value(const DynamicPrintConfig& config,
value = int(milling_diameter->values.size());
}
else if (m_opt_map.find(opt_key) == m_opt_map.end() ||
// This option don't have corresponded field
// This option don't have corresponded field
opt_key == "bed_shape" || opt_key == "filament_ramming_parameters" ||
opt_key == "compatible_printers" || opt_key == "compatible_prints" ) {
value = get_config_value(config, opt_key);
@ -677,28 +680,28 @@ bool ConfigOptionsGroup::is_visible(ConfigOptionMode mode)
if (m_options_mode.empty())
return true;
int opt_mode_size = m_options_mode.size();
int opt_mode_size = m_options_mode.size();
if (opt_mode_size == 1 && m_options_mode[0].size() == 1 && m_options_mode[0].begin()->second.size() == 1)
return get_invisible_idx(m_options_mode[0], mode).empty();
return get_invisible_idx(m_options_mode[0], mode).empty();
size_t hidden_row_cnt = 0;
for (size_t i = 0; i < opt_mode_size; i++) {
if ((m_options_mode[i].size() == 1
&& m_options_mode[i].begin()->second.size() == 1
&& m_options_mode[i].begin()->second[0] == (size_t)-1
&& m_options_mode[i].begin()->first > mode)
|| get_visible_idx(m_options_mode[i], mode).empty()) {
hidden_row_cnt++;
}
}
for (size_t i = 0; i < opt_mode_size; i++) {
if ((m_options_mode[i].size() == 1
&& m_options_mode[i].begin()->second.size() == 1
&& m_options_mode[i].begin()->second[0] == (size_t)-1
&& m_options_mode[i].begin()->first > mode)
|| get_visible_idx(m_options_mode[i], mode).empty()) {
hidden_row_cnt++;
}
}
return hidden_row_cnt != opt_mode_size;
}
bool ConfigOptionsGroup::update_visibility(ConfigOptionMode mode)
{
if (m_options_mode.empty() || !m_grid_sizer)
return true;
if (m_options_mode.empty() || !m_grid_sizer)
return true;
if (custom_ctrl) {
bool show = custom_ctrl->update_visibility(mode);
@ -707,11 +710,11 @@ bool ConfigOptionsGroup::update_visibility(ConfigOptionMode mode)
}
int opt_mode_size = m_options_mode.size();
if (m_grid_sizer->GetEffectiveRowsCount() != opt_mode_size &&
if (m_grid_sizer->GetEffectiveRowsCount() != opt_mode_size &&
opt_mode_size == 1 && m_options_mode[0].size() == 1 && m_options_mode[0].begin()->second.size() == 1)
return get_invisible_idx(m_options_mode[0], mode).empty();
Show(true);
Show(true);
ConfigOptionMode best_mode = ConfigOptionMode::comExpert;
for (const auto& map : m_options_mode)
@ -772,8 +775,8 @@ void ConfigOptionsGroup::msw_rescale()
if (btn) {
btn->SetSize(btn->GetBestSize());
return;
}
}
}
};
// scale widgets and extra widgets if any exists
@ -971,7 +974,7 @@ boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config
}
else if (opt_key == "printhost_authorization_type") {
ret = static_cast<int>(config.option<ConfigOptionEnum<AuthorizationType>>(opt_key)->value);
}
}
}
break;
case coPoints:

View File

@ -109,8 +109,8 @@ public:
wxFont sidetext_font {wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT) };
wxFont label_font {wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT) };
int sidetext_width{ -1 };
int label_width{ -1 };
int sidetext_width{ -1 };
int label_width{ -1 };
int sublabel_width{ -1 };
/// Returns a copy of the pointer of the parent wxWindow.
@ -180,12 +180,7 @@ public:
void clear_fields_except_of(const std::vector<std::string> left_fields);
void hide_labels() {
title_width = 0;
// del from 2.3
//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; title_width = 0;}
OptionsGroup( wxWindow* _parent, const wxString& title, bool is_tab_opt = false,
column_t extra_clmn = nullptr);
@ -197,6 +192,8 @@ public:
protected:
std::map<t_config_option_key, Option> m_options;
wxWindow* m_parent {nullptr};
// vector: an entry per line
//map : mode -> items idx in the line
std::vector<std::map<ConfigOptionMode, std::vector<size_t>>> m_options_mode;
std::vector<wxSizer*> m_line_sizer;
std::vector<wxWindow*> m_extra_column_item_ptrs;

View File

@ -1930,6 +1930,8 @@ bool Tab::create_pages(std::string setting_type_name, int idx_page)
TabPrinter* tab = nullptr;
if ((tab = dynamic_cast<TabPrinter*>(this)) == nullptr) continue;
widget_t reset_to_filament_color = [this, idx_page, tab](wxWindow* parent) -> wxBoxSizer* {
tab->m_reset_to_filament_color = new ScalableButton(parent, wxID_ANY, "undo", _L("Reset to Filament Color"),
wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT, true);
ScalableButton* btn = tab->m_reset_to_filament_color;
btn->SetFont(Slic3r::GUI::wxGetApp().normal_font());
btn->SetSize(btn->GetBestSize());