utils: add shared StyledExt styling helper

This commit is contained in:
2026-11-16 14:02:33 +07:00
parent d7e4047070
commit 745a01d7af
29 changed files with 332 additions and 68 deletions
+11 -2
View File
@@ -7,7 +7,7 @@ use gpui::{
AnyElement, App, AppContext as _, Bounds, ClickEvent, Context, Div, ElementId, Global,
InteractiveElement as _, IntoElement, KeyDownEvent, MouseButton, ParentElement as _, Pixels,
Point, Render, RenderOnce, Role, SharedString, Stateful, StatefulInteractiveElement as _,
Styled as _, Window, canvas, div, px, relative,
StyleRefinement, Styled as _, Window, canvas, div, px, relative,
};
use gpui_native_core::button::{Button, ButtonVariant};
use gpui_native_core::common::{Sizable as _, v_flex};
@@ -17,7 +17,7 @@ use gpui_native_core::spinner::Spinner;
use gpui_native_core::tooltip::Tooltip;
use gpui_native_icons::IconRole;
use gpui_native_theme::{ActiveTheme as _, POPUP_MAX_HEIGHT, Size};
use gpui_native_utils::adjacent_selectable;
use gpui_native_utils::{StyledExt as _, adjacent_selectable};
/// Reports the next selected tab by pointer and keys.
type ChangeHandler = Rc<dyn Fn(usize, &mut Window, &mut App)>;
@@ -315,6 +315,7 @@ pub struct Tabs {
on_reorder: Option<ReorderHandler>,
on_overflow_open: Option<OpenHandler>,
tabs: Option<TabsFn>,
style: StyleRefinement,
}
impl Tabs {
@@ -337,6 +338,7 @@ impl Tabs {
on_reorder: None,
on_overflow_open: None,
tabs: None,
style: StyleRefinement::default(),
}
}
@@ -713,6 +715,12 @@ impl Tabs {
}
}
impl gpui::Styled for Tabs {
fn style(&mut self) -> &mut StyleRefinement {
&mut self.style
}
}
impl RenderOnce for Tabs {
fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement {
let tabs = match self.tabs {
@@ -820,6 +828,7 @@ impl RenderOnce for Tabs {
.id(self.id.clone())
.flex()
.text_size(medium_text_size)
.refine_style(&self.style)
.track_focus(&focus)
.focusable()
.tab_stop(true)