Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
948 changes: 192 additions & 756 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ gpui-component-assets = { path = "crates/assets", version = "0.5.1" }
story = { path = "crates/story" }

gpui = { git = "https://github.com/zed-industries/zed" }
gpui-macros = "0.2.2"
gpui_platform = { git = "https://github.com/zed-industries/zed", features = ["font-kit"] }
gpui_macros = { git = "https://github.com/zed-industries/zed" }
sum-tree = { version = "0.2.0", package = "zed-sum-tree" }
# reqwest = { version = "0.12.15-zed", package = "zed-reqwest" }
reqwest = { git = "https://github.com/zed-industries/reqwest.git", rev = "c15662463bda39148ba154100dd44d3fba5873a4", default-features = false, features = [
Expand Down Expand Up @@ -91,7 +92,8 @@ taffy = { opt-level = 3 }
ttf-parser = { opt-level = 3 }
smol = { opt-level = 3 }
gpui = { opt-level = 3 }
gpui-macros = { opt-level = 3 }
gpui_platform = { opt-level = 3 }
gpui_macros = { opt-level = 3 }
tree-sitter = { opt-level = 3 }
sum_tree = { opt-level = 3 }
ropey = { opt-level = 3 }
Expand Down
2 changes: 1 addition & 1 deletion crates/assets/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::borrow::Cow;
/// use gpui::*;
/// use gpui_component_assets::Assets;
///
/// let app = Application::new().with_assets(Assets);
/// let app = gpui_platform::application().with_assets(Assets);
/// ```
#[derive(RustEmbed)]
#[folder = "assets"]
Expand Down
1 change: 1 addition & 0 deletions crates/story/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ inspector = ["gpui-component/inspector"]
[dependencies]
anyhow.workspace = true
gpui.workspace = true
gpui_platform.workspace = true
gpui-component = { workspace = true, features = [
"tree-sitter-languages",
] }
Expand Down
2 changes: 1 addition & 1 deletion crates/story/examples/brush.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ impl Render for Example {
}

fn main() {
let app = Application::new().with_assets(Assets);
let app = gpui_platform::application().with_assets(Assets);

app.run(move |cx| {
gpui_component_story::init(cx);
Expand Down
2 changes: 1 addition & 1 deletion crates/story/examples/dock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ impl Render for StoryWorkspace {
}

fn main() {
let app = Application::new().with_assets(Assets);
let app = gpui_platform::application().with_assets(Assets);

app.run(move |cx| {
init(cx);
Expand Down
2 changes: 1 addition & 1 deletion crates/story/examples/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,7 @@ impl Render for Example {
}

fn main() {
let app = Application::new().with_assets(Assets);
let app = gpui_platform::application().with_assets(Assets);

app.run(move |cx| {
gpui_component_story::init(cx);
Expand Down
2 changes: 1 addition & 1 deletion crates/story/examples/html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl Render for Example {
}

fn main() {
let app = Application::new().with_assets(Assets);
let app = gpui_platform::application().with_assets(Assets);

app.run(move |cx| {
gpui_component_story::init(cx);
Expand Down
2 changes: 1 addition & 1 deletion crates/story/examples/large-text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ impl Render for Example {
}

fn main() {
let app = Application::new().with_assets(Assets);
let app = gpui_platform::application().with_assets(Assets);

app.run(move |cx| {
gpui_component_story::init(cx);
Expand Down
2 changes: 1 addition & 1 deletion crates/story/examples/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl Render for Example {
}

fn main() {
let app = Application::new().with_assets(Assets);
let app = gpui_platform::application().with_assets(Assets);

app.run(move |cx| {
gpui_component_story::init(cx);
Expand Down
2 changes: 1 addition & 1 deletion crates/story/examples/stream_markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ impl Render for Example {
}

fn main() {
let app = Application::new().with_assets(Assets);
let app = gpui_platform::application().with_assets(Assets);

app.run(move |cx| {
gpui_component_story::init(cx);
Expand Down
2 changes: 1 addition & 1 deletion crates/story/examples/tiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ impl Render for StoryTiles {
}

fn main() {
let app = Application::new().with_assets(Assets);
let app = gpui_platform::application().with_assets(Assets);

app.run(move |cx| {
gpui_component::init(cx);
Expand Down
2 changes: 1 addition & 1 deletion crates/story/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ impl Render for Gallery {
}

fn main() {
let app = Application::new().with_assets(Assets);
let app = gpui_platform::application().with_assets(Assets);

// Parse `cargo run -- <story_name>`
let name = std::env::args().nth(1);
Expand Down
2 changes: 1 addition & 1 deletion crates/story/src/stories/chart_story/stacked_bar_chart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use gpui::{App, Bounds, Pixels, TextAlign, Window, px};
use gpui_component::{
ActiveTheme, PixelsExt,
ActiveTheme,
plot::{
AXIS_GAP, AxisText, Grid, IntoPlot, Plot, PlotAxis,
scale::{Scale, ScaleBand, ScaleLinear, ScaleOrdinal},
Expand Down
2 changes: 1 addition & 1 deletion crates/story/src/title_bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use gpui::{
Window, div, px,
};
use gpui_component::{
ActiveTheme as _, IconName, PixelsExt, Side, Sizable as _, Theme, TitleBar, WindowExt as _,
ActiveTheme as _, IconName, Side, Sizable as _, Theme, TitleBar, WindowExt as _,
badge::Badge,
button::{Button, ButtonVariants as _},
label::Label,
Expand Down
4 changes: 2 additions & 2 deletions crates/ui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ doctest = false

[features]
decimal = ["dep:rust_decimal"]
inspector = ["gpui-macros/inspector", "gpui/inspector"]
inspector = ["gpui_macros/inspector", "gpui/inspector"]

# For syntax highlighting in Markdown and CodeEditor.
tree-sitter-languages = [
Expand Down Expand Up @@ -58,8 +58,8 @@ tree-sitter-languages = [
[dependencies]
anyhow.workspace = true
gpui = { workspace = true }
gpui_macros.workspace = true
gpui-component-macros = { workspace = true }
gpui-macros.workspace = true
notify.workspace = true
ropey.workspace = true
rust-i18n.workspace = true
Expand Down
6 changes: 3 additions & 3 deletions crates/ui/src/chart/area_chart.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
use std::rc::Rc;

use gpui::{px, App, Background, Bounds, Hsla, Pixels, SharedString, TextAlign, Window};
use gpui::{App, Background, Bounds, Hsla, Pixels, SharedString, TextAlign, Window, px};
use gpui_component_macros::IntoPlot;
use num_traits::{Num, ToPrimitive};

use crate::{
ActiveTheme,
plot::{
AXIS_GAP, AxisText, Grid, Plot, PlotAxis, StrokeStyle,
scale::{Scale, ScaleLinear, ScalePoint, Sealed},
shape::Area,
AxisText, Grid, Plot, PlotAxis, StrokeStyle, AXIS_GAP,
},
ActiveTheme, PixelsExt,
};

#[derive(IntoPlot)]
Expand Down
2 changes: 1 addition & 1 deletion crates/ui/src/chart/bar_chart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use gpui_component_macros::IntoPlot;
use num_traits::{Num, ToPrimitive};

use crate::{
ActiveTheme, PixelsExt,
ActiveTheme,
plot::{
AXIS_GAP, AxisText, Grid, Plot, PlotAxis,
label::Text,
Expand Down
2 changes: 1 addition & 1 deletion crates/ui/src/chart/candlestick_chart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use gpui_component_macros::IntoPlot;
use num_traits::{Num, ToPrimitive};

use crate::{
ActiveTheme, PixelsExt,
ActiveTheme,
plot::{
AXIS_GAP, AxisText, Grid, Plot, PlotAxis, origin_point,
scale::{Scale, ScaleBand, ScaleLinear, Sealed},
Expand Down
6 changes: 3 additions & 3 deletions crates/ui/src/chart/line_chart.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
use std::rc::Rc;

use gpui::{px, App, Bounds, Hsla, Pixels, SharedString, TextAlign, Window};
use gpui::{App, Bounds, Hsla, Pixels, SharedString, TextAlign, Window, px};
use gpui_component_macros::IntoPlot;
use num_traits::{Num, ToPrimitive};

use crate::{
ActiveTheme,
plot::{
AXIS_GAP, AxisText, Grid, Plot, PlotAxis, StrokeStyle,
scale::{Scale, ScaleLinear, ScalePoint, Sealed},
shape::Line,
AxisText, Grid, Plot, PlotAxis, StrokeStyle, AXIS_GAP,
},
ActiveTheme, PixelsExt,
};

#[derive(IntoPlot)]
Expand Down
4 changes: 2 additions & 2 deletions crates/ui/src/chart/pie_chart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ use gpui_component_macros::IntoPlot;
use num_traits::Zero;

use crate::{
ActiveTheme,
plot::{
shape::{Arc, ArcData, Pie},
Plot,
shape::{Arc, ArcData, Pie},
},
ActiveTheme, PixelsExt,
};

#[derive(IntoPlot)]
Expand Down
15 changes: 0 additions & 15 deletions crates/ui/src/geometry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,21 +234,6 @@ impl AxisExt for Axis {
}
}

/// A trait for converting [`Pixels`] to `f32` and `f64`.
pub trait PixelsExt {
fn as_f32(&self) -> f32;
fn as_f64(self) -> f64;
}
impl PixelsExt for Pixels {
fn as_f32(&self) -> f32 {
f32::from(self)
}

fn as_f64(self) -> f64 {
f64::from(self)
}
}

/// A trait to extend the [`Length`] enum with utility methods.
pub trait LengthExt {
/// Converts the [`Length`] to [`Pixels`] based on a given `base_size` and `rem_size`.
Expand Down
2 changes: 1 addition & 1 deletion crates/ui/src/input/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use ropey::Rope;
use smallvec::SmallVec;

use crate::{
ActiveTheme as _, Colorize, PixelsExt, Root,
ActiveTheme as _, Colorize, Root,
input::{RopeExt as _, blink_cursor::CURSOR_WIDTH, text_wrapper::LineLayout},
};

Expand Down
6 changes: 2 additions & 4 deletions crates/ui/src/plot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ pub use gpui_component_macros::IntoPlot;

use std::{fmt::Debug, ops::Add};

use gpui::{point, px, App, Bounds, IntoElement, Path, PathBuilder, Pixels, Point, Window};
use gpui::{App, Bounds, IntoElement, Path, PathBuilder, Pixels, Point, Window, point, px};

use crate::PixelsExt;

pub use axis::{AxisText, PlotAxis, AXIS_GAP};
pub use axis::{AXIS_GAP, AxisText, PlotAxis};
pub use grid::Grid;
pub use label::PlotLabel;

Expand Down
4 changes: 1 addition & 3 deletions crates/ui/src/plot/shape/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

use std::{f32::consts::PI, fmt::Debug};

use gpui::{point, px, Bounds, Hsla, Path, PathBuilder, Pixels, Point, Window};

use crate::PixelsExt;
use gpui::{Bounds, Hsla, Path, PathBuilder, Pixels, Point, Window, point, px};

const EPSILON: f32 = 1e-12;
const HALF_PI: f32 = PI / 2.;
Expand Down
5 changes: 1 addition & 4 deletions crates/ui/src/plot/shape/line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ use gpui::{
quad, size,
};

use crate::{
PixelsExt,
plot::{StrokeStyle, origin_point},
};
use crate::plot::{StrokeStyle, origin_point};

#[allow(clippy::type_complexity)]
pub struct Line<T> {
Expand Down
2 changes: 1 addition & 1 deletion crates/ui/src/progress/progress_circle.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{ActiveTheme, PixelsExt, Sizable, Size, StyledExt};
use crate::{ActiveTheme, Sizable, Size, StyledExt};
use gpui::prelude::FluentBuilder as _;
use gpui::{
Animation, AnimationExt as _, AnyElement, App, ElementId, Hsla, InteractiveElement as _,
Expand Down
4 changes: 1 addition & 3 deletions crates/ui/src/resizable/mod.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
use std::ops::Range;

use gpui::{
px, Along, App, Axis, Bounds, Context, ElementId, EventEmitter, IsZero, Pixels, Window,
Along, App, Axis, Bounds, Context, ElementId, EventEmitter, IsZero, Pixels, Window, px,
};

use crate::PixelsExt;

mod panel;
mod resize_handle;
pub use panel::*;
Expand Down
2 changes: 1 addition & 1 deletion crates/ui/src/sidebar/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{
ActiveTheme, Collapsible, Icon, IconName, PixelsExt, Side, Sizable, StyledExt,
ActiveTheme, Collapsible, Icon, IconName, Side, Sizable, StyledExt,
button::{Button, ButtonVariants},
h_flex,
scroll::ScrollableElement,
Expand Down
2 changes: 1 addition & 1 deletion crates/ui/src/styled.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{ActiveTheme, PixelsExt as _};
use crate::ActiveTheme;
use gpui::{
App, BoxShadow, Corners, DefiniteLength, Div, Edges, FocusHandle, Hsla, ParentElement, Pixels,
Refineable, StyleRefinement, Styled, Window, div, point, px,
Expand Down
2 changes: 1 addition & 1 deletion crates/ui/src/virtual_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use gpui::{
};
use smallvec::SmallVec;

use crate::{AxisExt, PixelsExt, scroll::ScrollbarHandle};
use crate::{AxisExt, scroll::ScrollbarHandle};

struct VirtualListScrollHandleState {
axis: Axis,
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/assets.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Then we need call the `with_assets` method when creating the GPUI application to
use gpui::*;
use gpui_component_assets::Assets;

let app = Application::new().with_assets(Assets);
let app = gpui_platform::application().with_assets(Assets);
```

Now, we can use `IconName` and `Icon` in our application as usual, the all icon assets are loaded from the default bundled assets.
Expand Down Expand Up @@ -87,7 +87,7 @@ We need call the `with_assets` method when creating the GPUI application to regi
```rs
fn main() {
// Register Assets to GPUI application.
let app = Application::new().with_assets(Assets);
let app = gpui_platform::application().with_assets(Assets);

app.run(move |cx| {
// We must initialize gpui_component before using it.
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl Render for HelloWorld {
}

fn main() {
let app = Application::new().with_assets(gpui_component_assets::Assets);
let app = gpui_platform::application().with_assets(gpui_component_assets::Assets);

app.run(move |cx| {
// This must be called before using any GPUI Component features.
Expand Down
1 change: 1 addition & 0 deletions examples/app_assets/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ edition.workspace = true
[dependencies]
anyhow.workspace = true
gpui.workspace = true
gpui_platform.workspace = true
gpui-component = { workspace = true }
rust-embed = { version = "8", features = ["interpolate-folder-path"] }

Expand Down
4 changes: 2 additions & 2 deletions examples/app_assets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl AssetSource for Assets {

fn main() {
// Call with_assets to register assets
let app = Application::new().with_assets(Assets);
let app = gpui_platform::application().with_assets(Assets);

// ...
}
Expand All @@ -78,5 +78,5 @@ gpui-component-assets = "*"
And then use it in your application:

```rs
let app = Application::new().with_assets(gpui_component_assets::Assets);
let app = gpui_platform::application().with_assets(gpui_component_assets::Assets);
```
Loading