ENH: vertical layout button
Change-Id: I0b205298688c9df88dcfe6eb6e72cc887a9ed5be Jira: none (cherry picked from commit 56ed912c3ee12fb0ee39f1dad191c4d379aa3015)
This commit is contained in:
@@ -368,7 +368,7 @@ struct Sidebar::priv
|
||||
StaticBox* m_panel_printer_title = nullptr;
|
||||
ScalableButton* m_printer_icon = nullptr;
|
||||
ScalableButton* m_printer_setting = nullptr;
|
||||
ScalableButton *m_extruder_sync = nullptr;
|
||||
Button *m_extruder_sync = nullptr;
|
||||
wxStaticText * m_text_printer_settings = nullptr;
|
||||
wxPanel* m_panel_printer_content = nullptr;
|
||||
|
||||
@@ -839,13 +839,6 @@ Sidebar::Sidebar(Plater *parent)
|
||||
// wxGetApp().get_tab(Preset::TYPE_FILAMENT)->restore_last_select_item();
|
||||
wxGetApp().run_wizard(ConfigWizard::RR_USER, ConfigWizard::SP_PRINTERS);
|
||||
});
|
||||
auto extruder_btn = new ScalableButton(p->m_panel_printer_title, wxID_ANY, "ams_fila_sync", wxEmptyString, wxDefaultSize, wxDefaultPosition,
|
||||
wxBU_EXACTFIT | wxNO_BORDER, false, 18);
|
||||
extruder_btn->SetToolTip(_L("Synchronize nozzle information and the number of AMS"));
|
||||
extruder_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent &e) {
|
||||
p->sync_extruder_list();
|
||||
});
|
||||
p->m_extruder_sync = extruder_btn;
|
||||
|
||||
wxBoxSizer* h_sizer_title = new wxBoxSizer(wxHORIZONTAL);
|
||||
h_sizer_title->Add(p->m_printer_icon, 0, wxALIGN_CENTRE | wxLEFT, FromDIP(SidebarProps::TitlebarMargin()));
|
||||
@@ -1016,6 +1009,22 @@ Sidebar::Sidebar(Plater *parent)
|
||||
p->m_dual_extruder_sizer->Add(FromDIP(2), 0);
|
||||
auto right_extruder = add_extruder(1, _L("Right Extruder"));
|
||||
p->m_right_ams_count = right_extruder;
|
||||
p->m_dual_extruder_sizer->Add(FromDIP(2), 0);
|
||||
|
||||
auto extruder_btn = new Button(p->m_panel_printer_content, _L("Sync AMS Nozzle information"), "ams_nozzle_sync");
|
||||
extruder_btn->SetFont(Label::Body_8);
|
||||
extruder_btn->SetToolTip(_L("Synchronize nozzle information and the number of AMS"));
|
||||
extruder_btn->SetCornerRadius(0);
|
||||
extruder_btn->SetBorderColor(0xE4E4E4);
|
||||
extruder_btn->SetPaddingSize({FromDIP(6), FromDIP(12)});
|
||||
extruder_btn->SetMinSize({FromDIP(48), FromDIP(68)});
|
||||
extruder_btn->SetMinSize({FromDIP(48), FromDIP(68)});
|
||||
extruder_btn->SetMaxSize({FromDIP(48), FromDIP(82)});
|
||||
extruder_btn->SetVertical();
|
||||
extruder_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent &e) { p->sync_extruder_list(); });
|
||||
p->m_extruder_sync = extruder_btn;
|
||||
p->m_dual_extruder_sizer->Add(FromDIP(2), 0);
|
||||
p->m_dual_extruder_sizer->Add(extruder_btn, 0, wxEXPAND);
|
||||
p->m_dual_extruder_sizer->Add(FromDIP(10), 0);
|
||||
|
||||
vsizer_printer->Add(p->m_dual_extruder_sizer, 0, wxEXPAND | wxTOP, FromDIP(5));
|
||||
@@ -1632,6 +1641,12 @@ void Sidebar::msw_rescale()
|
||||
//BBS
|
||||
p->m_bed_type_list->Rescale();
|
||||
p->m_bed_type_list->SetMinSize({-1, 3 * wxGetApp().em_unit()});
|
||||
|
||||
p->m_extruder_sync->SetPaddingSize({FromDIP(6), FromDIP(12)});
|
||||
p->m_extruder_sync->SetMinSize({FromDIP(48), FromDIP(68)});
|
||||
p->m_extruder_sync->SetMinSize({FromDIP(48), FromDIP(68)});
|
||||
p->m_extruder_sync->SetMaxSize({FromDIP(48), FromDIP(82)});
|
||||
p->m_extruder_sync->Rescale();
|
||||
#if 0
|
||||
if (p->mode_sizer)
|
||||
p->mode_sizer->msw_rescale();
|
||||
|
||||
@@ -3552,10 +3552,6 @@ void TabFilament::build()
|
||||
|
||||
|
||||
optgroup = page->new_optgroup(L("Print temperature"), L"param_extruder_temp");
|
||||
line = { L("Nozzle"), L("Nozzle temperature when printing") };
|
||||
line.append_option(optgroup->get_option("nozzle_temperature_initial_layer"));
|
||||
line.append_option(optgroup->get_option("nozzle_temperature"));
|
||||
optgroup->append_line(line);
|
||||
|
||||
optgroup = page->new_optgroup(L("Bed temperature"), L"param_bed_temp");
|
||||
line = { L("Cool Plate (SuperTack)"),
|
||||
@@ -3624,6 +3620,13 @@ void TabFilament::build()
|
||||
on_value_change(opt_key, value);
|
||||
};
|
||||
|
||||
optgroup = page->new_optgroup(L("Nozzle temperature"), L"param_temperature");
|
||||
|
||||
line = { L("Nozzle"), L("Nozzle temperature when printing") };
|
||||
line.append_option(optgroup->get_option("nozzle_temperature_initial_layer"));
|
||||
line.append_option(optgroup->get_option("nozzle_temperature"));
|
||||
optgroup->append_line(line);
|
||||
|
||||
//BBS
|
||||
optgroup = page->new_optgroup(L("Volumetric speed limitation"), L"param_volumetric_speed");
|
||||
optgroup->append_single_option_line("filament_max_volumetric_speed");
|
||||
|
||||
@@ -29,10 +29,10 @@ Button::Button()
|
||||
std::make_pair(0xF0F0F1, (int) StateColor::Disabled),
|
||||
std::make_pair(0x52c7b8, (int) StateColor::Hovered | StateColor::Checked),
|
||||
std::make_pair(0x009688, (int) StateColor::Checked),
|
||||
std::make_pair(*wxLIGHT_GREY, (int) StateColor::Hovered),
|
||||
std::make_pair(*wxLIGHT_GREY, (int) StateColor::Hovered),
|
||||
std::make_pair(*wxWHITE, (int) StateColor::Normal));
|
||||
text_color = StateColor(
|
||||
std::make_pair(*wxLIGHT_GREY, (int) StateColor::Disabled),
|
||||
std::make_pair(*wxLIGHT_GREY, (int) StateColor::Disabled),
|
||||
std::make_pair(*wxBLACK, (int) StateColor::Normal));
|
||||
}
|
||||
|
||||
@@ -148,7 +148,12 @@ bool Button::GetValue() const { return state_handler.states() & StateHandler::Ch
|
||||
|
||||
void Button::SetCenter(bool isCenter)
|
||||
{
|
||||
this->isCenter = isCenter;
|
||||
this->isCenter = isCenter; }
|
||||
|
||||
void Button::SetVertical(bool vertical)
|
||||
{
|
||||
this->vertical = vertical;
|
||||
messureSize();
|
||||
}
|
||||
|
||||
// Background Foreground Border on focus
|
||||
@@ -258,26 +263,45 @@ void Button::render(wxDC& dc)
|
||||
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
||||
// calc content size
|
||||
wxSize szIcon;
|
||||
wxSize szContent = textSize.GetSize();
|
||||
wxSize textSize = this->textSize.GetSize();
|
||||
|
||||
ScalableBitmap icon;
|
||||
if (m_selected || ((states & (int)StateColor::State::Hovered) != 0))
|
||||
icon = active_icon;
|
||||
else
|
||||
icon = inactive_icon;
|
||||
int padding = 5;
|
||||
wxSize padding = this->paddingSize;
|
||||
int spacing = 5;
|
||||
// Wrap text
|
||||
auto text = GetLabel();
|
||||
if (vertical && textSize.x + padding.x * 2 > size.x) {
|
||||
Label::split_lines(dc, size.x - padding.x * 2, text, text, 2);
|
||||
textSize = dc.GetMultiLineTextExtent(text);
|
||||
if (padding.x * 2 + textSize.x > size.x) {
|
||||
text = wxControl::Ellipsize(text, dc, wxELLIPSIZE_END, size.x - padding.x * 2);
|
||||
textSize = dc.GetMultiLineTextExtent(text);
|
||||
}
|
||||
}
|
||||
auto szContent = textSize;
|
||||
if (icon.bmp().IsOk()) {
|
||||
if (szContent.y > 0) {
|
||||
//BBS norrow size between text and icon
|
||||
szContent.x += padding;
|
||||
if (vertical)
|
||||
szContent.y += spacing;
|
||||
else
|
||||
szContent.x += spacing;
|
||||
}
|
||||
szIcon = icon.GetBmpSize();
|
||||
szContent.x += szIcon.x;
|
||||
if (szIcon.y > szContent.y)
|
||||
szContent.y = szIcon.y;
|
||||
if (vertical) {
|
||||
szContent.y += szIcon.y;
|
||||
if (szIcon.x > szContent.x) szContent.x = szIcon.x;
|
||||
} else {
|
||||
szContent.x += szIcon.x;
|
||||
if (szIcon.y > szContent.y) szContent.y = szIcon.y;
|
||||
}
|
||||
if (szContent.x > size.x) {
|
||||
int d = std::min(padding, szContent.x - size.x);
|
||||
padding -= d;
|
||||
int d = std::min(padding.x, (szContent.x - size.x) / 2);
|
||||
padding.x -= d;
|
||||
szContent.x -= d;
|
||||
}
|
||||
}
|
||||
@@ -291,17 +315,28 @@ void Button::render(wxDC& dc)
|
||||
// start draw
|
||||
wxPoint pt = rcContent.GetLeftTop();
|
||||
if (icon.bmp().IsOk()) {
|
||||
pt.y += (rcContent.height - szIcon.y) / 2;
|
||||
if (vertical)
|
||||
pt.x += (rcContent.width - szIcon.x) / 2;
|
||||
else
|
||||
pt.y += (rcContent.height - szIcon.y) / 2;
|
||||
dc.DrawBitmap(icon.bmp(), pt);
|
||||
//BBS norrow size between text and icon
|
||||
pt.x += szIcon.x + padding;
|
||||
pt.y = rcContent.y;
|
||||
if (vertical) {
|
||||
pt.y += szIcon.y + spacing;
|
||||
pt.x = rcContent.x;
|
||||
} else {
|
||||
pt.x += szIcon.x + spacing;
|
||||
pt.y = rcContent.y;
|
||||
}
|
||||
}
|
||||
auto text = GetLabel();
|
||||
if (!text.IsEmpty()) {
|
||||
if (pt.x + textSize.width > size.x)
|
||||
text = wxControl::Ellipsize(text, dc, wxELLIPSIZE_END, size.x - pt.x);
|
||||
pt.y += (rcContent.height - textSize.height) / 2;
|
||||
if (vertical) {
|
||||
pt.x += (rcContent.width - textSize.x) / 2;
|
||||
} else {
|
||||
if (pt.x + textSize.x > size.x)
|
||||
text = wxControl::Ellipsize(text, dc, wxELLIPSIZE_END, size.x - pt.x);
|
||||
pt.y += (rcContent.height - textSize.y) / 2;
|
||||
}
|
||||
dc.SetTextForeground(text_color.colorForStates(states));
|
||||
#if 0
|
||||
dc.SetBrush(*wxLIGHT_GREY);
|
||||
@@ -323,17 +358,27 @@ void Button::messureSize()
|
||||
if (this->active_icon.bmp().IsOk()) {
|
||||
if (szContent.y > 0) {
|
||||
//BBS norrow size between text and icon
|
||||
szContent.x += 5;
|
||||
if (vertical)
|
||||
szContent.y += 5;
|
||||
else
|
||||
szContent.x += 5;
|
||||
}
|
||||
wxSize szIcon = this->active_icon.GetBmpSize();
|
||||
szContent.x += szIcon.x;
|
||||
if (szIcon.y > szContent.y)
|
||||
szContent.y = szIcon.y;
|
||||
if (vertical) {
|
||||
szContent.y += szIcon.y;
|
||||
if (szIcon.x > szContent.x) szContent.x = szIcon.x;
|
||||
} else {
|
||||
szContent.x += szIcon.x;
|
||||
if (szIcon.y > szContent.y) szContent.y = szIcon.y;
|
||||
}
|
||||
}
|
||||
wxSize size = szContent + paddingSize * 2;
|
||||
if (minSize.GetHeight() > 0)
|
||||
size.SetHeight(minSize.GetHeight());
|
||||
|
||||
if (auto w = GetMaxWidth(); w > 0 && size.GetWidth() > w)
|
||||
size.SetWidth(GetMaxWidth());
|
||||
|
||||
if (minSize.GetWidth() > size.GetWidth())
|
||||
wxWindow::SetMinSize(minSize);
|
||||
else
|
||||
@@ -377,7 +422,7 @@ void Button::keyDownUp(wxKeyEvent &event)
|
||||
return;
|
||||
}
|
||||
if (event.GetEventType() == wxEVT_KEY_DOWN &&
|
||||
(event.GetKeyCode() == WXK_TAB || event.GetKeyCode() == WXK_LEFT || event.GetKeyCode() == WXK_RIGHT
|
||||
(event.GetKeyCode() == WXK_TAB || event.GetKeyCode() == WXK_LEFT || event.GetKeyCode() == WXK_RIGHT
|
||||
|| event.GetKeyCode() == WXK_UP || event.GetKeyCode() == WXK_DOWN))
|
||||
HandleAsNavigationKey(event);
|
||||
else
|
||||
|
||||
@@ -39,7 +39,8 @@ class Button : public StaticBox
|
||||
bool pressedDown = false;
|
||||
bool m_selected = true;
|
||||
bool canFocus = true;
|
||||
bool isCenter = true;
|
||||
bool isCenter = true;
|
||||
bool vertical = false;
|
||||
|
||||
static const int buttonWidth = 200;
|
||||
static const int buttonHeight = 50;
|
||||
@@ -60,7 +61,7 @@ public:
|
||||
void SetInactiveIcon(const wxString& icon);
|
||||
|
||||
void SetMinSize(const wxSize& size) override;
|
||||
|
||||
|
||||
void SetPaddingSize(const wxSize& size);
|
||||
|
||||
void SetStyle(const ButtonStyle style /*= ButtonStyle::Regular*/, const ButtonType type /*= ButtonType::None*/);
|
||||
@@ -81,6 +82,8 @@ public:
|
||||
|
||||
void SetCenter(bool isCenter);
|
||||
|
||||
void SetVertical(bool vertical = true);
|
||||
|
||||
void Rescale();
|
||||
|
||||
protected:
|
||||
|
||||
@@ -117,11 +117,12 @@ public:
|
||||
Wrap(dc, text, widthMax);
|
||||
}
|
||||
|
||||
void Wrap(wxDC const & dc, const wxString &text, int widthMax)
|
||||
void Wrap(wxDC const &dc, const wxString &text, int widthMax, int maxCount = 0)
|
||||
{
|
||||
const wxArrayString ls = wxSplit(text, '\n', '\0');
|
||||
for (wxArrayString::const_iterator i = ls.begin(); i != ls.end(); ++i) {
|
||||
wxString line = *i;
|
||||
int count = 0;
|
||||
|
||||
if (i != ls.begin()) {
|
||||
// Do this even if the line is empty, except if it's the first one.
|
||||
@@ -181,6 +182,12 @@ public:
|
||||
// And redo the layout with the rest.
|
||||
if (line[lastSpace] == ' ') ++lastSpace;
|
||||
line = line.substr(lastSpace);
|
||||
|
||||
if (maxCount > 0 && ++count == maxCount - 1) {
|
||||
OnNewLine();
|
||||
DoOutputLine(line);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -246,10 +253,10 @@ private:
|
||||
};
|
||||
|
||||
|
||||
wxSize Label::split_lines(wxDC &dc, int width, const wxString &text, wxString &multiline_text)
|
||||
wxSize Label::split_lines(wxDC &dc, int width, const wxString &text, wxString &multiline_text, int max_count)
|
||||
{
|
||||
wxLabelWrapper2 wrap;
|
||||
wrap.Wrap(dc, text, width);
|
||||
wrap.Wrap(dc, text, width, max_count);
|
||||
multiline_text = wrap.GetText();
|
||||
return dc.GetMultiLineTextExtent(multiline_text);
|
||||
}
|
||||
|
||||
@@ -53,12 +53,12 @@ public:
|
||||
static wxFont Body_11;
|
||||
static wxFont Body_9;
|
||||
static wxFont Body_8;
|
||||
|
||||
|
||||
static void initSysFont();
|
||||
|
||||
static wxFont sysFont(int size, bool bold = false);
|
||||
|
||||
static wxSize split_lines(wxDC &dc, int width, const wxString &text, wxString &multiline_text);
|
||||
static wxSize split_lines(wxDC &dc, int width, const wxString &text, wxString &multiline_text, int max_count = 0);
|
||||
};
|
||||
|
||||
#endif // !slic3r_GUI_Label_hpp_
|
||||
|
||||
Reference in New Issue
Block a user