separate state from rsc
This commit is contained in:
1 parent
462c0e6416
commit
5da1e9e767
22 files changed
+373
-492
No files matched your search
+10
-10
@@ -51,15 +51,15 @@ impl<State, O, H: WidgetOption<State>> TextBuilder<State, O, H> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<State: HasUi + StateLike<State>, O> TextBuilder<State, O> {
|
||||
pub fn hint<W: WidgetLike<State, Tag>, Tag>(
|
||||
impl<Rsc: HasUi, O> TextBuilder<Rsc, O> {
|
||||
pub fn hint<W: WidgetLike<Rsc, Tag>, Tag>(
|
||||
self,
|
||||
hint: W,
|
||||
) -> TextBuilder<State, O, impl WidgetOption<State>> {
|
||||
) -> TextBuilder<Rsc, O, impl WidgetOption<Rsc>> {
|
||||
TextBuilder {
|
||||
content: self.content,
|
||||
attrs: self.attrs,
|
||||
hint: move |ui: &mut State| Some(hint.add_strong(ui).any()),
|
||||
hint: move |rsc: &mut Rsc| Some(hint.add_strong(rsc).any()),
|
||||
output: self.output,
|
||||
state: PhantomData,
|
||||
}
|
||||
@@ -75,19 +75,19 @@ pub trait TextBuilderOutput<State>: Sized {
|
||||
}
|
||||
|
||||
pub struct TextOutput;
|
||||
impl<State: HasUi> TextBuilderOutput<State> for TextOutput {
|
||||
impl<Rsc: HasUi> TextBuilderOutput<Rsc> for TextOutput {
|
||||
type Output = Text;
|
||||
|
||||
fn run<H: WidgetOption<State>>(
|
||||
state: &mut State,
|
||||
builder: TextBuilder<State, Self, H>,
|
||||
fn run<H: WidgetOption<Rsc>>(
|
||||
state: &mut Rsc,
|
||||
builder: TextBuilder<Rsc, Self, H>,
|
||||
) -> Self::Output {
|
||||
let mut buf = TextBuffer::new_empty(Metrics::new(
|
||||
builder.attrs.font_size,
|
||||
builder.attrs.line_height,
|
||||
));
|
||||
let hint = builder.hint.get(state);
|
||||
let font_system = &mut state.get_mut().text.font_system;
|
||||
let font_system = &mut state.ui_mut().text.font_system;
|
||||
buf.set_text(font_system, &builder.content, &Attrs::new(), SHAPING, None);
|
||||
let mut text = Text {
|
||||
content: builder.content.into(),
|
||||
@@ -118,7 +118,7 @@ impl<State: HasUi> TextBuilderOutput<State> for TextEditOutput {
|
||||
TextView::new(buf, builder.attrs, builder.hint.get(state)),
|
||||
builder.output.mode,
|
||||
);
|
||||
let font_system = &mut state.get_mut().text.font_system;
|
||||
let font_system = &mut state.ui_mut().text.font_system;
|
||||
text.buf
|
||||
.set_text(font_system, &builder.content, &Attrs::new(), SHAPING, None);
|
||||
builder.attrs.apply(font_system, &mut text.buf, None);
|
||||
|
||||
Reference in new issue
Block a user