feat(automation): instrument core widgets with stable automation ids

This commit is contained in:
SoftFever
2026-06-03 04:09:42 +08:00
parent 622272e674
commit 6eb479243d
2 changed files with 11 additions and 0 deletions

View File

@@ -54,6 +54,7 @@
#include "GUI_App.hpp"
#include "UnsavedChangesDialog.hpp"
#include "MsgDialog.hpp"
#include "Automation/AutomationRegistry.hpp"
#include "Notebook.hpp"
#include "GUI_Factories.hpp"
#include "GUI_ObjectList.hpp"
@@ -1326,6 +1327,7 @@ void MainFrame::init_tabpanel() {
//BBS add pages
m_monitor = new MonitorPanel(m_tabpanel, wxID_ANY, wxDefaultPosition, wxDefaultSize);
m_monitor->SetBackgroundColour(*wxWHITE);
Slic3r::GUI::Automation::set_automation_id(m_monitor, "tab_device");
m_tabpanel->AddPage(m_monitor, _L("Device"), std::string("tab_monitor_active"), std::string("tab_monitor_active"), false);
m_printer_view = new PrinterWebView(m_tabpanel);
@@ -1384,6 +1386,7 @@ void MainFrame::show_device(bool bBBLPrinter) {
if (!m_monitor) {
m_monitor = new MonitorPanel(m_tabpanel, wxID_ANY, wxDefaultPosition, wxDefaultSize);
m_monitor->SetBackgroundColour(*wxWHITE);
Slic3r::GUI::Automation::set_automation_id(m_monitor, "tab_device");
}
m_monitor->Show(false);
m_tabpanel->InsertPage(tpMonitor, m_monitor, _L("Device"), std::string("tab_monitor_active"), std::string("tab_monitor_active"));
@@ -1833,6 +1836,10 @@ wxBoxSizer* MainFrame::create_side_tools()
m_slice_option_btn = new SideButton(slice_panel, "", "sidebutton_dropdown", 0, 14);
m_print_btn = new SideButton(print_panel, _L("Print plate"), "");
m_print_option_btn = new SideButton(print_panel, "", "sidebutton_dropdown", 0, 14);
// Stable automation ids for external scripts (safe no-op when automation is disabled).
// m_print_btn doubles as the export-G-code action depending on m_print_select.
Slic3r::GUI::Automation::set_automation_id(m_slice_btn, "btn_slice");
Slic3r::GUI::Automation::set_automation_id(m_print_btn, "btn_export");
auto slice_sizer = new wxBoxSizer(wxHORIZONTAL);
slice_sizer->Add(m_slice_option_btn, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, FromDIP(1));

View File

@@ -121,6 +121,7 @@
#include "NotificationManager.hpp"
#include "PresetComboBoxes.hpp"
#include "MsgDialog.hpp"
#include "Automation/AutomationRegistry.hpp"
#include "ProjectDirtyStateManager.hpp"
#include "Gizmos/GLGizmoSimplify.hpp" // create suggestion notification
#include "Gizmos/GLGizmoSVG.hpp" // Drop SVG file
@@ -1768,6 +1769,7 @@ Sidebar::Sidebar(Plater *parent)
});
p->combo_printer = new PlaterPresetComboBox(p->panel_printer_preset, Preset::TYPE_PRINTER);
Slic3r::GUI::Automation::set_automation_id(p->combo_printer, "combo_printer");
p->combo_printer->SetBorderWidth(0);
p->combo_printer->SetMaxSize(wxSize(-1, FromDIP(30))); // limiting height makes badge visible
// ORCA paint whole combobox on focus
@@ -2167,6 +2169,7 @@ Sidebar::Sidebar(Plater *parent)
/* first filament item */
init_filament_combo(&p->combos_filament[0], 0);
Slic3r::GUI::Automation::set_automation_id(p->combos_filament[0], "combo_filament");
//bSizer_filament_content->Add(p->sizer_filaments, 1, wxALIGN_CENTER | wxALL);
wxSizer *sizer_filaments2 = new wxBoxSizer(wxVERTICAL);
@@ -5062,6 +5065,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
}
wxGLCanvas* view3D_canvas = view3D->get_wxglcanvas();
Slic3r::GUI::Automation::set_automation_id(view3D_canvas, "canvas_3d");
//BBS: GUI refactor
wxGLCanvas* preview_canvas = preview->get_wxglcanvas();