From 5049f400f01caae56ec6b6c4c5e456c329fbe99d Mon Sep 17 00:00:00 2001 From: Maximilian Mader Date: Fri, 1 Jan 2021 18:58:19 +0100 Subject: [PATCH] [GTK3] Change config slider formatting a bit --- gtk3/config.h | 2 +- gtk3/main.c | 6 +++--- gtk3/preferences_window.c | 8 +++----- gtk3/resources/ui/preferences_window.ui | 4 ++-- gtk3/util.c | 6 +++--- 5 files changed, 12 insertions(+), 14 deletions(-) diff --git a/gtk3/config.h b/gtk3/config.h index 5ad4f93..3f68e6c 100644 --- a/gtk3/config.h +++ b/gtk3/config.h @@ -30,7 +30,7 @@ EXPAND_GROUP(emulation, \ EXPAND_GROUP_MEMBER(boot_rom_path, string, "auto") /* overrides search location for boot ROMs by name */ \ EXPAND_GROUP_MEMBER(rewind_duration, integer, 10) \ - EXPAND_GROUP_MEMBER(dmg_revision_name, string, "DMG_CPU_C") \ + EXPAND_GROUP_MEMBER(dmg_revision_name, string, "DMG_CPU_B") \ EXPAND_GROUP_MEMBER(sgb_revision_name, string, "SGB2") \ EXPAND_GROUP_MEMBER(cgb_revision_name, string, "CPU_CGB_E") \ EXPAND_GROUP_MEMBER(model, string, "cgb") \ diff --git a/gtk3/main.c b/gtk3/main.c index 84e11ae..adb9e07 100644 --- a/gtk3/main.c +++ b/gtk3/main.c @@ -702,7 +702,7 @@ static void init(void) { GB_set_sample_rate(&gb, GB_audio_get_sample_rate()); GB_set_highpass_filter_mode(&gb, config_get_highpass_mode()); - GB_set_interference_volume(&gb, (double) config.audio.interference_volume / 256.0); + GB_set_interference_volume(&gb, (double) config.audio.interference_volume / 100.0); GB_set_log_callback(&gb, wrapped_console_log); GB_set_input_callback(&gb, wrapped_console_get_sync_input); @@ -1131,8 +1131,8 @@ void on_preferences_notify_sample_rate(PreferencesWindow *pref, const guint *sam void on_preferences_notify_interference_volume(PreferencesWindow *pref, const guint *interference_volume) { if (GB_is_inited(&gb)) { - // wouldn’t it be nice to use the value set in the GtkAdjustment of the slider instead of 256.0 here? - GB_set_interference_volume(&gb, (double) *interference_volume / 256.0); + // wouldn’t it be nice to use the value set in the GtkAdjustment of the slider instead of 100.0 here? + GB_set_interference_volume(&gb, (double) *interference_volume / 100.0); } } diff --git a/gtk3/preferences_window.c b/gtk3/preferences_window.c index 0d5cd60..4dcac96 100644 --- a/gtk3/preferences_window.c +++ b/gtk3/preferences_window.c @@ -67,12 +67,10 @@ static void preferences_window_init(PreferencesWindow *self) { gtk_widget_init_template(GTK_WIDGET(self)); // Add a couple of "snapping points" to the sliders - for (signed i = -3; i < 4; i++) { - gtk_scale_add_mark(self->light_temperature_slider, ((double) i / 4.0) * 256.0, GTK_POS_BOTTOM, NULL); - } + gtk_scale_add_mark(self->light_temperature_slider, 0.0, GTK_POS_BOTTOM, NULL); - for (unsigned i = 1; i < 8; i++) { - gtk_scale_add_mark(self->interference_volume_slider, ((double) i / 8.0) * 256.0, GTK_POS_BOTTOM, NULL); + for (unsigned i = 1; i < 10; i++) { + gtk_scale_add_mark(self->interference_volume_slider, ((double) i / 10.0) * 100.0, GTK_POS_BOTTOM, NULL); } preferences_window_update_boot_rom_selector(self); diff --git a/gtk3/resources/ui/preferences_window.ui b/gtk3/resources/ui/preferences_window.ui index e5d0b20..3b49b4e 100644 --- a/gtk3/resources/ui/preferences_window.ui +++ b/gtk3/resources/ui/preferences_window.ui @@ -1042,9 +1042,9 @@ Author: Maximilian Mader - 256 + 100 1 - 8 + 10 diff --git a/gtk3/util.c b/gtk3/util.c index 58a436e..96b4295 100644 --- a/gtk3/util.c +++ b/gtk3/util.c @@ -163,8 +163,8 @@ gchar* format_scale_value_pct(GtkScale *scale, gdouble value) { gdouble lower = gtk_adjustment_get_lower(adj); gdouble upper = gtk_adjustment_get_upper(adj); gdouble range = fabs(upper - lower); - gdouble pct = (value / range) * 100.0; - return g_strdup_printf ("%.1f%% ", pct); + gdouble pct = ((value + fabs(lower)) / range) * 100.0; + return g_strdup_printf ("%.0f%% ", pct); } gchar* format_scale_color_temperature(GtkScale *scale, gdouble value) { @@ -174,5 +174,5 @@ gchar* format_scale_color_temperature(GtkScale *scale, gdouble value) { gdouble range = fabs(upper - lower); gdouble normalized = (value + lower) / range; gdouble kelvin = 12000 + normalized * (12000 - 1000); - return g_strdup_printf ("%.1fK ", kelvin); + return g_strdup_printf ("%.0fK ", kelvin); }