Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bevy 0.14 #287

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
steps:
- uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.76.0
toolchain: 1.79.0
components: clippy, rustfmt
- uses: actions/checkout@v3
- uses: actions/cache@v3
Expand All @@ -31,7 +31,7 @@ jobs:
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-build-1.76.0-${{ hashFiles('**/Cargo.toml') }}
key: ${{ runner.os }}-cargo-build-1.79.0-${{ hashFiles('**/Cargo.toml') }}
- name: Install alsa and udev
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev
if: runner.os == 'linux'
Expand Down
28 changes: 17 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "kayak_ui"
description = "A UI library built using the bevy game engine!"
version = "0.5.0"
version = "0.6.0"
edition = "2021"
resolver = "2"
authors = ["John Mitchell"]
Expand All @@ -14,12 +14,12 @@ exclude = ["assets/*", "screenshots/*", "book"]
members = ["kayak_ui_macros", "kayak_font"]

[features]
svg = ["dep:bevy_svg"]
# svg = ["dep:bevy_svg"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bevy = { version = "0.13", default-features = false, features = ["bevy_render", "bevy_asset", "bevy_core_pipeline"] }
bevy = { version = "0.14", default-features = false, features = ["bevy_render", "bevy_asset", "bevy_core_pipeline"] }
bevy_svg = { git = "https://github.com/arnfaldur/bevy_svg", rev="53a53e5af050a7b5b236068546be46c5729674e3", default-features = false, optional = true }
bitflags = "1.3.2"
bytemuck = "1.12"
Expand All @@ -28,8 +28,8 @@ fancy-regex = "0.11.0"
indexmap = "1.9"
instant = "0.1"
interpolation = { version = "0.2" }
kayak_font = { path = "./kayak_font", version = "0.5" }
kayak_ui_macros = { path = "./kayak_ui_macros", version = "0.5" }
kayak_font = { path = "./kayak_font", version = "0.6" }
kayak_ui_macros = { path = "./kayak_ui_macros", version = "0.6" }
log = "0.4"
morphorm = "0.3"
reorder = "2.1"
Expand All @@ -40,8 +40,8 @@ smol_str = {version = "0.2", default-features = false}

[dev-dependencies]
fastrand = "1.8"
bevy-inspector-egui = "0.23"
bevy = { version = "0.13", default-features = true }
bevy-inspector-egui = "0.25"
bevy = { version = "0.14", default-features = true }

[[example]]
name = "tabs"
Expand All @@ -51,21 +51,27 @@ path = "examples/tabs/tabs.rs"
name = "todo"
path = "examples/todo/todo.rs"

[[example]]
name = "main_menu"
path = "examples/main_menu.rs"

[[example]]
name = "svg"
path = "examples/svg.rs"
# path = "examples/svg.rs"
path = "examples/main_menu.rs"
test = false
doc = false
bench = false
required-features = ["svg"]
# required-features = ["svg"]

[[example]]
name = "accordion"
path = "examples/accordion.rs"
# path = "examples/accordion.rs"
path = "examples/main_menu.rs"
test = false
doc = false
bench = false
required-features = ["svg"]
# required-features = ["svg"]

[package.metadata.docs.rs]
features = ["bevy/x11"]
2 changes: 1 addition & 1 deletion examples/avsb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,5 +223,5 @@ fn main() {
))
.add_systems(Startup, startup)
.add_systems(Update, swap)
.run()
.run();
}
17 changes: 9 additions & 8 deletions examples/bevy_scene.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
use bevy::{
color::palettes::css::{INDIGO, MAROON, TEAL},
math::{Vec3Swizzles, Vec4Swizzles},
prelude::*,
window::PrimaryWindow,
};
use kayak_ui::prelude::{widgets::*, *};

const TILE_SIZE: Vec2 = Vec2::from_array([50.0, 50.0]);
const COLORS: &[Color] = &[Color::TEAL, Color::MAROON, Color::INDIGO];
const COLORS: &[Srgba] = &[TEAL, MAROON, INDIGO];

// ! === Unnecessary Details Below === ! //
// Below this point are mainly implementation details. The main purpose of this example is to show how to know
Expand Down Expand Up @@ -108,18 +109,18 @@ fn on_color_change(
}

let mut active_tile = active_tile.single_mut();
active_tile.color = COLORS[active_color.index];
active_tile.color = COLORS[active_color.index].into();

let mut ghost_tile = ghost_tile.single_mut();
ghost_tile.color = ghost_color(COLORS[active_color.index]);
ghost_tile.color = ghost_color(COLORS[active_color.index].into());
}

