From 88b3dfe2f9c91a711bd996a41bde6b7578431f5c Mon Sep 17 00:00:00 2001 From: capitalistspz Date: Wed, 3 Jun 2026 22:39:54 +0100 Subject: [PATCH] Use `wxComboBox` instead of `wxChoice` For some reason `wxChoice` on GTK frequently produces ``` *** BUG *** In pixman_region32_init_rect: Invalid rectangle passed Set a breakpoint on '_pixman_log_error' to debug ``` and displays incorrectly --- src/gui/wxgui/CameraSettingsWindow.cpp | 25 +++++++++++++++---------- src/gui/wxgui/CameraSettingsWindow.h | 8 +++++--- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/gui/wxgui/CameraSettingsWindow.cpp b/src/gui/wxgui/CameraSettingsWindow.cpp index b7f00df3..a362dabc 100644 --- a/src/gui/wxgui/CameraSettingsWindow.cpp +++ b/src/gui/wxgui/CameraSettingsWindow.cpp @@ -1,7 +1,8 @@ #include "CameraSettingsWindow.h" #include "input/camera/CameraManager.h" - +#include +#include #include #include #include @@ -16,16 +17,15 @@ CameraSettingsWindow::CameraSettingsWindow(wxWindow* parent) { auto* topSizer = new wxBoxSizer(wxHORIZONTAL); { - m_cameraChoice = new wxChoice(this, wxID_ANY, wxDefaultPosition, {300, -1}); - m_cameraChoice->Bind(wxEVT_CHOICE, &CameraSettingsWindow::OnSelectCameraChoice, this); - m_cameraChoice->SetToolTip(_("Cameras are only listed if they support 640x480")); + m_cameraComboBox = new wxComboBox(this, wxID_ANY); + m_cameraComboBox->Bind(wxEVT_COMBOBOX, &CameraSettingsWindow::OnSelectCameraChoice, this); + m_cameraComboBox->SetToolTip(_("Cameras are only listed if they support 640x480")); - m_refreshButton = new wxButton(this, wxID_ANY, wxString::FromUTF8("⟳")); - m_refreshButton->Fit(); + m_refreshButton = new wxButton(this, wxID_ANY, _("Refresh")); m_refreshButton->Bind(wxEVT_BUTTON, &CameraSettingsWindow::OnRefreshPressed, this); wxQueueEvent(m_refreshButton, new wxCommandEvent{wxEVT_BUTTON}); - topSizer->Add(m_cameraChoice); + topSizer->Add(m_cameraComboBox); topSizer->Add(m_refreshButton); } @@ -46,9 +46,12 @@ CameraSettingsWindow::CameraSettingsWindow(wxWindow* parent) void CameraSettingsWindow::OnSelectCameraChoice(wxCommandEvent&) { - const auto selection = m_cameraChoice->GetSelection(); + const auto selection = m_cameraComboBox->GetSelection(); if (selection < 0) + { + m_cameraComboBox->Select(0); return; + } if (selection == 0) CameraManager::ResetDevice(); else @@ -62,9 +65,11 @@ void CameraSettingsWindow::OnRefreshPressed(wxCommandEvent&) { choices.push_back(fmt::format("{} ({})", entry.name, entry.uniqueId)); } - m_cameraChoice->Set(choices); + m_cameraComboBox->Set(choices); if (auto currentDevice = CameraManager::GetCurrentDevice()) - m_cameraChoice->SetSelection(static_cast(*currentDevice) + 1); + m_cameraComboBox->SetSelection(static_cast(*currentDevice) + 1); + else + m_cameraComboBox->SetSelection(0); } void CameraSettingsWindow::UpdateImage(const wxTimerEvent&) diff --git a/src/gui/wxgui/CameraSettingsWindow.h b/src/gui/wxgui/CameraSettingsWindow.h index c61f0870..aa5b2f02 100644 --- a/src/gui/wxgui/CameraSettingsWindow.h +++ b/src/gui/wxgui/CameraSettingsWindow.h @@ -1,12 +1,14 @@ #pragma once #include #include -#include -#include +#include + +class wxButton; +class wxComboBox; class CameraSettingsWindow : public wxDialog { - wxChoice* m_cameraChoice; + wxComboBox* m_cameraComboBox; wxButton* m_refreshButton; wxWindow* m_imageWindow; wxBitmap m_imageBitmap;