home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
MediaPortal 1
Development
General Development (no feature request here!)
Fix start in window draws offscreen and wrong aspect ratio
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="visteon" data-source="post: 205076" data-attributes="member: 58626"><p>I know most people start MP full screen.</p><p></p><p>For those of us that dont its a pain that the window is often offscreen especially with the BlueTwo Wide Skin.</p><p></p><p>I have added this code in </p><p></p><p>MediaPortal.cs</p><p></p><p>This makes sure the window client area is the same aspect ratio as the skin and the window is on screen. I have tested on two systems with both BlueTwo skins and with / without resize to skin checked.</p><p></p><p>I hope a dev will pick this up, clean it up if required and add it to the code.</p><p></p><p>Best regards to all.<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite1" alt=":)" title="Smile :)" loading="lazy" data-shortname=":)" /> </p><p></p><p>Paul </p><p></p><p>I have shown it between existing Log.Info calls to identify the section to be changed.</p><p></p><p> Log.Info("Main: Loading windowmanager");</p><p></p><p> if (splashScreen != null)</p><p> splashScreen.SetInformation("Initializing skin...");</p><p></p><p> Log.Info("Main: Resizing windowmanager");</p><p> using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml")))</p><p> {</p><p> bool autosize = xmlreader.GetValueAsBool("general", "autosize", true);</p><p> if (!GUIGraphicsContext.Fullscreen)</p><p> {</p><p> int nHBorderAllowance = this.Width - this.ClientRectangle.Width;</p><p> int nVBorderAllowance = this.Height - this.ClientRectangle.Height;</p><p> float fAspectRatio = 1.0f;</p><p> </p><p> if (GUIGraphicsContext.SkinSize.Height > 0)</p><p> {</p><p> fAspectRatio = (float)GUIGraphicsContext.SkinSize.Width / (float)GUIGraphicsContext.SkinSize.Height;</p><p> }</p><p> </p><p> if (autosize)</p><p> {</p><p> // This will set the window size as large as possible up to the skin size, limited to the desktop size by windows ? </p><p> Size = new Size(GUIGraphicsContext.SkinSize.Width + nHBorderAllowance, GUIGraphicsContext.SkinSize.Height + nVBorderAllowance);</p><p> }</p><p> else</p><p> {</p><p> //Restore aspect ratio</p><p> Size = new Size((int)((float)(this.Height - nVBorderAllowance) * fAspectRatio) + nHBorderAllowance, this.Height);</p><p> }</p><p></p><p> if (this.Width > GUIGraphicsContext.currentScreen.WorkingArea.Width || this.Height > GUIGraphicsContext.currentScreen.WorkingArea.Height)</p><p> {</p><p> Log.Info("Main: Limiting Window Size : fAspectRatio = {0}", fAspectRatio);</p><p> </p><p> //Try to fit width to working area then scale height to maintain aspect ratio</p><p> int nNewWidth = GUIGraphicsContext.currentScreen.WorkingArea.Width - nHBorderAllowance;</p><p> int nNewHeight = (int)((float)nNewWidth / fAspectRatio);</p><p></p><p> if (nNewHeight + nVBorderAllowance > GUIGraphicsContext.currentScreen.WorkingArea.Height)</p><p> {</p><p> // Height still too big</p><p> nNewHeight = GUIGraphicsContext.currentScreen.WorkingArea.Height - nVBorderAllowance;</p><p> nNewWidth = (int)((float)nNewHeight * fAspectRatio);</p><p> }</p><p> Size = new Size(nNewWidth + nHBorderAllowance, nNewHeight + nVBorderAllowance);</p><p> }</p><p> Log.Info("Main: Window Size : this.Width = {0} : Height = {1} : this.ClientRectangle.Width = {2} : Height = {3}", this.Width, this.Height, this.ClientRectangle.Width, this.ClientRectangle.Height);</p><p> //Position the window within the working area</p><p> if (this.Right > GUIGraphicsContext.currentScreen.WorkingArea.Right)</p><p> {</p><p> this.Left = GUIGraphicsContext.currentScreen.WorkingArea.Right - this.Width;</p><p> }</p><p> if (this.Left < GUIGraphicsContext.currentScreen.WorkingArea.Left)</p><p> {</p><p> this.Left = GUIGraphicsContext.currentScreen.WorkingArea.Left;</p><p> }</p><p> if (this.Bottom > GUIGraphicsContext.currentScreen.WorkingArea.Bottom)</p><p> {</p><p> this.Top = GUIGraphicsContext.currentScreen.WorkingArea.Bottom - this.Height;</p><p> }</p><p> if (this.Top < GUIGraphicsContext.currentScreen.WorkingArea.Top)</p><p> {</p><p> this.Top = GUIGraphicsContext.currentScreen.WorkingArea.Top;</p><p> }</p><p> }</p><p> else</p><p> {</p><p> GUIGraphicsContext.Load();</p><p> GUIWindowManager.OnResize();</p><p> }</p><p> }</p><p></p><p> Log.Info("Main: Initializing windowmanager");</p></blockquote><p></p>
[QUOTE="visteon, post: 205076, member: 58626"] I know most people start MP full screen. For those of us that dont its a pain that the window is often offscreen especially with the BlueTwo Wide Skin. I have added this code in MediaPortal.cs This makes sure the window client area is the same aspect ratio as the skin and the window is on screen. I have tested on two systems with both BlueTwo skins and with / without resize to skin checked. I hope a dev will pick this up, clean it up if required and add it to the code. Best regards to all.:) Paul I have shown it between existing Log.Info calls to identify the section to be changed. Log.Info("Main: Loading windowmanager"); if (splashScreen != null) splashScreen.SetInformation("Initializing skin..."); Log.Info("Main: Resizing windowmanager"); using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml"))) { bool autosize = xmlreader.GetValueAsBool("general", "autosize", true); if (!GUIGraphicsContext.Fullscreen) { int nHBorderAllowance = this.Width - this.ClientRectangle.Width; int nVBorderAllowance = this.Height - this.ClientRectangle.Height; float fAspectRatio = 1.0f; if (GUIGraphicsContext.SkinSize.Height > 0) { fAspectRatio = (float)GUIGraphicsContext.SkinSize.Width / (float)GUIGraphicsContext.SkinSize.Height; } if (autosize) { // This will set the window size as large as possible up to the skin size, limited to the desktop size by windows ? Size = new Size(GUIGraphicsContext.SkinSize.Width + nHBorderAllowance, GUIGraphicsContext.SkinSize.Height + nVBorderAllowance); } else { //Restore aspect ratio Size = new Size((int)((float)(this.Height - nVBorderAllowance) * fAspectRatio) + nHBorderAllowance, this.Height); } if (this.Width > GUIGraphicsContext.currentScreen.WorkingArea.Width || this.Height > GUIGraphicsContext.currentScreen.WorkingArea.Height) { Log.Info("Main: Limiting Window Size : fAspectRatio = {0}", fAspectRatio); //Try to fit width to working area then scale height to maintain aspect ratio int nNewWidth = GUIGraphicsContext.currentScreen.WorkingArea.Width - nHBorderAllowance; int nNewHeight = (int)((float)nNewWidth / fAspectRatio); if (nNewHeight + nVBorderAllowance > GUIGraphicsContext.currentScreen.WorkingArea.Height) { // Height still too big nNewHeight = GUIGraphicsContext.currentScreen.WorkingArea.Height - nVBorderAllowance; nNewWidth = (int)((float)nNewHeight * fAspectRatio); } Size = new Size(nNewWidth + nHBorderAllowance, nNewHeight + nVBorderAllowance); } Log.Info("Main: Window Size : this.Width = {0} : Height = {1} : this.ClientRectangle.Width = {2} : Height = {3}", this.Width, this.Height, this.ClientRectangle.Width, this.ClientRectangle.Height); //Position the window within the working area if (this.Right > GUIGraphicsContext.currentScreen.WorkingArea.Right) { this.Left = GUIGraphicsContext.currentScreen.WorkingArea.Right - this.Width; } if (this.Left < GUIGraphicsContext.currentScreen.WorkingArea.Left) { this.Left = GUIGraphicsContext.currentScreen.WorkingArea.Left; } if (this.Bottom > GUIGraphicsContext.currentScreen.WorkingArea.Bottom) { this.Top = GUIGraphicsContext.currentScreen.WorkingArea.Bottom - this.Height; } if (this.Top < GUIGraphicsContext.currentScreen.WorkingArea.Top) { this.Top = GUIGraphicsContext.currentScreen.WorkingArea.Top; } } else { GUIGraphicsContext.Load(); GUIWindowManager.OnResize(); } } Log.Info("Main: Initializing windowmanager"); [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 1
Development
General Development (no feature request here!)
Fix start in window draws offscreen and wrong aspect ratio
Contact us
RSS
Top
Bottom