[GTK3] Change config slider formatting a bit

This commit is contained in:
Maximilian Mader 2021-01-01 18:58:19 +01:00
parent 863e6de420
commit 5049f400f0
Signed by: Max
GPG Key ID: F71D56A3151C4FB3
5 changed files with 12 additions and 14 deletions

View File

@ -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") \

View File

@ -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)) {
// wouldnt 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);
// wouldnt 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);
}
}

View File

@ -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);

View File

@ -1042,9 +1042,9 @@ Author: Maximilian Mader
</object>
<object class="GtkAdjustment" id="volumeAdjustment">
<property name="upper">256</property>
<property name="upper">100</property>
<property name="step_increment">1</property>
<property name="page_increment">8</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="colorTemperatureAdjustment">

View File

@ -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);
}