Frame¶
Functions for working with the position and size of a view.
-
PuglRect puglGetFrame(const PuglView *view)¶
Get the current position and size of the view.
The position is in screen coordinates with an upper left origin.
-
PuglStatus puglSetFrame(PuglView *view, PuglRect frame)¶
Set the current position and size of the view.
The position is in screen coordinates with an upper left origin.
- Returns
PuglStatus.PUGL_UNKNOWN_ERROR
on failure, in which case the view frame is unchanged.
-
PuglStatus puglSetDefaultSize(PuglView *view, int width, int height)¶
Set the default size of the view.
This should be called before puglResize() to set the default size of the view, which will be the initial size of the window if this is a top level view.
- Returns
PuglStatus.PUGL_UNKNOWN_ERROR
on failure, but always succeeds if the view is not yet realized.
-
PuglStatus puglSetMinSize(PuglView *view, int width, int height)¶
Set the minimum size of the view.
If an initial minimum size is known, this should be called before
puglRealize()
to avoid stutter, though it can be called afterwards as well.- Returns
PuglStatus.PUGL_UNKNOWN_ERROR
on failure, but always succeeds if the view is not yet realized.
-
PuglStatus puglSetMaxSize(PuglView *view, int width, int height)¶
Set the maximum size of the view.
If an initial maximum size is known, this should be called before
puglRealize()
to avoid stutter, though it can be called afterwards as well.- Returns
PuglStatus.PUGL_UNKNOWN_ERROR
on failure, but always succeeds if the view is not yet realized.
-
PuglStatus puglSetAspectRatio(PuglView *view, int minX, int minY, int maxX, int maxY)¶
Set the view aspect ratio range.
The x and y values here represent a ratio of width to height. To set a fixed aspect ratio, set the minimum and maximum values to the same ratio.
Note that setting different minimum and maximum constraints does not currenty work on MacOS (the minimum is used), so only setting a fixed aspect ratio works properly across all platforms.
If an initial aspect ratio is known, this should be called before
puglRealize()
to avoid stutter, though it can be called afterwards as well.- Returns
PuglStatus.PUGL_UNKNOWN_ERROR
on failure, but always succeeds if the view is not yet realized.