mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-08-30 21:36:57 +00:00
NEW:support multiple extruder new control
jira:[device page] Change-Id: Idf68a3385172cbaa123cedb4e2b814c15cc09f07 (cherry picked from commit 7700b911a6fec782ce6b484b9b030963283a846c)
This commit is contained in:
@@ -9,6 +9,8 @@
|
||||
#include <wx/dcclient.h>
|
||||
#include <wx/dcgraph.h>
|
||||
|
||||
wxDEFINE_EVENT(wxCUSTOMEVT_SELECT_NOZZLE_POS, wxCommandEvent);
|
||||
|
||||
SwitchButton::SwitchButton(wxWindow* parent, wxWindowID id)
|
||||
: wxBitmapToggleButton(parent, id, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE | wxBU_EXACTFIT)
|
||||
, m_on(this, "toggle_on", 16)
|
||||
@@ -223,8 +225,12 @@ void SwitchBoard::render(wxDC &dc)
|
||||
|
||||
void SwitchBoard::doRender(wxDC &dc)
|
||||
{
|
||||
wxColour disable_color = wxColour(0xCECECE);
|
||||
|
||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||
dc.SetBrush(wxBrush(0xeeeeee));
|
||||
|
||||
if (is_enable) {dc.SetBrush(wxBrush(0xeeeeee));
|
||||
} else {dc.SetBrush(disable_color);}
|
||||
dc.DrawRoundedRectangle(0, 0, GetSize().x, GetSize().y, 8);
|
||||
|
||||
/*left*/
|
||||
@@ -245,7 +251,8 @@ void SwitchBoard::doRender(wxDC &dc)
|
||||
|
||||
/*right*/
|
||||
if (switch_right) {
|
||||
dc.SetBrush(wxBrush(wxColour(0, 174, 66)));
|
||||
if (is_enable) {dc.SetBrush(wxBrush(wxColour(0, 174, 66)));
|
||||
} else {dc.SetBrush(disable_color);}
|
||||
dc.DrawRoundedRectangle(GetSize().x / 2, 0, GetSize().x / 2, GetSize().y, 8);
|
||||
}
|
||||
|
||||
@@ -262,15 +269,25 @@ void SwitchBoard::doRender(wxDC &dc)
|
||||
|
||||
void SwitchBoard::on_left_down(wxMouseEvent &evt)
|
||||
{
|
||||
if (!is_enable) {
|
||||
return;
|
||||
}
|
||||
int index = -1;
|
||||
auto pos = ClientToScreen(evt.GetPosition());
|
||||
auto rect = ClientToScreen(wxPoint(0, 0));
|
||||
|
||||
if (pos.x > 0 && pos.x < rect.x + GetSize().x / 2) {
|
||||
switch_left = true;
|
||||
switch_right = false;
|
||||
index = 1;
|
||||
} else {
|
||||
switch_left = false;
|
||||
switch_right = true;
|
||||
index = 0;
|
||||
}
|
||||
Refresh();
|
||||
|
||||
wxCommandEvent event(wxCUSTOMEVT_SELECT_NOZZLE_POS);
|
||||
event.SetInt(index);
|
||||
wxPostEvent(this, event);
|
||||
}
|
||||
@@ -8,6 +8,8 @@
|
||||
#include "Label.hpp"
|
||||
#include "Button.hpp"
|
||||
|
||||
wxDECLARE_EVENT(wxCUSTOMEVT_SELECT_NOZZLE_POS, wxCommandEvent);
|
||||
|
||||
class SwitchButton : public wxBitmapToggleButton
|
||||
{
|
||||
public:
|
||||
@@ -53,12 +55,16 @@ public:
|
||||
|
||||
bool switch_left{false};
|
||||
bool switch_right{false};
|
||||
bool is_enable {true};
|
||||
|
||||
public:
|
||||
void paintEvent(wxPaintEvent &evt);
|
||||
void render(wxDC &dc);
|
||||
void doRender(wxDC &dc);
|
||||
void on_left_down(wxMouseEvent &evt);
|
||||
void Enable(){is_enable = true;Refresh();};
|
||||
void Disable(){is_enable = false;Refresh();};
|
||||
bool IsEnabled(){return is_enable;};
|
||||
};
|
||||
|
||||
#endif // !slic3r_GUI_SwitchButton_hpp_
|
||||
|
||||
@@ -58,7 +58,7 @@ void TempInput::Create(wxWindow *parent, wxString text, wxString label, wxString
|
||||
if (m_read_only) return;
|
||||
// enter input mode
|
||||
auto temp = text_ctrl->GetValue();
|
||||
if (temp.length() > 0 && temp[0] == (0x5f)) {
|
||||
if (temp.length() > 0 && temp[0] == (0x5f)) {
|
||||
text_ctrl->SetValue(wxEmptyString);
|
||||
}
|
||||
if (wdialog != nullptr) { wdialog->Dismiss(); }
|
||||
@@ -111,7 +111,7 @@ void TempInput::Create(wxWindow *parent, wxString text, wxString label, wxString
|
||||
});
|
||||
text_ctrl->Bind(wxEVT_RIGHT_DOWN, [this](auto &e) {}); // disable context menu
|
||||
text_ctrl->Bind(wxEVT_LEFT_DOWN, [this](auto &e) {
|
||||
if (m_read_only) {
|
||||
if (m_read_only) {
|
||||
return;
|
||||
} else {
|
||||
e.Skip();
|
||||
@@ -145,6 +145,7 @@ void TempInput::SetFinish()
|
||||
{
|
||||
wxCommandEvent event(wxCUSTOMEVT_SET_TEMP_FINISH);
|
||||
event.SetInt(temp_type);
|
||||
event.SetString(wxString::Format("%d", m_input_type));
|
||||
wxPostEvent(this->GetParent(), event);
|
||||
}
|
||||
|
||||
@@ -165,26 +166,38 @@ wxString TempInput::erasePending(wxString &str)
|
||||
|
||||
void TempInput::SetTagTemp(int temp)
|
||||
{
|
||||
text_ctrl->SetValue(wxString::Format("%d", temp));
|
||||
messureSize();
|
||||
Refresh();
|
||||
auto tp = wxString::Format("%d", temp);
|
||||
if (text_ctrl->GetValue() != tp) {
|
||||
text_ctrl->SetValue(tp);
|
||||
messureSize();
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
void TempInput::SetTagTemp(wxString temp)
|
||||
{
|
||||
text_ctrl->SetValue(temp);
|
||||
messureSize();
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void TempInput::SetCurrTemp(int temp)
|
||||
{
|
||||
SetLabel(wxString::Format("%d", temp));
|
||||
}
|
||||
|
||||
void TempInput::SetCurrTemp(wxString temp)
|
||||
void TempInput::SetTagTemp(wxString temp)
|
||||
{
|
||||
SetLabel(temp);
|
||||
if (text_ctrl->GetValue() != temp) {
|
||||
text_ctrl->SetValue(temp);
|
||||
messureSize();
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
void TempInput::SetCurrTemp(int temp)
|
||||
{
|
||||
auto tp = wxString::Format("%d", temp);
|
||||
if (GetLabel() != tp) {
|
||||
SetLabel(tp);
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
void TempInput::SetCurrTemp(wxString temp)
|
||||
{
|
||||
if (GetLabel() != temp) {
|
||||
SetLabel(temp);
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
void TempInput::SetCurrType(TempInputType type) {
|
||||
@@ -212,10 +225,10 @@ void TempInput::Warning(bool warn, WarningType type)
|
||||
wxBoxSizer *sizer_text;
|
||||
sizer_text = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
|
||||
|
||||
warning_text = new wxStaticText(body, wxID_ANY,
|
||||
wxEmptyString,
|
||||
|
||||
warning_text = new wxStaticText(body, wxID_ANY,
|
||||
wxEmptyString,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxALIGN_CENTER_HORIZONTAL);
|
||||
warning_text->SetFont(::Label::Body_12);
|
||||
@@ -445,19 +458,19 @@ void TempInput::render(wxDC &dc)
|
||||
auto text = wxWindow::GetLabel();
|
||||
dc.SetFont(::Label::Head_14);
|
||||
labelSize = dc.GetMultiLineTextExtent(wxWindow::GetLabel());
|
||||
|
||||
|
||||
if (!IsEnabled()) {
|
||||
dc.SetTextForeground(wxColour(0xAC, 0xAC, 0xAC));
|
||||
dc.SetTextBackground(background_color.colorForStates((int) StateColor::Disabled));
|
||||
}
|
||||
}
|
||||
else {
|
||||
dc.SetTextForeground(wxColour(0x32, 0x3A, 0x3D));
|
||||
dc.SetTextBackground(background_color.colorForStates((int) states));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*if (!text.IsEmpty()) {
|
||||
|
||||
|
||||
}*/
|
||||
wxSize textSize = text_ctrl->GetSize();
|
||||
if (align_right) {
|
||||
|
||||
@@ -71,12 +71,12 @@ public:
|
||||
const wxSize & size = wxDefaultSize,
|
||||
long style = 0);
|
||||
|
||||
|
||||
|
||||
wxPopupTransientWindow *wdialog{nullptr};
|
||||
int temp_type;
|
||||
bool actice = false;
|
||||
|
||||
|
||||
|
||||
wxString erasePending(wxString &str);
|
||||
|
||||
void SetTagTemp(int temp);
|
||||
@@ -85,7 +85,8 @@ public:
|
||||
void SetCurrTemp(int temp);
|
||||
void SetCurrTemp(wxString temp);
|
||||
void SetCurrType(TempInputType type);
|
||||
|
||||
TempInputType GetCurrType(){return m_input_type;};
|
||||
|
||||
bool AllisNum(std::string str);
|
||||
void SetFinish();
|
||||
void Warning(bool warn, WarningType type = WARNING_UNKNOWN);
|
||||
|
||||
Reference in New Issue
Block a user