mirror of
https://github.com/griffi-gh/hUI.git
synced 2024-11-21 14:48:42 -06:00
fix gap/padding layout (kinda) for remaining size
This commit is contained in:
parent
3c6e6be754
commit
c1be9bf22b
|
@ -4,7 +4,6 @@ use hui::{
|
|||
color, size,
|
||||
draw::{ImageHandle, TextureFormat},
|
||||
layout::{Alignment, Direction},
|
||||
rect::Sides,
|
||||
element::{
|
||||
container::Container,
|
||||
fill_rect::FillRect,
|
||||
|
@ -39,12 +38,7 @@ ui_main!(
|
|||
.with_size(size!(100%, auto))
|
||||
.with_direction(Direction::Horizontal)
|
||||
.with_align((Alignment::Begin, Alignment::Center))
|
||||
.with_padding(Sides {
|
||||
left: 5.,
|
||||
right: 0.,
|
||||
top: 5.,
|
||||
bottom: 5.,
|
||||
})
|
||||
.with_padding(5.)
|
||||
.with_gap(15.)
|
||||
.with_background(color::rgb_hex(0x3d3c3e))
|
||||
.with_wrap(true) //XXX: not authentic but great for demostration
|
||||
|
@ -58,8 +52,7 @@ ui_main!(
|
|||
.add_child(ui);
|
||||
}
|
||||
Container::default()
|
||||
//HACK: due to a bug in the layout system, 100%= doesn't work as expected
|
||||
.with_size(size!(94%=, 100%))
|
||||
.with_size(size!(100%=, 100%))
|
||||
.with_align((Alignment::End, Alignment::Center))
|
||||
.with_children(|ui| {
|
||||
Text::new("- ×")
|
||||
|
|
|
@ -224,9 +224,10 @@ impl UiElement for Container {
|
|||
{
|
||||
let last_line = lines.last_mut().unwrap();
|
||||
last_line.content_size = line_size;
|
||||
last_line.remaining_space = max_line_pri - match self.direction {
|
||||
Direction::Horizontal => line_size.x,
|
||||
Direction::Vertical => line_size.y,
|
||||
//HACK: why? - self.gap, may be different for the last element or if it's the only element in the line
|
||||
last_line.remaining_space = max_line_pri - self.gap - match self.direction {
|
||||
Direction::Horizontal => line_size.x + self.padding.left + self.padding.right,
|
||||
Direction::Vertical => line_size.y + self.padding.top + self.padding.bottom,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -286,11 +287,12 @@ impl UiElement for Container {
|
|||
|
||||
//Update the content size of the last line
|
||||
{
|
||||
//HACK: why? - self.gap, may be different for the last element or if it's the only element in the line
|
||||
let cur_line = lines.last_mut().unwrap();
|
||||
cur_line.content_size = line_size;
|
||||
cur_line.remaining_space = max_line_pri - match self.direction {
|
||||
Direction::Horizontal => line_size.x,
|
||||
Direction::Vertical => line_size.y,
|
||||
cur_line.remaining_space = max_line_pri - self.gap - match self.direction {
|
||||
Direction::Horizontal => line_size.x + self.padding.left + self.padding.right,
|
||||
Direction::Vertical => line_size.y + self.padding.top + self.padding.bottom,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue