Skip to content

Commit

Permalink
component -> panel
Browse files Browse the repository at this point in the history
  • Loading branch information
mockersf committed Dec 6, 2024
1 parent e6abbaf commit 6996f87
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Ratatecs

Experiment with [Bevy ECS](https://bevyengine.org) and [Ratatui](https://ratatui.rs) to build TUI with completely isolated components.
Experiment with [Bevy ECS](https://bevyengine.org) and [Ratatui](https://ratatui.rs) to build TUI with completely isolated panels (group of widgets).

- Component inner state is stored in the ECS
- Component selection through State
- Each component pushes a z-ordered list of widgets that are rendered at the end of the frame
- Panel inner state is stored in the ECS
- Panel selection through State
- Each panel pushes a z-ordered list of widgets that are rendered at the end of the frame

Bevy handles the run loop, storing state in the world, and passing the needed arguments to each function through dependency injection.

Expand All @@ -13,14 +13,14 @@ Bevy handles the run loop, storing state in the world, and passing the needed ar
## Example Usage

![example with 5 components](https://raw.githubusercontent.com/vleue/ratatecs/main/ratatecs.gif)
![example with 5 panels](https://raw.githubusercontent.com/vleue/ratatecs/main/ratatecs.gif)

```rust,no_run
use ratatecs::prelude::*;
fn main() {
App::new()
.add_plugins((RatatEcsPlugins, app::component))
.add_plugins((RatatEcsPlugins, app::panel))
.run();
}
Expand All @@ -32,14 +32,14 @@ mod app {
#[derive(Resource)]
struct Counter(u32);
pub fn component(app: &mut App) {
// Store the state of this component in the world
pub fn panel(app: &mut App) {
// Store the state of this panel in the world
app.insert_resource(Counter(0));
// Systems that update the state or react to user inputs
app.add_systems(Update, (exit_on_esc, change_counter));
// System to render thos component
// System to render thos panel
app.add_systems(PostUpdate, render);
}
Expand Down
File renamed without changes.
10 changes: 4 additions & 6 deletions examples/simple.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use ratatecs::prelude::*;

fn main() {
App::new()
.add_plugins((RatatEcsPlugins, app::component))
.run();
App::new().add_plugins((RatatEcsPlugins, app::panel)).run();
}

mod app {
Expand All @@ -14,14 +12,14 @@ mod app {
#[derive(Resource)]
struct Counter(u32);

pub fn component(app: &mut App) {
// Store the state of this component in the world
pub fn panel(app: &mut App) {
// Store the state of this panel in the world
app.insert_resource(Counter(0));

// Systems that update the state or react to user inputs
app.add_systems(Update, (exit_on_esc, change_counter));

// System to render thos component
// System to render thos panel
app.add_systems(PostUpdate, render);
}

Expand Down

0 comments on commit 6996f87

Please sign in to comment.