mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-16 01:52:11 +00:00
### FIXES • 3mf file version check dialog opens bambu releases page instead Orca ### CODE COMPARISON <img width="112" height="36" alt="Screenshot-20251128125737" src="https://github.com/user-attachments/assets/73718a18-8159-43d5-bb80-0eb90d59a8f6" /> **wxHyperlinkCtrl** • System decides what colors to use. so blue color is visible even with colors set • No need to use SetCursor() ``` auto wiki_url = "https://github.com/OrcaSlicer/OrcaSlicer/wiki/Built-in-placeholders-variables"; wxHyperlinkCtrl* wiki = new wxHyperlinkCtrl(this, wxID_ANY, _L("Wiki Guide"), wiki_url); wiki->SetToolTip(wiki_url); // required to showing navigation point to user wiki->SetFont(Label::Body_14); // not works properly wiki->SetVisitedColour(wxColour("#009687")); // not works properly wiki->SetHoverColour( wxColour("#26A69A")); // not works properly wiki->SetNormalColour( wxColour("#009687")); // not works properly ``` <img width="132" height="39" alt="Screenshot-20251128125847" src="https://github.com/user-attachments/assets/f6818dc0-5078-498a-bf09-1fd36e81ebe5" /> **wxStaticText** • Works reliably on colors and fonts • All event has to defined manually ``` wxStaticText* wiki = new wxStaticText(this, wxID_ANY, _L("Wiki Guide")); auto wiki_url = "https://github.com/OrcaSlicer/OrcaSlicer/wiki/Built-in-placeholders-variables"; wiki->SetToolTip(wiki_url); // required to showing navigation point to user wiki->SetForegroundColour(wxColour("#009687")); wiki->SetCursor(wxCURSOR_HAND); wxFont font = Label::Body_14; font.SetUnderlined(true); wiki->SetFont(font); wiki->Bind(wxEVT_LEFT_DOWN ,[this, wiki_url](wxMouseEvent e) {wxLaunchDefaultBrowser(wiki_url);}); wiki->Bind(wxEVT_ENTER_WINDOW,[this, wiki ](wxMouseEvent e) {SetForegroundColour(wxColour("#26A69A"));}); wiki->Bind(wxEVT_LEAVE_WINDOW,[this, wiki ](wxMouseEvent e) {SetForegroundColour(wxColour("#009687"));}); ``` <img width="132" height="39" alt="Screenshot-20251128125847" src="https://github.com/user-attachments/assets/f6818dc0-5078-498a-bf09-1fd36e81ebe5" /> **HyperLink** • Fully automated and single line solution • Colors can be controllable from one place • Works reliably on colors and fonts • Reduces duplicate code ``` HyperLink* wiki = new HyperLink(this, _L("Wiki Guide"), "https://github.com/OrcaSlicer/OrcaSlicer/wiki/Built-in-placeholders-variables"); wiki->SetFont(Label::Body_14) // OPTIONAL default is Label::Body_14; ``` ### CHANGES • Unifies all hyperlinks with same style and makes them controllable from one place • Replaces all wxHyperlink with simple custom class. Problem with wxHyperlink it mostly rendered as blue even color set • Reduces duplicate code • Adds wiki links for calibration dialogs • Probably will add "Wiki Guide" to more dialogs overtime <img width="349" height="238" alt="Screenshot-20251127212007" src="https://github.com/user-attachments/assets/69da2732-ea35-44de-8ebc-97a01f86328f" /> <img width="355" height="459" alt="Screenshot-20251127212021" src="https://github.com/user-attachments/assets/c0df40f8-c15d-47fa-b31a-cf8d8b337472" /> <img width="442" height="382" alt="Screenshot-20251127212046" src="https://github.com/user-attachments/assets/5d94242b-6364-4b0a-8b2f-a1f482199bd1" /> <img width="225" height="241" alt="Screenshot-20250824171339" src="https://github.com/user-attachments/assets/39ca6af3-6f8a-42ee-bf1d-c13d0f54bb63" /> <img width="442" height="639" alt="Screenshot-20251127212403" src="https://github.com/user-attachments/assets/c1c580f8-3e1b-42f0-aa8e-bac41c2ff76b" /> <img width="476" height="286" alt="Screenshot-20251127212515" src="https://github.com/user-attachments/assets/28b130ce-c7c0-4ada-9842-ff7154c00c21" /> <img width="1460" height="245" alt="Screenshot-20251127212541" src="https://github.com/user-attachments/assets/3fca2649-9cd3-4aea-9153-b2f508fdfefe" /> <img width="401" height="291" alt="Screenshot-20251127213243" src="https://github.com/user-attachments/assets/82b4ec1f-6074-4018-9efa-a1b6b819ae28" />
234 lines
7.3 KiB
C++
234 lines
7.3 KiB
C++
#ifndef slic3r_GUI_SelectMachinePop_hpp_
|
|
#define slic3r_GUI_SelectMachinePop_hpp_
|
|
|
|
#include <wx/wx.h>
|
|
#include <wx/intl.h>
|
|
#include <wx/collpane.h>
|
|
#include <wx/dataview.h>
|
|
#include <wx/artprov.h>
|
|
#include <wx/xrc/xmlres.h>
|
|
#include <wx/dataview.h>
|
|
#include <wx/gdicmn.h>
|
|
#include <wx/font.h>
|
|
#include <wx/colour.h>
|
|
#include <wx/settings.h>
|
|
#include <wx/string.h>
|
|
#include <wx/sizer.h>
|
|
#include <wx/stattext.h>
|
|
#include <wx/hyperlink.h>
|
|
#include <wx/button.h>
|
|
#include <wx/dialog.h>
|
|
#include <wx/popupwin.h>
|
|
#include <wx/spinctrl.h>
|
|
#include <wx/artprov.h>
|
|
#include <wx/wrapsizer.h>
|
|
#include <wx/srchctrl.h>
|
|
|
|
#include "ReleaseNote.hpp"
|
|
#include "GUI_Utils.hpp"
|
|
#include "wxExtensions.hpp"
|
|
#include "DeviceManager.hpp"
|
|
#include "Plater.hpp"
|
|
#include "BBLStatusBar.hpp"
|
|
#include "BBLStatusBarSend.hpp"
|
|
#include "Widgets/Label.hpp"
|
|
#include "Widgets/Button.hpp"
|
|
#include "Widgets/CheckBox.hpp"
|
|
#include "Widgets/ComboBox.hpp"
|
|
#include "Widgets/ScrolledWindow.hpp"
|
|
#include "Widgets/PopupWindow.hpp"
|
|
#include <wx/simplebook.h>
|
|
#include <wx/hashmap.h>
|
|
|
|
namespace Slic3r { namespace GUI {
|
|
|
|
enum PrinterState {
|
|
OFFLINE,
|
|
IDLE,
|
|
BUSY,
|
|
LOCK,
|
|
IN_LAN
|
|
};
|
|
|
|
enum PrinterBindState {
|
|
NONE,
|
|
ALLOW_BIND,
|
|
ALLOW_UNBIND
|
|
};
|
|
|
|
wxDECLARE_EVENT(EVT_FINISHED_UPDATE_MACHINE_LIST, wxCommandEvent);
|
|
wxDECLARE_EVENT(EVT_WILL_DISMISS_MACHINE_LIST, wxCommandEvent);
|
|
wxDECLARE_EVENT(EVT_UPDATE_WINDOWS_POSITION, wxCommandEvent);
|
|
wxDECLARE_EVENT(EVT_DISSMISS_MACHINE_LIST, wxCommandEvent);
|
|
wxDECLARE_EVENT(EVT_CONNECT_LAN_PRINT, wxCommandEvent);
|
|
wxDECLARE_EVENT(EVT_EDIT_PRINT_NAME, wxCommandEvent);
|
|
wxDECLARE_EVENT(EVT_UNBIND_MACHINE, wxCommandEvent);
|
|
wxDECLARE_EVENT(EVT_BIND_MACHINE, wxCommandEvent);
|
|
|
|
#define SELECT_MACHINE_POPUP_SIZE wxSize(FromDIP(216), FromDIP(364))
|
|
#define SELECT_MACHINE_LIST_SIZE wxSize(FromDIP(212), FromDIP(360))
|
|
#define SELECT_MACHINE_ITEM_SIZE wxSize(FromDIP(190), FromDIP(35))
|
|
#define SELECT_MACHINE_GREY900 wxColour(38, 46, 48)
|
|
#define SELECT_MACHINE_GREY600 wxColour(144, 144, 144)
|
|
#define SELECT_MACHINE_GREY400 wxColour(206, 206, 206)
|
|
#define SELECT_MACHINE_BRAND wxColour(0, 150, 136)
|
|
#define SELECT_MACHINE_REMIND wxColour(255, 111, 0)
|
|
#define SELECT_MACHINE_LIGHT_GREEN wxColour(219, 253, 231)
|
|
|
|
class MachineObjectPanel : public wxPanel
|
|
{
|
|
private:
|
|
bool m_is_my_devices {false};
|
|
bool m_show_edit{false};
|
|
bool m_show_bind{false};
|
|
bool m_hover {false};
|
|
bool m_is_macos_special_version{false};
|
|
|
|
|
|
PrinterBindState m_bind_state;
|
|
PrinterState m_state;
|
|
|
|
ScalableBitmap m_unbind_img;
|
|
ScalableBitmap m_edit_name_img;
|
|
ScalableBitmap m_select_unbind_img;
|
|
|
|
ScalableBitmap m_printer_status_offline;
|
|
ScalableBitmap m_printer_status_busy;
|
|
ScalableBitmap m_printer_status_idle;
|
|
ScalableBitmap m_printer_status_lock;
|
|
ScalableBitmap m_printer_in_lan;
|
|
|
|
MachineObject *m_info;
|
|
|
|
protected:
|
|
wxStaticBitmap *m_bitmap_info;
|
|
wxStaticBitmap *m_bitmap_bind;
|
|
|
|
public:
|
|
MachineObjectPanel(wxWindow * parent,
|
|
wxWindowID id = wxID_ANY,
|
|
const wxPoint & pos = wxDefaultPosition,
|
|
const wxSize & size = wxDefaultSize,
|
|
long style = wxTAB_TRAVERSAL,
|
|
const wxString &name = wxEmptyString);
|
|
|
|
~MachineObjectPanel();
|
|
|
|
void show_bind_dialog();
|
|
void set_printer_state(PrinterState state);
|
|
void show_printer_bind(bool show, PrinterBindState state);
|
|
void show_edit_printer_name(bool show);
|
|
void update_machine_info(MachineObject *info, bool is_my_devices = false);
|
|
protected:
|
|
void OnPaint(wxPaintEvent &event);
|
|
void render(wxDC &dc);
|
|
void doRender(wxDC &dc);
|
|
void on_mouse_enter(wxMouseEvent &evt);
|
|
void on_mouse_leave(wxMouseEvent &evt);
|
|
void on_mouse_left_up(wxMouseEvent &evt);
|
|
};
|
|
|
|
class MachinePanel
|
|
{
|
|
public:
|
|
wxString mIndex;
|
|
MachineObjectPanel *mPanel;
|
|
};
|
|
|
|
class PinCodePanel : public wxPanel
|
|
{
|
|
public:
|
|
PinCodePanel(wxWindow* parent,
|
|
int type,
|
|
wxWindowID winid = wxID_ANY,
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
const wxSize& size = wxDefaultSize);
|
|
~PinCodePanel() {};
|
|
|
|
ScalableBitmap m_bitmap;
|
|
bool m_hover{false};
|
|
int m_type{0};
|
|
|
|
void OnPaint(wxPaintEvent& event);
|
|
void render(wxDC& dc);
|
|
void doRender(wxDC& dc);
|
|
|
|
void on_mouse_enter(wxMouseEvent& evt);
|
|
void on_mouse_leave(wxMouseEvent& evt);
|
|
void on_mouse_left_up(wxMouseEvent& evt);
|
|
};
|
|
|
|
class SelectMachinePopup : public PopupWindow
|
|
{
|
|
public:
|
|
SelectMachinePopup(wxWindow *parent);
|
|
~SelectMachinePopup();
|
|
|
|
// PopupWindow virtual methods are all overridden to log them
|
|
virtual void Popup(wxWindow *focus = NULL) wxOVERRIDE;
|
|
virtual void OnDismiss() wxOVERRIDE;
|
|
virtual bool ProcessLeftDown(wxMouseEvent &event) wxOVERRIDE;
|
|
virtual bool Show(bool show = true) wxOVERRIDE;
|
|
|
|
void update_machine_list(wxCommandEvent &event);
|
|
void start_ssdp(bool on_off);
|
|
bool was_dismiss() { return m_dismiss; }
|
|
|
|
private:
|
|
int m_my_devices_count{0};
|
|
int m_other_devices_count{0};
|
|
PinCodePanel* m_panel_ping_code{nullptr};
|
|
PinCodePanel* m_panel_direct_connection{nullptr};
|
|
wxWindow* m_placeholder_panel{nullptr};
|
|
HyperLink* m_hyperlink{nullptr}; // ORCA
|
|
Label* m_ping_code_text{nullptr};
|
|
wxStaticBitmap* m_img_ping_code{nullptr};
|
|
wxBoxSizer * m_sizer_body{nullptr};
|
|
wxBoxSizer * m_sizer_my_devices{nullptr};
|
|
wxBoxSizer * m_sizer_other_devices{nullptr};
|
|
wxBoxSizer * m_sizer_search_bar{nullptr};
|
|
wxSearchCtrl* m_search_bar{nullptr};
|
|
wxScrolledWindow * m_scrolledWindow{nullptr};
|
|
wxWindow * m_panel_body{nullptr};
|
|
wxTimer * m_refresh_timer{nullptr};
|
|
std::vector<MachinePanel*> m_user_list_machine_panel;
|
|
std::vector<MachinePanel*> m_other_list_machine_panel;
|
|
boost::thread* get_print_info_thread{ nullptr };
|
|
std::shared_ptr<int> m_token = std::make_shared<int>(0);
|
|
std::string m_print_info = "";
|
|
bool m_dismiss { false };
|
|
|
|
std::map<std::string, MachineObject*> m_bind_machine_list;
|
|
std::map<std::string, MachineObject*> m_free_machine_list;
|
|
|
|
private:
|
|
void OnLeftUp(wxMouseEvent &event);
|
|
void on_timer(wxTimerEvent &event);
|
|
|
|
void update_other_devices();
|
|
void update_user_devices();
|
|
bool search_for_printer(MachineObject* obj);
|
|
void on_dissmiss_win(wxCommandEvent &event);
|
|
wxWindow *create_title_panel(wxString text);
|
|
};
|
|
|
|
class EditDevNameDialog : public DPIDialog
|
|
{
|
|
public:
|
|
EditDevNameDialog(Plater *plater = nullptr);
|
|
~EditDevNameDialog();
|
|
|
|
void set_machine_obj(MachineObject *obj);
|
|
void on_dpi_changed(const wxRect &suggested_rect) override;
|
|
void on_edit_name(wxCommandEvent &e);
|
|
|
|
Button* m_button_confirm{nullptr};
|
|
TextInput* m_textCtr{nullptr};
|
|
wxStaticText* m_static_valid{nullptr};
|
|
MachineObject* m_info{nullptr};
|
|
};
|
|
|
|
}} // namespace Slic3r::GUI
|
|
|
|
#endif
|