Impl Scrollable for Focusable<E>, Stateful<E>.
This commit is contained in:
parent
d63e256f19
commit
7305967c09
1 changed files with 20 additions and 3 deletions
|
|
@ -2,19 +2,36 @@ mod scroll_view;
|
||||||
mod scrollable;
|
mod scrollable;
|
||||||
mod scrollbar;
|
mod scrollbar;
|
||||||
|
|
||||||
use gpui::{AnyElement, AnyView, Div, Element, ElementId};
|
use gpui::{AnyElement, AnyView, Div, Element, ElementId, Focusable, InteractiveElement, Stateful};
|
||||||
pub use scroll_view::*;
|
pub use scroll_view::*;
|
||||||
pub use scrollable::*;
|
pub use scrollable::*;
|
||||||
pub use scrollbar::*;
|
pub use scrollbar::*;
|
||||||
|
|
||||||
pub trait Scrollable: Element + Sized {
|
pub trait Scrollable: Element {
|
||||||
/// Wraps the element in a ScrollView.
|
/// Wraps the element in a ScrollView.
|
||||||
///
|
///
|
||||||
/// Current this is only have a vertical scrollbar.
|
/// Current this is only have a vertical scrollbar.
|
||||||
fn scrollable(self, id: impl Into<ElementId>, view: impl Into<AnyView>) -> ScrollView {
|
fn scrollable(self, id: impl Into<ElementId>, view: impl Into<AnyView>) -> ScrollView {
|
||||||
ScrollView::new(id.into(), view, ScrollbarAxis::Vertical).content(move |_| self)
|
ScrollView::new(
|
||||||
|
ElementId::Name(format!("{}:{}", id.into(), "ScrollView").into()),
|
||||||
|
view,
|
||||||
|
ScrollbarAxis::Vertical,
|
||||||
|
)
|
||||||
|
.content(move |_| self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Scrollable for AnyElement {}
|
impl Scrollable for AnyElement {}
|
||||||
impl Scrollable for Div {}
|
impl Scrollable for Div {}
|
||||||
|
impl<E> Scrollable for Focusable<E>
|
||||||
|
where
|
||||||
|
E: Element,
|
||||||
|
Self: InteractiveElement,
|
||||||
|
{
|
||||||
|
}
|
||||||
|
impl<E> Scrollable for Stateful<E>
|
||||||
|
where
|
||||||
|
E: Element,
|
||||||
|
Self: InteractiveElement,
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue