Clay-UI
view release on metacpan or search on metacpan
lib/Clay/XS.pm view on Meta::CPAN
=item *
C<Clay__CloseElement>, C<Clay__ConfigureOpenElement> and C<Clay_OnHover>
croak when no element is open.
=item *
C<Clay__ConfigureOpenElement> configures the element just opened, once,
before any child is declared (as the C C<CLAY()> macro does). A second
call, or one after a child, croaks.
=item *
C<Clay_SetPointerState> and C<Clay_UpdateScrollContainers> work on the
layout of the last completed frame. They croak between
C<Clay_BeginLayout> and C<Clay_EndLayout>, also while a frame is left
unfinished (see below).
=item *
C<Clay_EndLayout> croaks without a matching C<Clay_BeginLayout>. If
elements are still open (for example because an exception interrupted a
declaration), it closes them, lets Clay finish the frame, and croaks
C<N element(s) still open at Clay_EndLayout (unbalanced Clay__OpenElement/Clay__CloseElement)>. When a callback error is held
as well, the message continues with C<; callback error:> and that
error's message; a held exception object is re-thrown unchanged
instead. The next frame works normally.
=item *
A frame that is never ended is I<unfinished>. The next
C<Clay_BeginLayout> finishes it like C<Clay_EndLayout> with a delta time
of 0 would (it closes the elements still open, lets Clay compute the
layout and discards the render commands), so Clay never begins a frame
over an unfinished one. The finished frame counts as a completed frame:
elements it did not declare start their exit transitions in it, and
the pointer and scroll functions work on its layout. If the unfinished
frame held a callback error, that C<Clay_BeginLayout> then re-throws it
and starts no frame (see L</ERRORS FROM CALLBACKS>); otherwise it starts
the new frame at once.
=back
=head2 How values are parsed
Every struct field is parsed when it crosses into Clay. These croak a
L</STRUCT ERRORS> object naming the struct and field:
=over 4
=item *
wrong reference types, at any nesting level;
=item *
non-numeric numbers;
=item *
numbers that are not finite as a C C<float>: NaN, infinities, and
values beyond about 3.4e38 (the C<max> of a sizing axis may be C<+Inf>
or larger, meaning no maximum);
=item *
integers outside the C field's range, for example negative padding or
an enum value Clay does not define.
=back
An example message: C<Clay_ElementDeclaration.layout.padding.left: expected an integer in 0..65535, got '-8'>.
Further rules:
=over 4
=item *
C<userData>, C<imageData> and C<customData> take an unsigned integer
that fits a pointer (C<refaddr> values do), read exactly. Pass integers
above 2**53 as Perl integers or decimal strings, not as floats.
=item *
Unknown keys are ignored, and so are extra array elements.
L</check_struct> reports both.
=item *
C<< floating => { parentId => ... } >> accepts a numeric id or an
element id hash from C<Clay_GetElementId>.
=back
=head1 CHECKING STRUCTS
=for highlighter language=perl
check_struct('Clay_LayoutConfig', $layout);
check_struct('Clay_Padding', $padding, 'layout.padding');
C<check_struct($type, $value, $root)> validates C<$value> as the struct
named by its exact C type (C<Clay_ElementDeclaration>,
C<Clay_LayoutConfig>, C<Clay_TextElementConfig>, C<Clay_Color>,
C<Clay_SizingAxis>, ...; L</check_struct> lists every accepted name,
which excludes C<Clay_ElementId>) without a context or a frame.
=over 4
=item *
It returns nothing and croaks a L</STRUCT ERRORS> object for the first
problem. An unknown type name croaks a plain string.
=item *
The error path starts at C<$root>, or at the type name when C<$root> is
undef.
=item *
( run in 0.917 second using v1.01-cache-2.11-cpan-60884a8df76 )