Skip to content

Commit 73e6fb7

Browse files
committed
Add missing SetMinimum/MaximumSize to the window classes
1 parent 79c3db2 commit 73e6fb7

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,50 @@ 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 void SetMinimumSize(Vector2u? minimumSize)
153+
{
154+
unsafe
155+
{
156+
if (minimumSize.HasValue)
157+
{
158+
var minimumSizeRef = minimumSize.Value;
159+
sfRenderWindow_setMinimumSize(CPointer, &minimumSizeRef);
160+
}
161+
else
162+
{
163+
sfRenderWindow_setMinimumSize(CPointer, null);
164+
}
165+
}
166+
}
167+
168+
////////////////////////////////////////////////////////////
169+
/// <summary>
170+
/// Set the maximum window rendering region size
171+
/// </summary>
172+
/// <param name="maximumSize">New maximum size, in pixels, null to reset the maximum size</param>
173+
////////////////////////////////////////////////////////////
174+
public override void SetMaximumSize(Vector2u? maximumSize)
175+
{
176+
unsafe
177+
{
178+
if (maximumSize.HasValue)
179+
{
180+
var maximumSizeRef = maximumSize.Value;
181+
sfRenderWindow_setMaximumSize(CPointer, &maximumSizeRef);
182+
}
183+
else
184+
{
185+
sfRenderWindow_setMaximumSize(CPointer, null);
186+
}
187+
}
188+
}
189+
146190
////////////////////////////////////////////////////////////
147191
/// <summary>
148192
/// Change the title of the window
@@ -210,7 +254,7 @@ public override void SetIcon(Vector2u size, byte[] pixels)
210254
/// Grab or release the mouse cursor
211255
/// </summary>
212256
/// <param name="grabbed">True to grab, false to release</param>
213-
///
257+
///
214258
/// <remarks>
215259
/// If set, grabs the mouse cursor inside this window's client
216260
/// area so it may no longer be moved outside its bounds.
@@ -329,7 +373,7 @@ public override void SetIcon(Vector2u size, byte[] pixels)
329373
/// The specified stencil value is truncated to the bit
330374
/// width of the current stencil buffer.
331375
/// </summary>
332-
/// <param name="color">Fill color to use to clear the render target</param>
376+
/// <param name="color">Fill color to use to clear the render target</param>
333377
/// <param name="stencilValue">Stencil value to clear to</param>
334378
////////////////////////////////////////////////////////////
335379
public void Clear(Color color, StencilValue stencilValue) => sfRenderWindow_clearColorAndStencil(CPointer, color, stencilValue);
@@ -548,7 +592,7 @@ public void Draw(Vertex[] vertices, uint start, uint count, PrimitiveType type,
548592
/// <summary>
549593
/// Save the current OpenGL render states and matrices.
550594
/// </summary>
551-
///
595+
///
552596
/// <example>
553597
/// // OpenGL code here...
554598
/// window.PushGLStates();
@@ -602,7 +646,7 @@ public void Draw(Vertex[] vertices, uint start, uint count, PrimitiveType type,
602646
/// states needed by SFML are set, so that subsequent Draw()
603647
/// calls will work as expected.
604648
/// </remarks>
605-
///
649+
///
606650
/// <example>
607651
/// // OpenGL code here...
608652
/// glPushAttrib(...);
@@ -761,6 +805,12 @@ private void Initialize()
761805
[DllImport(CSFML.Graphics, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
762806
private static extern void sfRenderWindow_setSize(IntPtr cPointer, Vector2u size);
763807

808+
[DllImport(CSFML.Graphics, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
809+
private static extern unsafe void sfRenderWindow_setMinimumSize(IntPtr cPointer, Vector2u* minimumSize);
810+
811+
[DllImport(CSFML.Graphics, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
812+
private static extern unsafe void sfRenderWindow_setMaximumSize(IntPtr cPointer, 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,50 @@ 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+
unsafe
174+
{
175+
if (minimumSize.HasValue)
176+
{
177+
var minimumSizeRef = minimumSize.Value;
178+
sfWindow_setMinimumSize(CPointer, &minimumSizeRef);
179+
}
180+
else
181+
{
182+
sfWindow_setMinimumSize(CPointer, null);
183+
}
184+
}
185+
}
186+
187+
////////////////////////////////////////////////////////////
188+
/// <summary>
189+
/// Set the maximum window rendering region size
190+
/// </summary>
191+
/// <param name="maximumSize">New maximum size, in pixels, null to reset the maximum size</param>
192+
////////////////////////////////////////////////////////////
193+
public override void SetMaximumSize(Vector2u? maximumSize)
194+
{
195+
unsafe
196+
{
197+
if (maximumSize.HasValue)
198+
{
199+
var maximumSizeRef = maximumSize.Value;
200+
sfWindow_setMaximumSize(CPointer, &maximumSizeRef);
201+
}
202+
else
203+
{
204+
sfWindow_setMaximumSize(CPointer, null);
205+
}
206+
}
207+
}
208+
165209
////////////////////////////////////////////////////////////
166210
/// <summary>
167211
/// Change the window's icon
@@ -201,7 +245,7 @@ public override void SetIcon(Vector2u size, byte[] pixels)
201245
/// Grab or release the mouse cursor
202246
/// </summary>
203247
/// <param name="grabbed">True to grab, false to release</param>
204-
///
248+
///
205249
/// <remarks>
206250
/// If set, grabs the mouse cursor inside this window's client
207251
/// area so it may no longer be moved outside its bounds.
@@ -441,6 +485,12 @@ protected Window(IntPtr cPointer, int dummy) :
441485
[DllImport(CSFML.Window, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
442486
private static extern void sfWindow_setSize(IntPtr cPointer, Vector2u size);
443487

488+
[DllImport(CSFML.Window, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
489+
private static extern unsafe void sfWindow_setMinimumSize(IntPtr cPointer, Vector2u* minimumSize);
490+
491+
[DllImport(CSFML.Window, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
492+
private static extern unsafe void sfWindow_setMaximumSize(IntPtr cPointer, 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,50 @@ 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+
unsafe
151+
{
152+
if (minimumSize.HasValue)
153+
{
154+
var minimumSizeRef = minimumSize.Value;
155+
sfWindowBase_setMinimumSize(CPointer, &minimumSizeRef);
156+
}
157+
else
158+
{
159+
sfWindowBase_setMinimumSize(CPointer, null);
160+
}
161+
}
162+
}
163+
164+
////////////////////////////////////////////////////////////
165+
/// <summary>
166+
/// Set the maximum window rendering region size
167+
/// </summary>
168+
/// <param name="maximumSize">New maximum size, in pixels, null to reset the maximum size</param>
169+
////////////////////////////////////////////////////////////
170+
public virtual void SetMaximumSize(Vector2u? maximumSize)
171+
{
172+
unsafe
173+
{
174+
if (maximumSize.HasValue)
175+
{
176+
var maximumSizeRef = maximumSize.Value;
177+
sfWindowBase_setMaximumSize(CPointer, &maximumSizeRef);
178+
}
179+
else
180+
{
181+
sfWindowBase_setMaximumSize(CPointer, null);
182+
}
183+
}
184+
}
185+
142186
////////////////////////////////////////////////////////////
143187
/// <summary>
144188
/// Change the title of the window
@@ -615,6 +659,12 @@ private void CallEventHandler(Event e)
615659
[DllImport(CSFML.Window, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
616660
private static extern void sfWindowBase_setSize(IntPtr cPointer, Vector2u size);
617661

662+
[DllImport(CSFML.Window, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
663+
private static extern unsafe void sfWindowBase_setMinimumSize(IntPtr cPointer, Vector2u* minimumSize);
664+
665+
[DllImport(CSFML.Window, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
666+
private static extern unsafe void sfWindowBase_setMaximumSize(IntPtr cPointer, 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)