Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
trimental committed May 24, 2023
1 parent e47443e commit c109c60
Show file tree
Hide file tree
Showing 8 changed files with 300 additions and 100 deletions.
68 changes: 45 additions & 23 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ indexmap = { version = "1.9.3", features = ["serde"] }
html-escape = "0.2.13"
fxhash = "0.2.1"
twox-hash = "1.6.3"
taffy = { git="https://github.com/DioxusLabs/taffy" }

[dependencies.glyphon]
version = "0.2"
Expand All @@ -67,3 +68,6 @@ lto = true
[dev-dependencies]
insta = "1.29.0"
pretty_assertions = "1.3.0"

[patch.crates-io]
cosmic-text = { path = "../cosmic-text" }
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![feature(default_free_fn)]
pub mod color;
pub mod fonts;
pub mod image;
Expand Down
44 changes: 17 additions & 27 deletions src/positioner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::{cell::RefCell, collections::HashMap};
use anyhow::Context;

use crate::{
table::{TABLE_COL_GAP, TABLE_ROW_GAP},
text::{TextBox, TextSystem},
utils::{Align, Point, Rect, Size},
Element,
Expand Down Expand Up @@ -107,33 +106,24 @@ impl Positioner {
}
Element::Table(table) => {
let pos = (DEFAULT_MARGIN + centering, self.reserved_height);
let width = table
.column_widths(
text_system,
(
self.screen_size.0 - pos.0 - DEFAULT_MARGIN - centering,
f32::INFINITY,
),
zoom,
)
.iter()
.fold(0., |acc, x| acc + x);
let height = table
.row_heights(
text_system,
(
self.screen_size.0 - pos.0 - DEFAULT_MARGIN - centering,
f32::INFINITY,
),
zoom,
)
.iter()
.fold(0., |acc, x| acc + x);
Rect::new(
pos,
let layout = table.layout(
text_system,
(
self.screen_size.0 - pos.0 - DEFAULT_MARGIN - centering,
f32::INFINITY,
),
zoom,
)?;
let min = layout.first().unwrap().first().unwrap();
let max = layout.last().unwrap().last().unwrap();
Rect::from_min_max(
(
DEFAULT_MARGIN + centering + min.location.x,
self.reserved_height + min.location.y,
),
(
width * (TABLE_COL_GAP * table.headers.len() as f32),
height + (TABLE_ROW_GAP * (table.rows.len() + 1) as f32),
DEFAULT_MARGIN + centering + max.location.x + max.size.width,
self.reserved_height + max.location.y + max.size.height,
),
)
}
Expand Down
Loading

0 comments on commit c109c60

Please sign in to comment.