[wip] gpui hello world

Fabien Freling 2024-04-05 23:57:47 +02:00
parent 603dc124dd
commit b41cf4198c
4 changed files with 4916 additions and 2 deletions

4857
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -6,3 +6,4 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
gpui = { git = "https://github.com/zed-industries/zed" }

View File

@ -24,9 +24,29 @@
];
buildInputs = [
curl
fontconfig
freetype
libgit2
openssl
sqlite
zlib
zstd
vulkan-loader
] ++ lib.optionals stdenv.isLinux [
alsa-lib
libxkbcommon
wayland
xorg.libxcb
];
};
env = {
LD_LIBRARY_PATH = with pkgs; lib.makeLibraryPath [
vulkan-loader
];
};
formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixfmt;
};
}

View File

@ -1,3 +1,39 @@
fn main() {
println!("Hello, world!");
use gpui::*;
struct HelloWorld {
text: SharedString,
}
impl Render for HelloWorld {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
div()
.flex()
.bg(rgb(0x2e7d32))
.size(Length::Definite(Pixels(300.0).into()))
.justify_center()
.items_center()
.shadow_lg()
.border()
.border_color(rgb(0x0000ff))
.text_xl()
.text_color(rgb(0xffffff))
.child(format!("Hello, {}!", &self.text))
}
}
fn main() {
App::new().run(|cx: &mut AppContext| {
let bounds = Bounds::centered(None, size(px(600.0), px(600.0)), cx);
cx.open_window(
WindowOptions {
bounds: Some(bounds),
..Default::default()
},
|cx| {
cx.new_view(|_cx| HelloWorld {
text: "World".into(),
})
},
);
});
}