Skip to content

Commit e2e4395

Browse files
committed
Add missing SetMinimum/MaximumSize to the window classes
1 parent 62c34c1 commit e2e4395

File tree

3 files changed

+155
-5
lines changed

3 files changed

+155
-5
lines changed

src/SFML.Graphics/RenderWindow.cs

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,44 @@ public override Vector2u Size
143143
////////////////////////////////////////////////////////////
144144
public bool IsSrgb => sfRenderWindow_isSrgb(CPointer);
145145

146+
////////////////////////////////////////////////////////////
147+
/// <summary>
148+
/// Set the minimum window rendering region size
149+
/// </summary>
150+
/// <param name="minimumSize">New minimum size, in pixels, null to reset the minimum size</param>
151+
////////////////////////////////////////////////////////////
152+
public override SetMinimumSize(Vector2u? minimumSize)
153+
{
154+
if (minimumSize.HasValue)
155+
{
156+
var minimumSizeRef = minimumSize.Value;
157+
sfRenderWindow_setMinimumSize(CPointer, ref minimumSizeRef);
158+
}
159+
else
160+
{
161+
sfRenderWindow_setMinimumSize(CPointer, IntPtr.Zero);
162+
}
163+
}
164+
165+
////////////////////////////////////////////////////////////
166+
/// <summary>
167+
/// Set the maximum window rendering region size
168+
/// </summary>
169+
/// <param name="maximumSize">New maximum size, in pixels, null to reset the maximum size</param>
170+
////////////////////////////////////////////////////////////
171+
public override MaximumSize(Vector2u? maximumSize)
172+
{
173+
if (maximumSize.HasValue)
174+
{
175+
var maximumSizeRef = maximumSize.Value;
176+
sfRenderWindow_setMaximumSize(CPointer, ref maximumSizeRef);
177+
}
178+
else
179+
{
180+
sfRenderWindow_setMaximumSize(CPointer, IntPtr.Zero);
181+
}
182+
}
183+
146184
////////////////////////////////////////////////////////////
147185
/// <summary>
148186
/// Change the title of the window
@@ -210,7 +248,7 @@ public override void SetIcon(Vector2u size, byte[] pixels)
210248
/// Grab or release the mouse cursor
211249
/// </summary>
212250
/// <param name="grabbed">True to grab, false to release</param>
213-
///
251+
///
214252
/// <remarks>
215253
/// If set, grabs the mouse cursor inside this window's client
216254
/// area so it may no longer be moved outside its bounds.
@@ -329,7 +367,7 @@ public override void SetIcon(Vector2u size, byte[] pixels)
329367
/// The specified stencil value is truncated to the bit
330368
/// width of the current stencil buffer.
331369
/// </summary>
332-
/// <param name="color">Fill color to use to clear the render target</param>
370+
/// <param name="color">Fill color to use to clear the render target</param>
333371
/// <param name="stencilValue">Stencil value to clear to</param>
334372
////////////////////////////////////////////////////////////
335373
public void Clear(Color color, StencilValue stencilValue) => sfRenderWindow_clearColorAndStencil(CPointer, color, stencilValue);
@@ -548,7 +586,7 @@ public void Draw(Vertex[] vertices, uint start, uint count, PrimitiveType type,
548586
/// <summary>
549587
/// Save the current OpenGL render states and matrices.
550588
/// </summary>
551-
///
589+
///
552590
/// <example>
553591
/// // OpenGL code here...
554592
/// window.PushGLStates();
@@ -602,7 +640,7 @@ public void Draw(Vertex[] vertices, uint start, uint count, PrimitiveType type,
602640
/// states needed by SFML are set, so that subsequent Draw()
603641
/// calls will work as expected.
604642
/// </remarks>
605-
///
643+
///
606644
/// <example>
607645
/// // OpenGL code here...
608646
/// glPushAttrib(...);
@@ -761,6 +799,18 @@ private void Initialize()
761799
[DllImport(CSFML.Graphics, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
762800
private static extern void sfRenderWindow_setSize(IntPtr cPointer, Vector2u size);
763801

802+
[DllImport(CSFML.Graphics, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
803+
private static extern void sfRenderWindow_setMinimumSize(IntPtr cPointer, IntPtr minimumSize);
804+
805+
[DllImport(CSFML.Graphics, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
806+
private static extern void sfRenderWindow_setMinimumSize(IntPtr cPointer, ref Vector2u minimumSize);
807+
808+
[DllImport(CSFML.Graphics, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
809+
private static extern void sfRenderWindow_setMaximumSize(IntPtr cPointer, IntPtr maximumSize);
810+
811+
[DllImport(CSFML.Graphics, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
812+
private static extern void sfRenderWindow_setMaximumSize(IntPtr cPointer, ref Vector2u maximumSize);
813+
764814
[DllImport(CSFML.Graphics, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
765815
private static extern void sfRenderWindow_setUnicodeTitle(IntPtr cPointer, IntPtr title);
766816

src/SFML.Window/Window.cs

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,44 @@ public override void SetTitle(string title)
162162
}
163163
}
164164

165+
////////////////////////////////////////////////////////////
166+
/// <summary>
167+
/// Set the minimum window rendering region size
168+
/// </summary>
169+
/// <param name="minimumSize">New minimum size, in pixels, null to reset the minimum size</param>
170+
////////////////////////////////////////////////////////////
171+
public override void SetMinimumSize(Vector2u? minimumSize)
172+
{
173+
if (minimumSize.HasValue)
174+
{
175+
var minimumSizeRef = minimumSize.Value;
176+
sfWindow_setMinimumSize(CPointer, ref minimumSizeRef);
177+
}
178+
else
179+
{
180+
sfWindow_setMinimumSize(CPointer, IntPtr.Zero);
181+
}
182+
}
183+
184+
////////////////////////////////////////////////////////////
185+
/// <summary>
186+
/// Set the maximum window rendering region size
187+
/// </summary>
188+
/// <param name="maximumSize">New maximum size, in pixels, null to reset the maximum size</param>
189+
////////////////////////////////////////////////////////////
190+
public override void SetMaximumSize(Vector2u? maximumSize)
191+
{
192+
if (maximumSize.HasValue)
193+
{
194+
var maximumSizeRef = maximumSize.Value;
195+
sfWindow_setMaximumSize(CPointer, ref maximumSizeRef);
196+
}
197+
else
198+
{
199+
sfWindow_setMaximumSize(CPointer, IntPtr.Zero);
200+
}
201+
}
202+
165203
////////////////////////////////////////////////////////////
166204
/// <summary>
167205
/// Change the window's icon
@@ -201,7 +239,7 @@ public override void SetIcon(Vector2u size, byte[] pixels)
201239
/// Grab or release the mouse cursor
202240
/// </summary>
203241
/// <param name="grabbed">True to grab, false to release</param>
204-
///
242+
///
205243
/// <remarks>
206244
/// If set, grabs the mouse cursor inside this window's client
207245
/// area so it may no longer be moved outside its bounds.
@@ -441,6 +479,18 @@ protected Window(IntPtr cPointer, int dummy) :
441479
[DllImport(CSFML.Window, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
442480
private static extern void sfWindow_setSize(IntPtr cPointer, Vector2u size);
443481

482+
[DllImport(CSFML.Window, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
483+
private static extern void sfWindow_setMinimumSize(IntPtr cPointer, IntPtr minimumSize);
484+
485+
[DllImport(CSFML.Window, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
486+
private static extern void sfWindow_setMinimumSize(IntPtr cPointer, ref Vector2u minimumSize);
487+
488+
[DllImport(CSFML.Window, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
489+
private static extern void sfWindow_setMaximumSize(IntPtr cPointer, IntPtr maximumSize);
490+
491+
[DllImport(CSFML.Window, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
492+
private static extern void sfWindow_setMaximumSize(IntPtr cPointer, ref Vector2u maximumSize);
493+
444494
[DllImport(CSFML.Window, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
445495
private static extern void sfWindow_setUnicodeTitle(IntPtr cPointer, IntPtr title);
446496

src/SFML.Window/WindowBase.cs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,44 @@ public virtual Vector2u Size
139139
set => sfWindowBase_setSize(CPointer, value);
140140
}
141141

142+
////////////////////////////////////////////////////////////
143+
/// <summary>
144+
/// Set the minimum window rendering region size
145+
/// </summary>
146+
/// <param name="minimumSize">New minimum size, in pixels, null to reset the minimum size</param>
147+
////////////////////////////////////////////////////////////
148+
public virtual void SetMinimumSize(Vector2u? minimumSize)
149+
{
150+
if (minimumSize.HasValue)
151+
{
152+
var minimumSizeRef = minimumSize.Value;
153+
sfWindowBase_setMinimumSize(CPointer, ref minimumSizeRef);
154+
}
155+
else
156+
{
157+
sfWindowBase_setMinimumSize(CPointer, IntPtr.Zero);
158+
}
159+
}
160+
161+
////////////////////////////////////////////////////////////
162+
/// <summary>
163+
/// Set the maximum window rendering region size
164+
/// </summary>
165+
/// <param name="maximumSize">New maximum size, in pixels, null to reset the maximum size</param>
166+
////////////////////////////////////////////////////////////
167+
public virtual void SetMaximumSize(Vector2u? maximumSize)
168+
{
169+
if (maximumSize.HasValue)
170+
{
171+
var maximumSizeRef = maximumSize.Value;
172+
sfWindowBase_setMaximumSize(CPointer, ref maximumSizeRef);
173+
}
174+
else
175+
{
176+
sfWindowBase_setMaximumSize(CPointer, IntPtr.Zero);
177+
}
178+
}
179+
142180
////////////////////////////////////////////////////////////
143181
/// <summary>
144182
/// Change the title of the window
@@ -615,6 +653,18 @@ private void CallEventHandler(Event e)
615653
[DllImport(CSFML.Window, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
616654
private static extern void sfWindowBase_setSize(IntPtr cPointer, Vector2u size);
617655

656+
[DllImport(CSFML.Window, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
657+
private static extern void sfWindowBase_setMinimumSize(IntPtr cPointer, IntPtr minimumSize);
658+
659+
[DllImport(CSFML.Window, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
660+
private static extern void sfWindowBase_setMinimumSize(IntPtr cPointer, ref Vector2u minimumSize);
661+
662+
[DllImport(CSFML.Window, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
663+
private static extern void sfWindowBase_setMaximumSize(IntPtr cPointer, IntPtr maximumSize);
664+
665+
[DllImport(CSFML.Window, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
666+
private static extern void sfWindowBase_setMaximumSize(IntPtr cPointer, ref Vector2u maximumSize);
667+
618668
[DllImport(CSFML.Window, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
619669
private static extern void sfWindowBase_setUnicodeTitle(IntPtr cPointer, IntPtr title);
620670

0 commit comments

Comments
 (0)