utils: add shared StyledExt styling helper
This commit is contained in:
@@ -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(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user