3.1 <AdwBreakpointCondition>

Structure: <AdwBreakpointCondition>

Describes condition for an Breakpoint.

Procedures

Method: breakpoint-condition:copy self ⇒ %return
Method: copy self ⇒ %return

Copies self.

self

Passed: a <AdwBreakpointCondition>.

a breakpoint condition

%return

Returned: a <AdwBreakpointCondition>.

a copy of self

Method: breakpoint-condition:free self
Method: free self

Frees self.

self

Passed: a <AdwBreakpointCondition>.

a breakpoint condition

Procedure: breakpoint-condition:new-and condition-1 condition-2 ⇒ %return

Creates a condition that triggers when condition-1 and condition-2 are both true.

condition-1

Passed: a <AdwBreakpointCondition>.

first condition

condition-2

Passed: a <AdwBreakpointCondition>.

second condition

%return

Returned: a <AdwBreakpointCondition>.

the newly created condition

Procedure: breakpoint-condition:new-length type value unit ⇒ %return

Creates a condition that triggers on length changes.

type

Passed: a <AdwBreakpointConditionLengthType>, or one of its symbols.

the length type

value

Passed: a real number.

the length value

unit

Passed: a <AdwLengthUnit>, or one of its symbols.

the length unit

%return

Returned: a <AdwBreakpointCondition>.

the newly created condition

Procedure: breakpoint-condition:new-or condition-1 condition-2 ⇒ %return

Creates a condition that triggers when either condition-1 or condition-2 is true.

condition-1

Passed: a <AdwBreakpointCondition>.

first condition

condition-2

Passed: a <AdwBreakpointCondition>.

second condition

%return

Returned: a <AdwBreakpointCondition>.

the newly created condition

Procedure: breakpoint-condition:new-ratio type width height ⇒ %return

Creates a condition that triggers on ratio changes.

The ratio is represented as width divided by height.

type

Passed: a <AdwBreakpointConditionRatioType>, or one of its symbols.

the ratio type

width

Passed: a 32-bit integer.

ratio width

height

Passed: a 32-bit integer.

ratio height

%return

Returned: a <AdwBreakpointCondition>.

the newly created condition

Procedure: breakpoint-condition:parse str ⇒ %return

Parses a condition from a string.

Length conditions are specified as <type>: <value>[<unit>], where:

  • <type> can be min-width, max-width, min-height or max-height
  • <value> is a fractional number
  • <unit> can be px, pt or sp

If the unit is omitted, px is assumed.

See BreakpointCondition.new_length.

Examples:

  • min-width: 500px
  • min-height: 400pt
  • max-width: 100sp
  • max-height: 500

Ratio conditions are specified as <type>: <width>[/<height>], where:

  • <type> can be min-aspect-ratio or max-aspect-ratio
  • <width> and <height> are integer numbers

See BreakpointCondition.new_ratio.

The ratio is represented as <width> divided by <height>.

If <height> is omitted, it’s assumed to be 1.

Examples:

  • min-aspect-ratio: 4/3
  • max-aspect-ratio: 1

The logical operators and, or can be used to compose a complex condition as follows:

  • <condition> and <condition>: the condition is true when both <condition>s are true, same as when using BreakpointCondition.new_and
  • <condition> or <condition>: the condition is true when either of the <condition>s is true, same as when using BreakpointCondition.new_or

Examples:

  • min-width: 400px and max-aspect-ratio: 4/3
  • max-width: 360sp or max-width: 360px

Conditions can be further nested using parentheses, for example:

  • min-width: 400px and (max-aspect-ratio: 4/3 or max-height: 400px)

If parentheses are omitted, the first operator takes priority.

str

Passed: a string.

the string specifying the condition

%return

Returned: a <AdwBreakpointCondition>.

the parsed condition

Method: breakpoint-condition:to-string self ⇒ %return
Method: to-string self ⇒ %return

Returns a textual representation of self.

The returned string can be parsed by BreakpointCondition.parse.

self

Passed: a <AdwBreakpointCondition>.

a breakpoint condition

%return

Returned: a string.

A newly allocated text string