GtkAspectFrame
GtkAspectFrame — A frame that constrains its child to a particular aspect ratio
Functions
GtkWidget * | gtk_aspect_frame_new () |
void | gtk_aspect_frame_set_xalign () |
float | gtk_aspect_frame_get_xalign () |
void | gtk_aspect_frame_set_yalign () |
float | gtk_aspect_frame_get_yalign () |
void | gtk_aspect_frame_set_ratio () |
float | gtk_aspect_frame_get_ratio () |
void | gtk_aspect_frame_set_obey_child () |
gboolean | gtk_aspect_frame_get_obey_child () |
void | gtk_aspect_frame_set_child () |
GtkWidget * | gtk_aspect_frame_get_child () |
Properties
Types and Values
Object Hierarchy
GObject ╰── GInitiallyUnowned ╰── GtkWidget ╰── GtkAspectFrame
Implemented Interfaces
GtkAspectFrame implements GtkAccessible, GtkBuildable and GtkConstraintTarget.
Includes
#include <gtk/gtk.h>
Description
The GtkAspectFrame is useful when you want pack a widget so that it can resize but always retains the same aspect ratio. For instance, one might be drawing a small preview of a larger image. GtkAspectFrame derives from GtkFrame, so it can draw a label and a frame around the child. The frame will be “shrink-wrapped” to the size of the child.
CSS nodes
GtkAspectFrame uses a CSS node with name frame.
Functions
gtk_aspect_frame_new ()
GtkWidget * gtk_aspect_frame_new (float xalign
,float yalign
,float ratio
,gboolean obey_child
);
Create a new GtkAspectFrame.
Parameters
xalign | Horizontal alignment of the child within the allocation of the GtkAspectFrame. This ranges from 0.0 (left aligned) to 1.0 (right aligned) | |
yalign | Vertical alignment of the child within the allocation of the GtkAspectFrame. This ranges from 0.0 (top aligned) to 1.0 (bottom aligned) | |
ratio | The desired aspect ratio. | |
obey_child | If |
Returns
the new GtkAspectFrame.
gtk_aspect_frame_set_xalign ()
void gtk_aspect_frame_set_xalign (GtkAspectFrame *self
,float xalign
);
Sets the horizontal alignment of the child within the allocation of the GtkAspectFrame.
Parameters
self | ||
xalign | horizontal alignment, from 0.0 (left aligned) to 1.0 (right aligned) |
gtk_aspect_frame_get_xalign ()
float
gtk_aspect_frame_get_xalign (GtkAspectFrame *self
);
Returns the horizontal alignment of the child within the allocation of the GtkAspectFrame.
Parameters
self |
Returns
the horizontal alignment
gtk_aspect_frame_set_yalign ()
void gtk_aspect_frame_set_yalign (GtkAspectFrame *self
,float yalign
);
Sets the vertical alignment of the child within the allocation of the GtkAspectFrame.
Parameters
self | ||
yalign | horizontal alignment, from 0.0 (top aligned) to 1.0 (bottom aligned) |
gtk_aspect_frame_get_yalign ()
float
gtk_aspect_frame_get_yalign (GtkAspectFrame *self
);
Returns the vertical alignment of the child within the allocation of the GtkAspectFrame.
Parameters
self |
Returns
the vertical alignment
gtk_aspect_frame_set_ratio ()
void gtk_aspect_frame_set_ratio (GtkAspectFrame *self
,float ratio
);
Sets the desired aspect ratio of the child.
Parameters
self | ||
ratio | aspect ratio of the child |
gtk_aspect_frame_get_ratio ()
float
gtk_aspect_frame_get_ratio (GtkAspectFrame *self
);
Returns the desired aspect ratio of the child.
Parameters
self |
Returns
the desired aspect ratio
gtk_aspect_frame_set_obey_child ()
void gtk_aspect_frame_set_obey_child (GtkAspectFrame *self
,gboolean obey_child
);
Sets whether the aspect ratio of the child's size request should override the set aspect ratio of the GtkAspectFrame.
Parameters
self | ||
obey_child | If |
gtk_aspect_frame_get_obey_child ()
gboolean
gtk_aspect_frame_get_obey_child (GtkAspectFrame *self
);
Returns whether the child's size request should override the set aspect ratio of the GtkAspectFrame.
Parameters
self |
Returns
whether to obey the child's size request
gtk_aspect_frame_set_child ()
void gtk_aspect_frame_set_child (GtkAspectFrame *self
,GtkWidget *child
);
Sets the child widget of self
.
Parameters
self | ||
child | the child widget. | [allow-none] |
gtk_aspect_frame_get_child ()
GtkWidget *
gtk_aspect_frame_get_child (GtkAspectFrame *self
);
Gets the child widget of self
.
Parameters
self |
Returns
the child widget of self@.
[nullable][transfer none]
Types and Values
GtkAspectFrame
typedef struct _GtkAspectFrame GtkAspectFrame;
Property Details
The “child”
property
“child” GtkWidget *
The child widget.
Owner: GtkAspectFrame
Flags: Read / Write
The “obey-child”
property
“obey-child” gboolean
Force aspect ratio to match that of the frame’s child.
Owner: GtkAspectFrame
Flags: Read / Write
Default value: TRUE
The “ratio”
property
“ratio” float
Aspect ratio if obey_child is FALSE.
Owner: GtkAspectFrame
Flags: Read / Write
Allowed values: [0.0001,10000]
Default value: 1
The “xalign”
property
“xalign” float
X alignment of the child.
Owner: GtkAspectFrame
Flags: Read / Write
Allowed values: [0,1]
Default value: 0.5
The “yalign”
property
“yalign” float
Y alignment of the child.
Owner: GtkAspectFrame
Flags: Read / Write
Allowed values: [0,1]
Default value: 0.5
© 2005–2020 The GNOME Project
Licensed under the GNU Lesser General Public License version 2.1 or later.
https://developer.gnome.org/gtk4/4.0/GtkAspectFrame.html