Extract interface IWindowCoordsTransformer from DisplayManager

This commit is contained in:
YoshiRulz 2020-12-03 17:46:34 +10:00
parent 6b30fb826c
commit 999df1b041
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
4 changed files with 46 additions and 18 deletions

View File

@ -0,0 +1,17 @@
using System.Drawing;
namespace BizHawk.Client.Common
{
public interface IWindowCoordsTransformer
{
(int Left, int Top, int Right, int Bottom) ClientExtraPadding { get; set; }
(int Left, int Top, int Right, int Bottom) GameExtraPadding { get; set; }
Size GetPanelNativeSize();
Point TransformPoint(Point p);
Point UntransformPoint(Point p);
}
}

View File

@ -4,7 +4,6 @@ using System.Drawing;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms;
using BizHawk.Client.Common; using BizHawk.Client.Common;
using BizHawk.Common; using BizHawk.Common;
@ -265,13 +264,13 @@ namespace BizHawk.Client.EmuHawk
public void SetClientExtraPadding(int left, int top, int right, int bottom) public void SetClientExtraPadding(int left, int top, int right, int bottom)
{ {
_displayManager.ClientExtraPadding = new Padding(left, top, right, bottom); _displayManager.ClientExtraPadding = (left, top, right, bottom);
_mainForm.FrameBufferResized(); _mainForm.FrameBufferResized();
} }
public void SetGameExtraPadding(int left, int top, int right, int bottom) public void SetGameExtraPadding(int left, int top, int right, int bottom)
{ {
_displayManager.GameExtraPadding = new Padding(left, top, right, bottom); _displayManager.GameExtraPadding = (left, top, right, bottom);
_mainForm.FrameBufferResized(); _mainForm.FrameBufferResized();
} }

View File

@ -30,7 +30,7 @@ namespace BizHawk.Client.EmuHawk
/// Its job is to receive OSD and emulator outputs, and produce one single buffer (BitmapBuffer? Texture2d?) for display by the PresentationPanel. /// Its job is to receive OSD and emulator outputs, and produce one single buffer (BitmapBuffer? Texture2d?) for display by the PresentationPanel.
/// Details TBD /// Details TBD
/// </summary> /// </summary>
public class DisplayManager : IDisposable public class DisplayManager : IWindowCoordsTransformer, IDisposable
{ {
private class DisplayManagerRenderTargetProvider : IRenderTargetProvider private class DisplayManagerRenderTargetProvider : IRenderTargetProvider
{ {
@ -189,15 +189,27 @@ namespace BizHawk.Client.EmuHawk
/// </summary> /// </summary>
private int _currEmuWidth, _currEmuHeight; private int _currEmuWidth, _currEmuHeight;
private Padding _clientExtraPadding;
private Padding _gameExtraPadding;
/// <summary> /// <summary>
/// additional pixels added at the unscaled level for the use of lua drawing. essentially increases the input video provider dimensions /// additional pixels added at the unscaled level for the use of lua drawing. essentially increases the input video provider dimensions
/// </summary> /// </summary>
public Padding GameExtraPadding { get; set; } public (int Left, int Top, int Right, int Bottom) GameExtraPadding
{
get => (_gameExtraPadding.Left, _gameExtraPadding.Top, _gameExtraPadding.Right, _gameExtraPadding.Bottom);
set => _gameExtraPadding = new Padding(value.Left, value.Top, value.Right, value.Bottom);
}
/// <summary> /// <summary>
/// additional pixels added at the native level for the use of lua drawing. essentially just gets tacked onto the final calculated window sizes. /// additional pixels added at the native level for the use of lua drawing. essentially just gets tacked onto the final calculated window sizes.
/// </summary> /// </summary>
public Padding ClientExtraPadding { get; set; } public (int Left, int Top, int Right, int Bottom) ClientExtraPadding
{
get => (_clientExtraPadding.Left, _clientExtraPadding.Top, _clientExtraPadding.Right, _clientExtraPadding.Bottom);
set => _clientExtraPadding = new Padding(value.Left, value.Top, value.Right, value.Bottom);
}
/// <summary> /// <summary>
/// custom fonts that don't need to be installed on the user side /// custom fonts that don't need to be installed on the user side
@ -227,7 +239,7 @@ namespace BizHawk.Client.EmuHawk
if (user) if (user)
{ {
padding += GameExtraPadding; padding += _gameExtraPadding;
} }
// an experimental feature // an experimental feature
@ -461,7 +473,7 @@ namespace BizHawk.Client.EmuHawk
return new Point((int)v.X, (int)v.Y); return new Point((int)v.X, (int)v.Y);
} }
internal Size GetPanelNativeSize() => _presentationPanel.NativeSize; public Size GetPanelNativeSize() => _presentationPanel.NativeSize;
/// <summary> /// <summary>
/// This will receive an emulated output frame from an IVideoProvider and run it through the complete frame processing pipeline /// This will receive an emulated output frame from an IVideoProvider and run it through the complete frame processing pipeline
@ -719,8 +731,8 @@ namespace BizHawk.Client.EmuHawk
chainOutsize = new Size(bufferWidth * zoom, bufferHeight * zoom); chainOutsize = new Size(bufferWidth * zoom, bufferHeight * zoom);
} }
chainOutsize.Width += ClientExtraPadding.Horizontal; chainOutsize.Width += _clientExtraPadding.Horizontal;
chainOutsize.Height += ClientExtraPadding.Vertical; chainOutsize.Height += _clientExtraPadding.Vertical;
var job = new JobInfo var job = new JobInfo
{ {
@ -1104,16 +1116,16 @@ namespace BizHawk.Client.EmuHawk
int currNativeWidth = _presentationPanel.NativeSize.Width; int currNativeWidth = _presentationPanel.NativeSize.Width;
int currNativeHeight = _presentationPanel.NativeSize.Height; int currNativeHeight = _presentationPanel.NativeSize.Height;
currNativeWidth += ClientExtraPadding.Horizontal; currNativeWidth += _clientExtraPadding.Horizontal;
currNativeHeight += ClientExtraPadding.Vertical; currNativeHeight += _clientExtraPadding.Vertical;
int width,height; int width,height;
if (name == "emu") if (name == "emu")
{ {
width = _currEmuWidth; width = _currEmuWidth;
height = _currEmuHeight; height = _currEmuHeight;
width += GameExtraPadding.Horizontal; width += _gameExtraPadding.Horizontal;
height += GameExtraPadding.Vertical; height += _gameExtraPadding.Vertical;
} }
else if (name == "native") else if (name == "native")
{ {

View File

@ -122,15 +122,15 @@ namespace BizHawk.Client.EmuHawk
DisplayManager.ClearLuaSurfaces(); DisplayManager.ClearLuaSurfaces();
if (DisplayManager.ClientExtraPadding != Padding.Empty) if (DisplayManager.ClientExtraPadding != (0, 0, 0, 0))
{ {
DisplayManager.ClientExtraPadding = new Padding(0); DisplayManager.ClientExtraPadding = (0, 0, 0, 0);
MainForm.FrameBufferResized(); MainForm.FrameBufferResized();
} }
if (DisplayManager.GameExtraPadding != Padding.Empty) if (DisplayManager.GameExtraPadding != (0, 0, 0, 0))
{ {
DisplayManager.GameExtraPadding = new Padding(0); DisplayManager.GameExtraPadding = (0, 0, 0, 0);
MainForm.FrameBufferResized(); MainForm.FrameBufferResized();
} }