mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-17 19:57:55 -06:00
ENH: [STUDIO-2647] Optimize the interface for selecting part types
Change-Id: Ia277a37ce102708c1c8d535bf323fd58bbd0d230
This commit is contained in:
parent
33ae019a95
commit
238080e0ab
4 changed files with 103 additions and 1 deletions
|
@ -386,6 +386,8 @@ set(SLIC3R_GUI_SOURCES
|
|||
GUI/AmsMappingPopup.cpp
|
||||
GUI/ReleaseNote.hpp
|
||||
GUI/ReleaseNote.cpp
|
||||
GUI/SingleChoiceDialog.hpp
|
||||
GUI/SingleChoiceDialog.cpp
|
||||
GUI/Calibration.hpp
|
||||
GUI/Calibration.cpp
|
||||
GUI/PrintOptionsDialog.hpp
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "NotificationManager.hpp"
|
||||
#include "MsgDialog.hpp"
|
||||
#include "Widgets/ProgressDialog.hpp"
|
||||
#include "SingleChoiceDialog.hpp"
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <wx/progdlg.h>
|
||||
|
@ -4940,7 +4941,8 @@ void ObjectList::change_part_type()
|
|||
}
|
||||
|
||||
const wxString names[] = { _L("Part"), _L("Negative Part"), _L("Modifier"), _L("Support Blocker"), _L("Support Enforcer") };
|
||||
auto new_type = ModelVolumeType(wxGetApp().GetSingleChoiceIndex(_L("Type:"), _L("Choose part type"), wxArrayString(5, names), int(type)));
|
||||
SingleChoiceDialog dlg(_L("Type:"), _L("Choose part type"), wxArrayString(5, names), int(type));
|
||||
auto new_type = ModelVolumeType(dlg.GetSingleChoiceIndex());
|
||||
|
||||
if (new_type == type || new_type == ModelVolumeType::INVALID)
|
||||
return;
|
||||
|
|
69
src/slic3r/GUI/SingleChoiceDialog.cpp
Normal file
69
src/slic3r/GUI/SingleChoiceDialog.cpp
Normal file
|
@ -0,0 +1,69 @@
|
|||
#include "SingleChoiceDialog.hpp"
|
||||
|
||||
#include "GUI_App.hpp"
|
||||
#include "MainFrame.hpp"
|
||||
|
||||
namespace Slic3r { namespace GUI {
|
||||
|
||||
SingleChoiceDialog::SingleChoiceDialog(const wxString &message, const wxString &caption, const wxArrayString &choices, int initialSelection, wxWindow *parent)
|
||||
: DPIDialog(parent ? parent : static_cast<wxWindow *>(wxGetApp().mainframe), wxID_ANY, caption, wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX)
|
||||
{
|
||||
SetBackgroundColour(*wxWHITE);
|
||||
|
||||
const int dlg_width = 200;
|
||||
wxBoxSizer *bSizer = new wxBoxSizer(wxVERTICAL);
|
||||
bSizer->SetMinSize(wxSize(FromDIP(dlg_width), -1));
|
||||
|
||||
wxStaticText *message_text = new wxStaticText(this, wxID_ANY, message, wxDefaultPosition, wxDefaultSize, 0);
|
||||
message_text->Wrap(-1);
|
||||
bSizer->Add(message_text, 0, wxALL, 5);
|
||||
|
||||
type_comboBox = new ComboBox(this, wxID_ANY, choices[0], wxDefaultPosition, wxSize(FromDIP(dlg_width - 10), -1), 0, NULL, wxCB_READONLY);
|
||||
for (const wxString &type_name : choices) { type_comboBox->Append(type_name); }
|
||||
bSizer->Add(type_comboBox, 0, wxALL | wxALIGN_CENTER, 5);
|
||||
bSizer->Add(0, 0, 1, wxEXPAND, FromDIP(type_comboBox->GetClientSize().GetHeight()));
|
||||
type_comboBox->SetSelection(initialSelection);
|
||||
|
||||
wxBoxSizer *bSizer_button = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
StateColor btn_bg_green(std::pair<wxColour, int>(wxColour(27, 136, 68), StateColor::Pressed), std::pair<wxColour, int>(wxColour(61, 203, 115), StateColor::Hovered),
|
||||
std::pair<wxColour, int>(AMS_CONTROL_BRAND_COLOUR, StateColor::Normal));
|
||||
|
||||
m_button_ok = new Button(this, _L("OK"));
|
||||
m_button_ok->SetBackgroundColor(btn_bg_green);
|
||||
m_button_ok->SetBorderColor(*wxWHITE);
|
||||
m_button_ok->SetTextColor(wxColour(0xFFFFFE));
|
||||
m_button_ok->SetFont(Label::Body_12);
|
||||
m_button_ok->SetSize(wxSize(FromDIP(58), FromDIP(24)));
|
||||
m_button_ok->SetMinSize(wxSize(FromDIP(58), FromDIP(24)));
|
||||
m_button_ok->SetCornerRadius(FromDIP(12));
|
||||
bSizer_button->Add(m_button_ok, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, FromDIP(int(dlg_width - 58 * 2) / 6));
|
||||
|
||||
m_button_ok->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &e) { EndModal(wxID_OK); });
|
||||
|
||||
StateColor btn_bg_white(std::pair<wxColour, int>(wxColour(206, 206, 206), StateColor::Pressed), std::pair<wxColour, int>(wxColour(238, 238, 238), StateColor::Hovered),
|
||||
std::pair<wxColour, int>(*wxWHITE, StateColor::Normal));
|
||||
|
||||
m_button_cancel = new Button(this, _L("Cancel"));
|
||||
m_button_cancel->SetBackgroundColor(btn_bg_white);
|
||||
m_button_cancel->SetBorderColor(wxColour(38, 46, 48));
|
||||
m_button_cancel->SetFont(Label::Body_12);
|
||||
m_button_cancel->SetSize(wxSize(FromDIP(58), FromDIP(24)));
|
||||
m_button_cancel->SetMinSize(wxSize(FromDIP(58), FromDIP(24)));
|
||||
m_button_cancel->SetCornerRadius(FromDIP(12));
|
||||
bSizer_button->Add(m_button_cancel, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, FromDIP(int(dlg_width - 58 * 2) / 6));
|
||||
|
||||
m_button_cancel->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &e) { EndModal(wxID_CANCEL); });
|
||||
|
||||
bSizer->Add(bSizer_button, 1, wxALIGN_CENTER_HORIZONTAL | wxBOTTOM, FromDIP(5));
|
||||
|
||||
this->SetSizer(bSizer);
|
||||
this->Layout();
|
||||
bSizer->Fit(this);
|
||||
wxGetApp().UpdateDlgDarkUI(this);
|
||||
}
|
||||
SingleChoiceDialog::~SingleChoiceDialog() {}
|
||||
int SingleChoiceDialog::GetSingleChoiceIndex() { return this->ShowModal() == wxID_OK ? GetTypeComboBox()->GetSelection() : -1; }
|
||||
|
||||
void SingleChoiceDialog::on_dpi_changed(const wxRect &suggested_rect) {}
|
||||
}} // namespace Slic3r::GUI
|
29
src/slic3r/GUI/SingleChoiceDialog.hpp
Normal file
29
src/slic3r/GUI/SingleChoiceDialog.hpp
Normal file
|
@ -0,0 +1,29 @@
|
|||
#ifndef slic3r_GUI_SingleChoice_hpp_
|
||||
#define slic3r_GUI_SingleChoice_hpp_
|
||||
|
||||
#include "GUI_Utils.hpp"
|
||||
#include "Widgets/Button.hpp"
|
||||
#include "Widgets/ComboBox.hpp"
|
||||
|
||||
namespace Slic3r { namespace GUI {
|
||||
|
||||
class SingleChoiceDialog : public DPIDialog
|
||||
{
|
||||
public:
|
||||
SingleChoiceDialog(const wxString &message, const wxString &caption, const wxArrayString &choices, int initialSelectionwx, wxWindow *parent = nullptr);
|
||||
~SingleChoiceDialog();
|
||||
|
||||
int GetSingleChoiceIndex();
|
||||
ComboBox *GetTypeComboBox() { return type_comboBox; };
|
||||
|
||||
void on_dpi_changed(const wxRect &suggested_rect) override;
|
||||
|
||||
protected:
|
||||
ComboBox *type_comboBox = nullptr;
|
||||
Button * m_button_ok = nullptr;
|
||||
Button * m_button_cancel = nullptr;
|
||||
};
|
||||
|
||||
}} // namespace Slic3r::GUI
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue