Reorganize element-related traits

This commit is contained in:
Nathan Sobo
2023-11-22 11:19:43 -07:00
parent ca1d9dd0e5
commit c23f17ee0b
42 changed files with 190 additions and 265 deletions
+4 -4
View File
@@ -10,9 +10,9 @@ use collections::HashMap;
use editor::Editor;
use futures::channel::oneshot;
use gpui::{
actions, div, red, Action, AppContext, Div, EventEmitter, InteractiveElement as _,
ParentElement as _, Render, RenderOnce, Styled, Subscription, Task, View, ViewContext,
VisualContext as _, WindowContext,
actions, div, red, Action, AppContext, Div, EventEmitter, InteractiveElement as _, IntoElement,
ParentElement as _, Render, Styled, Subscription, Task, View, ViewContext, VisualContext as _,
WindowContext,
};
use project::search::SearchQuery;
use serde::Deserialize;
@@ -538,7 +538,7 @@ impl BufferSearchBar {
self.update_matches(cx)
}
fn render_action_button(&self) -> impl RenderOnce {
fn render_action_button(&self) -> impl IntoElement {
// let tooltip_style = theme.tooltip.clone();
// let style = theme.search.action_button.clone();
+4 -4
View File
@@ -1,6 +1,6 @@
use bitflags::bitflags;
pub use buffer_search::BufferSearchBar;
use gpui::{actions, Action, AppContext, RenderOnce};
use gpui::{actions, Action, AppContext, IntoElement};
pub use mode::SearchMode;
use project::search::SearchQuery;
use ui::ButtonVariant;
@@ -82,7 +82,7 @@ impl SearchOptions {
options
}
pub fn as_button(&self, active: bool) -> impl RenderOnce {
pub fn as_button(&self, active: bool) -> impl IntoElement {
ui::IconButton::new(0, self.icon())
.on_click({
let action = self.to_toggle_action();
@@ -95,7 +95,7 @@ impl SearchOptions {
}
}
fn toggle_replace_button(active: bool) -> impl RenderOnce {
fn toggle_replace_button(active: bool) -> impl IntoElement {
// todo: add toggle_replace button
ui::IconButton::new(0, ui::Icon::Replace)
.on_click(|_, cx| {
@@ -109,7 +109,7 @@ fn toggle_replace_button(active: bool) -> impl RenderOnce {
fn render_replace_button(
action: impl Action + 'static + Send + Sync,
icon: ui::Icon,
) -> impl RenderOnce {
) -> impl IntoElement {
// todo: add tooltip
ui::IconButton::new(0, icon).on_click(move |_, cx| {
cx.dispatch_action(action.boxed_clone());
+2 -2
View File
@@ -1,4 +1,4 @@
use gpui::{MouseDownEvent, RenderOnce, WindowContext};
use gpui::{IntoElement, MouseDownEvent, WindowContext};
use ui::{Button, ButtonVariant, IconButton};
use crate::mode::SearchMode;
@@ -7,7 +7,7 @@ pub(super) fn render_nav_button(
icon: ui::Icon,
_active: bool,
on_click: impl Fn(&MouseDownEvent, &mut WindowContext) + 'static,
) -> impl RenderOnce {
) -> impl IntoElement {
// let tooltip_style = cx.theme().tooltip.clone();
// let cursor_style = if active {
// CursorStyle::PointingHand