Main window: Limited geometry support
This commit is contained in:
@@ -1,7 +1,9 @@
|
|||||||
|
|
||||||
# v7.0.0.4 Beta (2023-??-??)
|
# v7.0.0.4 Beta (2023-??-??)
|
||||||
|
|
||||||
- Updated manual.
|
- Limited support for the mpv option `geometry`, it supports location in percent,
|
||||||
|
for size use `autofit`. Please read the instructions in the mpv.net manual or in the conf editor.
|
||||||
|
- Updated and improved manual.
|
||||||
- mpv.net is available via command line package manager winget.
|
- mpv.net is available via command line package manager winget.
|
||||||
- New libplacebo config editor options added.
|
- New libplacebo config editor options added.
|
||||||
- The conf editor uses a newly developed combo box control (dropdown menu)
|
- The conf editor uses a newly developed combo box control (dropdown menu)
|
||||||
|
|||||||
@@ -636,14 +636,32 @@ https://mpv.io/manual/master/#window
|
|||||||
- [window-scale](https://mpv.io/manual/master/#options-window-scale)
|
- [window-scale](https://mpv.io/manual/master/#options-window-scale)
|
||||||
|
|
||||||
|
|
||||||
**Partly implemented are:**
|
**Partly implemented or modified:**
|
||||||
|
|
||||||
- [autofit-larger](https://mpv.io/manual/master/#options-autofit-larger)
|
#### --autofit=\<int\>
|
||||||
Supported is a single integer value in the range 0-100.
|
|
||||||
- [autofit-smaller](https://mpv.io/manual/master/#options-autofit-smaller)
|
\<int\> Initial window height in percent. Default: 60
|
||||||
Supported is a single integer value in the range 0-100.
|
|
||||||
- [autofit](https://mpv.io/manual/master/#options-autofit)
|
#### --autofit-smaller=\<int\>
|
||||||
Supported is a single integer value in the range 0-100.
|
|
||||||
|
\<int\> Minimum window height in percent. Default: 10
|
||||||
|
|
||||||
|
#### --autofit-larger=\<int\>
|
||||||
|
|
||||||
|
\<int\> Maximum window height in percent. Default: 80
|
||||||
|
|
||||||
|
#### --geometry\<x:y\>
|
||||||
|
|
||||||
|
Initial window location in percent. Default: 50:50 (centered)
|
||||||
|
|
||||||
|
x=0 docks the window to the left side.
|
||||||
|
x=100 docks the window to the right side.
|
||||||
|
|
||||||
|
y=0 docks the window to the top side.
|
||||||
|
y=100 docks the window to the bottom side.
|
||||||
|
|
||||||
|
|
||||||
|
**mpv.net specific window features:**
|
||||||
|
|
||||||
mpv.net specific window features are documented in the [screen section](#screen).
|
mpv.net specific window features are documented in the [screen section](#screen).
|
||||||
|
|
||||||
|
|||||||
7
src/MpvNet.Windows/Properties/launchSettings.json
Normal file
7
src/MpvNet.Windows/Properties/launchSettings.json
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"profiles": {
|
||||||
|
"MpvNet.Windows": {
|
||||||
|
"commandName": "Project"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -348,20 +348,23 @@ file = libplacebo
|
|||||||
directory = Video/libplacebo/Debanding
|
directory = Video/libplacebo/Debanding
|
||||||
help = <0.0..1000.0> Add some extra noise to the image. This significantly helps cover up remaining quantization artifacts. Higher numbers add more noise. Defaults to 4.0, which is very mild.
|
help = <0.0..1000.0> Add some extra noise to the image. This significantly helps cover up remaining quantization artifacts. Higher numbers add more noise. Defaults to 4.0, which is very mild.
|
||||||
|
|
||||||
name = deband_grain_neutral_r
|
name = sigmoid
|
||||||
file = libplacebo
|
file = libplacebo
|
||||||
directory = Video/libplacebo/Debanding
|
directory = Video/libplacebo/Sigmoidization
|
||||||
help = 'Neutral' grain value for each channel being debanded. Grain application will be modulated to avoid disturbing colors close to this value. Set this to a value corresponding to black in the relevant colorspace.
|
help = Enables sigmoidization.
|
||||||
|
default = yes
|
||||||
|
option = yes
|
||||||
|
option = no
|
||||||
|
|
||||||
name = deband_grain_neutral_g
|
name = sigmoid_center
|
||||||
file = libplacebo
|
file = libplacebo
|
||||||
directory = Video/libplacebo/Debanding
|
directory = Video/libplacebo/Sigmoidization
|
||||||
help = 'Neutral' grain value for each channel being debanded. Grain application will be modulated to avoid disturbing colors close to this value. Set this to a value corresponding to black in the relevant colorspace.
|
help = <0.0..1.0> The center (bias) of the sigmoid curve. Defaults to 0.75.
|
||||||
|
|
||||||
name = deband_grain_neutral_b
|
name = sigmoid_slope
|
||||||
file = libplacebo
|
file = libplacebo
|
||||||
directory = Video/libplacebo/Debanding
|
directory = Video/libplacebo/Sigmoidization
|
||||||
help = 'Neutral' grain value for each channel being debanded. Grain application will be modulated to avoid disturbing colors close to this value. Set this to a value corresponding to black in the relevant colorspace.
|
help = <1.0..20.0> The slope (steepness) of the sigmoid curve. Defaults to 6.5.
|
||||||
|
|
||||||
name = screenshot-directory
|
name = screenshot-directory
|
||||||
file = mpv
|
file = mpv
|
||||||
@@ -558,6 +561,16 @@ file = mpv
|
|||||||
directory = Screen
|
directory = Screen
|
||||||
help = <int> Initial window height in percent. Default: 60
|
help = <int> Initial window height in percent. Default: 60
|
||||||
|
|
||||||
|
name = autofit-smaller
|
||||||
|
file = mpv
|
||||||
|
directory = Screen
|
||||||
|
help = <int> Minimum window height in percent. Default: 10
|
||||||
|
|
||||||
|
name = autofit-larger
|
||||||
|
file = mpv
|
||||||
|
directory = Screen
|
||||||
|
help = <int> Maximum window height in percent. Default: 80
|
||||||
|
|
||||||
name = autofit-image
|
name = autofit-image
|
||||||
file = mpvnet
|
file = mpvnet
|
||||||
directory = Screen
|
directory = Screen
|
||||||
@@ -568,15 +581,10 @@ file = mpvnet
|
|||||||
directory = Screen
|
directory = Screen
|
||||||
help = <int> Initial window height in percent for audio files. Default: 70
|
help = <int> Initial window height in percent for audio files. Default: 70
|
||||||
|
|
||||||
name = autofit-smaller
|
name = geometry
|
||||||
file = mpv
|
file = mpvnet
|
||||||
directory = Screen
|
directory = Screen
|
||||||
help = <int> Minimum window height in percent. Default: 10
|
help = <x:y> Initial window location in percent. Default: 50:50 (centered)\n\nx=0 docks the window to the left side.\nx=100 docks the window to the right side.\ny=0 docks the window to the top side.\ny=100 docks the window to the bottom side.
|
||||||
|
|
||||||
name = autofit-larger
|
|
||||||
file = mpv
|
|
||||||
directory = Screen
|
|
||||||
help = <int> Maximum window height in percent. Default: 80
|
|
||||||
|
|
||||||
name = start-size
|
name = start-size
|
||||||
file = mpvnet
|
file = mpvnet
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using System.Threading;
|
|||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using System.Windows.Threading;
|
using System.Windows.Threading;
|
||||||
using System.Windows.Forms.Integration;
|
using System.Windows.Forms.Integration;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
using MpvNet.Windows.WPF;
|
using MpvNet.Windows.WPF;
|
||||||
using MpvNet.Windows.UI;
|
using MpvNet.Windows.UI;
|
||||||
@@ -506,7 +507,7 @@ public partial class MainForm : Form
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetFormPosAndSize(bool force = false, bool checkAutofit = true)
|
void SetFormPosAndSize(bool force = false, bool checkAutofit = true, bool load = false)
|
||||||
{
|
{
|
||||||
if (!force)
|
if (!force)
|
||||||
{
|
{
|
||||||
@@ -601,14 +602,14 @@ public partial class MainForm : Form
|
|||||||
height = windowSize.Height;
|
height = windowSize.Height;
|
||||||
width = windowSize.Width;
|
width = windowSize.Width;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player.WasInitialSizeSet = true;
|
Player.WasInitialSizeSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetSize(width, height, screen, checkAutofit);
|
SetSize(width, height, screen, checkAutofit, load);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetSize(int width, int height, Screen screen, bool checkAutofit = true)
|
void SetSize(int width, int height, Screen screen, bool checkAutofit = true, bool load = false)
|
||||||
{
|
{
|
||||||
Rectangle workingArea = WinApiHelp.GetWorkingArea(Handle, screen.WorkingArea);
|
Rectangle workingArea = WinApiHelp.GetWorkingArea(Handle, screen.WorkingArea);
|
||||||
|
|
||||||
@@ -655,16 +656,19 @@ public partial class MainForm : Form
|
|||||||
var rect = new Rect(new Rectangle(screen.Bounds.X, screen.Bounds.Y, width, height));
|
var rect = new Rect(new Rectangle(screen.Bounds.X, screen.Bounds.Y, width, height));
|
||||||
WinApiHelp.AddWindowBorders(Handle, ref rect, GetDpi(Handle));
|
WinApiHelp.AddWindowBorders(Handle, ref rect, GetDpi(Handle));
|
||||||
|
|
||||||
int left = middlePos.X - rect.Width / 2;
|
width = rect.Width;
|
||||||
int top = middlePos.Y - rect.Height / 2;
|
height = rect.Height;
|
||||||
|
|
||||||
|
int left = middlePos.X - width / 2;
|
||||||
|
int top = middlePos.Y - height / 2;
|
||||||
|
|
||||||
Rectangle currentRect = new Rectangle(Left, Top, Width, Height);
|
Rectangle currentRect = new Rectangle(Left, Top, Width, Height);
|
||||||
|
|
||||||
if (GetHorizontalLocation(screen) == -1) left = Left;
|
if (GetHorizontalLocation(screen) == -1) left = Left;
|
||||||
if (GetHorizontalLocation(screen) == 1) left = currentRect.Right - rect.Width;
|
if (GetHorizontalLocation(screen) == 1) left = currentRect.Right - width;
|
||||||
|
|
||||||
if (GetVerticalLocation(screen) == -1) top = Top;
|
if (GetVerticalLocation(screen) == -1) top = Top;
|
||||||
if (GetVerticalLocation(screen) == 1) top = currentRect.Bottom - rect.Height;
|
if (GetVerticalLocation(screen) == 1) top = currentRect.Bottom - height;
|
||||||
|
|
||||||
Screen[] screens = Screen.AllScreens;
|
Screen[] screens = Screen.AllScreens;
|
||||||
|
|
||||||
@@ -673,20 +677,54 @@ public partial class MainForm : Form
|
|||||||
int minTop = screens.Select(val => WinApiHelp.GetWorkingArea(Handle, val.WorkingArea).Y).Min();
|
int minTop = screens.Select(val => WinApiHelp.GetWorkingArea(Handle, val.WorkingArea).Y).Min();
|
||||||
int maxBottom = screens.Select(val => WinApiHelp.GetWorkingArea(Handle, val.WorkingArea).Bottom).Max();
|
int maxBottom = screens.Select(val => WinApiHelp.GetWorkingArea(Handle, val.WorkingArea).Bottom).Max();
|
||||||
|
|
||||||
|
if (load && App.CommandLine.Contains(" --geometry="))
|
||||||
|
{
|
||||||
|
string geometryString = Environment.GetCommandLineArgs()
|
||||||
|
.Where(i => i.StartsWith("--geometry=")).First().Substring(11);
|
||||||
|
|
||||||
|
var geometry = ParseGeometry(geometryString, WinApiHelp.GetWorkingArea(
|
||||||
|
Handle, Screen.FromHandle(Handle).WorkingArea), width, height);
|
||||||
|
|
||||||
|
if (geometry.x != int.MaxValue)
|
||||||
|
left = geometry.x;
|
||||||
|
|
||||||
|
if (geometry.y != int.MaxValue)
|
||||||
|
top = geometry.y;
|
||||||
|
}
|
||||||
|
|
||||||
if (left < minLeft)
|
if (left < minLeft)
|
||||||
left = minLeft;
|
left = minLeft;
|
||||||
|
|
||||||
if (left + rect.Width > maxRight)
|
if (left + width > maxRight)
|
||||||
left = maxRight - rect.Width;
|
left = maxRight - width;
|
||||||
|
|
||||||
if (top < minTop)
|
if (top < minTop)
|
||||||
top = minTop;
|
top = minTop;
|
||||||
|
|
||||||
if (top + rect.Height > maxBottom)
|
if (top + height > maxBottom)
|
||||||
top = maxBottom - rect.Height;
|
top = maxBottom - height;
|
||||||
|
|
||||||
uint SWP_NOACTIVATE = 0x0010;
|
uint SWP_NOACTIVATE = 0x0010;
|
||||||
SetWindowPos(Handle, IntPtr.Zero, left, top, rect.Width, rect.Height, SWP_NOACTIVATE);
|
SetWindowPos(Handle, IntPtr.Zero, left, top, width, height, SWP_NOACTIVATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
(int x, int y) ParseGeometry(string input, Rectangle workingArea, int width, int height)
|
||||||
|
{
|
||||||
|
int x = int.MaxValue;
|
||||||
|
int y = int.MaxValue;
|
||||||
|
|
||||||
|
Match match = Regex.Match(input, @"^(\d+)%?:(\d+)%?$");
|
||||||
|
|
||||||
|
if (match.Success)
|
||||||
|
{
|
||||||
|
x = int.Parse(match.Groups[1].Value);
|
||||||
|
y = int.Parse(match.Groups[2].Value);
|
||||||
|
|
||||||
|
x = workingArea.Left + Convert.ToInt32((workingArea.Width - width) / 100.0 * x);
|
||||||
|
y = workingArea.Top + Convert.ToInt32((workingArea.Height - height) / 100.0 * y);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CycleFullscreen(bool enabled)
|
public void CycleFullscreen(bool enabled)
|
||||||
@@ -1220,10 +1258,12 @@ public partial class MainForm : Form
|
|||||||
protected override void OnLoad(EventArgs e)
|
protected override void OnLoad(EventArgs e)
|
||||||
{
|
{
|
||||||
base.OnLoad(e);
|
base.OnLoad(e);
|
||||||
|
|
||||||
if (Player.GPUAPI != "vulkan")
|
if (Player.GPUAPI != "vulkan")
|
||||||
Player.VideoSizeAutoResetEvent.WaitOne(App.StartThreshold);
|
Player.VideoSizeAutoResetEvent.WaitOne(App.StartThreshold);
|
||||||
|
|
||||||
_lastCycleFullscreen = Environment.TickCount;
|
_lastCycleFullscreen = Environment.TickCount;
|
||||||
SetFormPosAndSize();
|
SetFormPosAndSize(false, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnLostFocus(EventArgs e)
|
protected override void OnLostFocus(EventArgs e)
|
||||||
|
|||||||
Reference in New Issue
Block a user