Checkpoint: Compiling after view type removal
This commit is contained in:
parent
c9c9db903d
commit
88ef74ec8f
44 changed files with 392 additions and 695 deletions
|
@ -1,4 +1,3 @@
|
|||
use std::marker::PhantomData;
|
||||
use std::sync::Arc;
|
||||
|
||||
use gpui2::MouseButton;
|
||||
|
@ -6,19 +5,18 @@ use gpui2::MouseButton;
|
|||
use crate::{h_stack, prelude::*};
|
||||
use crate::{ClickHandler, Icon, IconColor, IconElement};
|
||||
|
||||
struct IconButtonHandlers<S: 'static + Send + Sync> {
|
||||
struct IconButtonHandlers<S: 'static> {
|
||||
click: Option<ClickHandler<S>>,
|
||||
}
|
||||
|
||||
impl<S: 'static + Send + Sync> Default for IconButtonHandlers<S> {
|
||||
impl<S: 'static> Default for IconButtonHandlers<S> {
|
||||
fn default() -> Self {
|
||||
Self { click: None }
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Component)]
|
||||
pub struct IconButton<S: 'static + Send + Sync> {
|
||||
state_type: PhantomData<S>,
|
||||
pub struct IconButton<S: 'static> {
|
||||
id: ElementId,
|
||||
icon: Icon,
|
||||
color: IconColor,
|
||||
|
@ -27,10 +25,9 @@ pub struct IconButton<S: 'static + Send + Sync> {
|
|||
handlers: IconButtonHandlers<S>,
|
||||
}
|
||||
|
||||
impl<S: 'static + Send + Sync> IconButton<S> {
|
||||
impl<S: 'static> IconButton<S> {
|
||||
pub fn new(id: impl Into<ElementId>, icon: Icon) -> Self {
|
||||
Self {
|
||||
state_type: PhantomData,
|
||||
id: id.into(),
|
||||
icon,
|
||||
color: IconColor::default(),
|
||||
|
@ -60,10 +57,7 @@ impl<S: 'static + Send + Sync> IconButton<S> {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn on_click(
|
||||
mut self,
|
||||
handler: impl Fn(&mut S, &mut ViewContext<S>) + 'static + Send + Sync,
|
||||
) -> Self {
|
||||
pub fn on_click(mut self, handler: impl 'static + Fn(&mut S, &mut ViewContext<S>) + Send + Sync) -> Self {
|
||||
self.handlers.click = Some(Arc::new(handler));
|
||||
self
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue