CtkAspectFrame: CTK+ 3 Reference Manual

## CtkAspectFrame CtkAspectFrame — A frame that constrains its child to a particular aspect ratio |

## Functions

CtkWidget * | ctk_aspect_frame_new ()
void | ctk_aspect_frame_set ()

## Properties

gboolean | obey-child | Read / Write
float | ratio | Read / Write
float | xalign | Read / Write
float | yalign | Read / Write

## Types and Values

struct | CtkAspectFrame
struct | CtkAspectFrameClass

## Object Hierarchy

        GObject
        ╰── GInitiallyUnowned
            ╰── CtkWidget
                ╰── CtkContainer
                    ╰── CtkBin
                        ╰── CtkFrame
                            ╰── CtkAspectFrame

## Implemented Interfaces

CtkAspectFrame implements AtkImplementorIface and CtkBuildable.

## Includes

    #include <ctk/ctk.h>

## Description

The CtkAspectFrame 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. CtkAspectFrame derives from CtkFrame, 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

CtkAspectFrame uses a CSS node with name frame.

## Functions

### ctk_aspect_frame_new ()

    CtkWidget *
    ctk_aspect_frame_new (const gchar *label,
                          gfloat xalign,
                          gfloat yalign,
                          gfloat ratio,
                          gboolean obey_child);

Create a new CtkAspectFrame.

#### Parameters

label | Label text. | [allow-none]
xalign | Horizontal alignment of the child within the allocation of the CtkAspectFrame. This ranges from 0.0 (left aligned) to 1.0 (right aligned) |
yalign | Vertical alignment of the child within the allocation of the CtkAspectFrame. This ranges from 0.0 (top aligned) to 1.0 (bottom aligned) |
ratio | The desired aspect ratio. |
obey_child | If `TRUE`, `ratio` is ignored, and the aspect ratio is taken from the requistion of the child. |

#### Returns

the new CtkAspectFrame.

### ctk_aspect_frame_set ()

    void
    ctk_aspect_frame_set (CtkAspectFrame *aspect_frame,
                          gfloat xalign,
                          gfloat yalign,
                          gfloat ratio,
                          gboolean obey_child);

Set parameters for an existing CtkAspectFrame.

#### Parameters

aspect_frame | a CtkAspectFrame |
xalign | Horizontal alignment of the child within the allocation of the CtkAspectFrame. This ranges from 0.0 (left aligned) to 1.0 (right aligned) |
yalign | Vertical alignment of the child within the allocation of the CtkAspectFrame. This ranges from 0.0 (top aligned) to 1.0 (bottom aligned) |
ratio | The desired aspect ratio. |
obey_child | If `TRUE`, `ratio` is ignored, and the aspect ratio is taken from the requistion of the child. |

## Types and Values

### struct CtkAspectFrame

    struct CtkAspectFrame;

### struct CtkAspectFrameClass

    struct CtkAspectFrameClass {
      CtkFrameClass parent_class;
    };

#### Members

## Property Details

### The `“obey-child”` property

      “obey-child”               gboolean

Force aspect ratio to match that of the frame's child.

Owner: CtkAspectFrame

Flags: Read / Write

Default value: TRUE

### The `“ratio”` property

      “ratio”                    float

Aspect ratio if obey_child is FALSE.

Owner: CtkAspectFrame

Flags: Read / Write

Allowed values: [0.0001,10000]

Default value: 1

### The `“xalign”` property

      “xalign”                   float

X alignment of the child.

Owner: CtkAspectFrame

Flags: Read / Write

Allowed values: [0,1]

Default value: 0.5

### The `“yalign”` property

      “yalign”                   float

Y alignment of the child.

Owner: CtkAspectFrame

Flags: Read / Write

Allowed values: [0,1]

Default value: 0.5