diff --git a/assets/icons/stop_sharing.svg b/assets/icons/stop_sharing.svg
new file mode 100644
index 0000000000..b0f06f68eb
--- /dev/null
+++ b/assets/icons/stop_sharing.svg
@@ -0,0 +1,5 @@
+
diff --git a/crates/gpui/src/geometry.rs b/crates/gpui/src/geometry.rs
index c83ad73b5d..40b0682787 100644
--- a/crates/gpui/src/geometry.rs
+++ b/crates/gpui/src/geometry.rs
@@ -1,12 +1,12 @@
-use std::fmt::Debug;
-
use super::scene::{Path, PathVertex};
use crate::{color::Color, json::ToJson};
+use derive_more::Neg;
pub use pathfinder_geometry::*;
use rect::RectF;
use refineable::Refineable;
use serde::{Deserialize, Deserializer};
use serde_json::json;
+use std::fmt::Debug;
use vector::{vec2f, Vector2F};
pub struct PathBuilder {
@@ -194,8 +194,8 @@ where
impl Size {
pub fn zero() -> Self {
Self {
- width: pixels(0.),
- height: pixels(0.),
+ width: pixels(0.).into(),
+ height: pixels(0.).into(),
}
}
@@ -235,6 +235,17 @@ pub struct Edges {
pub left: T,
}
+impl Edges {
+ pub fn uniform(value: T) -> Self {
+ Self {
+ top: value.clone(),
+ right: value.clone(),
+ bottom: value.clone(),
+ left: value.clone(),
+ }
+ }
+}
+
impl Edges {
pub fn auto() -> Self {
Self {
@@ -247,10 +258,10 @@ impl Edges {
pub fn zero() -> Self {
Self {
- top: pixels(0.),
- right: pixels(0.),
- bottom: pixels(0.),
- left: pixels(0.),
+ top: pixels(0.).into(),
+ right: pixels(0.).into(),
+ bottom: pixels(0.).into(),
+ left: pixels(0.).into(),
}
}
@@ -270,10 +281,10 @@ impl Edges {
impl Edges {
pub fn zero() -> Self {
Self {
- top: pixels(0.),
- right: pixels(0.),
- bottom: pixels(0.),
- left: pixels(0.),
+ top: pixels(0.).into(),
+ right: pixels(0.).into(),
+ bottom: pixels(0.).into(),
+ left: pixels(0.).into(),
}
}
@@ -322,7 +333,7 @@ impl Edges {
}
}
-#[derive(Clone, Copy)]
+#[derive(Clone, Copy, Neg)]
pub enum AbsoluteLength {
Pixels(f32),
Rems(f32),
@@ -360,7 +371,7 @@ impl Default for AbsoluteLength {
}
/// A non-auto length that can be defined in pixels, rems, or percent of parent.
-#[derive(Clone, Copy)]
+#[derive(Clone, Copy, Neg)]
pub enum DefiniteLength {
Absolute(AbsoluteLength),
Relative(f32), // 0. to 1.
@@ -404,7 +415,7 @@ impl Default for DefiniteLength {
}
/// A length that can be defined in pixels, rems, percent of parent, or auto.
-#[derive(Clone, Copy)]
+#[derive(Clone, Copy, Neg)]
pub enum Length {
Definite(DefiniteLength),
Auto,
@@ -419,16 +430,16 @@ impl std::fmt::Debug for Length {
}
}
-pub fn relative>(fraction: f32) -> T {
- DefiniteLength::Relative(fraction).into()
+pub fn relative(fraction: f32) -> DefiniteLength {
+ DefiniteLength::Relative(fraction)
}
-pub fn rems>(rems: f32) -> T {
- AbsoluteLength::Rems(rems).into()
+pub fn rems(rems: f32) -> AbsoluteLength {
+ AbsoluteLength::Rems(rems)
}
-pub fn pixels>(pixels: f32) -> T {
- AbsoluteLength::Pixels(pixels).into()
+pub fn pixels(pixels: f32) -> AbsoluteLength {
+ AbsoluteLength::Pixels(pixels)
}
pub fn auto() -> Length {
diff --git a/crates/gpui2/src/element.rs b/crates/gpui2/src/element.rs
index ba90a7d7df..aadceddc05 100644
--- a/crates/gpui2/src/element.rs
+++ b/crates/gpui2/src/element.rs
@@ -34,6 +34,27 @@ pub trait Element: 'static + IntoElement {
phase: ElementPhase::Init,
}))
}
+
+ /// Applies a given function `then` to the current element if `condition` is true.
+ /// This function is used to conditionally modify the element based on a given condition.
+ /// If `condition` is false, it just returns the current element as it is.
+ ///
+ /// # Parameters
+ /// - `self`: The current element
+ /// - `condition`: The boolean condition based on which `then` is applied to the element.
+ /// - `then`: A function that takes in the current element and returns a possibly modified element.
+ ///
+ /// # Return
+ /// It returns the potentially modified element.
+ fn when(mut self, condition: bool, then: impl FnOnce(Self) -> Self) -> Self
+ where
+ Self: Sized,
+ {
+ if condition {
+ self = then(self);
+ }
+ self
+ }
}
/// Used to make ElementState into a trait object, so we can wrap it in AnyElement.
diff --git a/crates/gpui2/src/elements/pressable.rs b/crates/gpui2/src/elements/pressable.rs
index 960342a5e6..30e853bf39 100644
--- a/crates/gpui2/src/elements/pressable.rs
+++ b/crates/gpui2/src/elements/pressable.rs
@@ -73,10 +73,15 @@ impl + Styleable> Element for Pressable {
if bounds.contains_point(event.position) {
pressed.set(true);
cx.repaint();
+ } else {
+ cx.bubble_event();
}
- } else if pressed.get() {
- pressed.set(false);
- cx.repaint();
+ } else {
+ if pressed.get() {
+ pressed.set(false);
+ cx.repaint();
+ }
+ cx.bubble_event();
}
});
diff --git a/crates/gpui2/src/style.rs b/crates/gpui2/src/style.rs
index e3e0f5b0c4..3e4acd57e7 100644
--- a/crates/gpui2/src/style.rs
+++ b/crates/gpui2/src/style.rs
@@ -314,6 +314,8 @@ pub trait Styleable {
}
}
+use crate as gpui2;
+
// Helpers methods that take and return mut self. This includes tailwind style methods for standard sizes etc.
//
// Example:
@@ -322,33 +324,12 @@ pub trait Styleable {
pub trait StyleHelpers: Styleable