chore: Upgrade to GPUI3 (#6)

* wip: gpui3

* wip: gpui3

* chore: fix clippy
This commit is contained in:
reya
2025-01-28 08:25:49 +07:00
committed by GitHub
parent 3c15e74e56
commit 72a6d79bc5
62 changed files with 2572 additions and 2511 deletions

View File

@@ -1,13 +1,10 @@
use gpui::{
div, svg, AnyElement, AppContext, EventEmitter, FocusHandle, FocusableView, IntoElement,
ParentElement, Render, SharedString, Styled, View, ViewContext, VisualContext, WindowContext,
div, svg, AnyElement, App, AppContext, Context, Entity, EventEmitter, FocusHandle, Focusable,
IntoElement, ParentElement, Render, SharedString, Styled, Window,
};
use ui::{
button::Button,
dock_area::{
panel::{Panel, PanelEvent},
state::PanelState,
},
dock_area::panel::{Panel, PanelEvent},
popup_menu::PopupMenu,
theme::{scale::ColorScaleStep, ActiveTheme},
StyledExt,
@@ -21,11 +18,11 @@ pub struct WelcomePanel {
}
impl WelcomePanel {
pub fn new(cx: &mut WindowContext) -> View<Self> {
cx.new_view(Self::view)
pub fn new(window: &mut Window, cx: &mut App) -> Entity<Self> {
cx.new(|cx| Self::view(window, cx))
}
fn view(cx: &mut ViewContext<Self>) -> Self {
fn view(_window: &mut Window, cx: &mut Context<Self>) -> Self {
Self {
name: "Welcome".into(),
closeable: true,
@@ -40,41 +37,37 @@ impl Panel for WelcomePanel {
"WelcomePanel".into()
}
fn title(&self, _cx: &WindowContext) -> AnyElement {
fn title(&self, _cx: &App) -> AnyElement {
self.name.clone().into_any_element()
}
fn closeable(&self, _cx: &WindowContext) -> bool {
fn closeable(&self, _cx: &App) -> bool {
self.closeable
}
fn zoomable(&self, _cx: &WindowContext) -> bool {
fn zoomable(&self, _cx: &App) -> bool {
self.zoomable
}
fn popup_menu(&self, menu: PopupMenu, _cx: &WindowContext) -> PopupMenu {
fn popup_menu(&self, menu: PopupMenu, _cx: &App) -> PopupMenu {
menu.track_focus(&self.focus_handle)
}
fn toolbar_buttons(&self, _cx: &WindowContext) -> Vec<Button> {
fn toolbar_buttons(&self, _window: &Window, _cx: &App) -> Vec<Button> {
vec![]
}
fn dump(&self, _cx: &AppContext) -> PanelState {
PanelState::new(self)
}
}
impl EventEmitter<PanelEvent> for WelcomePanel {}
impl FocusableView for WelcomePanel {
fn focus_handle(&self, _: &AppContext) -> gpui::FocusHandle {
impl Focusable for WelcomePanel {
fn focus_handle(&self, _: &App) -> gpui::FocusHandle {
self.focus_handle.clone()
}
}
impl Render for WelcomePanel {
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> impl IntoElement {
fn render(&mut self, _window: &mut gpui::Window, cx: &mut Context<Self>) -> impl IntoElement {
div()
.size_full()
.flex()