From 666797fdee43eb681131959685af3e64a2a30a49 Mon Sep 17 00:00:00 2001 From: rakslice Date: Thu, 14 Nov 2024 01:35:09 -0800 Subject: [PATCH 1/3] add scaling settings for sdl to gtk3 ui --- BasiliskII/src/Unix/prefs_editor_gtk3.cpp | 25 +++- BasiliskII/src/Unix/ui/prefs-editor.ui | 139 ++++++++++++++++++---- 2 files changed, 143 insertions(+), 21 deletions(-) diff --git a/BasiliskII/src/Unix/prefs_editor_gtk3.cpp b/BasiliskII/src/Unix/prefs_editor_gtk3.cpp index 5147f87c..286ad2ac 100644 --- a/BasiliskII/src/Unix/prefs_editor_gtk3.cpp +++ b/BasiliskII/src/Unix/prefs_editor_gtk3.cpp @@ -60,6 +60,8 @@ static GtkToggleButton *screen_full; static GtkToggleButton *screen_win; static GtkComboBox *screen_res; +static GtkEntry *mag_rate; + static GtkWidget *volumes_view; static GtkTreeModel *volume_store; static GtkTreeIter toplevel; @@ -151,7 +153,7 @@ const char *sysinfo = ABOUT_MODE "\nBuilt with " ABOUT_VIDEO " and " ABOUT_AUDIO // The widgets from prefs-editor.ui that need their values set on launch const char *check_boxes[] = { "udptunnel", "keycodes", "ignoresegv", "idlewait", "jit", "jitfpu", "jitinline", - "jitlazyflush", "jit68k", "gfxaccel", "swap_opt_cmd", NULL }; + "jitlazyflush", "jit68k", "gfxaccel", "swap_opt_cmd", "scale_nearest", "scale_integer", NULL }; const char *inv_check_boxes[] = { "nocdrom", "nosound", "nogui", NULL }; const char *entries[] = { "extfs", "dsp", "mixer", "keycodefile", "scsi0", "scsi1", "scsi2", "scsi3", "scsi4", @@ -315,6 +317,17 @@ void cb_browse_dir(GtkWidget *button, GtkWidget *entry) file_chooser_show(chooser); } +// User changed scaling settings +void cb_scaling(GtkWidget * widget) +{ + const char *mag_rate_str = gtk_entry_get_text(GTK_ENTRY(mag_rate)); + if (mag_rate_str) { + PrefsReplaceString("mag_rate", mag_rate_str); + } else { + PrefsRemoveItem("mag_rate"); + } +} + // User changed one of the screen mode settings void cb_screen_mode(GtkWidget *widget) { @@ -1212,6 +1225,8 @@ static void get_graphics_settings (void) screen_win = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "screen-mode-window")); screen_res = GTK_COMBO_BOX(gtk_builder_get_object(builder, "screen-res")); + mag_rate = GTK_ENTRY(gtk_builder_get_object(builder, "mag_rate")); + const char *str = PrefsFindString("screen"); if (str) { if (sscanf(str, "win/%d/%d", &dis_width, &dis_height) == 2) @@ -1273,6 +1288,14 @@ static void get_graphics_settings (void) gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(screen_res))), res_str); } g_free(res_str); + + // scaling + const char *mag_rate_str = PrefsFindString("mag_rate"); + if (!mag_rate_str) { + mag_rate_str = "1.0"; + } + gtk_entry_set_text(GTK_ENTRY(mag_rate), mag_rate_str); + // check boxes are handled separately } // Add names of serial devices diff --git a/BasiliskII/src/Unix/ui/prefs-editor.ui b/BasiliskII/src/Unix/ui/prefs-editor.ui index 950518d1..a9d7c70a 100644 --- a/BasiliskII/src/Unix/ui/prefs-editor.ui +++ b/BasiliskII/src/Unix/ui/prefs-editor.ui @@ -1,5 +1,5 @@ - + @@ -444,7 +444,7 @@ 10 vertical - + True False @@ -627,6 +627,102 @@ 2 + + + True + False + Scale factor: + + + 2 + 2 + + + + + True + True + 1.0 + number + + + + 3 + 2 + + + + + Integer Scaling + scale_integer + True + True + False + True + + + + 2 + 4 + 2 + + + + + True + False + start + Scaling (SDL) + + + + + + 2 + 1 + 2 + + + + + Nearest + scale_nearest + True + True + False + True + + + + 2 + 3 + 2 + + + + + + + + + + + + + + + + + + + + + + + + + + False @@ -1679,7 +1775,7 @@ for most non-Apple keyboards - + True False @@ -1770,23 +1866,23 @@ for most non-Apple keyboards - - Show settings window on startup - nogui - True - True - False - You can always access the Settings by right-clicking on the launcher icon - start - True - - - - 0 - 6 - 2 - - + + Show settings window on startup + nogui + True + True + False + You can always access the Settings by right-clicking on the launcher icon + start + True + + + + 0 + 6 + 2 + + ramsize @@ -1917,6 +2013,9 @@ for most non-Apple keyboards + + + system-pane From 678fffa5f51c688ac27fa9eb76a38cb678b28b6f Mon Sep 17 00:00:00 2001 From: rakslice Date: Thu, 14 Nov 2024 19:25:33 -0800 Subject: [PATCH 2/3] GTK2 version of SDL scaling settings --- BasiliskII/src/Unix/prefs_editor_gtk.cpp | 49 +++++++++++++++++++++++- BasiliskII/src/include/user_strings.h | 4 ++ BasiliskII/src/user_strings.cpp | 4 ++ 3 files changed, 55 insertions(+), 2 deletions(-) diff --git a/BasiliskII/src/Unix/prefs_editor_gtk.cpp b/BasiliskII/src/Unix/prefs_editor_gtk.cpp index c3452ff7..1ca718be 100644 --- a/BasiliskII/src/Unix/prefs_editor_gtk.cpp +++ b/BasiliskII/src/Unix/prefs_editor_gtk.cpp @@ -345,7 +345,8 @@ static GtkWidget *make_checkbox(GtkWidget *top, int label_id, const char *prefs_ gtk_widget_show(button); gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), PrefsFindBool(prefs_item)); g_signal_connect(button, "toggled", func, NULL); - gtk_box_pack_start(GTK_BOX(top), button, FALSE, FALSE, 0); + if (top) + gtk_box_pack_start(GTK_BOX(top), button, FALSE, FALSE, 0); return button; } @@ -876,6 +877,8 @@ static GtkWidget *l_frameskip, *l_display_x, *l_display_y; static int display_type; static int dis_width, dis_height; +static GtkWidget *mag_rate, *scale_nearest, *scale_integer; + #ifdef ENABLE_FBDEV_DGA static GtkWidget *w_fbdev_name, *w_fbdevice_file; static GtkWidget *l_fbdev_name, *l_fbdevice_file; @@ -948,6 +951,18 @@ static void tb_nosound(GtkWidget *widget) set_graphics_sensitive(); } +// "Nearest" button toggled +static void tb_scale_nearest(GtkWidget *widget) +{ + PrefsReplaceBool("scale_nearest", GTK_TOGGLE_BUTTON(widget)->active); +} + +// "Integer Scaling" button toggled +static void tb_scale_integer(GtkWidget *widget) +{ + PrefsReplaceBool("scale_integer", GTK_TOGGLE_BUTTON(widget)->active); +} + // Read graphics preferences static void parse_graphics_prefs(void) { @@ -1010,6 +1025,8 @@ static void read_graphics_settings(void) #endif PrefsReplaceString("dsp", get_file_entry_path(w_dspdevice_file)); PrefsReplaceString("mixer", get_file_entry_path(w_mixerdevice_file)); + + PrefsReplaceString("mag_rate", gtk_entry_get_text(GTK_ENTRY(mag_rate))); } // Create "Graphics/Sound" pane @@ -1017,11 +1034,12 @@ static void create_graphics_pane(GtkWidget *top) { GtkWidget *box, *table, *label, *combo; char str[32]; + char *markup; parse_graphics_prefs(); box = make_pane(top, STR_GRAPHICS_SOUND_PANE_TITLE); - table = make_table(box, 2, 5); + table = make_table(box, 4, 5); label = gtk_label_new(GetString(STR_VIDEO_TYPE_CTRL)); gtk_widget_show(label); @@ -1125,6 +1143,33 @@ static void create_graphics_pane(GtkWidget *top) w_dspdevice_file = make_file_entry(box, STR_DSPDEVICE_FILE_CTRL, "dsp"); w_mixerdevice_file = make_file_entry(box, STR_MIXERDEVICE_FILE_CTRL, "mixer"); + // SDL scaling settings section + label = gtk_label_new(GetString(STR_SDL_SCALING)); + markup = g_markup_printf_escaped ("%s", GetString(STR_SDL_SCALING)); + gtk_label_set_markup(GTK_LABEL(label), markup); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); + gtk_widget_show(label); + // attach((table), child, left_attach, right_attach, top_attach, bottom_attach, xoptions, yoptions, xpadding, ypadding) + gtk_table_attach(GTK_TABLE(table), label, 2, 4, 0, 1, (GtkAttachOptions)GTK_FILL, (GtkAttachOptions)0, 4, 4); + + label = gtk_label_new(GetString(STR_SCALE_FACTOR)); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, 2, 3, 1, 2, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4); + + mag_rate = gtk_entry_new(); + const char *mag_rate_str = PrefsFindString("mag_rate"); + if (!mag_rate_str) + mag_rate_str = "1.0"; + gtk_entry_set_text(GTK_ENTRY(mag_rate), mag_rate_str); + + gtk_widget_show(mag_rate); + gtk_table_attach(GTK_TABLE(table), mag_rate, 3, 4, 1, 2, (GtkAttachOptions)GTK_FILL, (GtkAttachOptions)0, 4, 4); + + scale_nearest = make_checkbox(NULL, STR_SCALE_NEAREST, "scale_nearest", G_CALLBACK(tb_scale_nearest)); + gtk_table_attach(GTK_TABLE(table), scale_nearest, 2, 4, 2, 3, (GtkAttachOptions)GTK_FILL, (GtkAttachOptions)0, 4, 4); + scale_integer = make_checkbox(NULL, STR_SCALE_INTEGER, "scale_integer", G_CALLBACK(tb_scale_integer)); + gtk_table_attach(GTK_TABLE(table), scale_integer, 2, 4, 3, 4, (GtkAttachOptions)GTK_FILL, (GtkAttachOptions)0, 4, 4); + set_graphics_sensitive(); hide_show_graphics_widgets(); diff --git a/BasiliskII/src/include/user_strings.h b/BasiliskII/src/include/user_strings.h index 647c65f6..fc81a9f2 100644 --- a/BasiliskII/src/include/user_strings.h +++ b/BasiliskII/src/include/user_strings.h @@ -174,6 +174,10 @@ enum { STR_DIRECT3D_LAB, STR_GRAPHICS_SDL_VSYNC_CTRL, STR_DEFAULT_LAB, + STR_SDL_SCALING, + STR_SCALE_FACTOR, + STR_SCALE_NEAREST, + STR_SCALE_INTEGER, STR_SERIAL_NETWORK_PANE_TITLE = 3500, // Serial/Networking pane STR_SERIALA_CTRL, diff --git a/BasiliskII/src/user_strings.cpp b/BasiliskII/src/user_strings.cpp index 1b8642dc..bf4f8c5a 100644 --- a/BasiliskII/src/user_strings.cpp +++ b/BasiliskII/src/user_strings.cpp @@ -189,6 +189,10 @@ user_string_def common_strings[] = { {STR_DIRECT3D_LAB, "Direct3D"}, {STR_GRAPHICS_SDL_VSYNC_CTRL, "Vertical Sync (Software)"}, {STR_DEFAULT_LAB, "Default"}, + {STR_SDL_SCALING, "Scaling (SDL)"}, + {STR_SCALE_FACTOR, "Scale factor:"}, + {STR_SCALE_NEAREST, "Nearest"}, + {STR_SCALE_INTEGER, "Integer Scaling"}, {STR_SERIAL_NETWORK_PANE_TITLE, "Serial/Network"}, {STR_SERIALA_CTRL, "Modem Port"}, From 3f46296a36af20ed4083bfd846e4fb4d3639e5c9 Mon Sep 17 00:00:00 2001 From: rakslice Date: Sat, 23 Nov 2024 17:25:43 -0800 Subject: [PATCH 3/3] incorporate BasiliskII unix gtk 2 GUI scaling changes into its SheepShaver counterpart --- SheepShaver/src/Unix/prefs_editor_gtk.cpp | 49 ++++++++++++++++++++++- SheepShaver/src/include/user_strings.h | 4 ++ SheepShaver/src/user_strings.cpp | 4 ++ 3 files changed, 55 insertions(+), 2 deletions(-) diff --git a/SheepShaver/src/Unix/prefs_editor_gtk.cpp b/SheepShaver/src/Unix/prefs_editor_gtk.cpp index 28af64e2..5728cb79 100644 --- a/SheepShaver/src/Unix/prefs_editor_gtk.cpp +++ b/SheepShaver/src/Unix/prefs_editor_gtk.cpp @@ -323,7 +323,8 @@ static GtkWidget *make_checkbox(GtkWidget *top, int label_id, const char *prefs_ gtk_widget_show(button); gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), PrefsFindBool(prefs_item)); g_signal_connect(button, "toggled", func, NULL); - gtk_box_pack_start(GTK_BOX(top), button, FALSE, FALSE, 0); + if (top) + gtk_box_pack_start(GTK_BOX(top), button, FALSE, FALSE, 0); return button; } @@ -755,6 +756,8 @@ static bool is_fbdev_dga_mode = false; static GtkWidget *w_dspdevice_file, *w_mixerdevice_file; +static GtkWidget *mag_rate, *scale_nearest, *scale_integer; + // "Window"/"Fullscreen" video type selected static void mn_display(GtkWidget *widget) { @@ -801,6 +804,18 @@ static void tb_nosound(GtkWidget *widget) set_graphics_sensitive(); } +// "Nearest" button toggled +static void tb_scale_nearest(GtkWidget *widget) +{ + PrefsReplaceBool("scale_nearest", GTK_TOGGLE_BUTTON(widget)->active); +} + +// "Integer Scaling" button toggled +static void tb_scale_integer(GtkWidget *widget) +{ + PrefsReplaceBool("scale_integer", GTK_TOGGLE_BUTTON(widget)->active); +} + // Read and convert graphics preferences static void parse_graphics_prefs(void) { @@ -898,6 +913,8 @@ static void read_graphics_settings(void) PrefsReplaceString("dsp", get_file_entry_path(w_dspdevice_file)); PrefsReplaceString("mixer", get_file_entry_path(w_mixerdevice_file)); + + PrefsReplaceString("mag_rate", gtk_entry_get_text(GTK_ENTRY(mag_rate))); } // Create "Graphics/Sound" pane @@ -905,11 +922,12 @@ static void create_graphics_pane(GtkWidget *top) { GtkWidget *box, *table, *label, *combo; char str[32]; + char *markup; parse_graphics_prefs(); box = make_pane(top, STR_GRAPHICS_SOUND_PANE_TITLE); - table = make_table(box, 2, 4); + table = make_table(box, 4, 4); label = gtk_label_new(GetString(STR_VIDEO_TYPE_CTRL)); gtk_widget_show(label); @@ -1001,6 +1019,33 @@ static void create_graphics_pane(GtkWidget *top) w_dspdevice_file = make_file_entry(box, STR_DSPDEVICE_FILE_CTRL, "dsp"); w_mixerdevice_file = make_file_entry(box, STR_MIXERDEVICE_FILE_CTRL, "mixer"); + // SDL scaling settings section + label = gtk_label_new(GetString(STR_SDL_SCALING)); + markup = g_markup_printf_escaped ("%s", GetString(STR_SDL_SCALING)); + gtk_label_set_markup(GTK_LABEL(label), markup); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); + gtk_widget_show(label); + // attach((table), child, left_attach, right_attach, top_attach, bottom_attach, xoptions, yoptions, xpadding, ypadding) + gtk_table_attach(GTK_TABLE(table), label, 2, 4, 0, 1, (GtkAttachOptions)GTK_FILL, (GtkAttachOptions)0, 4, 4); + + label = gtk_label_new(GetString(STR_SCALE_FACTOR)); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, 2, 3, 1, 2, (GtkAttachOptions)0, (GtkAttachOptions)0, 4, 4); + + mag_rate = gtk_entry_new(); + const char *mag_rate_str = PrefsFindString("mag_rate"); + if (!mag_rate_str) + mag_rate_str = "1.0"; + gtk_entry_set_text(GTK_ENTRY(mag_rate), mag_rate_str); + + gtk_widget_show(mag_rate); + gtk_table_attach(GTK_TABLE(table), mag_rate, 3, 4, 1, 2, (GtkAttachOptions)GTK_FILL, (GtkAttachOptions)0, 4, 4); + + scale_nearest = make_checkbox(NULL, STR_SCALE_NEAREST, "scale_nearest", G_CALLBACK(tb_scale_nearest)); + gtk_table_attach(GTK_TABLE(table), scale_nearest, 2, 4, 2, 3, (GtkAttachOptions)GTK_FILL, (GtkAttachOptions)0, 4, 4); + scale_integer = make_checkbox(NULL, STR_SCALE_INTEGER, "scale_integer", G_CALLBACK(tb_scale_integer)); + gtk_table_attach(GTK_TABLE(table), scale_integer, 2, 4, 3, 4, (GtkAttachOptions)GTK_FILL, (GtkAttachOptions)0, 4, 4); + set_graphics_sensitive(); } diff --git a/SheepShaver/src/include/user_strings.h b/SheepShaver/src/include/user_strings.h index 7b73dcff..c875d169 100644 --- a/SheepShaver/src/include/user_strings.h +++ b/SheepShaver/src/include/user_strings.h @@ -144,6 +144,10 @@ enum { STR_DIRECT3D_LAB, STR_GRAPHICS_SDL_VSYNC_CTRL, STR_DEFAULT_LAB, + STR_SDL_SCALING, + STR_SCALE_FACTOR, + STR_SCALE_NEAREST, + STR_SCALE_INTEGER, // Serial/Network pane STR_SERIAL_NETWORK_PANE_TITLE = 3400, diff --git a/SheepShaver/src/user_strings.cpp b/SheepShaver/src/user_strings.cpp index 3cc6924d..031697e0 100644 --- a/SheepShaver/src/user_strings.cpp +++ b/SheepShaver/src/user_strings.cpp @@ -154,6 +154,10 @@ user_string_def common_strings[] = { {STR_DIRECT3D_LAB, "Direct3D"}, {STR_GRAPHICS_SDL_VSYNC_CTRL, "Vertical Sync (Software)"}, {STR_DEFAULT_LAB, "Default"}, + {STR_SDL_SCALING, "Scaling (SDL)"}, + {STR_SCALE_FACTOR, "Scale factor:"}, + {STR_SCALE_NEAREST, "Nearest"}, + {STR_SCALE_INTEGER, "Integer Scaling"}, {STR_SERIAL_NETWORK_PANE_TITLE, "Serial/Network"}, {STR_SERPORTA_CTRL, "Modem Port"},