GUI: when the config panel is open, and using keyboard shortcuts for frame-limiter (F4) or aspect-ratio (F6), reflect it at the GUI, but ONLY if there are no intermediate changes at the GUI (i.e., only if the "Apply" button is currently disabled). This would prevent re-applying obsolete values when clicking Apply/OK for for these two configs (after they were changed via KB while the GUI was open).

This is a very light infrastructure to allow some synchronization between KB shortcuts and the GUI. Currently only used for frame limiter and aspect ratio KB shortcuts. I wanted to also use it with frame-skipping (shift-F4), however, frame skipping GUI seem to have other issues which prevent it from properly reflecting KB modifications, so it's out for now.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4627 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
avihal@gmail.com 2011-05-06 12:46:58 +00:00
parent 03d288cc93
commit 3523626462
7 changed files with 41 additions and 11 deletions

View File

@ -737,3 +737,5 @@ extern void UI_DisableSysShutdown();
pxAssertMsg( !wxGetApp().SysExecutorThread.IsSelf(), "Thread affinity violation: Call is *not* allowed from SysExecutor thread." ) pxAssertMsg( !wxGetApp().SysExecutorThread.IsSelf(), "Thread affinity violation: Call is *not* allowed from SysExecutor thread." )
extern ExecutorThread& GetSysExecutorThread(); extern ExecutorThread& GetSysExecutorThread();
extern bool g_ConfigPanelChanged; //Indicates that the main config panel is open and holds unapplied changes.

View File

@ -87,6 +87,8 @@ struct GlobalCommandDescriptor
const wxChar* Fullname; // Name displayed in pulldown menus const wxChar* Fullname; // Name displayed in pulldown menus
const wxChar* Tooltip; // text displayed in toolbar tooltips and menu status bars. const wxChar* Tooltip; // text displayed in toolbar tooltips and menu status bars.
bool AlsoApplyToGui; // Indicates that the GUI should be updated if possible.
int ToolbarIconId; // not implemented yet, leave 0 for now. int ToolbarIconId; // not implemented yet, leave 0 for now.
}; };

View File

