mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-14 22:14:23 +00:00
e272acd1bc
Sharing a project displays a notification (window) on every screen. Previously there was an issue with the positioning of windows on all screens except the primary screen. As you can see here: ![image](https://github.com/zed-industries/zed/assets/53836821/314cf367-8c70-4e8e-bc4a-dcbb99cb4f71) Now: ![image](https://github.com/zed-industries/zed/assets/53836821/42af9ef3-8af9-453a-ad95-147b5f9d90ba) @mikayla-maki and I also decided to refactor the `WindowOptions` a bit. Previously you could specify bounds which controlled the positioning and size of the window in the global coordinate space, while also providing a display id (which screen to show the window on). This can lead to unusual behavior because you could theoretically specify a global bound which does not even belong to the display id which was provided. Therefore we changed the api to this: ```rust struct WindowOptions { /// The bounds of the window in screen coordinates /// None -> inherit, Some(bounds) -> set bounds. pub bounds: Option<Bounds<DevicePixels>>, /// The display to create the window on, if this is None, /// the window will be created on the main display pub display_id: Option<DisplayId>, } ``` This lets you specify a display id, which maps to the screen where the window should be created and bounds relative to the upper left of the screen. Release Notes: - Fixed positioning of popup windows (e.g. when sharing a project) when using multiple external displays. --------- Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
74 lines
2.4 KiB
Rust
74 lines
2.4 KiB
Rust
use std::time::Duration;
|
|
|
|
use gpui::*;
|
|
|
|
struct Assets {}
|
|
|
|
impl AssetSource for Assets {
|
|
fn load(&self, path: &str) -> Result<std::borrow::Cow<'static, [u8]>> {
|
|
std::fs::read(path).map(Into::into).map_err(Into::into)
|
|
}
|
|
|
|
fn list(&self, path: &str) -> Result<Vec<SharedString>> {
|
|
Ok(std::fs::read_dir(path)?
|
|
.filter_map(|entry| {
|
|
Some(SharedString::from(
|
|
entry.ok()?.path().to_string_lossy().to_string(),
|
|
))
|
|
})
|
|
.collect::<Vec<_>>())
|
|
}
|
|
}
|
|
|
|
struct AnimationExample {}
|
|
|
|
impl Render for AnimationExample {
|
|
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
|
|
div().flex().flex_col().size_full().justify_around().child(
|
|
div().flex().flex_row().w_full().justify_around().child(
|
|
div()
|
|
.flex()
|
|
.bg(rgb(0x2e7d32))
|
|
.size(Length::Definite(Pixels(300.0).into()))
|
|
.justify_center()
|
|
.items_center()
|
|
.shadow_lg()
|
|
.text_xl()
|
|
.text_color(black())
|
|
.child("hello")
|
|
.child(
|
|
svg()
|
|
.size_8()
|
|
.path("examples/image/arrow_circle.svg")
|
|
.text_color(black())
|
|
.with_animation(
|
|
"image_circle",
|
|
Animation::new(Duration::from_secs(2))
|
|
.repeat()
|
|
.with_easing(bounce(ease_in_out)),
|
|
|svg, delta| {
|
|
svg.with_transformation(Transformation::rotate(percentage(
|
|
delta,
|
|
)))
|
|
},
|
|
),
|
|
),
|
|
),
|
|
)
|
|
}
|
|
}
|
|
|
|
fn main() {
|
|
App::new()
|
|
.with_assets(Assets {})
|
|
.run(|cx: &mut AppContext| {
|
|
let options = WindowOptions {
|
|
bounds: Some(Bounds::centered(None, size(px(300.), px(300.)), cx)),
|
|
..Default::default()
|
|
};
|
|
cx.open_window(options, |cx| {
|
|
cx.activate(false);
|
|
cx.new_view(|_cx| AnimationExample {})
|
|
});
|
|
});
|
|
}
|