Skip to content

Commit

Permalink
Add IsMinimizedEXT and IsMaximizedEXT
Browse files Browse the repository at this point in the history
  • Loading branch information
kg committed Dec 20, 2024
1 parent 1ab39b6 commit 0012766
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/FNAPlatform/FNAPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ static FNAPlatform()
SetWindowResizable = SDL3_FNAPlatform.SetWindowResizable;
GetWindowBorderless = SDL3_FNAPlatform.GetWindowBorderless;
SetWindowBorderless = SDL3_FNAPlatform.SetWindowBorderless;
GetWindowMinimized = SDL3_FNAPlatform.GetWindowMinimized;
GetWindowMaximized = SDL3_FNAPlatform.GetWindowMaximized;
SetWindowTitle = SDL3_FNAPlatform.SetWindowTitle;
IsScreenKeyboardShown = SDL3_FNAPlatform.IsScreenKeyboardShown;
RegisterGame = SDL3_FNAPlatform.RegisterGame;
Expand Down Expand Up @@ -168,6 +170,8 @@ static FNAPlatform()
SetWindowResizable = SDL2_FNAPlatform.SetWindowResizable;
GetWindowBorderless = SDL2_FNAPlatform.GetWindowBorderless;
SetWindowBorderless = SDL2_FNAPlatform.SetWindowBorderless;
GetWindowMinimized = SDL2_FNAPlatform.GetWindowMinimized;
GetWindowMaximized = SDL2_FNAPlatform.GetWindowMaximized;
SetWindowTitle = SDL2_FNAPlatform.SetWindowTitle;
IsScreenKeyboardShown = SDL2_FNAPlatform.IsScreenKeyboardShown;
RegisterGame = SDL2_FNAPlatform.RegisterGame;
Expand Down Expand Up @@ -302,8 +306,10 @@ ref string resultDeviceName
public delegate void SetWindowResizableFunc(IntPtr window, bool resizable);
public static readonly SetWindowResizableFunc SetWindowResizable;

public delegate bool GetWindowBorderlessFunc(IntPtr window);
public static readonly GetWindowBorderlessFunc GetWindowBorderless;
public delegate bool GetWindowBoolFunc(IntPtr window);
public static readonly GetWindowBoolFunc GetWindowBorderless,
GetWindowMinimized,
GetWindowMaximized;

public delegate void SetWindowBorderlessFunc(IntPtr window, bool borderless);
public static readonly SetWindowBorderlessFunc SetWindowBorderless;
Expand Down
16 changes: 16 additions & 0 deletions src/FNAPlatform/FNAWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,22 @@ public override bool IsBorderlessEXT
}
}

public override bool IsMinimizedEXT
{
get
{
return FNAPlatform.GetWindowMinimized(window);
}
}

public override bool IsMaximizedEXT
{
get
{
return FNAPlatform.GetWindowMaximized(window);
}
}

public override string ScreenDeviceName
{
get
Expand Down
10 changes: 10 additions & 0 deletions src/FNAPlatform/SDL2_FNAPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,16 @@ public static bool GetWindowBorderless(IntPtr window)
return ((SDL.SDL_GetWindowFlags(window) & (uint) SDL.SDL_WindowFlags.SDL_WINDOW_BORDERLESS) != 0);
}

public static bool GetWindowMinimized(IntPtr window)
{
return ((SDL.SDL_GetWindowFlags(window) & (uint) SDL.SDL_WindowFlags.SDL_WINDOW_MINIMIZED) != 0);
}

public static bool GetWindowMaximized(IntPtr window)
{
return ((SDL.SDL_GetWindowFlags(window) & (uint) SDL.SDL_WindowFlags.SDL_WINDOW_MAXIMIZED) != 0);
}

public static void SetWindowBorderless(IntPtr window, bool borderless)
{
SDL.SDL_SetWindowBordered(
Expand Down
10 changes: 10 additions & 0 deletions src/FNAPlatform/SDL3_FNAPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,16 @@ public static bool GetWindowBorderless(IntPtr window)
return ((SDL.SDL_GetWindowFlags(window) & SDL.SDL_WindowFlags.SDL_WINDOW_BORDERLESS) != 0);
}

public static bool GetWindowMinimized(IntPtr window)
{
return ((SDL.SDL_GetWindowFlags(window) & SDL.SDL_WindowFlags.SDL_WINDOW_MINIMIZED) != 0);
}

public static bool GetWindowMaximized(IntPtr window)
{
return ((SDL.SDL_GetWindowFlags(window) & SDL.SDL_WindowFlags.SDL_WINDOW_MAXIMIZED) != 0);
}

public static void SetWindowBorderless(IntPtr window, bool borderless)
{
SDL.SDL_SetWindowBordered(
Expand Down
28 changes: 28 additions & 0 deletions src/GameWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,34 @@ public virtual bool IsBorderlessEXT
}
}

/// <summary>
/// Determines whether the window is minimized.
/// </summary>
/// <exception cref="System.NotImplementedException">
/// Thrown when trying to use this property on an unsupported platform.
/// </exception>
public virtual bool IsMinimizedEXT
{
get
{
return false;
}
}

/// <summary>
/// Determines whether the window is maximized.
/// </summary>
/// <exception cref="System.NotImplementedException">
/// Thrown when trying to use this property on an unsupported platform.
/// </exception>
public virtual bool IsMaximizedEXT
{
get
{
return false;
}
}

#endregion

#region Private Variables
Expand Down

0 comments on commit 0012766

Please sign in to comment.