// Code generated by girgen. DO NOT EDIT.

package adw

import (
	"runtime"
	"unsafe"

	"github.com/diamondburned/gotk4/pkg/core/gextras"
	coreglib "github.com/diamondburned/gotk4/pkg/core/glib"
	"github.com/diamondburned/gotk4/pkg/gtk/v4"
)

// #include <stdlib.h>
// #include <adwaita.h>
// #include <glib-object.h>
import "C"

// GType values.
var (
	GTypeClampLayout = coreglib.Type(C.adw_clamp_layout_get_type())
)

func init() {
	coreglib.RegisterGValueMarshalers([]coreglib.TypeMarshaler{
		coreglib.TypeMarshaler{T: GTypeClampLayout, F: marshalClampLayout},
	})
}

// ClampLayoutOverrides contains methods that are overridable.
type ClampLayoutOverrides struct {
}

func defaultClampLayoutOverrides(v *ClampLayout) ClampLayoutOverrides {
	return ClampLayoutOverrides{}
}

// ClampLayout: layout manager constraining its children to a given size.
//
// <picture> <source srcset="clamp-wide-dark.png" media="(prefers-color-scheme:
// dark)"> <img src="clamp-wide.png" alt="clamp-wide"> </picture> <picture>
// <source srcset="clamp-narrow-dark.png" media="(prefers-color-scheme: dark)">
// <img src="clamp-narrow.png" alt="clamp-narrow"> </picture>
//
// AdwClampLayout constraints the size of the widgets it contains to a given
// maximum size. It will constrain the width if it is horizontal, or the height
// if it is vertical. The expansion of the children from their minimum to their
// maximum size is eased out for a smooth transition.
//
// If a child requires more than the requested maximum size, it will be
// allocated the minimum size it can fit in instead.
//
// AdwClampLayout can scale with the text scale factor, use the clamplayout:unit
// property to enable that behavior.
type ClampLayout struct {
	_ [0]func() // equal guard
	gtk.LayoutManager

	*coreglib.Object
	gtk.Orientable
}

var (
	_ gtk.LayoutManagerer = (*ClampLayout)(nil)
	_ coreglib.Objector   = (*ClampLayout)(nil)
)

func init() {
	coreglib.RegisterClassInfo[*ClampLayout, *ClampLayoutClass, ClampLayoutOverrides](
		GTypeClampLayout,
		initClampLayoutClass,
		wrapClampLayout,
		defaultClampLayoutOverrides,
	)
}

func initClampLayoutClass(gclass unsafe.Pointer, overrides ClampLayoutOverrides, classInitFunc func(*ClampLayoutClass)) {
	if classInitFunc != nil {
		class := (*ClampLayoutClass)(gextras.NewStructNative(gclass))
		classInitFunc(class)
	}
}

func wrapClampLayout(obj *coreglib.Object) *ClampLayout {
	return &ClampLayout{
		LayoutManager: gtk.LayoutManager{
			Object: obj,
		},
		Object: obj,
		Orientable: gtk.Orientable{
			Object: obj,
		},
	}
}

func marshalClampLayout(p uintptr) (interface{}, error) {
	return wrapClampLayout(coreglib.ValueFromNative(unsafe.Pointer(p)).Object()), nil
}

// NewClampLayout creates a new AdwClampLayout.
//
// The function returns the following values:
//
//   - clampLayout: newly created AdwClampLayout.
func NewClampLayout() *ClampLayout {
	var _cret *C.GtkLayoutManager // in

	_cret = C.adw_clamp_layout_new()

	var _clampLayout *ClampLayout // out

	_clampLayout = wrapClampLayout(coreglib.AssumeOwnership(unsafe.Pointer(_cret)))

	return _clampLayout
}

// MaximumSize gets the maximum size allocated to the children.
//
// The function returns the following values:
//
//   - gint: maximum size to allocate to the children.
func (self *ClampLayout) MaximumSize() int {
	var _arg0 *C.AdwClampLayout // out
	var _cret C.int             // in

	_arg0 = (*C.AdwClampLayout)(unsafe.Pointer(coreglib.InternObject(self).Native()))

	_cret = C.adw_clamp_layout_get_maximum_size(_arg0)
	runtime.KeepAlive(self)

	var _gint int // out

	_gint = int(_cret)

	return _gint
}

