diff --git a/docs/changelog.md b/docs/changelog.md index 9a7cff3..c157453 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,7 +1,9 @@ # 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. - New libplacebo config editor options added. - The conf editor uses a newly developed combo box control (dropdown menu) diff --git a/docs/manual.md b/docs/manual.md index 732aa7a..30454f0 100644 --- a/docs/manual.md +++ b/docs/manual.md @@ -636,14 +636,32 @@ https://mpv.io/manual/master/#window - [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) - Supported is a single integer value in the range 0-100. -- [autofit-smaller](https://mpv.io/manual/master/#options-autofit-smaller) - Supported is a single integer value in the range 0-100. -- [autofit](https://mpv.io/manual/master/#options-autofit) - Supported is a single integer value in the range 0-100. +#### --autofit=\ + +\ Initial window height in percent. Default: 60 + +#### --autofit-smaller=\ + +\ Minimum window height in percent. Default: 10 + +#### --autofit-larger=\ + +\ Maximum window height in percent. Default: 80 + +#### --geometry\ + +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). diff --git a/src/MpvNet.Windows/Properties/launchSettings.json b/src/MpvNet.Windows/Properties/launchSettings.json new file mode 100644 index 0000000..4456362 --- /dev/null +++ b/src/MpvNet.Windows/Properties/launchSettings.json @@ -0,0 +1,7 @@ +{ + "profiles": { + "MpvNet.Windows": { + "commandName": "Project" + } + } +} \ No newline at end of file diff --git a/src/MpvNet.Windows/Resources/editor_conf.txt b/src/MpvNet.Windows/Resources/editor_conf.txt index 36c3e46..fb4a575 100644 --- a/src/MpvNet.Windows/Resources/editor_conf.txt +++ b/src/MpvNet.Windows/Resources/editor_conf.txt @@ -348,20 +348,23 @@ file = libplacebo 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. -name = deband_grain_neutral_r +name = sigmoid file = libplacebo -directory = Video/libplacebo/Debanding -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. +directory = Video/libplacebo/Sigmoidization +help = Enables sigmoidization. +default = yes +option = yes +option = no -name = deband_grain_neutral_g +name = sigmoid_center file = libplacebo -directory = Video/libplacebo/Debanding -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. +directory = Video/libplacebo/Sigmoidization +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 -directory = Video/libplacebo/Debanding -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. +directory = Video/libplacebo/Sigmoidization +help = <1.0..20.0> The slope (steepness) of the sigmoid curve. Defaults to 6.5. name = screenshot-directory file = mpv @@ -558,6 +561,16 @@ file = mpv directory = Screen help = Initial window height in percent. Default: 60 +name = autofit-smaller +file = mpv +directory = Screen +help = Minimum window height in percent. Default: 10 + +name = autofit-larger +file = mpv +directory = Screen +help = Maximum window height in percent. Default: 80 + name = autofit-image file = mpvnet directory = Screen @@ -568,15 +581,10 @@ file = mpvnet directory = Screen help = Initial window height in percent for audio files. Default: 70 -name = autofit-smaller -file = mpv +name = geometry +file = mpvnet directory = Screen -help = Minimum window height in percent. Default: 10 - -name = autofit-larger -file = mpv -directory = Screen -help = Maximum window height in percent. Default: 80 +help = 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 = start-size file = mpvnet diff --git a/src/MpvNet.Windows/WinForms/MainForm.cs b/src/MpvNet.Windows/WinForms/MainForm.cs index dffc6e6..e103822 100644 --- a/src/MpvNet.Windows/WinForms/MainForm.cs +++ b/src/MpvNet.Windows/WinForms/MainForm.cs @@ -6,6 +6,7 @@ using System.Threading; using System.Windows.Forms; using System.Windows.Threading; using System.Windows.Forms.Integration; +using System.Text.RegularExpressions; using MpvNet.Windows.WPF; using MpvNet.Windows.UI; @@ -506,7 +507,7 @@ public partial class MainForm : Form return null; } - void SetFormPosAndSize(bool force = false, bool checkAutofit = true) + void SetFormPosAndSize(bool force = false, bool checkAutofit = true, bool load = false) { if (!force) { @@ -601,14 +602,14 @@ public partial class MainForm : Form height = windowSize.Height; width = windowSize.Width; } - + 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); @@ -655,16 +656,19 @@ public partial class MainForm : Form var rect = new Rect(new Rectangle(screen.Bounds.X, screen.Bounds.Y, width, height)); WinApiHelp.AddWindowBorders(Handle, ref rect, GetDpi(Handle)); - int left = middlePos.X - rect.Width / 2; - int top = middlePos.Y - rect.Height / 2; + width = rect.Width; + height = rect.Height; + + int left = middlePos.X - width / 2; + int top = middlePos.Y - height / 2; Rectangle currentRect = new Rectangle(Left, Top, Width, Height); 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 = currentRect.Bottom - rect.Height; + if (GetVerticalLocation(screen) == 1) top = currentRect.Bottom - height; 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 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) left = minLeft; - if (left + rect.Width > maxRight) - left = maxRight - rect.Width; + if (left + width > maxRight) + left = maxRight - width; if (top < minTop) top = minTop; - if (top + rect.Height > maxBottom) - top = maxBottom - rect.Height; + if (top + height > maxBottom) + top = maxBottom - height; 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) @@ -1220,10 +1258,12 @@ public partial class MainForm : Form protected override void OnLoad(EventArgs e) { base.OnLoad(e); + if (Player.GPUAPI != "vulkan") Player.VideoSizeAutoResetEvent.WaitOne(App.StartThreshold); + _lastCycleFullscreen = Environment.TickCount; - SetFormPosAndSize(); + SetFormPosAndSize(false, true, true); } protected override void OnLostFocus(EventArgs e)