Update GPUI and apply opacity feature. (#215)

This commit is contained in:
Jason Lee 2024-09-04 19:29:51 +08:00 committed by GitHub
parent 9e67525650
commit 2c469da55a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 30 additions and 86 deletions

23
Cargo.lock generated
View file

@ -474,7 +474,7 @@ dependencies = [
"bitflags 2.6.0",
"cexpr",
"clang-sys",
"itertools 0.12.1",
"itertools 0.11.0",
"log",
"prettyplease",
"proc-macro2",
@ -944,7 +944,7 @@ dependencies = [
[[package]]
name = "collections"
version = "0.1.0"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#1dce79297865a43e65cb36ce6368c74088b9d62a"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#4f7507eb244527afcab0c186b39eba047d11a158"
dependencies = [
"rustc-hash",
]
@ -1275,7 +1275,7 @@ dependencies = [
[[package]]
name = "derive_refineable"
version = "0.1.0"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#1dce79297865a43e65cb36ce6368c74088b9d62a"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#4f7507eb244527afcab0c186b39eba047d11a158"
dependencies = [
"proc-macro2",
"quote",
@ -2203,7 +2203,7 @@ dependencies = [
[[package]]
name = "gpui"
version = "0.1.0"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#1dce79297865a43e65cb36ce6368c74088b9d62a"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#4f7507eb244527afcab0c186b39eba047d11a158"
dependencies = [
"anyhow",
"as-raw-xcb-connection",
@ -2302,7 +2302,7 @@ dependencies = [
[[package]]
name = "gpui_macros"
version = "0.1.0"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#1dce79297865a43e65cb36ce6368c74088b9d62a"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#4f7507eb244527afcab0c186b39eba047d11a158"
dependencies = [
"proc-macro2",
"quote",
@ -2497,7 +2497,7 @@ dependencies = [
[[package]]
name = "http_client"
version = "0.1.0"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#1dce79297865a43e65cb36ce6368c74088b9d62a"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#4f7507eb244527afcab0c186b39eba047d11a158"
dependencies = [
"anyhow",
"derive_more",
@ -3048,7 +3048,7 @@ dependencies = [
[[package]]
name = "media"
version = "0.1.0"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#1dce79297865a43e65cb36ce6368c74088b9d62a"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#4f7507eb244527afcab0c186b39eba047d11a158"
dependencies = [
"anyhow",
"bindgen",
@ -4149,7 +4149,7 @@ dependencies = [
[[package]]
name = "refineable"
version = "0.1.0"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#1dce79297865a43e65cb36ce6368c74088b9d62a"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#4f7507eb244527afcab0c186b39eba047d11a158"
dependencies = [
"derive_refineable",
]
@ -4484,7 +4484,7 @@ checksum = "d369a96f978623eb3dc28807c4852d6cc617fed53da5d3c400feff1ef34a714a"
[[package]]
name = "semantic_version"
version = "0.1.0"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#1dce79297865a43e65cb36ce6368c74088b9d62a"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#4f7507eb244527afcab0c186b39eba047d11a158"
dependencies = [
"anyhow",
"serde",
@ -4848,7 +4848,6 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
name = "story"
version = "0.1.0"
dependencies = [
"anyhow",
"charts-rs",
"chrono",
"fake",
@ -4933,7 +4932,7 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
[[package]]
name = "sum_tree"
version = "0.1.0"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#1dce79297865a43e65cb36ce6368c74088b9d62a"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#4f7507eb244527afcab0c186b39eba047d11a158"
dependencies = [
"arrayvec",
"log",
@ -5552,7 +5551,7 @@ checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"
[[package]]
name = "util"
version = "0.1.0"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#1dce79297865a43e65cb36ce6368c74088b9d62a"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#4f7507eb244527afcab0c186b39eba047d11a158"
dependencies = [
"anyhow",
"async-fs 1.6.0",

View file

@ -7,7 +7,6 @@ edition = "2021"
ui.workspace = true
gpui.workspace = true
fake = "2.9.2"
anyhow = "1"
charts-rs = "0.3"
regex = "1"
chrono = "0.4"

View file

@ -12,7 +12,7 @@ use ui::{
label::Label,
list::ListItem,
list::{List, ListDelegate},
theme::{hsl, ActiveTheme, Colorize as _},
theme::{hsl, ActiveTheme},
v_flex,
};

View file

@ -15,7 +15,7 @@ use crate::{
tab::{Tab, TabBar},
theme::ActiveTheme,
tooltip::Tooltip,
v_flex, AxisExt, IconName, Placement, Selectable, Sizable, StyledExt,
v_flex, AxisExt, IconName, Placement, Selectable, Sizable,
};
use super::{ClosePanel, DockArea, Panel, PanelView, StackPanel, ToggleZoom};

View file

@ -11,7 +11,7 @@ use crate::{
h_flex,
input::ClearButton,
list::{self, List, ListDelegate, ListItem},
theme::{ActiveTheme, Colorize},
theme::ActiveTheme,
v_flex, Disableable, Icon, IconName, Sizable, Size, StyleSized, StyledExt,
};

View file

@ -3,7 +3,7 @@ use gpui::{
RenderOnce, SharedString, Stateful, StatefulInteractiveElement, Styled,
};
use crate::theme::{ActiveTheme as _, Colorize};
use crate::theme::ActiveTheme as _;
#[derive(IntoElement)]
pub struct Link {

View file

@ -187,7 +187,7 @@ impl RenderOnce for Modal {
.with_easing(cubic_bezier(0.32, 0.72, 0., 1.)),
move |this, delta| {
let y_offset = px(0.) + delta * px(30.);
this.top(y + y_offset)
this.top(y + y_offset).opacity(delta)
},
),
),

View file

@ -266,7 +266,7 @@ impl Render for Notification {
this.left(px(0.) + x_offset).opacity(1. - delta)
} else {
let y_offset = px(-45.) + delta * px(45.);
this.top(px(0.) + y_offset)
this.top(px(0.) + y_offset).opacity(delta)
}
},
)

View file

@ -3,7 +3,7 @@ use gpui::{
WindowContext,
};
use crate::theme::{ActiveTheme, Colorize};
use crate::theme::ActiveTheme;
#[derive(IntoElement)]
pub struct Progress {

View file

@ -4,11 +4,7 @@ use gpui::{
WindowContext,
};
use crate::{
h_flex,
theme::{ActiveTheme, Colorize},
IconName,
};
use crate::{h_flex, theme::ActiveTheme, IconName};
#[derive(IntoElement)]
pub struct Radio {

View file

@ -1,6 +1,6 @@
use std::{cell::Cell, rc::Rc};
use crate::theme::{ActiveTheme, Colorize};
use crate::theme::ActiveTheme;
use gpui::{
fill, point, px, relative, size, Bounds, ContentMask, Edges, Element, EntityId, Hitbox,
IntoElement, MouseDownEvent, MouseMoveEvent, MouseUpEvent, PaintQuad, Pixels, Point, Position,

View file

@ -5,7 +5,7 @@ use gpui::{
RenderOnce, Styled,
};
use crate::{theme::ActiveTheme, StyledExt};
use crate::theme::ActiveTheme;
#[derive(IntoElement)]
pub struct Skeleton {

View file

@ -1,7 +1,4 @@
use crate::{
theme::{ActiveTheme, Colorize},
tooltip::Tooltip,
};
use crate::{theme::ActiveTheme, tooltip::Tooltip};
use gpui::{
canvas, div, px, relative, Axis, Bounds, DragMoveEvent, EntityId, EventEmitter,
InteractiveElement, IntoElement, MouseButton, MouseDownEvent, ParentElement as _, Pixels,

View file

@ -2,11 +2,9 @@ use std::fmt::{self, Display, Formatter};
use crate::{
scroll::{Scrollable, ScrollbarAxis},
theme::{ActiveTheme, Colorize},
};
use gpui::{
div, px, Axis, Div, Element, EntityId, Fill, FocusHandle, Pixels, Styled, WindowContext,
theme::ActiveTheme,
};
use gpui::{div, px, Axis, Div, Element, EntityId, FocusHandle, Pixels, Styled, WindowContext};
/// Returns a `Div` as horizontal flex layout.
pub fn h_flex() -> Div {
@ -122,45 +120,6 @@ pub trait StyledExt: Styled + Sized {
font_weight!(font_extrabold, EXTRA_BOLD);
font_weight!(font_black, BLACK);
/// Set the opacity of the element.
fn opacity(mut self, opacity: f32) -> Self {
let text_color = self.style().text.clone().and_then(|t| t.color);
let bg_color = self.style().background.clone();
let border_color = self.style().border_color;
let box_shadow = self.style().box_shadow.clone();
let this = if let Some(bg) = bg_color {
match bg {
Fill::Color(color) => self.bg(color.opacity(opacity)),
}
} else {
self
};
let this = if let Some(color) = border_color {
this.border_color(color.opacity(opacity))
} else {
this
};
let this = if let Some(mut shadow) = box_shadow {
for shadow in shadow.iter_mut() {
shadow.color = shadow.color.opacity(opacity);
}
this.shadow(shadow)
} else {
this
};
let this = if let Some(text_color) = text_color {
this.text_color(text_color.opacity(opacity))
} else {
this
};
this
}
/// Set as Popover style
fn popover_style(self, cx: &mut WindowContext) -> Self {
self.bg(cx.theme().popover)

View file

@ -1,10 +1,6 @@
use std::time::Duration;
use crate::{
h_flex,
theme::{ActiveTheme, Colorize},
Disableable, Sizable, Size,
};
use crate::{h_flex, theme::ActiveTheme, Disableable, Sizable, Size};
use gpui::{
div, prelude::FluentBuilder as _, px, Animation, AnimationExt as _, Div, ElementId,
InteractiveElement, IntoElement, ParentElement as _, RenderOnce, SharedString, Stateful,

View file

@ -1,4 +1,4 @@
use crate::theme::{ActiveTheme, Colorize};
use crate::theme::ActiveTheme;
use crate::Selectable;
use gpui::prelude::FluentBuilder as _;
use gpui::{

View file

@ -3,7 +3,7 @@ use std::{cell::Cell, ops::Range, rc::Rc};
use crate::{
h_flex,
scroll::{ScrollableAxis, ScrollableMask, Scrollbar, ScrollbarState},
theme::{ActiveTheme, Colorize},
theme::ActiveTheme,
v_flex, Icon, IconName,
};
use gpui::{
@ -691,7 +691,8 @@ where
view.delegate.load_more(cx);
})
})
}).detach()
})
.detach()
}
}
}

View file

@ -9,10 +9,7 @@ use gpui::{
use rust_i18n::t;
use crate::{
button::Button,
h_flex,
theme::{ActiveTheme, Colorize},
v_flex, Disableable as _, IconName, Selectable,
button::Button, h_flex, theme::ActiveTheme, v_flex, Disableable as _, IconName, Selectable,
};
use super::utils::days_in_month;