pub struct Margin {
pub left: f32,
pub right: f32,
pub top: f32,
pub bottom: f32,
/* private fields */
}Expand description
Maintains a margin around a singular child.
Using a negative margin will expand the minimum size but not restrict the space of the child. This can be used to make the child occupy more space than it would otherwise.
The space is restricted by the margin before alignment is applied, so if the child’s alignment
is Center the child will be centered based on the restricted space, resulting in an
unexpected shift if top != bottom or left != right. All other alignments are unaffected.
Maintains the margin as a minimum size even if child is None, however, once a child is
assigned, it cannot be removed. If you intend to use the margin as a minimum size, you should
use Minimum with no child instead.
Fields§
§left: f32The left margin amount.
right: f32The right margin amount.
top: f32The top margin amount.
bottom: f32The bottom margin amount.
Implementations§
Source§impl Margin
impl Margin
Sourcepub fn with_child(self, index: NodeIndex) -> Self
pub fn with_child(self, index: NodeIndex) -> Self
Sourcepub fn with_align(self, align: (Alignment, Alignment)) -> Self
pub fn with_align(self, align: (Alignment, Alignment)) -> Self
Set the horizontal and vertical alignment.
Sourcepub fn with_margins(self, left: f32, right: f32, top: f32, bottom: f32) -> Self
pub fn with_margins(self, left: f32, right: f32, top: f32, bottom: f32) -> Self
Set the left, right, top, and bottom margins.
Sourcepub fn with_equal_x(self, lr: f32) -> Self
pub fn with_equal_x(self, lr: f32) -> Self
Set the left and right margins to the same value.
Sourcepub fn with_equal_y(self, tb: f32) -> Self
pub fn with_equal_y(self, tb: f32) -> Self
Set the top and bottom margins to the same value.
Sourcepub fn with_equal_xy(self, lr: f32, tb: f32) -> Self
pub fn with_equal_xy(self, lr: f32, tb: f32) -> Self
Set both the left and right margins, and both the top and bottom margins.
Sourcepub fn with_equal(self, margin: f32) -> Self
pub fn with_equal(self, margin: f32) -> Self
Set the left, right, top, and bottom margins to the same value.
Sourcepub fn with_right(self, right: f32) -> Self
pub fn with_right(self, right: f32) -> Self
Set the right margin.
Sourcepub fn with_bottom(self, bottom: f32) -> Self
pub fn with_bottom(self, bottom: f32) -> Self
Set the bottom margin.
Trait Implementations§
Source§impl UiNode for Margin
impl UiNode for Margin
Source§fn get_align_mut(&mut self) -> (&mut Alignment, &mut Alignment)
fn get_align_mut(&mut self) -> (&mut Alignment, &mut Alignment)
Source§fn calculate_min_size(&self, tree: &UiTree) -> (f32, f32)
fn calculate_min_size(&self, tree: &UiTree) -> (f32, f32)
Source§fn calculate_rects(&self, cache: &NodeCache, tree: &UiTree) -> Vec<Rect>
fn calculate_rects(&self, cache: &NodeCache, tree: &UiTree) -> Vec<Rect>
get_visible_children. Read more