linter updates

Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
2021-11-12 15:48:17 +01:00
parent c1a4547261
commit c8f6a6d272
36 changed files with 1005 additions and 614 deletions

View File

@@ -13,8 +13,7 @@ widget!(SenderWidget<SenderState> {
impl Template for SenderWidget {
fn template(self, id: Entity, bc: &mut BuildContext) -> Self {
self.name("SenderWidget")
.child(
self.name("SenderWidget").child(
Button::new()
.text("Click me to send a message!")
.v_align("center")
@@ -23,7 +22,7 @@ impl Template for SenderWidget {
states.get_mut::<SenderState>(id).send_message();
false
})
.build(bc)
.build(bc),
)
}
}
@@ -31,13 +30,13 @@ impl Template for SenderWidget {
// States
enum Action {
UpdateProgress(f64)
UpdateProgress(f64),
}
#[derive(Default, AsAny)]
struct SenderState {
actions: Vec<Action>,
target: Entity
target: Entity,
}
impl SenderState {
@@ -48,8 +47,11 @@ impl SenderState {
impl State for SenderState {
fn init(&mut self, _: &mut Registry, ctx: &mut Context) {
self.target = Entity::from(ctx.widget().try_clone::<u32>("target")
.expect("ERROR: SenderState::init(): target entity not found!"));
self.target = Entity::from(
ctx.widget()
.try_clone::<u32>("target")
.expect("ERROR: SenderState::init(): target entity not found!"),
);
}
fn update(&mut self, _: &mut Registry, ctx: &mut Context) {
@@ -77,11 +79,7 @@ widget!(ReceiverWidget<ReceiverState>);
impl Template for ReceiverWidget {
fn template(self, _id: Entity, bc: &mut BuildContext) -> Self {
self.name("ReceiverWidget")
.child(
ProgressBar::new()
.id("progress_bar")
.build(bc)
)
.child(ProgressBar::new().id("progress_bar").build(bc))
}
}
@@ -89,15 +87,22 @@ impl Template for ReceiverWidget {
#[derive(Default, AsAny)]
struct ReceiverState {
progress_bar: Entity
progress_bar: Entity,
}
impl State for ReceiverState {
fn init(&mut self, _: &mut Registry, ctx: &mut Context) {
self.progress_bar = ctx.entity_of_child("progress_bar").expect("Cannot find ProgressBar!");
self.progress_bar = ctx
.entity_of_child("progress_bar")
.expect("Cannot find ProgressBar!");
}
fn messages(&mut self, mut messages: MessageReader, _registry: &mut Registry, ctx: &mut Context) {
fn messages(
&mut self,
mut messages: MessageReader,
_registry: &mut Registry,
ctx: &mut Context,
) {
for action in messages.read::<Action>() {
match action {
Action::UpdateProgress(amount) => {
@@ -135,7 +140,7 @@ pub fn main() {
.orientation("vertical")
.child(sender)
.child(receiver)
.build(ctx)
.build(ctx),
)
.build(ctx)
})