mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-19 11:23:42 +00:00
@@ -8,6 +8,8 @@
|
|||||||
#include "GLCanvas3D.hpp"
|
#include "GLCanvas3D.hpp"
|
||||||
#include "Plater.hpp"
|
#include "Plater.hpp"
|
||||||
|
|
||||||
|
#include "Widgets/LabeledStaticBox.hpp"
|
||||||
|
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
|
|
||||||
#include "I18N.hpp"
|
#include "I18N.hpp"
|
||||||
@@ -29,7 +31,9 @@ ObjectLayers::ObjectLayers(wxWindow* parent) :
|
|||||||
|
|
||||||
m_og->activate();
|
m_og->activate();
|
||||||
m_og->sizer->Clear(true);
|
m_og->sizer->Clear(true);
|
||||||
m_og->sizer->Add(m_grid_sizer, 0, wxEXPAND | wxLEFT | wxRIGHT, wxOSX ? 0 : 5);
|
m_og->sizer->Add(m_grid_sizer, 0, wxEXPAND | wxLEFT | wxRIGHT, 5);
|
||||||
|
if (auto stb = dynamic_cast<LabeledStaticBox*>(m_og->stb))
|
||||||
|
stb->SetCornerRadius(0);
|
||||||
|
|
||||||
m_bmp_delete = ScalableBitmap(parent, "delete");
|
m_bmp_delete = ScalableBitmap(parent, "delete");
|
||||||
m_bmp_add = ScalableBitmap(parent, "add");
|
m_bmp_add = ScalableBitmap(parent, "add");
|
||||||
@@ -74,7 +78,7 @@ wxSizer* ObjectLayers::create_layer(const t_layer_height_range& range, PlusMinus
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Add text
|
// Add text
|
||||||
auto head_text = new wxStaticText(m_parent, wxID_ANY, _L("Height Range"), wxDefaultPosition, wxDefaultSize, wxST_ELLIPSIZE_END);
|
auto head_text = new wxStaticText(m_og->ctrl_parent(), wxID_ANY, _L("Height Range"), wxDefaultPosition, wxDefaultSize, wxST_ELLIPSIZE_END);
|
||||||
head_text->SetBackgroundStyle(wxBG_STYLE_PAINT);
|
head_text->SetBackgroundStyle(wxBG_STYLE_PAINT);
|
||||||
head_text->SetFont(wxGetApp().normal_font());
|
head_text->SetFont(wxGetApp().normal_font());
|
||||||
m_grid_sizer->Add(head_text, 0, wxALIGN_CENTER_VERTICAL);
|
m_grid_sizer->Add(head_text, 0, wxALIGN_CENTER_VERTICAL);
|
||||||
@@ -105,7 +109,7 @@ wxSizer* ObjectLayers::create_layer(const t_layer_height_range& range, PlusMinus
|
|||||||
|
|
||||||
m_grid_sizer->Add(editor, 1, wxEXPAND);
|
m_grid_sizer->Add(editor, 1, wxEXPAND);
|
||||||
|
|
||||||
auto middle_text = new wxStaticText(m_parent, wxID_ANY, _L("to"), wxDefaultPosition, wxDefaultSize, wxST_ELLIPSIZE_END);
|
auto middle_text = new wxStaticText(m_og->ctrl_parent(), wxID_ANY, _L("to"), wxDefaultPosition, wxDefaultSize, wxST_ELLIPSIZE_END);
|
||||||
middle_text->SetBackgroundStyle(wxBG_STYLE_PAINT);
|
middle_text->SetBackgroundStyle(wxBG_STYLE_PAINT);
|
||||||
middle_text->SetFont(wxGetApp().normal_font());
|
middle_text->SetFont(wxGetApp().normal_font());
|
||||||
m_grid_sizer->Add(middle_text, 0, wxALIGN_CENTER_VERTICAL);
|
m_grid_sizer->Add(middle_text, 0, wxALIGN_CENTER_VERTICAL);
|
||||||
@@ -135,12 +139,12 @@ wxSizer* ObjectLayers::create_layer(const t_layer_height_range& range, PlusMinus
|
|||||||
m_grid_sizer->Add(editor, 1, wxEXPAND);
|
m_grid_sizer->Add(editor, 1, wxEXPAND);
|
||||||
|
|
||||||
auto sizer2 = new wxBoxSizer(wxHORIZONTAL);
|
auto sizer2 = new wxBoxSizer(wxHORIZONTAL);
|
||||||
auto unit_text = new wxStaticText(m_parent, wxID_ANY, "mm", wxDefaultPosition, wxDefaultSize, wxST_ELLIPSIZE_END);
|
auto unit_text = new wxStaticText(m_og->ctrl_parent(), wxID_ANY, "mm", wxDefaultPosition, wxDefaultSize, wxST_ELLIPSIZE_END);
|
||||||
unit_text->SetBackgroundStyle(wxBG_STYLE_PAINT);
|
unit_text->SetBackgroundStyle(wxBG_STYLE_PAINT);
|
||||||
unit_text->SetFont(wxGetApp().normal_font());
|
unit_text->SetFont(wxGetApp().normal_font());
|
||||||
sizer2->Add(unit_text, 0, wxALIGN_CENTER_VERTICAL);
|
sizer2->Add(unit_text, 0, wxALIGN_CENTER_VERTICAL);
|
||||||
|
|
||||||
m_grid_sizer->Add(sizer2);
|
m_grid_sizer->Add(sizer2, 0, wxALIGN_CENTER_VERTICAL);
|
||||||
|
|
||||||
// BBS
|
// BBS
|
||||||
// Add control for the "Layer height"
|
// Add control for the "Layer height"
|
||||||
@@ -170,12 +174,12 @@ void ObjectLayers::create_layers_list()
|
|||||||
{
|
{
|
||||||
for (const auto &layer : m_object->layer_config_ranges) {
|
for (const auto &layer : m_object->layer_config_ranges) {
|
||||||
const t_layer_height_range& range = layer.first;
|
const t_layer_height_range& range = layer.first;
|
||||||
auto del_btn = new PlusMinusButton(m_parent, m_bmp_delete, range);
|
auto del_btn = new PlusMinusButton(m_og->ctrl_parent(), m_bmp_delete, range);
|
||||||
del_btn->DisableFocusFromKeyboard();
|
del_btn->DisableFocusFromKeyboard();
|
||||||
del_btn->SetBackgroundColour(m_parent->GetBackgroundColour());
|
del_btn->SetBackgroundColour(m_parent->GetBackgroundColour());
|
||||||
del_btn->SetToolTip(_L("Remove height range"));
|
del_btn->SetToolTip(_L("Remove height range"));
|
||||||
|
|
||||||
auto add_btn = new PlusMinusButton(m_parent, m_bmp_add, range);
|
auto add_btn = new PlusMinusButton(m_og->ctrl_parent(), m_bmp_add, range);
|
||||||
add_btn->DisableFocusFromKeyboard();
|
add_btn->DisableFocusFromKeyboard();
|
||||||
add_btn->SetBackgroundColour(m_parent->GetBackgroundColour());
|
add_btn->SetBackgroundColour(m_parent->GetBackgroundColour());
|
||||||
wxString tooltip = wxGetApp().obj_list()->can_add_new_range_after_current(range);
|
wxString tooltip = wxGetApp().obj_list()->can_add_new_range_after_current(range);
|
||||||
@@ -183,8 +187,10 @@ void ObjectLayers::create_layers_list()
|
|||||||
add_btn->Enable(tooltip.IsEmpty());
|
add_btn->Enable(tooltip.IsEmpty());
|
||||||
|
|
||||||
auto sizer = create_layer(range, del_btn, add_btn);
|
auto sizer = create_layer(range, del_btn, add_btn);
|
||||||
sizer->Add(del_btn, 0, wxRIGHT | wxLEFT, em_unit(m_parent));
|
auto b_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
sizer->Add(add_btn);
|
b_sizer->Add(del_btn, 0, wxRIGHT | wxLEFT, em_unit(m_parent));
|
||||||
|
b_sizer->Add(add_btn);
|
||||||
|
sizer->Add(b_sizer, 0, wxALIGN_CENTER_HORIZONTAL | wxTOP, m_parent->FromDIP(1)); // aligns +/- buttons vertically since we got 1px gap on bottom of icons
|
||||||
|
|
||||||
del_btn->Bind(wxEVT_BUTTON, [del_btn](wxEvent &) {
|
del_btn->Bind(wxEVT_BUTTON, [del_btn](wxEvent &) {
|
||||||
wxGetApp().obj_list()->del_layer_range(del_btn->range);
|
wxGetApp().obj_list()->del_layer_range(del_btn->range);
|
||||||
@@ -218,6 +224,8 @@ void ObjectLayers::update_layers_list()
|
|||||||
// only call sizer->Clear(true) via CallAfter, otherwise crash happens in Linux when press enter in Height Range
|
// only call sizer->Clear(true) via CallAfter, otherwise crash happens in Linux when press enter in Height Range
|
||||||
// because an element cannot be destroyed while there are pending events for this element.(https://github.com/wxWidgets/Phoenix/issues/1854)
|
// because an element cannot be destroyed while there are pending events for this element.(https://github.com/wxWidgets/Phoenix/issues/1854)
|
||||||
wxGetApp().CallAfter([this, type, objects_ctrl, range]() {
|
wxGetApp().CallAfter([this, type, objects_ctrl, range]() {
|
||||||
|
m_og->ctrl_parent()->Freeze();
|
||||||
|
|
||||||
// Delete all controls from options group
|
// Delete all controls from options group
|
||||||
m_grid_sizer->Clear(true);
|
m_grid_sizer->Clear(true);
|
||||||
|
|
||||||
@@ -228,8 +236,10 @@ void ObjectLayers::update_layers_list()
|
|||||||
else
|
else
|
||||||
create_layer(range, nullptr, nullptr);
|
create_layer(range, nullptr, nullptr);
|
||||||
|
|
||||||
|
m_og->ctrl_parent()->Thaw();
|
||||||
|
|
||||||
m_parent->Layout();
|
m_parent->Layout();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectLayers::update_scene_from_editor_selection() const
|
void ObjectLayers::update_scene_from_editor_selection() const
|
||||||
@@ -340,7 +350,7 @@ LayerRangeEditor::LayerRangeEditor( ObjectLayers* parent,
|
|||||||
m_valid_value(value),
|
m_valid_value(value),
|
||||||
m_type(type),
|
m_type(type),
|
||||||
m_set_focus_data(set_focus_data_fn),
|
m_set_focus_data(set_focus_data_fn),
|
||||||
wxTextCtrl(parent->m_parent, wxID_ANY, value, wxDefaultPosition,
|
wxTextCtrl(parent->m_og->ctrl_parent(), wxID_ANY, value, wxDefaultPosition,
|
||||||
wxSize(em_unit(parent->m_parent), wxDefaultCoord), wxTE_PROCESS_ENTER
|
wxSize(em_unit(parent->m_parent), wxDefaultCoord), wxTE_PROCESS_ENTER
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
| wxBORDER_SIMPLE
|
| wxBORDER_SIMPLE
|
||||||
|
|||||||
@@ -4,12 +4,6 @@
|
|||||||
#include "../GUI_Utils.hpp"
|
#include "../GUI_Utils.hpp"
|
||||||
#include "Label.hpp"
|
#include "Label.hpp"
|
||||||
|
|
||||||
/*
|
|
||||||
Fix label overflowing to inner frame
|
|
||||||
Fix use elypsis if text too long
|
|
||||||
setmin size
|
|
||||||
*/
|
|
||||||
|
|
||||||
LabeledStaticBox::LabeledStaticBox()
|
LabeledStaticBox::LabeledStaticBox()
|
||||||
: state_handler(this)
|
: state_handler(this)
|
||||||
{
|
{
|
||||||
@@ -28,7 +22,6 @@ LabeledStaticBox::LabeledStaticBox()
|
|||||||
std::make_pair(0xDBDBDB, (int) StateColor::Normal),
|
std::make_pair(0xDBDBDB, (int) StateColor::Normal),
|
||||||
std::make_pair(0xDBDBDB, (int) StateColor::Disabled)
|
std::make_pair(0xDBDBDB, (int) StateColor::Disabled)
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LabeledStaticBox::LabeledStaticBox(
|
LabeledStaticBox::LabeledStaticBox(
|
||||||
@@ -63,11 +56,10 @@ bool LabeledStaticBox::Create(
|
|||||||
m_pos = this->GetPosition();
|
m_pos = this->GetPosition();
|
||||||
|
|
||||||
int tW,tH,descent,externalLeading;
|
int tW,tH,descent,externalLeading;
|
||||||
GetTextExtent("Yy", &tW, &tH, &descent, &externalLeading, &m_font);
|
// empty label sets m_label_height as 0 that causes extra spacing at top
|
||||||
|
GetTextExtent(m_label.IsEmpty() ? "Orca" : m_label, &tW, &tH, &descent, &externalLeading, &m_font);
|
||||||
m_label_height = tH - externalLeading;
|
m_label_height = tH - externalLeading;
|
||||||
|
m_label_width = tW;
|
||||||
GetTextExtent(m_label, &tW, &tH, &descent, &externalLeading, &m_font);
|
|
||||||
m_label_width = tW;
|
|
||||||
|
|
||||||
Bind(wxEVT_PAINT,([this](wxPaintEvent e) {
|
Bind(wxEVT_PAINT,([this](wxPaintEvent e) {
|
||||||
wxPaintDC dc(this);
|
wxPaintDC dc(this);
|
||||||
@@ -179,3 +171,10 @@ void LabeledStaticBox::DrawBorderAndLabel(wxDC& dc)
|
|||||||
dc.DrawText(m_label, wxPoint(10 * m_scale, 0));
|
dc.DrawText(m_label, wxPoint(10 * m_scale, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LabeledStaticBox::GetBordersForSizer(int* borderTop, int* borderOther) const {
|
||||||
|
wxStaticBox::GetBordersForSizer(borderTop, borderOther);
|
||||||
|
#ifdef __WXOSX__
|
||||||
|
*borderOther = 5; // Make sure macOS uses the same border padding as other platforms
|
||||||
|
#endif
|
||||||
|
}
|
||||||
@@ -63,6 +63,9 @@ protected:
|
|||||||
int m_label_width;
|
int m_label_width;
|
||||||
float m_scale;
|
float m_scale;
|
||||||
wxPoint m_pos;
|
wxPoint m_pos;
|
||||||
|
|
||||||
|
void GetBordersForSizer(int *borderTop, int *borderOther) const override;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // !slic3r_GUI_LabeledStaticBox_hpp_
|
#endif // !slic3r_GUI_LabeledStaticBox_hpp_
|
||||||
Reference in New Issue
Block a user