core: implement fluent builder for data builders

This commit is contained in:
2026-11-15 19:43:37 +07:00
parent 3fe4ac4427
commit fd6a8c0342
9 changed files with 39 additions and 9 deletions
+4 -1
View File
@@ -8,7 +8,7 @@
use std::cell::RefCell;
use std::rc::Rc;
use gpui::prelude::FluentBuilder as _;
use gpui::prelude::FluentBuilder;
use gpui::{
App, Bounds, Context, ElementId, Entity, InteractiveElement as _, IntoElement, KeyBinding,
MouseButton, MouseDownEvent, ParentElement as _, Pixels, Render, Role, ScrollHandle,
@@ -183,6 +183,9 @@ where
}
}
// Combobox is a data builder, not an element, adopt the combinators explicitly.
impl<T> FluentBuilder for Combobox<T> where T: Clone + PartialEq + 'static {}
/// The stateful combobox.
pub struct ComboboxState<T>
where
+7 -1
View File
@@ -2,7 +2,7 @@
use std::rc::Rc;
use gpui::prelude::FluentBuilder as _;
use gpui::prelude::FluentBuilder;
use gpui::{
AnyElement, App, Context, ElementId, Entity, InteractiveElement as _, IntoElement, KeyBinding,
MouseButton, ParentElement as _, Render, Role, ScrollHandle, SharedString,
@@ -87,6 +87,9 @@ impl Command {
}
}
// Command is a data builder, not an element, adopt the combinators explicitly.
impl FluentBuilder for Command {}
/// Filters and ranks the commands for a query.
pub type CommandMatcher = Rc<dyn Fn(&str, &[Command]) -> Vec<Command>>;
/// Runs the chosen command.
@@ -148,6 +151,9 @@ impl CommandPalette {
}
}
// CommandPalette is a data builder, not an element, adopt the combinators explicitly.
impl FluentBuilder for CommandPalette {}
/// The stateful palette.
pub struct CommandPaletteState {
id: ElementId,
+4 -1
View File
@@ -1,4 +1,4 @@
use gpui::prelude::FluentBuilder as _;
use gpui::prelude::FluentBuilder;
use gpui::{
App, ElementId, InteractiveElement as _, IntoElement, ParentElement as _, RenderOnce, Role,
SharedString, StatefulInteractiveElement as _, Styled as _, Toggled, Window, div,
@@ -67,6 +67,9 @@ where
}
}
// Radio is a data builder, not an element, adopt the combinators explicitly.
impl<V> FluentBuilder for Radio<V> {}
/// Group of radio buttons.
#[derive(IntoElement)]
#[must_use]
+4 -1
View File
@@ -1,6 +1,6 @@
use std::rc::Rc;
use gpui::prelude::FluentBuilder as _;
use gpui::prelude::FluentBuilder;
use gpui::{
AnimationExt as _, App, Bounds, ElementId, Entity, InteractiveElement as _, IntoElement,
KeyDownEvent, ParentElement as _, Point, RenderOnce, Role, SharedString, SpringAnimation,
@@ -60,6 +60,9 @@ where
}
}
// SegmentedOption is a data builder, not an element, adopt the combinators explicitly.
impl<T> FluentBuilder for SegmentedOption<T> {}
/// A pill strip of mutually exclusive choices.
#[derive(IntoElement)]
#[must_use]
+4 -1
View File
@@ -1,6 +1,6 @@
use std::rc::Rc;
use gpui::prelude::FluentBuilder as _;
use gpui::prelude::FluentBuilder;
use gpui::{
App, ElementId, InteractiveElement as _, IntoElement, KeyDownEvent, ParentElement as _,
RenderOnce, Role, SharedString, StatefulInteractiveElement as _, StyleRefinement, Styled as _,
@@ -61,6 +61,9 @@ where
}
}
// SelectOption is a data builder, not an element, adopt the combinators explicitly.
impl<T> FluentBuilder for SelectOption<T> {}
/// A control that shows the chosen value and opens a menu of the choices.
#[derive(IntoElement)]
#[must_use]
+4 -1
View File
@@ -3,7 +3,7 @@
use std::rc::Rc;
use std::time::Duration;
use gpui::prelude::FluentBuilder as _;
use gpui::prelude::FluentBuilder;
use gpui::{
Animation, AnimationExt as _, App, Context, ElementId, Entity, InteractiveElement as _,
IntoElement, ParentElement as _, RenderOnce, Role, SharedString,
@@ -100,6 +100,9 @@ impl Toast {
}
}
// Toast is a data builder, not an element, adopt the combinators explicitly.
impl FluentBuilder for Toast {}
/// One raised toast, with its identity in the store.
#[derive(Clone)]
pub struct ToastEntry {