Skip to content

Commit

Permalink
Remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
nicopap committed Sep 27, 2023
1 parent d84d0ee commit b4fa84a
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 226 deletions.
22 changes: 10 additions & 12 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ Now that dsl declarations MUST spawn a single entity, the `cmds` argument
can only be a `&mut EntityCommands`. The components of the root entity will
be added to the entity of the `EntityCommands`.

## `cuicui_chirp`: Add `use` and `fn` statements
## `cuicui_chirp`: Add `fn` statements

It is now possible to define templates in `chirp` files. It is also possible
to load external chirp files and spawn them in-line.
It is now possible to define templates in `chirp` files.

Use `fn` to define a template, use `use` to use them:
Use `fn` to define a template. To use them, call them like you would call a
rust macro (with a trailing `!`):

```ron
fn my_template() {
Expand All @@ -114,11 +114,9 @@ fn template_with_arguments(fantasy_color) {
}
Palette {
// Use a `fn` template
use my_template
// Just in-line another scene.
use "path/to/scene.chirp"
my_template!()
// Use a `fn` template with arguments
use template_with_arguments(Color::PINK)
template_with_arguments!(Color::PINK)
}
```

Expand All @@ -129,11 +127,11 @@ Currently only `fn` defined within the same file are recognized.
With this distribution mode, all children start at the beginning of
this container. They are not "distributed", they overlap.

## Add `cuicui_layout::debug::Options::hide_invisible`
## Add `cuicui_layout::debug::Options::show_hidden`

Now `cuicui_layout`'s debug view do not draw outline of invisibile containers.
To control this new behavior, toggle the `hide_invisible` field. It is `true`
by default. Setting it to `false` will show the outline of hidden containers.
Now `cuicui_layout`'s debug view do not draw outline of invisibile containers by default.
To control this new behavior, toggle the `show_hidden` field. It is `false`
by default. Setting it to `true` will show the outline of hidden containers.

# 0.9.0

Expand Down
26 changes: 5 additions & 21 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,34 +59,18 @@ rust-hsluv = "0.1.4"
# https://github.com/bevyengine/bevy/pull/9621
# bevy_sprite should just work. The following line is to quickly generate the lines
# necessary to patch dependencies with a local version of bevy.
[patch.crates-io]
bevy-ui-navigation = { path = "../ui-navigation" }
bevy = { path = "../../gitimpo/bevy" }
bevy_app = { path = "../../gitimpo/bevy/crates/bevy_app" }
bevy_asset = { path = "../../gitimpo/bevy/crates/bevy_asset" }
bevy_core = { path = "../../gitimpo/bevy/crates/bevy_core" }
bevy_ecs = { path = "../../gitimpo/bevy/crates/bevy_ecs" }
bevy_hierarchy = { path = "../../gitimpo/bevy/crates/bevy_hierarchy" }
bevy_log = { path = "../../gitimpo/bevy/crates/bevy_log" }
bevy_math = { path = "../../gitimpo/bevy/crates/bevy_math" }
bevy_reflect = { path = "../../gitimpo/bevy/crates/bevy_reflect" }
bevy_utils = { path = "../../gitimpo/bevy/crates/bevy_utils" }
bevy_window = { path = "../../gitimpo/bevy/crates/bevy_window" }
bevy_mikktspace = { path = "../../gitimpo/bevy/crates/bevy_mikktspace" }
bevy_transform = { path = "../../gitimpo/bevy/crates/bevy_transform" }
bevy_render = { path = "../../gitimpo/bevy/crates/bevy_render" }
bevy_time = { path = "../../gitimpo/bevy/crates/bevy_time" }
bevy_core_pipeline = { path = "../../gitimpo/bevy/crates/bevy_core_pipeline" }
bevy_pbr = { path = "../../gitimpo/bevy/crates/bevy_pbr" }
# [patch.crates-io]
# bevy = { git = "https://github.com/nicopap/bevy.git", branch = "v0.11.2-no-ui-panic" }
#app|asset|core|ecs|hierarchy|log|math|reflect|utils|window|mikktspace|transform|render|time|core_pipeline|pbr|

[workspace.metadata.release]
dependent-version = "upgrade"

# This is only to profile & analyze ASM output of the binary examples
[profile.release]
# codegen-units = 1
codegen-units = 1
opt-level = 3
lto = false
lto = "fat"
split-debuginfo = "packed"
debug = 1

Expand Down
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ A workaround will probably be provided in cuicui 0.10.
```rust
use bevy::prelude::*;
use cuicui_layout_bevy_ui::UiDsl as Dsl;
use cuicui_layout::{LayoutRootCamera, dsl, dsl_functions::{px, pct}};
use cuicui_layout::{LayoutRootCamera, dsl, dsl_functions::{px, pct, child}};

fn setup(mut cmds: Commands, serv: Res<AssetServer>) {

Expand All @@ -48,20 +48,25 @@ let button = serv.load("button.png");

dsl! {
&mut cmds.spawn_empty(),
Root(row screen_root main_margin(100.) distrib_start align_start image(&bg)) {
Root(layout(">dSaS") screen_root main_margin(100.) image(&bg)) {
Menu(rules(px(310), pct(100)) main_margin(40.) image(&board) column) {
TitleCard(image(&title_card) width(pct(100)))
MiniTitleCard(ui(title_card) width(pct(50)))
TitleCard2(ui(title_card) width(pct(50)))
code(let cmds) {
for n in &menu_buttons {
let name = format!("{n} button");
dsl!(cmds, Entity(ui(*n) named(name) image(&button) height(px(33))));
}
dsl!(cmds, Buttons(column height(child(2.)) width(pct(100))));
cmds.with_children(|cmds|{
for n in &menu_buttons {
let name = format!("{n} button");
dsl!(
&mut cmds.spawn_empty(),
Entity(ui(*n) named(name) image(&button) height(px(33)))
);
}
});
}
}
}
};

}
```

