Skip to content

Commit

Permalink
made code simpler
Browse files Browse the repository at this point in the history
  • Loading branch information
marci1175 committed Dec 5, 2023
1 parent 515f5f3 commit 89a4ce2
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/app/ui/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ impl TemplateApp {

}
else {

self.drop_file_animation = false;

}


Expand All @@ -132,10 +134,10 @@ impl TemplateApp {
size: self.font_size,
};

let drop_warning = Area::new("drop_warning").show(ctx, |ui|{
Area::new("drop_warning").show(ctx, |ui|{

ui.painter()
.rect(egui::Rect { min: Pos2::new(window_size[0] / 3., window_size[0] / 5. + self.how_on / 50.), max: Pos2::new(window_size[0] / 1.5, window_size[0] / 3. + self.how_on / 50.) }, 5.0, Color32::from_rgba_unmultiplied(0, 0, 0, self.how_on as u8), Stroke::default());
.rect(egui::Rect { min: Pos2::new(window_size[0] / 3., window_size[0] / 5. + self.how_on / 50.), max: Pos2::new(window_size[0] / 1.5, window_size[0] / 3. + self.how_on / 50.) }, 5.0, Color32::from_rgba_unmultiplied(0, 0, 0, self.how_on as u8 / 8), Stroke::default());
ui.painter()
.text(Pos2::new(window_size[0] / 2., window_size[0] / 4. + self.how_on / 50.), Align2([Align::Center, Align::Center]), "Drop to upload", font_id, Color32::from_rgba_unmultiplied(255, 255, 255, self.how_on as u8));

Expand All @@ -144,15 +146,11 @@ impl TemplateApp {

}

if self.drop_file_animation && !(self.how_on >= 255.) {
self.how_on += 1.; //step
ctx.request_repaint()
}
else if !self.drop_file_animation && self.how_on >= 0.{
self.how_on -= 1.;
ctx.request_repaint()
}

self.how_on = ctx.animate_value_with_time(Id::from("drop_warning"), match self.drop_file_animation {
true => 255.,
false => 0.
}, 0.4);

//Messages go here
ui.allocate_ui(
match self.usr_msg_expanded {
Expand Down

0 comments on commit 89a4ce2

Please sign in to comment.