Add tooltips with numerical value to all sliders

Add a tooltip with the numerical value to all slider widgets in the GUI
on the slider.

Done with Claude.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
This commit is contained in:
Rafael Kitover
2025-10-04 22:38:48 +00:00
parent cf3a48e15c
commit 9551313e19
3 changed files with 58 additions and 6 deletions

View File

@@ -8,6 +8,7 @@
#include <wx/log.h>
#include <wx/object.h>
#include <wx/radiobut.h>
#include <wx/slider.h>
#include <wx/textctrl.h>
#include <wx/valnum.h>
@@ -301,6 +302,14 @@ private:
} // namespace
// Helper function to update slider tooltip with its current value
static void UpdateSliderTooltip(wxSlider* slider, wxCommandEvent& event) {
if (slider) {
slider->SetToolTip(wxString::Format("%d", slider->GetValue()));
}
event.Skip();
}
// static
DisplayConfig* DisplayConfig::NewInstance(wxWindow* parent) {
VBAM_CHECK(parent);
@@ -422,9 +431,13 @@ DisplayConfig::DisplayConfig(wxWindow* parent)
wxSlider* gba_darken_slider = GetValidatedChild<wxSlider>("GBADarken");
gba_darken_slider->SetValidator(widgets::OptionUnsignedValidator(config::OptionID::kGBADarken));
gba_darken_slider->SetToolTip(wxString::Format("%d", gba_darken_slider->GetValue()));
gba_darken_slider->Bind(wxEVT_SLIDER, std::bind(UpdateSliderTooltip, gba_darken_slider, std::placeholders::_1));
wxSlider* gbc_lighten_slider = GetValidatedChild<wxSlider>("GBCLighten");
gbc_lighten_slider->SetValidator(widgets::OptionUnsignedValidator(config::OptionID::kGBLighten));
gbc_lighten_slider->SetToolTip(wxString::Format("%d", gbc_lighten_slider->GetValue()));
gbc_lighten_slider->Bind(wxEVT_SLIDER, std::bind(UpdateSliderTooltip, gbc_lighten_slider, std::placeholders::_1));
filter_selector_ = GetValidatedChild<wxChoice>("Filter");
filter_selector_->SetValidator(FilterValidator());

View File

@@ -135,6 +135,14 @@ private:
} // namespace
// Helper function to update slider tooltip with its current value
static void UpdateSliderTooltip(wxSlider* slider, wxCommandEvent& event) {
if (slider) {
slider->SetToolTip(wxString::Format("%d", slider->GetValue()));
}
event.Skip();
}
// static
SoundConfig* SoundConfig::NewInstance(wxWindow* parent) {
VBAM_CHECK(parent);
@@ -145,6 +153,8 @@ SoundConfig::SoundConfig(wxWindow* parent) : BaseDialog(parent, "SoundConfig") {
// Volume slider configuration.
wxSlider* volume_slider = GetValidatedChild<wxSlider>("Volume");
volume_slider->SetValidator(widgets::OptionIntValidator(config::OptionID::kSoundVolume));
volume_slider->SetToolTip(wxString::Format("%d", volume_slider->GetValue()));
volume_slider->Bind(wxEVT_SLIDER, std::bind(UpdateSliderTooltip, volume_slider, std::placeholders::_1));
GetValidatedChild("Volume100")
->Bind(wxEVT_BUTTON, std::bind(&wxSlider::SetValue, volume_slider, 100));
@@ -229,17 +239,26 @@ SoundConfig::SoundConfig(wxWindow* parent) : BaseDialog(parent, "SoundConfig") {
buffers_info_label_ = GetValidatedChild<wxControl>("BuffersInfo");
buffers_slider_ = GetValidatedChild<wxSlider>("Buffers");
buffers_slider_->SetValidator(widgets::OptionIntValidator(config::OptionID::kSoundBuffers));
buffers_slider_->SetToolTip(wxString::Format("%d", buffers_slider_->GetValue()));
buffers_slider_->Bind(wxEVT_SLIDER, std::bind(UpdateSliderTooltip, buffers_slider_, std::placeholders::_1));
buffers_slider_->Bind(wxEVT_SLIDER, &SoundConfig::OnBuffersChanged, this);
// Game Boy configuration.
GetValidatedChild("GBEcho")->SetValidator(
widgets::OptionIntValidator(config::OptionID::kSoundGBEcho));
GetValidatedChild("GBStereo")
->SetValidator(widgets::OptionIntValidator(config::OptionID::kSoundGBStereo));
wxSlider* gb_echo_slider = GetValidatedChild<wxSlider>("GBEcho");
gb_echo_slider->SetValidator(widgets::OptionIntValidator(config::OptionID::kSoundGBEcho));
gb_echo_slider->SetToolTip(wxString::Format("%d", gb_echo_slider->GetValue()));
gb_echo_slider->Bind(wxEVT_SLIDER, std::bind(UpdateSliderTooltip, gb_echo_slider, std::placeholders::_1));
wxSlider* gb_stereo_slider = GetValidatedChild<wxSlider>("GBStereo");
gb_stereo_slider->SetValidator(widgets::OptionIntValidator(config::OptionID::kSoundGBStereo));
gb_stereo_slider->SetToolTip(wxString::Format("%d", gb_stereo_slider->GetValue()));
gb_stereo_slider->Bind(wxEVT_SLIDER, std::bind(UpdateSliderTooltip, gb_stereo_slider, std::placeholders::_1));
// Game Boy Advance configuration.
GetValidatedChild("GBASoundFiltering")
->SetValidator(widgets::OptionIntValidator(config::OptionID::kSoundGBAFiltering));
wxSlider* gba_filtering_slider = GetValidatedChild<wxSlider>("GBASoundFiltering");
gba_filtering_slider->SetValidator(widgets::OptionIntValidator(config::OptionID::kSoundGBAFiltering));
gba_filtering_slider->SetToolTip(wxString::Format("%d", gba_filtering_slider->GetValue()));
gba_filtering_slider->Bind(wxEVT_SLIDER, std::bind(UpdateSliderTooltip, gba_filtering_slider, std::placeholders::_1));
// Audio Device configuration.
audio_device_selector_ = GetValidatedChild<wxChoice>("Device");

View File

@@ -4,6 +4,7 @@
#include <wx/colordlg.h>
#include <wx/ffile.h>
#include <wx/slider.h>
#include "core/gb/gbGlobals.h"
#include "core/gba/gbaGlobals.h"
@@ -16,6 +17,15 @@
#endif
namespace {
// Helper function to update slider tooltip with its current value
static void UpdateSliderTooltip(wxSlider* slider, wxCommandEvent& event) {
if (slider) {
slider->SetToolTip(wxString::Format("%d", slider->GetValue()));
}
event.Skip();
}
void utilReadScreenPixels(uint8_t* dest, int w, int h) {
uint8_t* b = dest;
int sizeX = w;
@@ -1549,6 +1559,11 @@ public:
getradio(, "CharBase3", charbase_, 0xc000);
getradio(, "CharBase4", charbase_, 0x10000);
getslider(, "Palette", palette_);
wxSlider* palette_slider = XRCCTRL(*this, "Palette", wxSlider);
if (palette_slider) {
palette_slider->SetToolTip(wxString::Format("%d", palette_slider->GetValue()));
palette_slider->Bind(wxEVT_SLIDER, std::bind(UpdateSliderTooltip, palette_slider, std::placeholders::_1));
}
getlab(tileno_, "Tile", "1WWW");
getlab(addr_, "Address", "06WWWWWW");
selx_ = sely_ = -1;
@@ -1741,6 +1756,11 @@ public:
getradio(, "CharBase0", charbase, 0);
getradio(, "CharBase1", charbase, 0x800);
getslider(, "Palette", palette);
wxSlider* palette_slider = XRCCTRL(*this, "Palette", wxSlider);
if (palette_slider) {
palette_slider->SetToolTip(wxString::Format("%d", palette_slider->GetValue()));
palette_slider->Bind(wxEVT_SLIDER, std::bind(UpdateSliderTooltip, palette_slider, std::placeholders::_1));
}
getlab(tileno, "Tile", "2WW");
getlab(addr, "Address", "WWWW");
selx = sely = -1;