Skip to content

Commit

Permalink
Merge pull request #38 from Cactice/reuse-in-other-repo
Browse files Browse the repository at this point in the history
Multiple components & nested layout
  • Loading branch information
Cactice authored Dec 16, 2023
2 parents d940b6f + f958a2d commit 3c4a311
Show file tree
Hide file tree
Showing 35 changed files with 1,320 additions and 851 deletions.
978 changes: 738 additions & 240 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
[workspace]
resolver = "2"
members = [
"concept",
"experiment",
"guppies",
"salvage",
"run-wasm",
"examples/life",
"examples/layout",
"examples/list",
]
default-members = ["examples/layout"]

[profile.release]
lto = true
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@

Using svg to generate dynamic vector graphics for GUI purpose

# Demo
`cargo run --bin layout`

# Status
WIP: Don't look. It's a mess.
199 changes: 0 additions & 199 deletions concept/src/responsive/constraint.rs

This file was deleted.

11 changes: 0 additions & 11 deletions concept/src/uses.rs

This file was deleted.

2 changes: 1 addition & 1 deletion examples/layout/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ path = "src/main.rs"
mobile-entry-point = "0.1.1"
guppies = { path = "../../guppies" }
salvage = { path = "../../salvage" }
concept = { path = "../../concept" }
experiment = { path = "../../experiment" }

[target.'cfg(target_os = "android")'.dependencies]
android_logger = "0.11.0"
Expand Down
8 changes: 4 additions & 4 deletions examples/layout/MenuBar.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 5 additions & 9 deletions examples/layout/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
use concept::{responsive::layout_machine::LayoutMachine, scroll::ScrollState, uses::use_svg};
use experiment::{responsive::layout_machine::LayoutMachine, uses::use_svg};
use guppies::bytemuck::cast_slice;
use guppies::{
glam::Mat4,
winit::event::{ElementState, WindowEvent},
GpuRedraw, Guppy,
};
use guppies::{GpuRedraw, Guppy};
use mobile_entry_point::mobile_entry_point;
use std::vec;

pub fn main() {
let mut layout_machine = LayoutMachine::default();

let svg_set = use_svg(
include_str!("../MenuBar.svg").to_string(),
|node, _pass_down| {
layout_machine.add_node(node);
|node, mut _pass_down| {
layout_machine.add_node(&node, &mut _pass_down);
},
None,
);

let mut guppy = Guppy::new([GpuRedraw::default()]);
Expand Down
4 changes: 2 additions & 2 deletions examples/life/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ name = "life"
path = "src/main.rs"

[dependencies]
mobile-entry-point = "0.1.0"
mobile-entry-point = "0.1.1"
guppies = { path = "../../guppies" }
salvage = { path = "../../salvage" }
concept = { path = "../../concept" }
experiment = { path = "../../experiment" }
regex = "1"
bytemuck = "1.13.1"
fastrand = "2.0.0"
Expand Down
38 changes: 25 additions & 13 deletions examples/life/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use concept::scroll::ScrollState;
use concept::spring::SpringMat4;
use concept::svg_init::get_center;
use concept::uses::use_svg;
use experiment::scroll::ScrollState;
use experiment::spring::SpringMat4;
use experiment::svg_init::get_center;
use experiment::uses::use_svg;
use guppies::bytemuck::{cast_slice, Pod, Zeroable};
use guppies::glam::{Mat4, Vec2};
use guppies::winit::event::Event;
use guppies::winit::event::{Event, WindowEvent};
use guppies::{GpuRedraw, Guppy};
use regex::Regex;
use salvage::svg_set::SvgSet;
Expand Down Expand Up @@ -84,6 +84,7 @@ pub fn main() {
}
};
},
None,
);
let mut life_game = LifeGame {
position_to_coordinates,
Expand All @@ -99,16 +100,27 @@ pub fn main() {
.map(|_| SpringMat4::default());
let start_center = Mat4::from_translation((life_game.position_to_coordinates[0], 0.).into());
let mut guppy = Guppy::new([GpuRedraw::default()]);

guppy.register(move |event, gpu_redraw| {
let clicked = scroll_state.event_handler(event);
if let Event::RedrawRequested(_) = event {
tip_animation.update(&mut texture.tip_transform, &mut player_animations);
player_animations
.iter_mut()
.enumerate()
.for_each(|(i, animation)| {
animation.update(&mut texture.player_avatar_transforms[i], &mut svg_set);
});
match event {
Event::WindowEvent {
window_id: _,
event,
} => match event {
WindowEvent::RedrawRequested => {
tip_animation.update(&mut texture.tip_transform, &mut player_animations);
player_animations
.iter_mut()
.enumerate()
.for_each(|(i, animation)| {
animation
.update(&mut texture.player_avatar_transforms[i], &mut svg_set);
});
}
_ => {}
},
_ => (),
}
if clicked {
if tip_animation.is_animating
Expand Down
4 changes: 2 additions & 2 deletions examples/list/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ name = "list"
path = "src/main.rs"

[dependencies]
mobile-entry-point = "0.1.0"
mobile-entry-point = "0.1.1"
guppies = { path = "../../guppies" }
salvage = { path = "../../salvage" }
concept = { path = "../../concept" }
experiment = { path = "../../experiment" }

[target.'cfg(target_os = "android")'.dependencies]
android_logger = "0.11.0"
Expand Down
Loading

0 comments on commit 3c4a311

Please sign in to comment.