Skip to main content

pite_core/nodes/
control.rs

1// SPDX-License-Identifier: MIT OR Apache-2.0
2//! Abstract base for UI elements: size, color, font size.
3
4use crate::schema::{DefaultPropVal, NodeTypeSchema, PropHint, PropSchema};
5
6pub static SCHEMA: NodeTypeSchema = NodeTypeSchema {
7    type_name: "Control",
8    description: "Abstract base for UI elements: size, color, and font size.",
9    inherits: Some("Node2D"),
10    abstract_class: true,
11    props: PROPS,
12};
13
14pub static PROPS: &[PropSchema] = &[
15    PropSchema {
16        key: "size",
17        label: "Size",
18        doc: "Bounding box size in world units.",
19        default_value: DefaultPropVal::Vec2(100.0, 40.0),
20        hint: PropHint::Vec2 { speed: 1.0 },
21        read_only: false,
22    },
23    PropSchema {
24        key: "color",
25        label: "Color",
26        doc: "Fill color as sRGB hex with alpha, e.g. `#ffffffff`.",
27        default_value: DefaultPropVal::Color([255, 255, 255, 255]),
28        hint: PropHint::Color,
29        read_only: false,
30    },
31    PropSchema {
32        key: "font_size",
33        label: "Font Size",
34        doc: "Text size in world units; scales with camera zoom.",
35        default_value: DefaultPropVal::Num(16.0),
36        hint: PropHint::Num {
37            speed: 1.0,
38            min: 6.0,
39            max: 128.0,
40        },
41        read_only: false,
42    },
43];