Add better border and alignment handling
This commit is contained in:
1 parent
9fce9fe962
commit
46c3353e08
8 files changed
+128
-76
No files matched your search
@@ -212,8 +212,8 @@
|
||||
<string name="TR_SCREENOVIDEO_WEBCAMDEVICES">Webcams</string>
|
||||
<string name="TR_SCREENOVIDEO_WEBCAMRESOLUTION">Webcam-Resolution</string>
|
||||
<string name="TR_SCREENOVIDEO_BUTTON_ADJUSTMENTS">Screen adjustments</string>
|
||||
<string name="TR_SCREENOVIDEOADJUSTMENTS_NOTES">Press CTR + ALT + SHIFT + Arrows to adjust screen</string>
|
||||
<string name="TR_SCREENOVIDEOADJUSTMENTS_NOTESRESET">CTR + ALT + SHIFT + 0 to reset</string>
|
||||
<string name="TR_SCREENOVIDEOADJUSTMENTS_NOTES">Press CTR + ALT (+ SHIFT) + Arrows|"+" to adjust screen</string>
|
||||
<string name="TR_SCREENOVIDEOADJUSTMENTS_NOTESRESET">CTR + ALT + 0 to reset</string>
|
||||
<string name="TR_SCREENOVIDEOADJUSTMENTS_TOPLEFT">Top left</string>
|
||||
<string name="TR_SCREENOVIDEOADJUSTMENTS_TOPRIGHT">Top right</string>
|
||||
<string name="TR_SCREENOVIDEOADJUSTMENTS_BOTTOMLEFT">Bottom left</string>
|
||||
|
||||
@@ -211,8 +211,8 @@
|
||||
<string name="TR_SCREENOVIDEO_WEBCAMDEVICES">Webcams</string>
|
||||
<string name="TR_SCREENOVIDEO_WEBCAMRESOLUTION">Webcam-Auflösung</string>
|
||||
<string name="TR_SCREENOVIDEO_BUTTON_ADJUSTMENTS">Anzeigeanpassungen</string>
|
||||
<string name="TR_SCREENOVIDEOADJUSTMENTS_NOTES">STRG + ALT + SHIFT + Pfeiltasten drücken um den Bildschirm anzupassen</string>
|
||||
<string name="TR_SCREENOVIDEOADJUSTMENTS_NOTESRESET">STRG + ALT + SHIFT + 0 um die Anpassungen zurückzusetzen</string>
|
||||
<string name="TR_SCREENOVIDEOADJUSTMENTS_NOTES">STRG + ALT (+ SHIFT) + Pfeiltasten|"+" drücken um den Bildschirm anzupassen</string>
|
||||
<string name="TR_SCREENOVIDEOADJUSTMENTS_NOTESRESET">STRG + ALT + 0 um die Anpassungen zurückzusetzen</string>
|
||||
<string name="TR_SCREENOVIDEOADJUSTMENTS_TOPLEFT">Oben links</string>
|
||||
<string name="TR_SCREENOVIDEOADJUSTMENTS_TOPRIGHT">Oben rechts</string>
|
||||
<string name="TR_SCREENOVIDEOADJUSTMENTS_BOTTOMLEFT">Unten links</string>
|
||||
|
||||
@@ -72,6 +72,8 @@ namespace Vocaluxe.Base
|
||||
public static int BorderTop;
|
||||
public static int BorderBottom;
|
||||
|
||||
public static EGeneralAlignment ScreenAlignment = EGeneralAlignment.Middle;
|
||||
|
||||
public static EAntiAliasingModes AAMode = EAntiAliasingModes.X0;
|
||||
|
||||
public static EOffOn VSync = EOffOn.TR_CONFIG_ON;
|
||||
@@ -225,6 +227,8 @@ namespace Vocaluxe.Base
|
||||
xmlReader.TryGetIntValue("//root/Graphics/ScreenW", ref ScreenW);
|
||||
xmlReader.TryGetIntValue("//root/Graphics/ScreenH", ref ScreenH);
|
||||
|
||||
xmlReader.TryGetEnumValue("//root/Graphics/ScreenAlignment", ref ScreenAlignment);
|
||||
|
||||
xmlReader.TryGetIntValue("//root/Graphics/BorderLeft", ref BorderLeft);
|
||||
xmlReader.TryGetIntValue("//root/Graphics/BorderRight", ref BorderRight);
|
||||
xmlReader.TryGetIntValue("//root/Graphics/BorderTop", ref BorderTop);
|
||||
@@ -403,6 +407,8 @@ namespace Vocaluxe.Base
|
||||
writer.WriteElementString("ScreenW", ScreenW.ToString());
|
||||
writer.WriteElementString("ScreenH", ScreenH.ToString());
|
||||
|
||||
writer.WriteElementString("ScreenAlignment", Enum.GetName(typeof(EGeneralAlignment), ScreenAlignment));
|
||||
|
||||
writer.WriteComment("Screen borders (pixels)");
|
||||
writer.WriteElementString("BorderLeft", BorderLeft.ToString());
|
||||
writer.WriteElementString("BorderRight", BorderRight.ToString());
|
||||
|
||||
+39
-16
@@ -353,32 +353,55 @@ namespace Vocaluxe.Base
|
||||
if (!eventsAvailable)
|
||||
keyEvent = inputKeyEvent;
|
||||
|
||||
if (keyEvent.IsArrowKey() || keyEvent.Key == Keys.NumPad0 || keyEvent.Key == Keys.D0)
|
||||
if (keyEvent.IsArrowKey() || keyEvent.Key == Keys.NumPad0 || keyEvent.Key == Keys.D0 || keyEvent.Key == Keys.Add)
|
||||
{
|
||||
_Cursor.Deactivate();
|
||||
|
||||
if (keyEvent.ModAlt && keyEvent.ModCtrl && keyEvent.ModShift)
|
||||
if (keyEvent.ModAlt && keyEvent.ModCtrl)
|
||||
{
|
||||
switch (keyEvent.Key)
|
||||
{
|
||||
case Keys.Left:
|
||||
CConfig.BorderLeft -= 1;
|
||||
CConfig.BorderRight -= 1;
|
||||
CConfig.BorderTop -= 1;
|
||||
CConfig.BorderBottom -= 1;
|
||||
break;
|
||||
case Keys.Right:
|
||||
CConfig.BorderLeft += 1;
|
||||
CConfig.BorderRight += 1;
|
||||
CConfig.BorderTop += 1;
|
||||
CConfig.BorderBottom += 1;
|
||||
if (keyEvent.ModShift)
|
||||
CConfig.BorderLeft++;
|
||||
else
|
||||
CConfig.BorderRight--;
|
||||
break;
|
||||
case Keys.Left:
|
||||
if (keyEvent.ModShift)
|
||||
CConfig.BorderLeft--;
|
||||
else
|
||||
CConfig.BorderRight++;
|
||||
break;
|
||||
case Keys.Down:
|
||||
if (keyEvent.ModShift)
|
||||
CConfig.BorderTop++;
|
||||
else
|
||||
CConfig.BorderBottom--;
|
||||
break;
|
||||
case Keys.Up:
|
||||
if (keyEvent.ModShift)
|
||||
CConfig.BorderTop--;
|
||||
else
|
||||
CConfig.BorderBottom++;
|
||||
break;
|
||||
case Keys.D0:
|
||||
case Keys.NumPad0:
|
||||
CConfig.BorderLeft = 0;
|
||||
CConfig.BorderRight = 0;
|
||||
CConfig.BorderTop = 0;
|
||||
CConfig.BorderBottom = 0;
|
||||
CConfig.BorderLeft = CConfig.BorderRight = CConfig.BorderTop = CConfig.BorderBottom = 0;
|
||||
break;
|
||||
case Keys.Add:
|
||||
switch (CConfig.ScreenAlignment)
|
||||
{
|
||||
case EGeneralAlignment.Middle:
|
||||
CConfig.ScreenAlignment = EGeneralAlignment.End;
|
||||
break;
|
||||
case EGeneralAlignment.End:
|
||||
CConfig.ScreenAlignment = EGeneralAlignment.Start;
|
||||
break;
|
||||
default:
|
||||
CConfig.ScreenAlignment = EGeneralAlignment.Middle;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
CConfig.SaveConfig();
|
||||
|
||||
@@ -52,11 +52,6 @@ namespace Vocaluxe.Lib.Draw
|
||||
private VertexBuffer _VertexBuffer;
|
||||
private IndexBuffer _IndexBuffer;
|
||||
|
||||
private int _H = 1;
|
||||
private int _W = 1;
|
||||
private int _Y;
|
||||
private int _X;
|
||||
|
||||
private CTexture _BlankTexture;
|
||||
|
||||
private readonly Queue<STexturedColoredVertex> _Vertices = new Queue<STexturedColoredVertex>();
|
||||
@@ -186,29 +181,14 @@ namespace Vocaluxe.Lib.Draw
|
||||
if (_Form.ClientSize.Width == 0 || _Form.ClientSize.Height == 0)
|
||||
_Form.ClientSize = _SizeBeforeMinimize;
|
||||
|
||||
int newH = _Form.ClientSize.Height;
|
||||
int newW = _Form.ClientSize.Width;
|
||||
_Y = 0;
|
||||
_X = 0;
|
||||
|
||||
if (newW / (float)newH > CSettings.GetRenderAspect())
|
||||
{
|
||||
//The windows width is too big
|
||||
newW = (int)Math.Round(newH * CSettings.GetRenderAspect());
|
||||
_X = (_Form.ClientSize.Width - newW) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
//The windows height is too big
|
||||
newH = (int)Math.Round(newW / CSettings.GetRenderAspect());
|
||||
_Y = (_Form.ClientSize.Height - newH) / 2;
|
||||
}
|
||||
|
||||
if (_H == newH && _W == newW)
|
||||
if (_H == _Form.ClientSize.Height && _W == _Form.ClientSize.Width && CConfig.ScreenAlignment == _CurrentAlignment)
|
||||
return;
|
||||
_H = newH;
|
||||
_W = newW;
|
||||
|
||||
_CurrentAlignment = CConfig.ScreenAlignment;
|
||||
_H = _Form.ClientSize.Height;
|
||||
_W = _Form.ClientSize.Width;
|
||||
|
||||
_AdjustAspect(false);
|
||||
|
||||
//Apply the new sizes to the PresentParameters
|
||||
_PresentParameters.BackBufferWidth = _Form.ClientSize.Width;
|
||||
@@ -220,7 +200,6 @@ namespace Vocaluxe.Lib.Draw
|
||||
_Reset();
|
||||
//All configurations got flushed due to Reset(), so apply them again
|
||||
_InitDevice();
|
||||
//Set the new Viewport
|
||||
_Device.Viewport = new Viewport(_X, _Y, _W, _H);
|
||||
}
|
||||
|
||||
@@ -376,10 +355,12 @@ namespace Vocaluxe.Lib.Draw
|
||||
|
||||
protected override void _AdjustNewBorders()
|
||||
{
|
||||
Matrix translate = Matrix.Translation(new Vector3(-(float)CSettings.RenderW / 2, (float)CSettings.RenderH / 2, 0));
|
||||
const float dx = (float)CSettings.RenderW / 2;
|
||||
const float dy = (float)CSettings.RenderH / 2;
|
||||
Matrix translate = Matrix.Translation(new Vector3(-dx, dy, 0));
|
||||
Matrix projection = Matrix.OrthoOffCenterLH(
|
||||
-(float)CSettings.RenderW / 2 - _BorderLeft, (float)CSettings.RenderW / 2 + _BorderRight,
|
||||
-(float)CSettings.RenderH / 2 - _BorderBottom, (float)CSettings.RenderH / 2 + _BorderTop,
|
||||
-dx - _BorderLeft, dx + _BorderRight,
|
||||
-dy - _BorderBottom, dy + _BorderTop,
|
||||
CSettings.ZNear, CSettings.ZFar);
|
||||
|
||||
if (_Device.SetTransform(TransformState.Projection, projection).IsFailure)
|
||||
|
||||
@@ -41,10 +41,16 @@ namespace Vocaluxe.Lib.Draw
|
||||
protected readonly Dictionary<int, TTextureType> _Textures = new Dictionary<int, TTextureType>();
|
||||
private readonly Queue<STextureQueue> _TexturesToLoad = new Queue<STextureQueue>();
|
||||
|
||||
protected int _H;
|
||||
protected int _W;
|
||||
protected int _Y;
|
||||
protected int _X;
|
||||
|
||||
protected int _BorderLeft;
|
||||
protected int _BorderRight;
|
||||
protected int _BorderTop;
|
||||
protected int _BorderBottom;
|
||||
protected EGeneralAlignment _CurrentAlignment = EGeneralAlignment.Middle;
|
||||
|
||||
public abstract void ClearScreen();
|
||||
protected abstract void _AdjustNewBorders();
|
||||
@@ -72,6 +78,48 @@ namespace Vocaluxe.Lib.Draw
|
||||
}
|
||||
}
|
||||
|
||||
protected void _AdjustAspect(bool reverse)
|
||||
{
|
||||
if (_W / (float)_H > CSettings.GetRenderAspect())
|
||||
{
|
||||
//The windows width is too big
|
||||
int old = _W;
|
||||
_W = (int)Math.Round(_H * CSettings.GetRenderAspect());
|
||||
int diff = old - _W;
|
||||
switch (_CurrentAlignment)
|
||||
{
|
||||
case EGeneralAlignment.Start:
|
||||
_X = 0;
|
||||
break;
|
||||
case EGeneralAlignment.Middle:
|
||||
_X = diff / 2;
|
||||
break;
|
||||
case EGeneralAlignment.End:
|
||||
_X = diff;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//The windows height is too big
|
||||
int old = _H;
|
||||
_H = (int)Math.Round(_W / CSettings.GetRenderAspect());
|
||||
int diff = old - _H;
|
||||
switch (_CurrentAlignment)
|
||||
{
|
||||
case EGeneralAlignment.Start:
|
||||
_Y = reverse ? diff : 0;
|
||||
break;
|
||||
case EGeneralAlignment.Middle:
|
||||
_Y = diff / 2;
|
||||
break;
|
||||
case EGeneralAlignment.End:
|
||||
_Y = reverse ? 0 : diff;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the next power of two if the device has the POW2 flag set
|
||||
/// </summary>
|
||||
@@ -404,6 +452,9 @@ namespace Vocaluxe.Lib.Draw
|
||||
_AdjustNewBorders();
|
||||
}
|
||||
|
||||
if (_CurrentAlignment != CConfig.ScreenAlignment)
|
||||
_DoResize();
|
||||
|
||||
if (CConfig.VSync == EOffOn.TR_CONFIG_OFF)
|
||||
{
|
||||
if (CTime.IsRunning())
|
||||
|
||||
@@ -88,18 +88,12 @@ namespace Vocaluxe.Lib.Draw
|
||||
{
|
||||
#region private vars
|
||||
private readonly GLControl _Control;
|
||||
|
||||
private int _H = 1;
|
||||
private int _W = 1;
|
||||
private int _Y;
|
||||
private int _X;
|
||||
|
||||
private bool _UsePBO;
|
||||
#endregion private vars
|
||||
|
||||
public COpenGL()
|
||||
{
|
||||
_Form = new CFormHook {ClientSize = new Size(CConfig.ScreenW, CConfig.ScreenH)};
|
||||
_Form = new CFormHook();
|
||||
|
||||
//Check AA Mode
|
||||
CConfig.AAMode = (EAntiAliasingModes)_CheckAntiAliasingMode((int)CConfig.AAMode);
|
||||
@@ -214,25 +208,10 @@ namespace Vocaluxe.Lib.Draw
|
||||
{
|
||||
_H = _Control.Height;
|
||||
_W = _Control.Width;
|
||||
_Y = 0;
|
||||
_X = 0;
|
||||
_CurrentAlignment = CConfig.ScreenAlignment;
|
||||
|
||||
if (_W / (float)_H > CSettings.GetRenderAspect())
|
||||
{
|
||||
//The windows width is too big
|
||||
_W = (int)Math.Round(_H * CSettings.GetRenderAspect());
|
||||
_X = (_Control.Width - _W) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
//The windows height is too big
|
||||
_H = (int)Math.Round(_W / CSettings.GetRenderAspect());
|
||||
_Y = (_Control.Height - _H) / 2;
|
||||
}
|
||||
|
||||
GL.MatrixMode(MatrixMode.Projection);
|
||||
GL.LoadIdentity();
|
||||
GL.Ortho(0, CSettings.RenderW, CSettings.RenderH, 0, CSettings.ZNear, CSettings.ZFar);
|
||||
_AdjustAspect(true);
|
||||
_AdjustNewBorders();
|
||||
GL.Viewport(_X, _Y, _W, _H);
|
||||
}
|
||||
|
||||
@@ -244,6 +223,9 @@ namespace Vocaluxe.Lib.Draw
|
||||
if (!base.Init())
|
||||
return false;
|
||||
|
||||
//OpenGL needs that here but D3D needs it in the constructor, so do NOT unify!
|
||||
_Form.ClientSize = new Size(CConfig.ScreenW, CConfig.ScreenH);
|
||||
|
||||
// Init Texturing
|
||||
GL.Enable(EnableCap.Texture2D);
|
||||
|
||||
@@ -288,7 +270,9 @@ namespace Vocaluxe.Lib.Draw
|
||||
|
||||
protected override void _AdjustNewBorders()
|
||||
{
|
||||
//TODO: Implement!!!
|
||||
GL.MatrixMode(MatrixMode.Projection);
|
||||
GL.LoadIdentity();
|
||||
GL.Ortho(-CConfig.BorderLeft, CConfig.BorderRight + CSettings.RenderW, CConfig.BorderBottom + CSettings.RenderH, -CConfig.BorderTop, CSettings.ZNear, CSettings.ZFar);
|
||||
}
|
||||
|
||||
public CTexture CopyScreen()
|
||||
|
||||
@@ -46,6 +46,13 @@ namespace VocaluxeLib
|
||||
Stretch
|
||||
}
|
||||
|
||||
public enum EGeneralAlignment
|
||||
{
|
||||
Middle,
|
||||
Start,
|
||||
End
|
||||
}
|
||||
|
||||
public enum EAlignment
|
||||
{
|
||||
Left,
|
||||
|
||||
Reference in new issue
Block a user