Monday, August 17, 2020

Lock the Window

We want to give developers the ability to lock the size of a GWindow. When a window is locked, the user will not be able to alter the window's size in any way. Moving around the window and minimizing it is still possible, but maximizing the window and adjusting the size is not. The goal of this feature is to give developers more control over how their users experience their content.

Why lock the window
There are plenty of reasons why a developer might want to lock the size of a window: 

  • Prevent the user from seeing non rendered areas of the screen.
  • Prevent distortion of the graphics due to aspect ratio.
  • Save development time instead of creating a resolution-independent HUD.


Feature goals

Changing the configuration style of a GWindow can already be done by passing a GWindowStyle flag to either the Create() or ReconfigureWindow() functions. Activating the lock feature will be done the same way by using a new flag, WindowedLocked. The naming of this flag conforms to the naming conventions of the other GWindow flags. As the other flags do so succinctly, the new flag is named to describe the state the window will be in when the flag is used. In this case, the GWindow will become windowed (not fullscreen or minimized), and the resizing ability will be locked from the user.


Current flags

Each existing flag has a different effect on a GWindow. To understand how the new flag will differentiate from the other flags, I created a window using each of them and took notes.

  • WindowedBordered: Makes a resizable window with a title bar and border.
  • WindowedBorderless: Makes a non-resizable window without a title bar or border.
  • FullscreenBordered: Fills the screen with a resizable window, including a title bar and border.
  • FullscreenBorderless: Fills the screen with a non-resizable window without a title bar or border.
  • Minimized: Makes a window that starts minimized

Looking at how the existing flags change a window, it is already possible to create a non-resizable window using one of the two borderless flags. The real need for the flag is to have a non-resizable bordered style window. For that reason, I made the WindowedLocked flag do everything to a window that the WindowedBordered flag does, except without making the window resizable of course.


Linux implementation

Implementing this feature is different on each platform, but there are similarities. On Windows, combining certain WinAPI flags will create a bordered window that cannot be resized. The Mac implementation is done very much the same way. On Linux though, instead of setting flags, the window's minimum and maximum sizes are adjusted to match the window's size. This prevents the window from being resized. This way of restricting the window's size is odd compared to the other two platforms. 


The cursor will change to a resize cursor when it reaches the edge of the window, but the window won't resize when the mouse drags the edge. Instead, the entire window moves with the mouse.

Locked

The new feature to lock the window is complete. When you have limited time to make an game, you don't want to spend more than a few minutes figuring this out. With just one flag, developers now have even more control over the games they make. 

No comments:

Post a Comment