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
+12 -2
View File
@@ -7,14 +7,15 @@ use gpui::prelude::FluentBuilder as _;
use gpui::{
App, ClickEvent, DefiniteLength, DispatchPhase, ElementId, InteractiveElement as _,
IntoElement, KeyDownEvent, MouseButton, MouseDownEvent, ParentElement as _, RenderOnce, Role,
SharedString, StatefulInteractiveElement as _, Styled as _, Window, canvas, div, relative,
SharedString, StatefulInteractiveElement as _, StyleRefinement, Styled as _, Window, canvas,
div, relative,
};
use gpui_native_icons::{Icon, IconRole, icon};
use gpui_native_theme::{ActiveTheme as _, BORDER_WIDTH, Size};
use gpui_native_utils::{focus_handle, focus_ring};
use crate::button::ButtonVariant;
use crate::common::{Sizable, h_flex};
use crate::common::{Sizable, StyledExt as _, h_flex};
use crate::menu::{
ChangeHandler, MenuChrome, MenuItem, MenuPanelSpec, TriggerBoundsCell, anchored_menu_panel,
};
@@ -42,6 +43,7 @@ pub struct DropdownMenu {
on_open_change: Option<ChangeHandler>,
items: Option<ItemsFn>,
min_width: Option<DefiniteLength>,
style: StyleRefinement,
}
impl DropdownMenu {
@@ -65,6 +67,7 @@ impl DropdownMenu {
on_open_change: None,
items: None,
min_width: None,
style: StyleRefinement::default(),
}
}
@@ -168,6 +171,12 @@ impl Sizable for DropdownMenu {
}
}
impl gpui::Styled for DropdownMenu {
fn style(&mut self) -> &mut StyleRefinement {
&mut self.style
}
}
impl RenderOnce for DropdownMenu {
fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement {
let theme = cx.theme();
@@ -410,6 +419,7 @@ impl RenderOnce for DropdownMenu {
div()
.relative()
.refine_style(&self.style)
.child(
canvas(
{