gallery catalog rework

This commit is contained in:
2026-11-03 07:31:19 +07:00
parent 9d5cf5684f
commit 6d7b9fbf24
3 changed files with 2275 additions and 1751 deletions
+4 -1
View File
@@ -18,7 +18,10 @@ gpui = { workspace = true, features = ["test-support"] }
default = ["full"]
full = ["list", "sidebar", "tabs", "tree"]
list = []
sidebar = []
sidebar = [
"dep:gpui-native-core",
"gpui-native-core/scroll_area",
]
tabs = [
"dep:gpui-native-core",
"gpui-native-core/button",
+15 -2
View File
@@ -9,6 +9,7 @@ use gpui::{
ParentElement as _, RenderOnce, Role, SharedString, StatefulInteractiveElement as _,
Styled as _, Window, div,
};
use gpui_native_core::scroll_area::ScrollArea;
use gpui_native_icons::{IconRole, icon};
use gpui_native_theme::ActiveTheme as _;
use gpui_native_utils::{nav_key, paint_selectable_row, selectable_label_color};
@@ -168,6 +169,11 @@ impl RenderOnce for Sidebar {
.collect();
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 label = self
@@ -176,6 +182,7 @@ impl RenderOnce for Sidebar {
.unwrap_or_else(|| SharedString::from(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.
let children: Vec<AnyElement> = entries
@@ -197,9 +204,9 @@ impl RenderOnce for Sidebar {
div()
.id(self.id)
.debug_selector(move || format!("sidebar-{id_text}"))
.size_full()
.flex()
.flex_col()
.gap_0p5()
.text_size(theme.sizes.medium.text_size)
.track_focus(&focus)
.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),
)
}
}