From 4c9525c9d988a674ed8a1726cfd2cc2c9659166f Mon Sep 17 00:00:00 2001 From: arcum42 Date: Fri, 24 Aug 2018 13:41:56 -0700 Subject: [PATCH] Spu2-X (Linux): Dialog cleanup. Add volume control. Switch Ok/Cancel buttons to be the same as other plugins on Linux. Add in code for GTK 3 to get rid of depreciation warnings. --- plugins/spu2-x/src/Linux/Config.cpp | 46 +++++++++++++------ plugins/spu2-x/src/Linux/ConfigDebug.cpp | 24 ++++++++-- plugins/spu2-x/src/Linux/ConfigSoundTouch.cpp | 36 ++++++++------- 3 files changed, 71 insertions(+), 35 deletions(-) diff --git a/plugins/spu2-x/src/Linux/Config.cpp b/plugins/spu2-x/src/Linux/Config.cpp index 9d946becdc..49b1c81557 100644 --- a/plugins/spu2-x/src/Linux/Config.cpp +++ b/plugins/spu2-x/src/Linux/Config.cpp @@ -234,14 +234,13 @@ void DisplayDialog() int return_value; GtkWidget *dialog; - GtkWidget *main_frame, *main_box; + GtkWidget *main_box; GtkWidget *mixing_frame, *mixing_box; GtkWidget *int_label, *int_box; GtkWidget *effects_check; GtkWidget *dealias_filter; - GtkWidget *debug_check; - GtkWidget *debug_button; + GtkWidget *debug_check, *debug_button, *debug_frame, *debug_box; GtkWidget *output_frame, *output_box; GtkWidget *mod_label, *mod_box; @@ -250,6 +249,7 @@ void DisplayDialog() GtkWidget *sdl_api_label, *sdl_api_box; #endif GtkWidget *latency_label, *latency_slide; + GtkWidget *volume_label, *volume_slide; GtkWidget *sync_label, *sync_box; GtkWidget *advanced_button; @@ -258,8 +258,8 @@ void DisplayDialog() "SPU2-X Config", NULL, /* parent window*/ (GtkDialogFlags)(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT), - "OK", GTK_RESPONSE_ACCEPT, "Cancel", GTK_RESPONSE_REJECT, + "OK", GTK_RESPONSE_ACCEPT, NULL); int_label = gtk_label_new("Interpolation:"); @@ -316,6 +316,14 @@ void DisplayDialog() #endif gtk_range_set_value(GTK_RANGE(latency_slide), SndOutLatencyMS); + volume_label = gtk_label_new("Volume:"); +#if GTK_MAJOR_VERSION < 3 + volume_slide = gtk_hscale_new_with_range(0, 100, 5); +#else + volume_slide = gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, 0, 100, 5); +#endif + gtk_range_set_value(GTK_RANGE(volume_slide), FinalVolume*100); + sync_label = gtk_label_new("Synchronization Mode:"); sync_box = gtk_combo_box_text_new(); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(sync_box), "TimeStretch (Recommended)"); @@ -330,8 +338,6 @@ void DisplayDialog() #else main_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5); #endif - main_frame = gtk_frame_new("SPU2-X Config"); - gtk_container_add(GTK_CONTAINER(main_frame), main_box); #if GTK_MAJOR_VERSION < 3 mixing_box = gtk_vbox_new(false, 5); @@ -339,6 +345,7 @@ void DisplayDialog() mixing_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5); #endif mixing_frame = gtk_frame_new("Mixing Settings:"); + gtk_container_add(GTK_CONTAINER(mixing_frame), mixing_box); #if GTK_MAJOR_VERSION < 3 @@ -347,14 +354,25 @@ void DisplayDialog() output_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5); #endif output_frame = gtk_frame_new("Output Settings:"); + +#if GTK_MAJOR_VERSION < 3 + debug_box = gtk_vbox_new(false, 5); +#else + debug_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5); +#endif + debug_frame = gtk_frame_new("Debug Settings:"); + + gtk_container_add(GTK_CONTAINER(debug_box), debug_check); + gtk_container_add(GTK_CONTAINER(debug_box), debug_button); + gtk_container_add(GTK_CONTAINER(debug_frame), debug_box); + gtk_container_add(GTK_CONTAINER(output_frame), output_box); gtk_container_add(GTK_CONTAINER(mixing_box), int_label); gtk_container_add(GTK_CONTAINER(mixing_box), int_box); gtk_container_add(GTK_CONTAINER(mixing_box), effects_check); gtk_container_add(GTK_CONTAINER(mixing_box), dealias_filter); - gtk_container_add(GTK_CONTAINER(mixing_box), debug_check); - gtk_container_add(GTK_CONTAINER(mixing_box), debug_button); + gtk_container_add(GTK_CONTAINER(mixing_box), debug_frame); gtk_container_add(GTK_CONTAINER(output_box), mod_label); gtk_container_add(GTK_CONTAINER(output_box), mod_box); @@ -368,17 +386,18 @@ void DisplayDialog() gtk_container_add(GTK_CONTAINER(output_box), sync_box); gtk_container_add(GTK_CONTAINER(output_box), latency_label); gtk_container_add(GTK_CONTAINER(output_box), latency_slide); + gtk_container_add(GTK_CONTAINER(output_box), volume_label); + gtk_container_add(GTK_CONTAINER(output_box), volume_slide); gtk_container_add(GTK_CONTAINER(output_box), advanced_button); - gtk_container_add(GTK_CONTAINER(main_box), mixing_frame); - gtk_container_add(GTK_CONTAINER(main_box), output_frame); + gtk_box_pack_start(GTK_BOX(main_box), mixing_frame, TRUE, TRUE, 5); + gtk_box_pack_start(GTK_BOX(main_box), output_frame, TRUE, TRUE, 5); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(effects_check), EffectsDisabled); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dealias_filter), postprocess_filter_dealias); - //FinalVolume; gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(debug_check), DebugEnabled); - gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), main_frame); + gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), main_box); gtk_widget_show_all(dialog); g_signal_connect(sync_box, "changed", G_CALLBACK(cb_adjust_latency), latency_slide); @@ -394,7 +413,6 @@ void DisplayDialog() Interpolation = gtk_combo_box_get_active(GTK_COMBO_BOX(int_box)); EffectsDisabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(effects_check)); - //FinalVolume; if (gtk_combo_box_get_active(GTK_COMBO_BOX(mod_box)) != -1) OutputModule = gtk_combo_box_get_active(GTK_COMBO_BOX(mod_box)); @@ -433,7 +451,7 @@ void DisplayDialog() SDLOut->SetApiSettings(wxString(SDL_GetAudioDriver(SdlOutputAPI), wxConvUTF8)); } #endif - + FinalVolume = gtk_range_get_value(GTK_RANGE(volume_slide)) / 100; SndOutLatencyMS = gtk_range_get_value(GTK_RANGE(latency_slide)); if (gtk_combo_box_get_active(GTK_COMBO_BOX(sync_box)) != -1) diff --git a/plugins/spu2-x/src/Linux/ConfigDebug.cpp b/plugins/spu2-x/src/Linux/ConfigDebug.cpp index 5ddd77ff28..6d0f9bf617 100644 --- a/plugins/spu2-x/src/Linux/ConfigDebug.cpp +++ b/plugins/spu2-x/src/Linux/ConfigDebug.cpp @@ -161,7 +161,7 @@ void DisplayDialog() int return_value; GtkWidget *msg_box, *log_box, *dump_box, *main_box; - GtkWidget *msg_frame, *log_frame, *dump_frame, *main_frame; + GtkWidget *msg_frame, *log_frame, *dump_frame; GtkWidget *msg_console_check, *msg_key_check, *msg_voice_check, *msg_dma_check; GtkWidget *msg_autodma_check, *msg_overrun_check, *msg_cache_check; @@ -176,17 +176,23 @@ void DisplayDialog() "Spu2-X Config", NULL, // parent window (GtkDialogFlags)(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT), - "OK", GTK_RESPONSE_ACCEPT, "Cancel", GTK_RESPONSE_REJECT, + "OK", GTK_RESPONSE_ACCEPT, NULL); +#if GTK_MAJOR_VERSION < 3 main_box = gtk_hbox_new(false, 5); - main_frame = gtk_frame_new("Spu2-X Config"); - gtk_container_add(GTK_CONTAINER(main_frame), main_box); +#else + main_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5); +#endif // Message Section +#if GTK_MAJOR_VERSION < 3 msg_box = gtk_vbox_new(false, 5); +#else + msg_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5); +#endif msg_console_check = gtk_check_button_new_with_label("Show In Console"); msg_key_check = gtk_check_button_new_with_label("KeyOn/Off Events"); @@ -216,7 +222,11 @@ void DisplayDialog() gtk_container_add(GTK_CONTAINER(msg_frame), msg_box); // Log Section +#if GTK_MAJOR_VERSION < 3 log_box = gtk_vbox_new(false, 5); +#else + log_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5); +#endif log_access_check = gtk_check_button_new_with_label("Log Register/DMA Actions"); log_dma_check = gtk_check_button_new_with_label("Log DMA Writes"); @@ -234,7 +244,11 @@ void DisplayDialog() gtk_container_add(GTK_CONTAINER(log_frame), log_box); // Dump Section + #if GTK_MAJOR_VERSION < 3 dump_box = gtk_vbox_new(false, 5); +#else + dump_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5); +#endif dump_core_check = gtk_check_button_new_with_label("Dump Core and Voice State"); dump_mem_check = gtk_check_button_new_with_label("Dump Memory Contents"); @@ -258,7 +272,7 @@ void DisplayDialog() gtk_container_add(GTK_CONTAINER(main_box), dump_frame); // Add all our widgets, and show everything we've added to the dialog. - gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), main_frame); + gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), main_box); gtk_widget_show_all(dialog); return_value = gtk_dialog_run(GTK_DIALOG(dialog)); diff --git a/plugins/spu2-x/src/Linux/ConfigSoundTouch.cpp b/plugins/spu2-x/src/Linux/ConfigSoundTouch.cpp index fe5e786e6a..0eb5b72f6f 100644 --- a/plugins/spu2-x/src/Linux/ConfigSoundTouch.cpp +++ b/plugins/spu2-x/src/Linux/ConfigSoundTouch.cpp @@ -87,7 +87,7 @@ void restore_defaults() void DisplayDialog() { int return_value; - GtkWidget *dialog, *main_label, *main_frame, *main_box; + GtkWidget *dialog, *main_label, *adv_box; GtkWidget *default_button; ReadSettings(); @@ -97,11 +97,11 @@ void DisplayDialog() "Advanced Settings", NULL, /* parent window*/ (GtkDialogFlags)(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT), - "OK", GTK_RESPONSE_ACCEPT, "Cancel", GTK_RESPONSE_REJECT, + "OK", GTK_RESPONSE_ACCEPT, NULL); - main_label = gtk_label_new("These are advanced configuration options fine tuning time stretching behavior. Larger values are better for slowdown, while smaller values are better for speedup (more then 60 fps.). All options are in microseconds."); + main_label = gtk_label_new("These are advanced configuration options for fine tuning time stretching behavior. \nLarger values are better for slowdown, while smaller values are better for speedup (more then 60 fps.). \nAll options are in microseconds."); gtk_label_set_line_wrap(GTK_LABEL(main_label), true); default_button = gtk_button_new_with_label("Reset to Defaults"); @@ -130,23 +130,27 @@ void DisplayDialog() #endif gtk_range_set_value(GTK_RANGE(over_slide), OverlapMS); - main_box = gtk_vbox_new(false, 5); - main_frame = gtk_frame_new("Spu2-X Config"); +#if GTK_MAJOR_VERSION < 3 + adv_box = gtk_vbox_new(false, 5); +#else + adv_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5); +#endif - gtk_container_add(GTK_CONTAINER(main_box), default_button); - gtk_container_add(GTK_CONTAINER(main_box), seq_label); - gtk_container_add(GTK_CONTAINER(main_box), seq_slide); - gtk_container_add(GTK_CONTAINER(main_box), seek_label); - gtk_container_add(GTK_CONTAINER(main_box), seek_slide); - gtk_container_add(GTK_CONTAINER(main_box), over_label); - gtk_container_add(GTK_CONTAINER(main_box), over_slide); - gtk_container_add(GTK_CONTAINER(main_frame), main_box); + gtk_box_pack_start(GTK_BOX(adv_box), main_label, TRUE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(adv_box), default_button, TRUE, TRUE, 5); - gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), main_label); - gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), main_frame); - gtk_widget_show_all(dialog); + gtk_box_pack_start(GTK_BOX(adv_box), seq_label, TRUE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(adv_box), seq_slide, TRUE, TRUE, 5); + gtk_box_pack_start(GTK_BOX(adv_box), seek_label, TRUE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(adv_box), seek_slide, TRUE, TRUE, 5); + + gtk_box_pack_start(GTK_BOX(adv_box), over_label, TRUE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(adv_box), over_slide, TRUE, TRUE, 5); + + gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), adv_box); g_signal_connect_swapped(default_button, "clicked", G_CALLBACK(restore_defaults), default_button); + gtk_widget_show_all(dialog); return_value = gtk_dialog_run(GTK_DIALOG(dialog));