@ -187,6 +187,7 @@ void Dialogs::BaseConfigurationDialog::AddOkCancel( wxSizer* sizer )
{ {
_parent::AddOkCancel( sizer, true ); _parent::AddOkCancel( sizer, true );
if( wxWindow* apply = FindWindow( wxID_APPLY ) ) apply->Disable(); if( wxWindow* apply = FindWindow( wxID_APPLY ) ) apply->Disable();
SomethingChanged_StateModified_IsChanged();
wxBitmapButton& screenshotButton( *new wxBitmapButton( this, wxID_SAVE, EmbeddedImage<res_ButtonIcon_Camera>().Get() ) ); wxBitmapButton& screenshotButton( *new wxBitmapButton( this, wxID_SAVE, EmbeddedImage<res_ButtonIcon_Camera>().Get() ) );
screenshotButton.SetToolTip( _("Saves a snapshot of this settings panel to a PNG file.") ); screenshotButton.SetToolTip( _("Saves a snapshot of this settings panel to a PNG file.") );
@ -217,6 +218,7 @@ void Dialogs::BaseConfigurationDialog::OnSetSettingsPage( wxCommandEvent& evt )
void Dialogs::BaseConfigurationDialog::SomethingChanged() void Dialogs::BaseConfigurationDialog::SomethingChanged()
{ {
if( wxWindow* apply = FindWindow( wxID_APPLY ) ) apply->Enable(); if( wxWindow* apply = FindWindow( wxID_APPLY ) ) apply->Enable();
SomethingChanged_StateModified_IsChanged();
} }
void Dialogs::BaseConfigurationDialog::OnSomethingChanged( wxCommandEvent& evt ) void Dialogs::BaseConfigurationDialog::OnSomethingChanged( wxCommandEvent& evt )
@ -250,6 +252,7 @@ void Dialogs::BaseConfigurationDialog::OnOk_Click( wxCommandEvent& evt )
if( m_ApplyState.ApplyAll() ) if( m_ApplyState.ApplyAll() )
{ {
if( wxWindow* apply = FindWindow( wxID_APPLY ) ) apply->Disable(); if( wxWindow* apply = FindWindow( wxID_APPLY ) ) apply->Disable();
SomethingChanged_StateModified_IsChanged();
if( m_listbook ) GetConfSettingsTabName() = m_labels[m_listbook->GetSelection()]; if( m_listbook ) GetConfSettingsTabName() = m_labels[m_listbook->GetSelection()];
AppSaveSettings(); AppSaveSettings();
disabler.DetachAll(); disabler.DetachAll();
@ -272,6 +275,8 @@ void Dialogs::BaseConfigurationDialog::OnApply_Click( wxCommandEvent& evt )
if( m_listbook ) GetConfSettingsTabName() = m_labels[m_listbook->GetSelection()]; if( m_listbook ) GetConfSettingsTabName() = m_labels[m_listbook->GetSelection()];
AppSaveSettings(); AppSaveSettings();
SomethingChanged_StateModified_IsChanged();
} }
//avih: FIXME: ? for some reason, this OnCancel_Click is called twice when clicking cancel or closing the dialog (Jake's code?). //avih: FIXME: ? for some reason, this OnCancel_Click is called twice when clicking cancel or closing the dialog (Jake's code?).

View File

@ -20,6 +20,7 @@
#include "AppCommon.h" #include "AppCommon.h"
#include "ApplyState.h" #include "ApplyState.h"
#include "App.h"
namespace Panels namespace Panels
{ {
@ -62,6 +63,11 @@ namespace Dialogs
void AddPage( const wxChar* label, int iconid ); void AddPage( const wxChar* label, int iconid );
void AllowApplyActivation( bool allow=true ); void AllowApplyActivation( bool allow=true );
virtual bool SomethingChanged_StateModified_IsChanged(){ //returns the state of the apply button.
if( wxWindow* apply = FindWindow( wxID_APPLY ) )
return apply->IsEnabled();
return false;
}
protected: protected:
void OnSettingsApplied( wxCommandEvent& evt ); void OnSettingsApplied( wxCommandEvent& evt );
@ -94,6 +100,12 @@ namespace Dialogs
void Apply(); void Apply();
void Cancel(); void Cancel();
//Stores the state of the apply button in a global var.
//This var will be used by KB shortcuts commands to decide if the gui should be modified (only when no intermediate changes)
virtual bool SomethingChanged_StateModified_IsChanged(){
return g_ConfigPanelChanged = BaseConfigurationDialog::SomethingChanged_StateModified_IsChanged();
}
protected: protected:
virtual wxString& GetConfSettingsTabName() const { return g_Conf->SysSettingsTabName; } virtual wxString& GetConfSettingsTabName() const { return g_Conf->SysSettingsTabName; }

View File

@ -307,3 +307,5 @@ void AppearanceThemesPanel::AppStatusEvent_OnSettingsApplied()
{ {
} }
bool g_ConfigPanelChanged = false;

View File

@ -222,6 +222,9 @@ void GSPanel::DirectKeyCommand( const KeyAcceleratorCode& kac )
DbgCon.WriteLn( "(gsFrame) Invoking command: %s", cmd->Id ); DbgCon.WriteLn( "(gsFrame) Invoking command: %s", cmd->Id );
cmd->Invoke(); cmd->Invoke();
if( cmd->AlsoApplyToGui && !g_ConfigPanelChanged)
AppApplySettings();
} }
void GSPanel::DirectKeyCommand( wxKeyEvent& evt ) void GSPanel::DirectKeyCommand( wxKeyEvent& evt )

View File

@ -16,6 +16,8 @@
#include "PrecompiledHeader.h" #include "PrecompiledHeader.h"
#include "MainFrame.h" #include "MainFrame.h"
#include "GSFrame.h" #include "GSFrame.h"
#include "ApplyState.h"
#include "AppAccelerators.h" #include "AppAccelerators.h"
#include "AppSaveStates.h" #include "AppSaveStates.h"
@ -161,6 +163,16 @@ namespace Implementations
pauser.AllowResume(); pauser.AllowResume();
} }
void UpdateImagePosition()
{
//AppApplySettings() would have been nicer, since it also immidiately affects the GUI (if open).
//However, the events sequence it generates also "depresses" Shift/CTRL/etc, so consecutive zoom with CTRL down breaks.
//Since zoom only affects the window viewport anyway, we can live with directly calling it.
if (GSFrame* gsFrame = wxGetApp().GetGsFramePtr())
if (GSPanel* woot = gsFrame->GetViewport())
woot->DoResize();
}
void GSwindow_CycleAspectRatio() void GSwindow_CycleAspectRatio()
{ {
AspectRatioType& art = g_Conf->GSWindow.AspectRatio; AspectRatioType& art = g_Conf->GSWindow.AspectRatio;
@ -173,17 +185,7 @@ namespace Implementations
} }
Console.WriteLn(L"(GSwindow) Aspect ratio: %s.", arts.c_str()); Console.WriteLn(L"(GSwindow) Aspect ratio: %s.", arts.c_str());
AppApplySettings(); UpdateImagePosition();
}
void UpdateImagePosition()
{
//AppApplySettings() would have been nicer, since it also immidiately affects the GUI (if open).
//However, the events sequence it generates also "depresses" Shift/CTRL/etc, so consecutive zoom with CTRL down breaks.
//Since zoom only affects the window viewport anyway, we can live with directly calling it.
if (GSFrame* gsFrame = wxGetApp().GetGsFramePtr())
if (GSPanel* woot = gsFrame->GetViewport())
woot->DoResize();
} }
void SetOffset(float x, float y) void SetOffset(float x, float y)
@ -432,12 +434,14 @@ static const GlobalCommandDescriptor CommandDeclarations[] =
Implementations::Framelimiter_MasterToggle, Implementations::Framelimiter_MasterToggle,
NULL, NULL,
NULL, NULL,
true,
}, },
{ "GSwindow_CycleAspectRatio", { "GSwindow_CycleAspectRatio",
Implementations::GSwindow_CycleAspectRatio, Implementations::GSwindow_CycleAspectRatio,
NULL, NULL,
NULL, NULL,
true,
}, },
{ "GSwindow_ZoomIn", { "GSwindow_ZoomIn",