From 2bbaa30322e95c8ebc86e595b9854de80139f1aa Mon Sep 17 00:00:00 2001 From: Frank Skare Date: Sun, 21 Jul 2019 19:22:17 +0200 Subject: [PATCH] options autofit-smaller, autofit-larger added --- Changelog.md | 21 +++++++++++++++------ README.md | 18 ++++++++++++------ mpv.net/Resources/mpvConfToml.txt | 13 +++++++++++-- mpv.net/WinForms/MainForm.cs | 30 ++++++++++++++++++++++++++---- mpv.net/mpv/mp.cs | 15 ++++++++++++--- 5 files changed, 76 insertions(+), 21 deletions(-) diff --git a/Changelog.md b/Changelog.md index dc309e2..e5244e2 100644 --- a/Changelog.md +++ b/Changelog.md @@ -4,12 +4,21 @@ WPF was returning a bad color on Win 7, this was fixed by reading the theme color from the Registry on Win 7. If the theme color is identical to the background color it's corrected -- new option dark-color was added to overwrite the OS theme color used in dark mode, find the option under 'General' -- new option light-color was added to overwrite the OS theme color used in non dark mode, find the option under 'General' -- various changes regarding input handling -- it's now possible to use a custom folder as config folder -- slightly increased startup performance -- start-threshold setting added. Threshold in milliseconds to wait for libmpv returning the video resolution before the window is shown, otherwise default dimensions are used as defined by autofit and start-size. Default: 1500 +- dark-color setting was added to overwrite the OS theme color used in dark mode, + find the setting on the General tab +- light-color setting was added to overwrite the OS theme color used in non dark mode, + find the setting on the General tab +- various changes regarding input handling, multi media keys and + mouse forward/backward were tested on my system +- it's now possible to use a custom folder as config folder, + TaskDialog shows five options: 1. appdata mpv.net, 2. appdata mpv (shared with mpv), + 3. portable_config, 4. startup, 5. custom +- slightly increased startup performance, start-threshold setting added. + Threshold in milliseconds to wait for libmpv returning the video resolution + before the window is shown, otherwise default dimensions are used as defined + by autofit and start-size. Default: 1500 +- autofit-smaller setting added. Minimum window height in percent. Default: 40% +- autofit-larger setting added. Maximum window height in percent. Default: 75% ### 4.7.3 diff --git a/README.md b/README.md index ffe39b8..b190fcd 100644 --- a/README.md +++ b/README.md @@ -138,24 +138,30 @@ input.conf defines mpv's key and mouse bindings and mpv.net uses comments to def mpv.net is able to share the settings with mpv. -If a directory named portable_config next to the mpvnet.exe exists, all config will be loaded from this directory only. +If a directory named portable_config next to the mpvnet.exe exists, +all config will be loaded from this directory only. ```Text \portable_config\ ``` -On first start if no portable config folder exists mpv.net asks which folder should be used as config folder. +On first start if no portable config folder exists mpv.net asks +which folder should be used as config folder. -If no mpv.conf file exists mpv.net generates it with the following defaults: +mpv specific settings are stored in the file mpv.conf, if no mpv.conf file exists +mpv.net generates it with the following defaults: -The key bindings and the context menu definitions are stored in the input.conf file, -if it's missing mpv.net generates it with the following defaults: +mpv.net specific settings are stored in the file mpvnet.conf + +The input (key/mouse) bindings and the context menu definitions are stored in the +input.conf file, if it's missing mpv.net generates it with the following defaults: -mpv.net supports almost all mpv settings and features, [limitations are listed in the wiki](https://github.com/stax76/mpv.net/wiki/Limitations). +mpv.net supports almost all mpv settings and features, +[limitations are listed in the wiki](https://github.com/stax76/mpv.net/wiki/Limitations). ### Scripting diff --git a/mpv.net/Resources/mpvConfToml.txt b/mpv.net/Resources/mpvConfToml.txt index 16c80f9..71f23f8 100644 --- a/mpv.net/Resources/mpvConfToml.txt +++ b/mpv.net/Resources/mpvConfToml.txt @@ -250,9 +250,18 @@ help = "Store screenshots in this directory. This path is joined with the filena [[settings]] name = "autofit" -default = "50%" filter = "Screen" -help = "Set the initial window size in percent. Please note that this setting is only partly implemented in mpv.net, accepted are only integer values with percent sign added. Default: 50%" +help = " Initial window height in percent. Default: 50%" + +[[settings]] +name = "autofit-smaller" +filter = "Screen" +help = " Minimum window height in percent. Default: 40%" + +[[settings]] +name = "autofit-larger" +filter = "Screen" +help = " Maximum window height in percent. Default: 75%" [[settings]] name = "keep-open-pause" diff --git a/mpv.net/WinForms/MainForm.cs b/mpv.net/WinForms/MainForm.cs index 90cd96a..63296e4 100644 --- a/mpv.net/WinForms/MainForm.cs +++ b/mpv.net/WinForms/MainForm.cs @@ -236,7 +236,7 @@ namespace mpvnet } Screen screen = Screen.FromControl(this); - int autoFitHeight = Convert.ToInt32(screen.Bounds.Height * mp.Autofit); + int autoFitHeight = Convert.ToInt32(screen.WorkingArea.Height * mp.Autofit); if (mp.VideoSize.Height == 0 || mp.VideoSize.Width == 0 || mp.VideoSize.Width / (float)mp.VideoSize.Height < 1.3) @@ -258,10 +258,32 @@ namespace mpvnet } } - if (height > screen.Bounds.Height * 0.9) - height = autoFitHeight; - int width = Convert.ToInt32(height * size.Width / (double)size.Height); + + if (height > screen.WorkingArea.Height * 0.9) + { + height = Convert.ToInt32(screen.WorkingArea.Height * 0.9); + width = Convert.ToInt32(height * size.Width / (double)size.Height); + } + + if (width > screen.WorkingArea.Width * 0.9) + { + width = Convert.ToInt32(screen.WorkingArea.Width * 0.9); + height = Convert.ToInt32(width * size.Height / (double)size.Width); + } + + if (height < screen.WorkingArea.Height * mp.AutofitSmaller) + { + height = Convert.ToInt32(screen.WorkingArea.Height * mp.AutofitSmaller); + width = Convert.ToInt32(height * size.Width / (double)size.Height); + } + + if (height > screen.WorkingArea.Height * mp.AutofitLarger) + { + height = Convert.ToInt32(screen.WorkingArea.Height * mp.AutofitLarger); + width = Convert.ToInt32(height * size.Width / (double)size.Height); + } + Point middlePos = new Point(Left + Width / 2, Top + Height / 2); var rect = new Native.RECT(new Rectangle(screen.Bounds.X, screen.Bounds.Y, width, height)); NativeHelp.AddWindowBorders(Handle, ref rect); diff --git a/mpv.net/mpv/mp.cs b/mpv.net/mpv/mp.cs index 051ab2c..d41c211 100644 --- a/mpv.net/mpv/mp.cs +++ b/mpv.net/mpv/mp.cs @@ -81,6 +81,8 @@ namespace mpvnet public static int Edition { get; set; } public static float Autofit { get; set; } = 0.5f; + public static float AutofitSmaller { get; set; } = 0.4f; + public static float AutofitLarger { get; set; } = 0.75f; public static void Init() { @@ -105,9 +107,16 @@ namespace mpvnet switch (name) { case "autofit": - if (value.Length == 3 && value.EndsWith("%")) - if (int.TryParse(value.Substring(0, 2), out int result)) - Autofit = result / 100f; + if (int.TryParse(value.Trim('%'), out int result)) + Autofit = result / 100f; + break; + case "autofit-smaller": + if (int.TryParse(value.Trim('%'), out int result2)) + AutofitSmaller = result2 / 100f; + break; + case "autofit-larger": + if (int.TryParse(value.Trim('%'), out int result3)) + AutofitLarger = result3 / 100f; break; case "fs": case "fullscreen": Fullscreen = value == "yes"; break;