mirror of
https://github.com/griffi-gh/hUI.git
synced 2024-11-21 22:58:42 -06:00
add br element, update docs
This commit is contained in:
parent
7f28aebb97
commit
a46cd7856b
|
@ -9,6 +9,9 @@ pub mod fill_rect;
|
||||||
#[cfg(feature = "builtin_elements")]
|
#[cfg(feature = "builtin_elements")]
|
||||||
pub mod spacer;
|
pub mod spacer;
|
||||||
|
|
||||||
|
#[cfg(feature = "builtin_elements")]
|
||||||
|
pub mod br;
|
||||||
|
|
||||||
// "The basics":
|
// "The basics":
|
||||||
|
|
||||||
#[cfg(feature = "builtin_elements")]
|
#[cfg(feature = "builtin_elements")]
|
||||||
|
|
22
hui/src/element/builtin/br.rs
Normal file
22
hui/src/element/builtin/br.rs
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
use crate::{
|
||||||
|
element::{MeasureContext, ProcessContext, UiElement},
|
||||||
|
measure::Response
|
||||||
|
};
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, Debug, Default)]
|
||||||
|
pub struct Br;
|
||||||
|
|
||||||
|
impl UiElement for Br {
|
||||||
|
fn name(&self) -> &'static str {
|
||||||
|
"Br"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn measure(&self, _: MeasureContext) -> Response {
|
||||||
|
Response {
|
||||||
|
should_wrap: true,
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn process(&self, _: ProcessContext) {}
|
||||||
|
}
|
|
@ -76,7 +76,11 @@ pub struct Container {
|
||||||
#[setters(into)]
|
#[setters(into)]
|
||||||
pub corner_radius: Corners<f32>,
|
pub corner_radius: Corners<f32>,
|
||||||
|
|
||||||
/// Set this to `true` to allow the elements wrap automatically\
|
/// Set this to `true` to allow the elements wrap automatically
|
||||||
|
///
|
||||||
|
/// Disabling/enabling this does not affect explicit wrapping\
|
||||||
|
/// (for example, `Br`, or any other element with `should_wrap` set to `true`)
|
||||||
|
///
|
||||||
/// This is an experimental feature and may not work as expected
|
/// This is an experimental feature and may not work as expected
|
||||||
pub wrap: bool,
|
pub wrap: bool,
|
||||||
|
|
||||||
|
@ -206,7 +210,7 @@ impl UiElement for Container {
|
||||||
};
|
};
|
||||||
|
|
||||||
//Wrap the element if it exceeds container's size and is not the first element in the line
|
//Wrap the element if it exceeds container's size and is not the first element in the line
|
||||||
if self.wrap && (end_pos_pri > max_line_pri) && (line_element_count > 0) {
|
if ((self.wrap && (end_pos_pri > max_line_pri)) || measure.should_wrap) && (line_element_count > 0) {
|
||||||
// >>>>>>> WRAP THAT B*TCH!
|
// >>>>>>> WRAP THAT B*TCH!
|
||||||
|
|
||||||
//Negate the leftover gap from the previous element
|
//Negate the leftover gap from the previous element
|
||||||
|
|
|
@ -26,6 +26,8 @@ pub struct Response {
|
||||||
/// (the element itself gets wrapped to the next line too)
|
/// (the element itself gets wrapped to the next line too)
|
||||||
///
|
///
|
||||||
/// You should almost never set this, and the exact behavior may change in the future
|
/// You should almost never set this, and the exact behavior may change in the future
|
||||||
|
///
|
||||||
|
/// Currently, this forces wrapping even if Container::wrap is set to false
|
||||||
pub should_wrap: bool,
|
pub should_wrap: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue