Skip to content

Framing Decision

A FramingDecision describes how a specific framing intent is realized on a canvas. It specifies the dimensions and anchor point of the framed area, and optionally protection dimensions and anchor point.

fdl.FramingDecision(*, id, label='', framing_intent_id, dimensions=DimensionsFloat(width=0.0, height=0.0), anchor_point=PointFloat(x=0.0, y=0.0), protection_dimensions=None, protection_anchor_point=None)

Bases: HandleWrapper

FramingDecision facade wrapping a C fdl_framing_decision_t handle.

custom_attrs property

Return all custom attributes as a dictionary.

adjust_anchor_point(canvas, h_method, v_method)

Adjust anchor point based on alignment within canvas.

adjust_protection_anchor_point(canvas, h_method, v_method)

Adjust protection anchor point based on alignment within canvas.

custom_attrs_count()

Return the number of custom attributes on this object.

from_framing_intent(canvas, framing_intent, rounding=None) classmethod

Create a FramingDecision from a canvas and framing intent.

from_model(model) classmethod

Create a standalone FramingDecision facade from a Pydantic model.

Note: Creates a temporary backing document. The returned object is self-contained but not attached to any parent FDL document.

get_custom_attr(name)

Get a custom attribute value by name.

Parameters:

Name Type Description Default
name str

Attribute name (without _ prefix).

required

Returns:

Type Description
str | int | float | bool | PointFloat | DimensionsFloat | DimensionsInt | None

The attribute value, or None if not found.

get_protection_rect()

Get protection rect or None if not defined.

get_rect()

Get framing rect as (anchor_x, anchor_y, width, height).

has_custom_attr(name)

Check if a custom attribute exists.

Parameters:

Name Type Description Default
name str

Attribute name (without _ prefix).

required

populate_from_intent(canvas, framing_intent, rounding=None)

Populate this framing decision from a canvas and framing intent (in-place).

remove_custom_attr(name)

Remove a custom attribute.

Parameters:

Name Type Description Default
name str

Attribute name (without _ prefix).

required

Returns:

Type Description
bool

True if the attribute was removed, False if it was not found.

set_custom_attr(name, value)

Set a custom attribute. Type is inferred from value.

Parameters:

Name Type Description Default
name str

Attribute name (without _ prefix).

required
value str | int | float | bool | PointFloat | DimensionsFloat | DimensionsInt

Attribute value (str, int, float, bool, PointFloat, DimensionsFloat, or DimensionsInt).

required

Raises:

Type Description
TypeError

If value is not str, int, float, bool, PointFloat, DimensionsFloat, or DimensionsInt.

ValueError

If an attribute with the same name exists with a different type.

set_protection(dims, anchor)

Set protection dimensions and anchor point on this framing decision.

to_model()

Convert to a Pydantic FramingDecisionModel instance.

Returns a pure-data Pydantic model suitable for serialization, API responses, and interoperability with web frameworks.