// TighteningThreshold gets the size above which the children are clamped.
//
// The function returns the following values:
//
//   - gint: size above which the children are clamped.
func (self *ClampLayout) TighteningThreshold() int {
	var _arg0 *C.AdwClampLayout // out
	var _cret C.int             // in

	_arg0 = (*C.AdwClampLayout)(unsafe.Pointer(coreglib.InternObject(self).Native()))

	_cret = C.adw_clamp_layout_get_tightening_threshold(_arg0)
	runtime.KeepAlive(self)

	var _gint int // out

	_gint = int(_cret)

	return _gint
}

// Unit gets the length unit for maximum size and tightening threshold.
//
// The function returns the following values:
//
//   - lengthUnit: length unit.
func (self *ClampLayout) Unit() LengthUnit {
	var _arg0 *C.AdwClampLayout // out
	var _cret C.AdwLengthUnit   // in

	_arg0 = (*C.AdwClampLayout)(unsafe.Pointer(coreglib.InternObject(self).Native()))

	_cret = C.adw_clamp_layout_get_unit(_arg0)
	runtime.KeepAlive(self)

	var _lengthUnit LengthUnit // out

	_lengthUnit = LengthUnit(_cret)

	return _lengthUnit
}

// SetMaximumSize sets the maximum size allocated to the children.
//
// It is the width if the layout is horizontal, or the height if it is vertical.
//
// The function takes the following parameters:
//
//   - maximumSize: maximum size.
func (self *ClampLayout) SetMaximumSize(maximumSize int) {
	var _arg0 *C.AdwClampLayout // out
	var _arg1 C.int             // out

	_arg0 = (*C.AdwClampLayout)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	_arg1 = C.int(maximumSize)

	C.adw_clamp_layout_set_maximum_size(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(maximumSize)
}

// SetTighteningThreshold sets the size above which the children are clamped.
//
// Starting from this size, the layout will tighten its grip on the children,
// slowly allocating less and less of the available size up to the maximum
// allocated size. Below that threshold and below the maximum size, the children
// will be allocated all the available size.
//
// If the threshold is greater than the maximum size to allocate to the
// children, they will be allocated the whole size up to the maximum.
// If the threshold is lower than the minimum size to allocate to the children,
// that size will be used as the tightening threshold.
//
// Effectively, tightening the grip on a child before it reaches its maximum
// size makes transitions to and from the maximum size smoother when resizing.
//
// The function takes the following parameters:
//
//   - tighteningThreshold: tightening threshold.
func (self *ClampLayout) SetTighteningThreshold(tighteningThreshold int) {
	var _arg0 *C.AdwClampLayout // out
	var _arg1 C.int             // out

	_arg0 = (*C.AdwClampLayout)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	_arg1 = C.int(tighteningThreshold)

	C.adw_clamp_layout_set_tightening_threshold(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(tighteningThreshold)
}

// SetUnit sets the length unit for maximum size and tightening threshold.
//
// Allows the sizes to vary depending on the text scale factor.
//
// The function takes the following parameters:
//
//   - unit: length unit.
func (self *ClampLayout) SetUnit(unit LengthUnit) {
	var _arg0 *C.AdwClampLayout // out
	var _arg1 C.AdwLengthUnit   // out

	_arg0 = (*C.AdwClampLayout)(unsafe.Pointer(coreglib.InternObject(self).Native()))
	_arg1 = C.AdwLengthUnit(unit)

	C.adw_clamp_layout_set_unit(_arg0, _arg1)
	runtime.KeepAlive(self)
	runtime.KeepAlive(unit)
}

// ClampLayoutClass: instance of this type is always passed by reference.
type ClampLayoutClass struct {
	*clampLayoutClass
}

// clampLayoutClass is the struct that's finalized.
type clampLayoutClass struct {
	native *C.AdwClampLayoutClass
}

func (c *ClampLayoutClass) ParentClass() *gtk.LayoutManagerClass {
	valptr := &c.native.parent_class
	var _v *gtk.LayoutManagerClass // out
	_v = (*gtk.LayoutManagerClass)(gextras.NewStructNative(unsafe.Pointer(valptr)))
	return _v
}
