Fix to work with new GPUI.
This commit is contained in:
parent
06008524dd
commit
c94e9feae2
3 changed files with 33 additions and 31 deletions
|
|
@ -278,11 +278,13 @@ impl Render for StoryWorkspace {
|
||||||
.gap_2()
|
.gap_2()
|
||||||
.child(
|
.child(
|
||||||
Button::new("theme-mode", cx)
|
Button::new("theme-mode", cx)
|
||||||
.when_else(
|
.map(|this| {
|
||||||
cx.theme().mode.is_dark(),
|
if cx.theme().mode.is_dark() {
|
||||||
|this| this.icon(IconName::Moon),
|
this.icon(IconName::Sun)
|
||||||
|this| this.icon(IconName::Sun),
|
} else {
|
||||||
)
|
this.icon(IconName::Moon)
|
||||||
|
}
|
||||||
|
})
|
||||||
.size(Size::Small)
|
.size(Size::Small)
|
||||||
.style(ButtonStyle::Ghost)
|
.style(ButtonStyle::Ghost)
|
||||||
.on_click(move |_, cx| {
|
.on_click(move |_, cx| {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use gpui::{
|
use gpui::{
|
||||||
div, prelude::FluentBuilder as _, AnyElement, Context, EventEmitter, FocusHandle,
|
div, prelude::FluentBuilder, AnyElement, Context, EventEmitter, FocusHandle, FocusableView,
|
||||||
FocusableView, InteractiveElement, IntoElement, KeyDownEvent, Model, MouseButton,
|
InteractiveElement, IntoElement, KeyDownEvent, Model, MouseButton, MouseDownEvent,
|
||||||
MouseDownEvent, ParentElement as _, Render, SharedString, Styled as _, ViewContext,
|
ParentElement as _, Render, SharedString, Styled as _, ViewContext,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{h_flex, theme::ActiveTheme, v_flex};
|
use crate::{h_flex, theme::ActiveTheme, v_flex};
|
||||||
|
|
@ -174,27 +174,22 @@ impl Render for OtpInput {
|
||||||
.h_8()
|
.h_8()
|
||||||
.text_lg()
|
.text_lg()
|
||||||
.on_mouse_down(MouseButton::Left, cx.listener(Self::on_input_mouse_down))
|
.on_mouse_down(MouseButton::Left, cx.listener(Self::on_input_mouse_down))
|
||||||
.when_some_else(
|
.map(|this| match c {
|
||||||
c,
|
Some(c) => this.child(if self.masked {
|
||||||
|this, c| {
|
SharedString::from("•")
|
||||||
this.child(if self.masked {
|
} else {
|
||||||
SharedString::from("•")
|
SharedString::from(c.to_string())
|
||||||
} else {
|
}),
|
||||||
SharedString::from(c.to_string())
|
None => this.when(is_input_focused && blink_show, |this| {
|
||||||
})
|
this.child(
|
||||||
},
|
div()
|
||||||
|this| {
|
.h_4()
|
||||||
this.when(is_input_focused && blink_show, |this| {
|
.w_0()
|
||||||
this.child(
|
.border_l_3()
|
||||||
div()
|
.border_color(crate::blue_500()),
|
||||||
.h_4()
|
)
|
||||||
.w_0()
|
}),
|
||||||
.border_l_3()
|
})
|
||||||
.border_color(crate::blue_500()),
|
|
||||||
)
|
|
||||||
})
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.into_any_element(),
|
.into_any_element(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@ use gpui::{
|
||||||
Interactivity, IntoElement, IsZero, Pixels, SharedString, Size, StyleRefinement, Styled,
|
Interactivity, IntoElement, IsZero, Pixels, SharedString, Size, StyleRefinement, Styled,
|
||||||
WindowContext,
|
WindowContext,
|
||||||
};
|
};
|
||||||
|
use image::Frame;
|
||||||
|
use smallvec::SmallVec;
|
||||||
|
|
||||||
use image::ImageBuffer;
|
use image::ImageBuffer;
|
||||||
|
|
||||||
|
|
@ -124,7 +126,10 @@ impl Asset for Image {
|
||||||
pixel.swap(0, 2);
|
pixel.swap(0, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(Arc::new(ImageData::new(buffer)))
|
Ok(Arc::new(ImageData::new(SmallVec::from_elem(
|
||||||
|
Frame::new(buffer),
|
||||||
|
1,
|
||||||
|
))))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -257,7 +262,7 @@ impl Element for SvgImg {
|
||||||
origin: new_origin,
|
origin: new_origin,
|
||||||
};
|
};
|
||||||
|
|
||||||
match cx.paint_image(img_bounds, px(0.).into(), data, false) {
|
match cx.paint_image(img_bounds, px(0.).into(), data, 0, false) {
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
Err(err) => eprintln!("failed to paint svg image: {:?}", err),
|
Err(err) => eprintln!("failed to paint svg image: {:?}", err),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue