pub struct Clay<'a> { /* private fields */ }Implementations§
Source§impl<'a> Clay<'a>
impl<'a> Clay<'a>
Sourcepub fn new(dimensions: Dimensions) -> Self
pub fn new(dimensions: Dimensions) -> Self
Examples found in repository?
9fn main() {
10 // Create the clay instance
11 let clay = Clay::new((800., 600.).into());
12
13 // Begin the layout
14 clay.begin();
15
16 // Adds a red rectangle with a corner radius of 5.
17 // The Layout makes the rectangle have a width and height of 50.
18 clay.with(
19 [
20 Id::new("red_rectangle"),
21 Layout::new().width(fixed!(50.)).height(fixed!(50.)).end(),
22 Rectangle::new()
23 .color((0xFF, 0x00, 0x00).into())
24 .corner_radius(CornerRadius::All(5.))
25 .end(),
26 ],
27 |_| {},
28 );
29
30 // Return the list of render commands of your layout
31 let render_commands = clay.end();
32
33 for command in render_commands {
34 println!("Id of the element: {}", command.id); // Note: Ids are in fact numbers generated by Clay
35 println!("Bounding box: {:?}", command.bounding_box);
36 println!("Type and config: {:?}", command.config);
37 }
38}Sourcepub fn data<T>(&self, data: &T) -> DataRef<'a>
pub fn data<T>(&self, data: &T) -> DataRef<'a>
Get a reference to the data to pass to clay or the builders. This is to ensure that the data is not dropped before clay is done with it.
Sourcepub fn required_memory_size() -> usize
pub fn required_memory_size() -> usize
Wrapper for Clay_MinMemorySize, returns the minimum required memory by clay
Sourcepub fn measure_text_function(&self, func: MeasureTextFunction)
pub fn measure_text_function(&self, func: MeasureTextFunction)
Sets the function used by clay to measure dimensions of strings of Text elements
Sourcepub fn max_element_count(&self, max_element_count: u32)
pub fn max_element_count(&self, max_element_count: u32)
Sets the maximum number of element that clay supports Use only if you know what you are doing or your getting errors from clay
Sourcepub fn max_measure_text_cache_word_count(&self, count: u32)
pub fn max_measure_text_cache_word_count(&self, count: u32)
Sets the capacity of the cache used for text in the measure text function Use only if you know what you are doing or your getting errors from clay
Sourcepub fn enable_debug_mode(&self, enable: bool)
pub fn enable_debug_mode(&self, enable: bool)
Enables or disables the debug mode of clay
Sourcepub fn layout_dimensions(&self, dimensions: Dimensions)
pub fn layout_dimensions(&self, dimensions: Dimensions)
Sets the dimensions of the global layout, use if, for example the window size you render to changed
Sourcepub fn pointer_state(&self, position: Vector2, is_down: bool)
pub fn pointer_state(&self, position: Vector2, is_down: bool)
Updates the state of the pointer for clay. Used to update scroll containers and for interactions functions
pub fn update_scroll_containers( &self, drag_scrolling_enabled: bool, scroll_delta: Vector2, delta_time: f32, )
pub fn pointer_over(&self, cfg: TypedConfig) -> bool
pub fn get_bounding_box(&self, id: TypedConfig) -> Option<BoundingBox>
Sourcepub fn begin(&self)
pub fn begin(&self)
Examples found in repository?
9fn main() {
10 // Create the clay instance
11 let clay = Clay::new((800., 600.).into());
12
13 // Begin the layout
14 clay.begin();
15
16 // Adds a red rectangle with a corner radius of 5.
17 // The Layout makes the rectangle have a width and height of 50.
18 clay.with(
19 [
20 Id::new("red_rectangle"),
21 Layout::new().width(fixed!(50.)).height(fixed!(50.)).end(),
22 Rectangle::new()
23 .color((0xFF, 0x00, 0x00).into())
24 .corner_radius(CornerRadius::All(5.))
25 .end(),
26 ],
27 |_| {},
28 );
29
30 // Return the list of render commands of your layout
31 let render_commands = clay.end();
32
33 for command in render_commands {
34 println!("Id of the element: {}", command.id); // Note: Ids are in fact numbers generated by Clay
35 println!("Bounding box: {:?}", command.bounding_box);
36 println!("Type and config: {:?}", command.config);
37 }
38}Sourcepub fn end(&self) -> impl Iterator<Item = RenderCommand<'_>>
pub fn end(&self) -> impl Iterator<Item = RenderCommand<'_>>
Examples found in repository?
9fn main() {
10 // Create the clay instance
11 let clay = Clay::new((800., 600.).into());
12
13 // Begin the layout
14 clay.begin();
15
16 // Adds a red rectangle with a corner radius of 5.
17 // The Layout makes the rectangle have a width and height of 50.
18 clay.with(
19 [
20 Id::new("red_rectangle"),
21 Layout::new().width(fixed!(50.)).height(fixed!(50.)).end(),
22 Rectangle::new()
23 .color((0xFF, 0x00, 0x00).into())
24 .corner_radius(CornerRadius::All(5.))
25 .end(),
26 ],
27 |_| {},
28 );
29
30 // Return the list of render commands of your layout
31 let render_commands = clay.end();
32
33 for command in render_commands {
34 println!("Id of the element: {}", command.id); // Note: Ids are in fact numbers generated by Clay
35 println!("Bounding box: {:?}", command.bounding_box);
36 println!("Type and config: {:?}", command.config);
37 }
38}Sourcepub fn with<F: FnOnce(&Clay<'_>), const N: usize>(
&self,
configs: [TypedConfig; N],
f: F,
)
pub fn with<F: FnOnce(&Clay<'_>), const N: usize>( &self, configs: [TypedConfig; N], f: F, )
Create an element, passing it’s config and a function to add childrens
// TODO: Add ExampleExamples found in repository?
9fn main() {
10 // Create the clay instance
11 let clay = Clay::new((800., 600.).into());
12
13 // Begin the layout
14 clay.begin();
15
16 // Adds a red rectangle with a corner radius of 5.
17 // The Layout makes the rectangle have a width and height of 50.
18 clay.with(
19 [
20 Id::new("red_rectangle"),
21 Layout::new().width(fixed!(50.)).height(fixed!(50.)).end(),
22 Rectangle::new()
23 .color((0xFF, 0x00, 0x00).into())
24 .corner_radius(CornerRadius::All(5.))
25 .end(),
26 ],
27 |_| {},
28 );
29
30 // Return the list of render commands of your layout
31 let render_commands = clay.end();
32
33 for command in render_commands {
34 println!("Id of the element: {}", command.id); // Note: Ids are in fact numbers generated by Clay
35 println!("Bounding box: {:?}", command.bounding_box);
36 println!("Type and config: {:?}", command.config);
37 }
38}Sourcepub fn text(&self, text: &str, config: TextElementConfig)
pub fn text(&self, text: &str, config: TextElementConfig)
Adds a text element to the current open element or to the root layout