mirror of
https://seed.radicle.dev/rad:z39mP9rQAaGmERfUMPULfPUi473tY.git
synced 2026-11-16 00:10:38 +08:00
lib: Improve content function types in imUI
This commit is contained in:
+4
-2
@@ -25,6 +25,8 @@ use crate::ui::{Column, ToRow};
|
||||
|
||||
use crate::ui::im::widget::{HeaderedTable, Widget};
|
||||
|
||||
use self::widget::AddContentFn;
|
||||
|
||||
const RENDERING_TICK_RATE: Duration = Duration::from_millis(250);
|
||||
|
||||
/// The main UI trait for the ability to render an application.
|
||||
@@ -406,10 +408,10 @@ where
|
||||
self.layout_dyn(layout, Box::new(add_contents))
|
||||
}
|
||||
|
||||
pub fn layout_dyn<'a, R>(
|
||||
pub fn layout_dyn<R>(
|
||||
&mut self,
|
||||
layout: impl Into<Layout>,
|
||||
add_contents: Box<dyn FnOnce(&mut Self) -> R + 'a>,
|
||||
add_contents: Box<AddContentFn<M, R>>,
|
||||
) -> InnerResponse<R> {
|
||||
let (area, _) = self.next_area().unwrap_or_default();
|
||||
let mut child_ui = self.child_ui(area, layout);
|
||||
|
||||
+6
-4
@@ -15,6 +15,8 @@ use crate::ui::{Column, ToRow};
|
||||
|
||||
use super::{Borders, Context, InnerResponse, Response, Ui};
|
||||
|
||||
pub type AddContentFn<'a, M, R> = dyn FnOnce(&mut Ui<M>) -> R + 'a;
|
||||
|
||||
pub trait Widget {
|
||||
fn ui<M>(self, ui: &mut Ui<M>, frame: &mut Frame) -> Response
|
||||
where
|
||||
@@ -37,10 +39,10 @@ impl Window {
|
||||
self.show_dyn(ctx, Box::new(add_contents))
|
||||
}
|
||||
|
||||
fn show_dyn<'c, M, R>(
|
||||
fn show_dyn<M, R>(
|
||||
self,
|
||||
ctx: &Context<M>,
|
||||
add_contents: Box<dyn FnOnce(&mut Ui<M>) -> R + 'c>,
|
||||
add_contents: Box<AddContentFn<M, R>>,
|
||||
) -> Option<InnerResponse<Option<R>>>
|
||||
where
|
||||
M: Clone,
|
||||
@@ -111,10 +113,10 @@ impl<'a> Group<'a> {
|
||||
self.show_dyn(ui, Box::new(add_contents))
|
||||
}
|
||||
|
||||
pub fn show_dyn<'c, M, R>(
|
||||
pub fn show_dyn<M, R>(
|
||||
self,
|
||||
ui: &mut Ui<M>,
|
||||
add_contents: Box<dyn FnOnce(&mut Ui<M>) -> R + 'c>,
|
||||
add_contents: Box<AddContentFn<M, R>>,
|
||||
) -> InnerResponse<R>
|
||||
where
|
||||
M: Clone,
|
||||
|
||||
Reference in New Issue
Block a user