Commit 386685be authored by Florian Blasius's avatar Florian Blasius 🤘

finish grid update

parent 1067704a
......@@ -53,6 +53,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Add fonts and icon sets specific to fluent design (Microsoft Segoe look)
* Add message example
* Remove widgets example
* Replaces Columns and Rows structs with Blocks
* Set grid columns and rows also as string
* Refactor grid layout code
### 0.3.1-alpha3
......
......@@ -91,7 +91,7 @@ impl GridLayout {
let child_size = self.children_sizes.borrow().get(&child).unwrap().1;
if let Some(size) = block_sizes.get(&grid_block) {
if *size < child_size + margin.left() + margin.right() {
if *size < child_size + margin.top() + margin.bottom() {
block_sizes.insert(grid_block, child_size + margin.top() + margin.bottom());
}
} else {
......@@ -154,9 +154,9 @@ impl GridLayout {
let mut block_sum = 0.0;
blocks_cache.reserve(blocks.len());
for col in blocks.iter() {
blocks_cache.push((block_sum, col.current_size()));
block_sum += col.current_size();
for block in blocks.iter() {
blocks_cache.push((block_sum, block.current_size()));
block_sum += block.current_size();
}
// fix rounding gab
......
......@@ -186,6 +186,12 @@ impl From<BlocksBuilder> for Blocks {
#[derive(Debug, Clone, PartialEq, Default)]
pub struct Blocks(pub Vec<Block>);
/// Alias type for `Blocks` to don't break old api.
pub type Columns = Blocks;
/// Alias type for `Blocks` to don't break old api.
pub type Rows = Blocks;
impl Blocks {
/// Creates a new `BlocksBuilder` object with default values.
#[inline]
......
......@@ -223,7 +223,7 @@ impl Template for MainView {
)
.child(
Container::new()
.background("green")
.style("content_container")
.padding(4)
.attach(Grid::row(1))
.child(
......
......@@ -10,18 +10,7 @@ fn main() {
.title("OrbTk - minimal example")
.position((100.0, 100.0))
.size(420.0, 730.0)
.child(
Grid::new()
.rows("32, *")
.child(Container::new().background("green").build(ctx))
.child(
Container::new()
.attach(Grid::column(1))
.background("blue")
.build(ctx),
)
.build(ctx),
)
.child(TextBlock::new().text("OrbTk").build(ctx))
.build(ctx)
})
.run();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment