diff --git a/desmume/src/gtk/main.cpp b/desmume/src/gtk/main.cpp index 4b8322f7b..a1b5a58a0 100644 --- a/desmume/src/gtk/main.cpp +++ b/desmume/src/gtk/main.cpp @@ -144,6 +144,7 @@ static void ToggleAutoFrameskip (GtkToggleAction *action); static void ToggleSwapScreens(GtkToggleAction *action); static void ToggleGap (GtkToggleAction *action); static void SetRotation(GtkAction *action, GtkRadioAction *current); +static void SetWinSize(GtkAction *action, GtkRadioAction *current); static void SetOrientation(GtkAction *action, GtkRadioAction *current); static void ToggleLayerVisibility(GtkToggleAction* action, gpointer data); static void ToggleHudDisplay(GtkToggleAction* action, gpointer data); @@ -219,6 +220,19 @@ static const char *ui_description = " " " " " " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " " " " " " " @@ -269,7 +283,6 @@ static const char *ui_description = " " " " " " -" " " " " " " " @@ -376,6 +389,7 @@ static const GtkActionEntry action_entries[] = { { "ViewMenu", NULL, "_View" }, { "RotationMenu", NULL, "_Rotation" }, { "OrientationMenu", NULL, "LCDs _Layout" }, + { "WinsizeMenu", NULL, "_Window Size" }, { "PriInterpolationMenu", NULL, "Primary _Interpolation" }, { "InterpolationMenu", NULL, "S_econdary Interpolation" }, { "HudMenu", NULL, "_HUD" }, @@ -456,6 +470,32 @@ static const GtkRadioActionEntry rotation_entries[] = { { "rotate_270", "gtk-orientation-reverse-landscape", "_270",NULL, NULL, 270 }, }; +enum winsize_enum { + WINSIZE_SCALE = 0, + WINSIZE_HALF = 1, + WINSIZE_1 = 2, + WINSIZE_1HALF = 3, + WINSIZE_2 = 4, + WINSIZE_2HALF = 5, + WINSIZE_3 = 6, + WINSIZE_4 = 8, + WINSIZE_5 = 10, +}; + +static winsize_enum winsize_current; + +static const GtkRadioActionEntry winsize_entries[] = { + { "winsize_half", NULL, "0_.5x", NULL, NULL, WINSIZE_HALF }, + { "winsize_1", NULL, "_1x", NULL, NULL, WINSIZE_1 }, + { "winsize_1half", NULL, "1.5x", NULL, NULL, WINSIZE_1HALF }, + { "winsize_2", NULL, "_2x", NULL, NULL, WINSIZE_2 }, + { "winsize_2half", NULL, "2.5x", NULL, NULL, WINSIZE_2HALF }, + { "winsize_3", NULL, "_3x", NULL, NULL, WINSIZE_3 }, + { "winsize_4", NULL, "_4x", NULL, NULL, WINSIZE_4 }, + { "winsize_5", NULL, "_5x", NULL, NULL, WINSIZE_5 }, + { "winsize_scale", NULL, "_Scale to window", NULL, NULL, WINSIZE_SCALE }, +}; + /* When adding modes here remember to add the relevent entry to screen_size */ enum orientation_enum { ORIENT_VERTICAL = 0, @@ -1376,12 +1416,16 @@ static void UpdateDrawingAreaAspect() } else { W += nds_screen.gap_size; } - } else { - } } - gtk_widget_set_size_request(GTK_WIDGET(pDrawingArea), W, H); + if (winsize_current == WINSIZE_SCALE) { + gtk_widget_set_size_request(GTK_WIDGET(pDrawingArea), W / 2, H / 2); + gtk_window_set_resizable(GTK_WINDOW(pWindow), TRUE); + } else { + gtk_widget_set_size_request(GTK_WIDGET(pDrawingArea), W * winsize_current / 2, H * winsize_current / 2); + gtk_window_set_resizable(GTK_WINDOW(pWindow), FALSE); + } } static void ToggleGap(GtkToggleAction* action) @@ -1396,6 +1440,13 @@ static void SetRotation(GtkAction *action, GtkRadioAction *current) UpdateDrawingAreaAspect(); } +static void SetWinsize(GtkAction *action, GtkRadioAction *current) +{ + winsize_current = (winsize_enum) gtk_radio_action_get_current_value(current); + gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "fullscreen"), winsize_current == WINSIZE_SCALE); + UpdateDrawingAreaAspect(); +} + static void SetOrientation(GtkAction *action, GtkRadioAction *current) { nds_screen.orientation = gtk_radio_action_get_current_value(current); @@ -2803,6 +2854,8 @@ common_gtk_main( class configured_features *my_config) 0, G_CALLBACK(Modify_Frameskip), NULL); gtk_action_group_add_radio_actions(action_group, rotation_entries, G_N_ELEMENTS(rotation_entries), 0, G_CALLBACK(SetRotation), NULL); + gtk_action_group_add_radio_actions(action_group, winsize_entries, G_N_ELEMENTS(winsize_entries), + WINSIZE_1, G_CALLBACK(SetWinsize), NULL); gtk_action_group_add_radio_actions(action_group, orientation_entries, G_N_ELEMENTS(orientation_entries), 0, G_CALLBACK(SetOrientation), NULL); { @@ -2816,6 +2869,7 @@ common_gtk_main( class configured_features *my_config) gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "printscreen"), FALSE); gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "cheatlist"), FALSE); gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "cheatsearch"), FALSE); + gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "fullscreen"), FALSE); gtk_ui_manager_insert_action_group (ui_manager, action_group, 0); @@ -2843,7 +2897,8 @@ common_gtk_main( class configured_features *my_config) pDrawingArea = gtk_drawing_area_new(); gtk_container_add (GTK_CONTAINER (pVBox), pDrawingArea); - gtk_widget_set_size_request(GTK_WIDGET(pDrawingArea), 256, 384); + winsize_current = WINSIZE_1; + UpdateDrawingAreaAspect(); gtk_widget_set_events(pDrawingArea, GDK_EXPOSURE_MASK | GDK_LEAVE_NOTIFY_MASK |