gallery catalog rework
This commit is contained in:
@@ -18,7 +18,10 @@ gpui = { workspace = true, features = ["test-support"] }
|
|||||||
default = ["full"]
|
default = ["full"]
|
||||||
full = ["list", "sidebar", "tabs", "tree"]
|
full = ["list", "sidebar", "tabs", "tree"]
|
||||||
list = []
|
list = []
|
||||||
sidebar = []
|
sidebar = [
|
||||||
|
"dep:gpui-native-core",
|
||||||
|
"gpui-native-core/scroll_area",
|
||||||
|
]
|
||||||
tabs = [
|
tabs = [
|
||||||
"dep:gpui-native-core",
|
"dep:gpui-native-core",
|
||||||
"gpui-native-core/button",
|
"gpui-native-core/button",
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ use gpui::{
|
|||||||
ParentElement as _, RenderOnce, Role, SharedString, StatefulInteractiveElement as _,
|
ParentElement as _, RenderOnce, Role, SharedString, StatefulInteractiveElement as _,
|
||||||
Styled as _, Window, div,
|
Styled as _, Window, div,
|
||||||
};
|
};
|
||||||
|
use gpui_native_core::scroll_area::ScrollArea;
|
||||||
use gpui_native_icons::{IconRole, icon};
|
use gpui_native_icons::{IconRole, icon};
|
||||||
use gpui_native_theme::ActiveTheme as _;
|
use gpui_native_theme::ActiveTheme as _;
|
||||||
use gpui_native_utils::{nav_key, paint_selectable_row, selectable_label_color};
|
use gpui_native_utils::{nav_key, paint_selectable_row, selectable_label_color};
|
||||||
@@ -168,6 +169,11 @@ impl RenderOnce for Sidebar {
|
|||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let focus = gpui_native_utils::focus_handle(&self.id, window, cx);
|
let focus = gpui_native_utils::focus_handle(&self.id, window, cx);
|
||||||
|
let scroll = window.with_element_namespace(self.id.clone(), |window| {
|
||||||
|
window
|
||||||
|
.use_keyed_state("scroll", cx, |_, _| gpui::ScrollHandle::new())
|
||||||
|
.clone()
|
||||||
|
});
|
||||||
let theme = cx.theme();
|
let theme = cx.theme();
|
||||||
|
|
||||||
let label = self
|
let label = self
|
||||||
@@ -176,6 +182,7 @@ impl RenderOnce for Sidebar {
|
|||||||
.unwrap_or_else(|| SharedString::from(self.id.to_string()));
|
.unwrap_or_else(|| SharedString::from(self.id.to_string()));
|
||||||
|
|
||||||
let id_text = self.id.to_string();
|
let id_text = self.id.to_string();
|
||||||
|
let scroll_area_id = (self.id.clone(), "entries");
|
||||||
|
|
||||||
// Entry paint reads the theme through this borrow.
|
// Entry paint reads the theme through this borrow.
|
||||||
let children: Vec<AnyElement> = entries
|
let children: Vec<AnyElement> = entries
|
||||||
@@ -197,9 +204,9 @@ impl RenderOnce for Sidebar {
|
|||||||
div()
|
div()
|
||||||
.id(self.id)
|
.id(self.id)
|
||||||
.debug_selector(move || format!("sidebar-{id_text}"))
|
.debug_selector(move || format!("sidebar-{id_text}"))
|
||||||
|
.size_full()
|
||||||
.flex()
|
.flex()
|
||||||
.flex_col()
|
.flex_col()
|
||||||
.gap_0p5()
|
|
||||||
.text_size(theme.sizes.medium.text_size)
|
.text_size(theme.sizes.medium.text_size)
|
||||||
.track_focus(&focus)
|
.track_focus(&focus)
|
||||||
.focusable()
|
.focusable()
|
||||||
@@ -219,7 +226,13 @@ impl RenderOnce for Sidebar {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.children(children)
|
.child(
|
||||||
|
ScrollArea::new(scroll_area_id)
|
||||||
|
.handle(scroll.read(cx).clone())
|
||||||
|
.h_full()
|
||||||
|
.gap_0p5()
|
||||||
|
.children(children),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2152
-1644
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user