Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 38 additions & 17 deletions Cargo.lock

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

28 changes: 23 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ documentation = "https://docs.rs/violet"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[workspace.dependencies]
flax = { git = "https://github.com/ten3roberts/flax", branch = "dev", version = "0.8.0", features = ["derive", "puffin"] }
flax = { git = "https://github.com/ten3roberts/flax", branch = "dev", version = "0.8.0", features = [
"derive",
"puffin",
] }

atomic_refcell = "0.1"
futures-signals = "0.3"
Expand All @@ -38,7 +41,10 @@ anyhow = "1.0"
once_cell = "1.19"
slab = "0.4"
tynm = "0.1"
tokio = { version = "1.39", default-features = false, features = ["macros", "rt"] }
tokio = { version = "1.39", default-features = false, features = [
"macros",
"rt",
] }
arrayvec = "0.7"
sync_wrapper = "1.0"
smallvec = "1.13"
Expand All @@ -47,10 +53,17 @@ tween = { version = "2.0.4", features = ["glam"] }

bytemuck = { version = "1.17", features = ["derive"] }
winit = "0.30"
wgpu = { version = "22.1", default-features = false, features = ["fragile-send-sync-non-atomic-wasm", "webgl", "wgsl"] }
wgpu = { version = "22.1", default-features = false, features = [
"fragile-send-sync-non-atomic-wasm",
"webgl",
"wgsl",
] }
palette = { version = "0.7", features = ["serializing"] }
dashmap = "6.0"
image = { version = "0.25", default-features = false, features = ["png", "jpeg"] }
image = { version = "0.25", default-features = false, features = [
"png",
"jpeg",
] }
color-hex = "0.2"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
Expand All @@ -60,7 +73,12 @@ rfd = "0.14"
tracing = "0.1"
pin-project = "1.1"

cosmic-text = { version = "0.12", default-features = false, features = ["wasm-web", "rayon", "swash", "no_std"] }
cosmic-text = { version = "0.14", default-features = false, features = [
"shape-run-cache",
"wasm-web",
"swash",
"std",
] }
guillotiere = "0.6"
bytes = "1.7"
more-asserts = "0.3"
Expand Down
79 changes: 32 additions & 47 deletions examples/layouting.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
use core::f32;

use glam::Vec2;
use palette::Srgba;
use tracing_subscriber::{layer::SubscriberExt, registry, util::SubscriberInitExt, EnvFilter};
use tracing_tree::HierarchicalLayer;
use violet_core::{
style::{base_colors::*, surface_primary, surface_secondary, SizeExt, StylesheetOptions},
style::{
base_colors::*, spacing_medium, surface_primary, surface_secondary, SizeExt,
StylesheetOptions,
},
unit::Unit,
widget::{bold, card, col, label, pill, raised_card, row, Button, Rectangle},
Edges, Widget,
widget::{col, row, Rectangle, Stack},
Widget, WidgetCollection,
};
use violet_lucide::icons::*;
use violet_wgpu::renderer::MainRendererConfig;

pub fn main() -> anyhow::Result<()> {
Expand All @@ -31,54 +34,36 @@ pub fn main() -> anyhow::Result<()> {
.build(),
)
.with_renderer_config(MainRendererConfig { debug_mode: false })
.run(main_ui())
.run(layout_using_flow())
}