/// A system that sets up the world
fn world_setup(mut commands: Commands, active_color: Res<ActiveColor>) {
commands
.spawn(SpriteBundle {
sprite: Sprite {
color: COLORS[active_color.index],
color: COLORS[active_color.index].into(),
custom_size: Some(TILE_SIZE),
..Default::default()
},
Expand All @@ -129,7 +130,7 @@ fn world_setup(mut commands: Commands, active_color: Res<ActiveColor>) {
commands
.spawn(SpriteBundle {
sprite: Sprite {
color: ghost_color(COLORS[active_color.index]),
color: ghost_color(COLORS[active_color.index].into()),
custom_size: Some(TILE_SIZE),
..Default::default()
},
Expand Down Expand Up @@ -160,7 +161,7 @@ fn world_to_tile(world_pos: Vec2) -> Vec2 {
/// Get the ghost tile color for a given color
fn ghost_color(color: Color) -> Color {
let mut c = color;
c.set_a(0.35);
c.set_alpha(0.35);
c
}

Expand Down Expand Up @@ -257,7 +258,7 @@ fn startup(

fn main() {
App::new()
.insert_resource(ClearColor(Color::rgb(0.0, 0.0, 0.0)))
.insert_resource(ClearColor(Color::srgb(0.0, 0.0, 0.0)))
.insert_resource(ActiveColor { index: 0 })
.add_plugins(DefaultPlugins)
.add_plugins((KayakContextPlugin, KayakWidgets))
Expand All @@ -271,5 +272,5 @@ fn main() {
on_color_change,
),
)
.run()
.run();
}
8 changes: 4 additions & 4 deletions examples/box_shadows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn startup(
height: Units::Pixels(182.0).into(),
box_shadow: vec![
BoxShadow {
color: Color::rgb(38.0 / 255.0, 57.0 / 255.0, 77.0 / 255.0),
color: Color::srgb(38.0 / 255.0, 57.0 / 255.0, 77.0 / 255.0),
radius: 30.0,
offset: Vec2::new(0.0, 20.0),
spread: Vec2::new(0.0, -10.0),
Expand All @@ -53,7 +53,7 @@ fn startup(
height: Units::Pixels(182.0).into(),
box_shadow: vec![
BoxShadow {
color: Color::rgba(0.0, 0.0, 0.0, 0.1),
color: Color::srgba(0.0, 0.0, 0.0, 0.1),
radius: 12.0,
offset: Vec2::new(0.0, 4.0),
spread: Vec2::new(0.0, 0.0),
Expand Down Expand Up @@ -175,9 +175,9 @@ fn startup(

fn main() {
App::new()
.insert_resource(ClearColor(Color::rgb(1.0, 1.0, 1.0)))
.insert_resource(ClearColor(Color::srgb(1.0, 1.0, 1.0)))
.add_plugins(DefaultPlugins.set(ImagePlugin::default_nearest()))
.add_plugins((KayakContextPlugin, KayakWidgets))
.add_systems(Startup, startup)
.run()
.run();
}
4 changes: 2 additions & 2 deletions examples/clipping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras sed tellus neque.

fn main() {
App::new()
.insert_resource(ClearColor(Color::rgb(0.0, 0.0, 0.0)))
.insert_resource(ClearColor(Color::srgb(0.0, 0.0, 0.0)))
.add_plugins(DefaultPlugins.set(ImagePlugin::default_nearest()))
.add_plugins((KayakContextPlugin, KayakWidgets))
.add_systems(Startup, startup)
.run()
.run();
}
4 changes: 2 additions & 2 deletions examples/conditional_widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ fn startup(

fn main() {
App::new()
.insert_resource(ClearColor(Color::rgb(0.0, 0.0, 0.0)))
.insert_resource(ClearColor(Color::srgb(0.0, 0.0, 0.0)))
.add_plugins(DefaultPlugins)
.add_plugins((KayakContextPlugin, KayakWidgets))
.add_systems(Startup, startup)
.run()
.run();
}
20 changes: 10 additions & 10 deletions examples/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,25 @@ impl Theme {
fn vampire() -> Self {
Self {
name: "Vampire".to_string(),
primary: Color::rgba(1.0, 0.475, 0.776, 1.0),
secondary: Color::rgba(0.641, 0.476, 0.876, 1.0),
background: Color::rgba(0.157, 0.165, 0.212, 1.0),
primary: Color::srgba(1.0, 0.475, 0.776, 1.0),
secondary: Color::srgba(0.641, 0.476, 0.876, 1.0),
background: Color::srgba(0.157, 0.165, 0.212, 1.0),
}
}
fn solar() -> Self {
Self {
name: "Solar".to_string(),
primary: Color::rgba(0.514, 0.580, 0.588, 1.0),
secondary: Color::rgba(0.149, 0.545, 0.824, 1.0),
background: Color::rgba(0.026, 0.212, 0.259, 1.0),
primary: Color::srgba(0.514, 0.580, 0.588, 1.0),
secondary: Color::srgba(0.149, 0.545, 0.824, 1.0),
background: Color::srgba(0.026, 0.212, 0.259, 1.0),
}
}
fn vector() -> Self {
Self {
name: "Vector".to_string(),
primary: Color::rgba(0.533, 1.0, 0.533, 1.0),
secondary: Color::rgba(0.098, 0.451, 0.098, 1.0),
background: Color::rgba(0.004, 0.059, 0.004, 1.0),
primary: Color::srgba(0.533, 1.0, 0.533, 1.0),
secondary: Color::srgba(0.098, 0.451, 0.098, 1.0),
background: Color::srgba(0.004, 0.059, 0.004, 1.0),
}
}
}
Expand Down Expand Up @@ -380,5 +380,5 @@ fn main() {
.add_plugins(DefaultPlugins)
.add_plugins((KayakContextPlugin, KayakWidgets))
.add_systems(Startup, startup)
.run()
.run();
}
2 changes: 1 addition & 1 deletion examples/custom_shader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,5 @@ fn main() {
MaterialUIPlugin::<MyUIMaterial>::default(),
))
.add_systems(Startup, startup)
.run()
.run();
}
2 changes: 1 addition & 1 deletion examples/demo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,5 @@ fn main() {
.add_plugins((KayakContextPlugin, KayakWidgets))
.add_systems(Startup, startup)
.add_systems(Update, update_resource)
.run()
.run();
}
2 changes: 1 addition & 1 deletion examples/font_size_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@ fn main() {
.add_plugins(DefaultPlugins)
.add_plugins((KayakContextPlugin, KayakWidgets))
.add_systems(Startup, startup)
.run()
.run();
}
2 changes: 1 addition & 1 deletion examples/hello_world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ fn main() {
.add_plugins(DefaultPlugins)
.add_plugins((KayakContextPlugin, KayakWidgets))
.add_systems(Startup, startup)
.run()
.run();
}
2 changes: 1 addition & 1 deletion examples/hello_world_no_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@ fn main() {
.add_plugins(DefaultPlugins)
.add_plugins((KayakContextPlugin, KayakWidgets))
.add_systems(Startup, startup)
.run()
.run();
}
2 changes: 1 addition & 1 deletion examples/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ fn main() {
.add_plugins(DefaultPlugins.set(ImagePlugin::default_nearest()))
.add_plugins((KayakContextPlugin, KayakWidgets))
.add_systems(Startup, startup)
.run()
.run();
}
6 changes: 3 additions & 3 deletions examples/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ fn startup(
>
<BackgroundBundle
styles={KStyle{
background_color: Color::rgb(0.4, 0.9, 0.4).into(),
color: Color::rgb(0.0, 0.0, 0.0).into(),
background_color: Color::srgb(0.4, 0.9, 0.4).into(),
color: Color::srgb(0.0, 0.0, 0.0).into(),
padding: Edge::all(Units::Pixels(5.0)).into(),
border_radius: Corner::all(10.0).into(),
row_index: 0.into(),
Expand Down Expand Up @@ -138,5 +138,5 @@ fn main() {
.add_plugins(DefaultPlugins)
.add_plugins((KayakContextPlugin, KayakWidgets))
.add_systems(Startup, startup)
.run()
.run();
}
4 changes: 2 additions & 2 deletions examples/main_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ fn startup(
let handle_click_close = OnEvent::new(
move |In(_entity): In<Entity>, event: ResMut<KEvent>, mut exit: EventWriter<AppExit>| {
if let EventType::Click(..) = event.event_type {
exit.send(AppExit);
exit.send(AppExit::Success);
}
},
);
Expand Down Expand Up @@ -219,5 +219,5 @@ fn main() {
.add_plugins(DefaultPlugins.set(ImagePlugin::default_nearest()))
.add_plugins((KayakContextPlugin, KayakWidgets))
.add_systems(Startup, startup)
.run()
.run();
}
4 changes: 2 additions & 2 deletions examples/modal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,13 @@ fn startup(

fn main() {
App::new()
.insert_resource(ClearColor(Color::rgb(0.0, 0.0, 0.0)))
.insert_resource(ClearColor(Color::srgb(0.0, 0.0, 0.0)))
.add_plugins(DefaultPlugins)
.add_plugins((
KayakContextPlugin,
KayakWidgets,
MaterialUIPlugin::<MyUIMaterial>::default(),
))
.add_systems(Startup, startup)
.run()
.run();
}
2 changes: 1 addition & 1 deletion examples/nine_patch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,5 @@ fn main() {
.add_plugins(DefaultPlugins.set(ImagePlugin::default_nearest()))
.add_plugins((KayakContextPlugin, KayakWidgets))
.add_systems(Startup, startup)
.run()
.run();
}
4 changes: 2 additions & 2 deletions examples/opacity_layers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ fn startup(

fn main() {
App::new()
.insert_resource(ClearColor(Color::rgb(0.0, 0.0, 0.0)))
.insert_resource(ClearColor(Color::srgb(0.0, 0.0, 0.0)))
.add_plugins(DefaultPlugins)
.add_plugins((KayakContextPlugin, KayakWidgets))
.add_systems(Startup, startup)
.run()
.run();
}
4 changes: 2 additions & 2 deletions examples/quads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ fn startup(
fastrand::i32(32..64) as f32,
fastrand::i32(32..64) as f32,
);
let color = Color::rgba(
let color = Color::srgba(
fastrand::f32(),
fastrand::f32(),
fastrand::f32(),
Expand Down Expand Up @@ -142,5 +142,5 @@ fn main() {
KayakWidgets,
))
.add_systems(Startup, startup)
.run()
.run();
}
Loading
Loading