Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7590cc4

Browse files
committed
Add architecture chapter
1 parent ca5c1f3 commit 7590cc4

7 files changed

Lines changed: 60 additions & 0 deletions

File tree

src/SUMMARY.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
- [Getting Started](getting-started/index.md)
66
- [Create GPUI App](getting-started/create-gpui-app.md)
77
- [Manual Project](getting-started/manual-project.md)
8+
- [Architecture](architecture/index.md)
9+
- [Application](architecture/application.md)
10+
- [Window](architecture/window.md)
811
- [State Management](state-management/index.md)
912
- [Entity](state-management/entity.md)
1013
- [Global](state-management/global.md)

src/architecture/application.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## Application
2+
3+
The `Application` is the entry point into your GPUI application.
4+
5+
### Creating an Application
6+
7+
The `new` function creates the `Application`.
8+
9+
```rust
10+
{{ #include snippets/creating_an_application.rs }}
11+
```
12+
13+
### Running an Application
14+
15+
The `run` function consumes the `Application` and takes a callback which will be fired once the application has finished loading. This callback is the entry point into your application, a mutable reference of `App` is supplied where you can start controlling aspects of your application like opening a [window](./window.md).
16+
17+
```rust
18+
{{ #include snippets/running_an_application.rs }}
19+
```

src/architecture/index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Architecture
2+
3+
In this chapter, you will learn the architecture of GPUI.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
use gpui::Application;
2+
3+
fn main() {
4+
let application = Application::new();
5+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
use gpui::{Application, WindowOptions};
2+
3+
fn main() {
4+
Application::new().run(|app| {
5+
app.open_window(WindowOptions::default(), |window, app| {
6+
// Return root view
7+
})
8+
.unwrap();
9+
});
10+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
use gpui::Application;
2+
3+
fn main() {
4+
let application = Application::new();
5+
6+
application.run(|_app| {
7+
// Entry point
8+
});
9+
}

src/architecture/window.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
## Window
2+
3+
`Window`'s contain the views and components that will be rendered in your application, they each correspond to a platform window.
4+
5+
### Opening a Window
6+
7+
Using `App` you can access the `open_window` function which takes a `WindowOptions` and a callback which supplies mutable references to a `Window` and `App` that is used to build the root view. To learn more on how views are created you can read the [Render section](../rendering/render.md).
8+
9+
```rust
10+
{{ #include snippets/opening_a_window.rs }}
11+
```

0 commit comments

Comments
 (0)