fn main_ui() -> impl Widget {
fn layout_using_flow() -> impl Widget {
fn container(content: impl WidgetCollection) -> Stack<impl WidgetCollection> {
Stack::new(content).with_background(surface_secondary())
// .with_margin(spacing_small())
}
row((
col((
card(()).with_maximize(Vec2::ONE),
window(LUCIDE_LIST_TREE, "Bottom Panel", card(())),
container(())
.with_margin(spacing_medium())
.with_background(STONE_700)
.with_maximize(Vec2::ONE)
// .with_min_size(Unit::px2(0.0, 200.0))
.with_size(Unit::px2(600.0, 400.0)),
Stack::new(Rectangle::new(SAPPHIRE_500).with_min_size(Unit::px2(260.0, 40.0))),
container(())
.with_margin(spacing_medium())
.with_background(RUBY_800)
.with_maximize(Vec2::ONE),
// .with_size(Unit::px2(1.0, 1.0)),
)),
// window(
// LUCIDE_SATELLITE,
// "Right Panel",
// col(
// // Slider::new(Mutable::new(50), 0, 100),
// // Slider::new(Mutable::new(20), 0, 100),
// // col((
// // row((Stack::new(label("Value")).with_maximize(Vec2::X), TextInput::new(Mutable::new("Editable".to_string())).input_box())),
// // )),
// raised_card(label("lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.").with_wrap(cosmic_text::Wrap::WordOrGlyph))
// ),
// )
// .with_max_size(Unit::px2(400.0, f32::MAX))
// .with_maximize(Vec2::Y),
container(())
.with_margin(spacing_medium())
.with_background(STONE_900)
.with_max_size(Unit::px2(40.0, f32::MAX))
.with_min_size(Unit::px2(40.0, 0.0))
.with_maximize(Vec2::Y),
))
.with_background(surface_primary())
.with_contain_margins(true)
}

fn window(
icon: impl Into<String>,
title: impl Into<String>,
content: impl Widget,
) -> impl Widget + SizeExt {
card(
col((
row((
label(icon).with_margin(Edges::right(8.0)),
bold(title),
// Rectangle::new(Srgba::new(0.0, 0.0, 0.0, 0.0)).with_maximize(Vec2::X),
pill(row((
Button::label(LUCIDE_MAXIMIZE).success(),
Button::label(LUCIDE_MINUS).warning(),
Button::label(LUCIDE_X).danger(),
))),
))
.center(),
content,
)), // .with_stretch(true),
)
.with_background(surface_secondary())
}
10 changes: 2 additions & 8 deletions examples/too_small.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
use glam::Vec2;
use palette::Srgba;
use tracing_subscriber::{layer::SubscriberExt, registry, util::SubscriberInitExt, EnvFilter};
use tracing_tree::HierarchicalLayer;
use violet_core::{
style::{
base_colors::*, default_corner_radius, surface_primary, surface_secondary, SizeExt,
StylesheetOptions,
},
style::{base_colors::*, surface_primary, SizeExt, StylesheetOptions},
unit::Unit,
widget::{bold, card, col, label, pill, raised_card, row, Button, Rectangle},
widget::{col, label, pill, row, Rectangle},
Edges, Widget,
};
use violet_lucide::icons::*;
use violet_wgpu::renderer::MainRendererConfig;

pub fn main() -> anyhow::Result<()> {
Expand Down
5 changes: 3 additions & 2 deletions violet-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ slab.workspace = true
tynm.workspace = true
arrayvec.workspace = true
sync_wrapper.workspace = true
ropey.workspace = true
tween.workspace = true
ropey.workspace = true
tween.workspace = true
nucleo = "0.5"

bytemuck.workspace = true
palette.workspace = true
Expand Down
6 changes: 4 additions & 2 deletions violet-core/src/constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub struct FixedAreaConstraint {

impl SizeResolver for FixedAreaConstraint {
fn query_size(&mut self, _: &flax::EntityRef, args: QueryArgs) -> (Vec2, Vec2, SizingHints) {
let size = (args.limits.max_size / self.unit_size)
let size = (args.limits.layout_max_size / self.unit_size)
.floor()
.max(Vec2::ONE);

Expand All @@ -30,7 +30,9 @@ impl SizeResolver for FixedAreaConstraint {
}

fn apply_layout(&mut self, _: &flax::EntityRef, args: LayoutArgs) -> (Vec2, BVec2) {
let width = (args.limits.max_size.x / self.unit_size).floor().max(1.0);
let width = (args.limits.layout_max_size.x / self.unit_size)
.floor()
.max(1.0);

let height = (self.area / width).ceil();

Expand Down
Loading
Loading