<img width="985" alt="image" src="https://github.com/user-attachments/assets/3d3860ff-ac7c-459a-bb6e-d0ea09b8eac8" /> <img width="936" alt="image" src="https://github.com/user-attachments/assets/abb39b8f-4139-4f41-9c12-2a22f767bec0" /> <img width="985" alt="image" src="https://github.com/user-attachments/assets/9fccce5f-8da5-4c78-8679-1a85dcfc56f0" /> Run example: ``` cargo run --example tabs ```
35 lines
788 B
Rust
35 lines
788 B
Rust
use gpui::*;
|
|
use story::{Assets, TabsStory};
|
|
|
|
pub struct Example {
|
|
root: Entity<TabsStory>,
|
|
}
|
|
|
|
impl Example {
|
|
pub fn new(window: &mut Window, cx: &mut Context<Self>) -> Self {
|
|
let root = TabsStory::view(window, cx);
|
|
|
|
Self { root }
|
|
}
|
|
|
|
fn view(window: &mut Window, cx: &mut App) -> Entity<Self> {
|
|
cx.new(|cx| Self::new(window, cx))
|
|
}
|
|
}
|
|
|
|
impl Render for Example {
|
|
fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
|
|
div().p_4().size_full().child(self.root.clone())
|
|
}
|
|
}
|
|
|
|
fn main() {
|
|
let app = Application::new().with_assets(Assets);
|
|
|
|
app.run(move |cx| {
|
|
story::init(cx);
|
|
cx.activate(true);
|
|
|
|
story::create_new_window("Tabs Example", Example::view, cx);
|
|
});
|
|
}
|