gpui: Remove use of use gpui::* in examples (#22311)

This PR removes the use of `use gpui::*` in the GPUI examples, as this
is not how consumers should be importing GPUI.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-12-20 18:09:30 -05:00 committed by GitHub
parent 7c6feeb3a8
commit a8afc63a91
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 77 additions and 32 deletions

View file

@ -1,6 +1,11 @@
use std::time::Duration; use std::time::Duration;
use gpui::*; use anyhow::Result;
use gpui::{
black, bounce, div, ease_in_out, percentage, prelude::*, px, rgb, size, svg, Animation,
AnimationExt as _, App, AppContext, AssetSource, Bounds, SharedString, Transformation,
ViewContext, WindowBounds, WindowOptions,
};
struct Assets {} struct Assets {}
@ -37,7 +42,7 @@ impl Render for AnimationExample {
div() div()
.flex() .flex()
.bg(rgb(0x2e7d32)) .bg(rgb(0x2e7d32))
.size(Length::Definite(Pixels(300.0).into())) .size(px(300.0))
.justify_center() .justify_center()
.items_center() .items_center()
.shadow_lg() .shadow_lg()

View file

@ -1,4 +1,7 @@
use gpui::*; use gpui::{
div, prelude::*, px, rgb, size, App, AppContext, Bounds, SharedString, ViewContext,
WindowBounds, WindowOptions,
};
struct HelloWorld { struct HelloWorld {
text: SharedString, text: SharedString,
@ -11,7 +14,7 @@ impl Render for HelloWorld {
.flex_col() .flex_col()
.gap_3() .gap_3()
.bg(rgb(0x505050)) .bg(rgb(0x505050))
.size(Length::Definite(Pixels(500.0).into())) .size(px(500.0))
.justify_center() .justify_center()
.items_center() .items_center()
.shadow_lg() .shadow_lg()

View file

@ -1,9 +1,14 @@
use std::fs;
use std::path::PathBuf; use std::path::PathBuf;
use std::str::FromStr; use std::str::FromStr;
use std::sync::Arc; use std::sync::Arc;
use gpui::*; use anyhow::Result;
use std::fs; use gpui::{
actions, div, img, prelude::*, px, rgb, size, App, AppContext, AssetSource, Bounds,
ImageSource, KeyBinding, Menu, MenuItem, Point, SharedString, SharedUri, TitlebarOptions,
ViewContext, WindowBounds, WindowContext, WindowOptions,
};
struct Assets { struct Assets {
base: PathBuf, base: PathBuf,
@ -55,7 +60,7 @@ impl RenderOnce for ImageContainer {
.size_full() .size_full()
.gap_4() .gap_4()
.child(self.text) .child(self.text)
.child(img(self.src).w(px(256.0)).h(px(256.0))), .child(img(self.src).size(px(256.0))),
) )
} }
} }
@ -75,7 +80,7 @@ impl Render for ImageShowcase {
.justify_center() .justify_center()
.items_center() .items_center()
.gap_8() .gap_8()
.bg(rgb(0xFFFFFF)) .bg(rgb(0xffffff))
.child( .child(
div() div()
.flex() .flex()

View file

@ -1,6 +1,13 @@
use std::ops::Range; use std::ops::Range;
use gpui::*; use gpui::{
actions, black, div, fill, hsla, opaque_grey, point, prelude::*, px, relative, rgb, rgba, size,
white, yellow, App, AppContext, Bounds, ClipboardItem, CursorStyle, ElementId,
ElementInputHandler, FocusHandle, FocusableView, GlobalElementId, KeyBinding, Keystroke,
LayoutId, MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, PaintQuad, Pixels, Point,
ShapedLine, SharedString, Style, TextRun, UTF16Selection, UnderlineStyle, View, ViewContext,
ViewInputHandler, WindowBounds, WindowContext, WindowOptions,
};
use unicode_segmentation::*; use unicode_segmentation::*;
actions!( actions!(
@ -463,7 +470,7 @@ impl Element for TextElement {
bounds.bottom(), bounds.bottom(),
), ),
), ),
rgba(0x3311FF30), rgba(0x3311ff30),
)), )),
None, None,
) )

View file

@ -1,6 +1,10 @@
use std::{fs, path::PathBuf, time::Duration}; use std::{fs, path::PathBuf, time::Duration};
use gpui::*; use anyhow::Result;
use gpui::{
div, hsla, img, point, prelude::*, px, rgb, size, svg, App, AppContext, AssetSource, Bounds,
BoxShadow, ClickEvent, SharedString, Task, Timer, ViewContext, WindowBounds, WindowOptions,
};
struct Assets { struct Assets {
base: PathBuf, base: PathBuf,
@ -76,7 +80,7 @@ impl Render for HelloWorld {
.flex() .flex()
.flex_row() .flex_row()
.size_full() .size_full()
.bg(rgb(0xE0E0E0)) .bg(rgb(0xe0e0e0))
.text_xl() .text_xl()
.child( .child(
div() div()

View file

@ -1,4 +1,6 @@
use gpui::*; use gpui::{
actions, div, prelude::*, rgb, App, AppContext, Menu, MenuItem, ViewContext, WindowOptions,
};
struct SetMenus; struct SetMenus;

View file

@ -1,4 +1,7 @@
use gpui::*; use gpui::{
div, prelude::*, px, rgb, size, App, AppContext, Bounds, ViewContext, WindowBounds,
WindowOptions,
};
struct Shadow {} struct Shadow {}

View file

@ -1,7 +1,11 @@
use std::fs;
use std::path::PathBuf; use std::path::PathBuf;
use gpui::*; use anyhow::Result;
use std::fs; use gpui::{
div, prelude::*, px, rgb, size, svg, App, AppContext, AssetSource, Bounds, SharedString,
ViewContext, WindowBounds, WindowOptions,
};
struct Assets { struct Assets {
base: PathBuf, base: PathBuf,

View file

@ -1,4 +1,6 @@
use gpui::*; use gpui::{
div, prelude::*, px, size, App, AppContext, Bounds, ViewContext, WindowBounds, WindowOptions,
};
struct HelloWorld {} struct HelloWorld {}

View file

@ -1,4 +1,7 @@
use gpui::*; use gpui::{
div, prelude::*, px, rgb, size, uniform_list, App, AppContext, Bounds, ViewContext,
WindowBounds, WindowOptions,
};
struct UniformListExample {} struct UniformListExample {}

View file

@ -1,5 +1,7 @@
use gpui::*; use gpui::{
use prelude::FluentBuilder as _; div, prelude::*, px, rgb, size, App, AppContext, Bounds, SharedString, Timer, ViewContext,
WindowBounds, WindowContext, WindowKind, WindowOptions,
};
struct SubWindow { struct SubWindow {
custom_titlebar: bool, custom_titlebar: bool,

View file

@ -1,4 +1,8 @@
use gpui::*; use gpui::{
div, point, prelude::*, px, rgb, App, AppContext, Bounds, DisplayId, Hsla, Pixels,
SharedString, Size, ViewContext, WindowBackgroundAppearance, WindowBounds, WindowKind,
WindowOptions,
};
struct WindowContent { struct WindowContent {
text: SharedString, text: SharedString,

View file

@ -1,15 +1,16 @@
use gpui::*; use gpui::{
use prelude::FluentBuilder; black, canvas, div, green, point, prelude::*, px, rgb, size, transparent_black, white, App,
AppContext, Bounds, CursorStyle, Decorations, Hsla, MouseButton, Pixels, Point, ResizeEdge,
Size, ViewContext, WindowBackgroundAppearance, WindowBounds, WindowDecorations, WindowOptions,
};
struct WindowShadow {} struct WindowShadow {}
/* // Things to do:
Things to do: // 1. We need a way of calculating which edge or corner the mouse is on,
1. We need a way of calculating which edge or corner the mouse is on, // and then dispatch on that
and then dispatch on that // 2. We need to improve the shadow rendering significantly
2. We need to improve the shadow rendering significantly // 3. We need to implement the techniques in here in Zed
3. We need to implement the techniques in here in Zed
*/
impl Render for WindowShadow { impl Render for WindowShadow {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement { fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
@ -128,7 +129,7 @@ impl Render for WindowShadow {
div() div()
.flex() .flex()
.bg(white()) .bg(white())
.size(Length::Definite(Pixels(300.0).into())) .size(px(300.0))
.justify_center() .justify_center()
.items_center() .items_center()
.shadow_lg() .shadow_lg()

View file

@ -1,5 +1,5 @@
use assets::Assets; use assets::Assets;
use gpui::*; use gpui::{rgb, App, KeyBinding, Length, StyleRefinement, View, WindowOptions};
use language::{language_settings::AllLanguageSettings, LanguageRegistry}; use language::{language_settings::AllLanguageSettings, LanguageRegistry};
use markdown::{Markdown, MarkdownStyle}; use markdown::{Markdown, MarkdownStyle};
use node_runtime::NodeRuntime; use node_runtime::NodeRuntime;