GS window: allow full manual image control (had zoom already, now adding move, stretch).

The following controls are KB only (no GUI) and they don't save nor load from the ini (thus always reset when starting pcsx2).
New KB commands:
Move image: CTRL + NUMPAD 8/2/4/6 for up/down/left/right. CTRL + NUMPAD 5 resets to center.
Vertical stretch: CTRL+ALT+ NUMPAD PLUS/MINUS/* for stretch/shrink/reset.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4537 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
avihal@gmail.com 2011-04-06 15:54:15 +00:00
parent e307c7d9c5
commit b4d0eddc7c
4 changed files with 101 additions and 7 deletions

View File

@ -713,6 +713,9 @@ AppConfig::GSWindowOptions::GSWindowOptions()
AspectRatio = AspectRatio_4_3;
Zoom = 100;
StretchY = 100;
OffsetX = 0;
OffsetY = 0;
WindowSize = wxSize( 640, 480 );
WindowPos = wxDefaultPosition;

View File

@ -190,6 +190,10 @@ public:
AspectRatioType AspectRatio;
Fixed100 Zoom;
Fixed100 StretchY;
Fixed100 OffsetX;
Fixed100 OffsetY;
wxSize WindowSize;
wxPoint WindowPos;

View File

@ -51,6 +51,16 @@ void GSPanel::InitDefaultAccelerators()
m_Accels->Map( AAC( WXK_NUMPAD_SUBTRACT ).Cmd(), "GSwindow_ZoomOut" );
m_Accels->Map( AAC( WXK_NUMPAD_MULTIPLY ).Cmd(), "GSwindow_ZoomToggle" );
m_Accels->Map( AAC( WXK_NUMPAD_ADD ).Cmd().Alt(), "GSwindow_ZoomInY" ); //CTRL on Windows (probably linux too), CMD on OSX
m_Accels->Map( AAC( WXK_NUMPAD_SUBTRACT ).Cmd().Alt(), "GSwindow_ZoomOutY" );
m_Accels->Map( AAC( WXK_NUMPAD_MULTIPLY ).Cmd().Alt(), "GSwindow_ZoomResetY" );
m_Accels->Map( AAC( WXK_NUMPAD8 ).Cmd(), "GSwindow_OffsetYminus" );
m_Accels->Map( AAC( WXK_NUMPAD2 ).Cmd(), "GSwindow_OffsetYplus" );
m_Accels->Map( AAC( WXK_NUMPAD4 ).Cmd(), "GSwindow_OffsetXminus" );
m_Accels->Map( AAC( WXK_NUMPAD6 ).Cmd(), "GSwindow_OffsetXplus" );
m_Accels->Map( AAC( WXK_NUMPAD5 ).Cmd(), "GSwindow_OffsetReset" );
m_Accels->Map( AAC( WXK_ESCAPE ), "Sys_Suspend" );
m_Accels->Map( AAC( WXK_F8 ), "Sys_TakeSnapshot" );
m_Accels->Map( AAC( WXK_F8 ).Shift(), "Sys_TakeSnapshot");
@ -131,6 +141,9 @@ void GSPanel::DoResize()
wxSize client = GetParent()->GetClientSize();
wxSize viewport = client;
if ( !client.GetHeight() || !client.GetWidth() )
return;
double clientAr = (double)client.GetWidth()/(double)client.GetHeight();
double targetAr = clientAr;
@ -150,9 +163,14 @@ void GSPanel::DoResize()
if( zoom == 0 )//auto zoom in untill black-bars are gone (while keeping the aspect ratio).
zoom = max( (float)arr, (float)(1.0/arr) );
viewport.Scale(zoom, zoom);
viewport.Scale(zoom, zoom*g_Conf->GSWindow.StretchY.ToFloat()/100.0 );
SetSize( viewport );
CenterOnParent();
int cx, cy;
GetPosition(&cx, &cy);
float unit = .01*(float)min(viewport.x, viewport.y);
SetPosition( wxPoint( cx + unit*g_Conf->GSWindow.OffsetX.ToFloat(), cy + unit*g_Conf->GSWindow.OffsetY.ToFloat() ) );
}
void GSPanel::OnResize(wxSizeEvent& event)

View File

@ -176,6 +176,69 @@ namespace Implementations
AppApplySettings();
}
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)
{
g_Conf->GSWindow.OffsetX = x;
g_Conf->GSWindow.OffsetY = y;
Console.WriteLn(L"GSwindow: set offset: x=%f, y=%f", x,y);
UpdateImagePosition();
}
void GSwindow_OffsetYplus(){
SetOffset(g_Conf->GSWindow.OffsetX.ToFloat(), g_Conf->GSWindow.OffsetY.ToFloat()+1);
}
void GSwindow_OffsetYminus(){
SetOffset(g_Conf->GSWindow.OffsetX.ToFloat(), g_Conf->GSWindow.OffsetY.ToFloat()-1);
}
void GSwindow_OffsetXplus(){
SetOffset(g_Conf->GSWindow.OffsetX.ToFloat()+1, g_Conf->GSWindow.OffsetY.ToFloat());
}
void GSwindow_OffsetXminus(){
SetOffset(g_Conf->GSWindow.OffsetX.ToFloat()-1, g_Conf->GSWindow.OffsetY.ToFloat());
}
void GSwindow_OffsetReset(){
SetOffset(0,0);
}
void SetZoomY(float zoom)
{
if( zoom <= 0 )
return;
g_Conf->GSWindow.StretchY = zoom;
Console.WriteLn(L"GSwindow: set vertical sterctch: %f", zoom);
UpdateImagePosition();
}
void GSwindow_ZoomInY()
{
SetZoomY( g_Conf->GSWindow.StretchY.ToFloat()+1 );
}
void GSwindow_ZoomOutY()
{
SetZoomY( g_Conf->GSWindow.StretchY.ToFloat()-1 );
}
void GSwindow_ZoomResetY()
{
SetZoomY( 100 );
}
void SetZoom(float zoom)
{
if( zoom < 0 )
@ -183,12 +246,7 @@ namespace Implementations
g_Conf->GSWindow.Zoom = zoom;
Console.WriteLn(L"GSwindow: set zoom: %f", zoom);
//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();
UpdateImagePosition();
}
@ -215,6 +273,7 @@ namespace Implementations
SetZoom( z );
}
void Sys_Suspend()
{
CoreThread.Suspend();
@ -395,6 +454,16 @@ static const GlobalCommandDescriptor CommandDeclarations[] =
NULL,
},
{ "GSwindow_ZoomInY", Implementations::GSwindow_ZoomInY, NULL, NULL, },
{ "GSwindow_ZoomOutY", Implementations::GSwindow_ZoomOutY, NULL, NULL, },
{ "GSwindow_ZoomResetY", Implementations::GSwindow_ZoomResetY, NULL, NULL, },
{ "GSwindow_OffsetYminus", Implementations::GSwindow_OffsetYminus, NULL, NULL, },
{ "GSwindow_OffsetYplus", Implementations::GSwindow_OffsetYplus, NULL, NULL, },
{ "GSwindow_OffsetXminus", Implementations::GSwindow_OffsetXminus, NULL, NULL, },
{ "GSwindow_OffsetXplus", Implementations::GSwindow_OffsetXplus, NULL, NULL, },
{ "GSwindow_OffsetReset", Implementations::GSwindow_OffsetReset, NULL, NULL, },
{ "Sys_Suspend",
Implementations::Sys_Suspend,
NULL,