Skip to content

Commit

Permalink
Ensure window is above the Windows taskbar
Browse files Browse the repository at this point in the history
  • Loading branch information
BazzaCuda committed May 2, 2023
1 parent de9d3f2 commit a036c0b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions main.pas
Original file line number Diff line number Diff line change
Expand Up @@ -301,20 +301,24 @@ function TFX.clearMediaMetaData: boolean;
end;

function TFX.checkScreenLimits: boolean;
// checks whether the UI window is taller than the height of the screen and readjusts until it isn't
// checks whether the UI window is taller than the height of the screen and readjusts until it isn't.
// this can happen with some phone videos which were filmed in portrait, e.g. Vines and Tiktoks.
// Purely for completeness, we also check the width.
begin
var rect := screen.WorkAreaRect; // the screen minus the taskbar, which we assume is at the bottom of the desktop
case UI.Height > rect.bottom - rect.top of TRUE: begin
UI.width := trunc(UI.width * 0.90); // Yes, adjust the width!!...
adjustAspectRatio; // ...then let adjustAspectRatio do the rest
end;end;
end;end; // adjustAspectRatio recalls checkScreenLimits

case UI.Width > rect.right - rect.left of TRUE: begin
UI.width := trunc(UI.width * 0.90);
adjustAspectRatio;
end;end;
adjustAspectRatio; // adjustAspectRatio recalls checkScreenLimits
end;end; // until both the width and height of the window fit the screen work area dimensions

var vR: TRect;
GetWindowRect(UI.Handle, vR);
case vR.bottom > rect.bottom of TRUE: UI.top := UI.top - (vR.bottom - rect.bottom); end; // is the bottom of the window below the taskbar? Move the window up.

case GV.userMoved of FALSE: doCentreWindow; end; // re-centre the window unless the user has deliberately positioned it somewhere

Expand Down

0 comments on commit a036c0b

Please sign in to comment.