Class Breakpoint
Window
or Dialog
.
Breakpoints are used to create adaptive UI, allowing to change the layout depending on available size.
Breakpoint is a size threshold, specified by its condition, as well as one or more setters.
Each setter has a target object, a property and a value. When a breakpoint is applied, each setter sets the target property on their target object to the specified value, and reset it back to the original value when it's unapplied.
For more complicated scenarios, Breakpoint::apply
and
Breakpoint::unapply
can be used instead.
Breakpoints can be used within Window
, ApplicationWindow
,
Dialog
or BreakpointBin
.
AdwBreakpoint
as GtkBuildable
:
AdwBreakpoint
supports specifying its condition via the <condition>
element. The contents of the element must be a string in a format accepted by
BreakpointCondition.parse(java.lang.String)
.
It also supports adding setters via the <setter>
element. Each <setter>
element must have the object
attribute specifying the target object, and
the property
attribute specifying the property name. The contents of the
element are used as the setter value.
For G_TYPE_OBJECT
and G_TYPE_BOXED
derived properties, empty contents are
treated as NULL
.
Setter values can be translated with the usual translatable
, context
and
comments
attributes.
Example of an AdwBreakpoint
UI definition:
<object class="AdwBreakpoint">
<condition>max-width: 400px</condition>
<setter object="button" property="visible">True</setter>
<setter object="box" property="orientation">vertical</setter>
<setter object="page" property="title" translatable="yes">Example</setter>
</object>
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Functional interface declaration of theApplyCallback
callback.static class
static class
Breakpoint.Builder<B extends Breakpoint.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static interface
Functional interface declaration of theUnapplyCallback
callback.Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
Nested classes/interfaces inherited from interface org.gnome.gtk.Buildable
Buildable.BuildableIface, Buildable.BuildableImpl
-
Constructor Summary
ConstructorDescriptionBreakpoint
(MemorySegment address) Create a Breakpoint proxy instance for the provided memory address.Breakpoint
(BreakpointCondition condition) Creates a newAdwBreakpoint
withcondition
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a setter to this Breakpoint.void
addSetters
(GObject[] objects, String[] names, Value[] values) AddsnSetters
setters to this Breakpoint.protected Breakpoint
asParent()
Returns this instance as if it were its parent type.static Breakpoint.Builder
<? extends Breakpoint.Builder> builder()
ABreakpoint.Builder
object constructs aBreakpoint
with the specified properties.void
Emits the "apply" signal.void
Emits the "unapply" signal.Gets the condition for this Breakpoint.static Type
getType()
Get the GType of the Breakpoint classonApply
(Breakpoint.ApplyCallback handler) Emitted when the breakpoint is applied.onUnapply
(Breakpoint.UnapplyCallback handler) Emitted when the breakpoint is unapplied.void
setCondition
(@Nullable BreakpointCondition condition) Sets the condition for this Breakpoint.Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getMemoryLayout, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newInstance, newInstance, newv, notify_, notify_, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.gnome.gtk.Buildable
getBuildableId
-
Constructor Details
-
Breakpoint
Create a Breakpoint proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
Breakpoint
Creates a newAdwBreakpoint
withcondition
.- Parameters:
condition
- the condition
-
-
Method Details
-
getType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()
doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName()
. This will call the native function pointer of this virtual method in the typeclass of the parent type. -
addSetter
Adds a setter to this Breakpoint.The setter will automatically set
property
onobject
tovalue
when applying the breakpoint, and set it back to its original value upon unapplying it.Note Setting properties to their original values does not work for properties that have irreversible side effects. For example, changing [property@Gtk.Button:label] while [property@Gtk.Button:icon-name] is set will reset the icon. However, resetting the label will not set
icon-name
to its original value. Use the [signal@Breakpoint::apply] and [signal@Breakpoint::unapply] signals for those properties instead, as follows: ``c static void breakpoint_apply_cb (MyWidget *self) { gtk_button_set_icon_name (self->button, "go-previous-symbolic"); } static void breakpoint_apply_cb (MyWidget *self) { gtk_button_set_label (self->button, _("_Back")); } // ... g_signal_connect_swapped (breakpoint, "apply", G_CALLBACK (breakpoint_apply_cb), self); g_signal_connect_swapped (breakpoint, "unapply", G_CALLBACK (breakpoint_unapply_cb), self);
``- Parameters:
object
- the target objectproperty
- the target propertyvalue
- the value to set
-
addSetters
AddsnSetters
setters to this Breakpoint.This is a convenience function for adding multiple setters at once.
See
addSetter(org.gnome.gobject.GObject, java.lang.String, org.gnome.gobject.Value)
.This function is meant to be used by language bindings.
- Parameters:
objects
- setter target objectnames
- setter target propertiesvalues
- setter values
-
getCondition
Gets the condition for this Breakpoint.- Returns:
- the condition
-
setCondition
Sets the condition for this Breakpoint.- Parameters:
condition
- the new condition
-
onApply
Emitted when the breakpoint is applied.This signal is emitted after the setters have been applied.
- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitApply
public void emitApply()Emits the "apply" signal. SeeonApply(org.gnome.adw.Breakpoint.ApplyCallback)
. -
onUnapply
Emitted when the breakpoint is unapplied.This signal is emitted before resetting the setter values.
- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitUnapply
public void emitUnapply()Emits the "unapply" signal. SeeonUnapply(org.gnome.adw.Breakpoint.UnapplyCallback)
. -
builder
ABreakpoint.Builder
object constructs aBreakpoint
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withBreakpoint.Builder.build()
.
-