Expand Down
1 change: 0 additions & 1 deletion chirp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ trace_parser = ["winnow/debug"]
trace_lexer = []
load_font = ["bevy/bevy_text"]
load_image = ["bevy/bevy_render"]
debug = ["bevy/bevy_ui", "bevy/bevy_render"]

[dependencies]
anyhow.workspace = true
Expand Down
3 changes: 0 additions & 3 deletions chirp/src/loader/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ use crate::{Handles, ParseDsl};
pub use spawn::{Chirp, ChirpState};

mod internal;
#[cfg(feature = "debug")]
pub mod print_hierarchy;
// mod remove_ids;
mod scene;
pub(super) mod spawn;

Expand Down
60 changes: 0 additions & 60 deletions chirp/src/loader/print_hierarchy.rs

This file was deleted.

98 changes: 0 additions & 98 deletions chirp/src/loader/remove_ids.rs

This file was deleted.

8 changes: 4 additions & 4 deletions chirp/src/parse_dsl/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//! [`super::split()`] function.
#![allow(clippy::inline_always)]
// allow: rust has difficulties inlining functions cross-crate. Since we only
// use inline(never) on functions that are very small, it won't add significative
// use inline(always) on functions that are very small, it won't add significative
// compile overhead in anycase, but may help the optimizer elide some code.

use std::{any, borrow::Cow, convert::Infallible, fs, io, marker::PhantomData, str, str::FromStr};
Expand Down Expand Up @@ -125,7 +125,7 @@ pub fn from_reflect<T: Reflect + FromReflect>(
///
/// # Errors
/// [`FromStr::from_str`] fails, there is a parsing error.
#[inline(never)]
#[inline(always)]
pub fn from_str<T: FromStr>(
_: &TypeRegistry,
_: Option<&mut LoadContext>,
Expand All @@ -147,7 +147,7 @@ where
///
/// # Errors
/// See [`HandleDslDeserError`] for possible errors.
#[inline(never)]
#[inline(always)]
pub fn to_handle<T: Asset + LoadAsset>(
_: &TypeRegistry,
load_context: Option<&mut LoadContext>,
Expand Down Expand Up @@ -175,7 +175,7 @@ pub fn to_handle<T: Asset + LoadAsset>(
///
/// This is always `Ok`. It is safe to unwrap. Rust guarentees that `Infallible`
/// can't be constructed.
#[inline(never)]
#[inline(always)]
pub fn quoted<'a>(
_: &TypeRegistry,
_: Option<&mut LoadContext>,
Expand Down
1 change: 0 additions & 1 deletion chirp/src/parser/grammar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ fn token_tree_impl<const SPLIT_COMMA: bool>(input: &mut Input<impl Itrp>) -> Voi
#[inline(always)]
fn method(input: &mut Input<impl Itrp>) -> VoidResult {
let state = input.state.clone();
// let token_tree = (token_tree);
let argument = delim(t::Lparen, many(token_tree), cut_err(t::Rparen));
let ident = |i: &mut _| match opt(any).parse_next(i) {
Ok(Some(Ident(ident))) => Ok(ident),
Expand Down
10 changes: 0 additions & 10 deletions chirp/src/parser/lex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,6 @@ impl<'i, const Q: u8> Quoted<'i, Q> {
}
}

// fn end_comment<const LANES: usize>(xs: [u8; LANES]) -> EndComment {
// let mid = usize::MAX / 2;
// let pos = xs.iter().fold(usize::MAX, |acc, x| match x {
// b'\n' if acc > mid => usize::MAX - acc,
// _ if acc > mid => acc - 1,
// _ => acc,
// });
// if pos < mid { EndComment::LineEnding(pos) } else { EndComment::None }
// }

#[derive(Clone, Copy)]
struct Swar8(u64);
impl Swar8 {
Expand Down
14 changes: 6 additions & 8 deletions examples/simple_menu/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,14 @@ fn setup(mut cmds: Commands, serv: Res<AssetServer>) {
TitleCard(image(&title_card) width(pct(100)))
TitleCard2(ui(title_card) width(pct(50)))
code(let cmds) {
let mut dsl: Dsl = default();
dsl.named("buttons");
dsl.column();
dsl.height(child(2.));
dsl.width(pct(100));
dsl.node(cmds, |cmds|{
dsl!(cmds, Buttons(column height(child(2.)) width(pct(100))));
cmds.with_children(|cmds|{
for n in &menu_buttons {
let mut cmds = cmds.spawn_empty();
let name = format!("{n} button");
dsl!(&mut cmds, Entity(ui(text!(*n)) named(name) image(&button) height(px(33))));
dsl!(
&mut cmds.spawn_empty(),
Entity(ui(text!(*n)) named(name) image(&button) height(px(33)))
);
}
});
}
Expand Down

0 comments on commit b4fa84a

Please sign in to comment.