Skip to content

Commit

Permalink
reformatting
Browse files Browse the repository at this point in the history
  • Loading branch information
marci1175 committed Aug 9, 2024
1 parent fcfbaaa commit 65cb5b8
Show file tree
Hide file tree
Showing 4 changed files with 405 additions and 281 deletions.
2 changes: 1 addition & 1 deletion build_info.matthias_build
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024.08.09. 10:51
2024.08.09. 22:54
15 changes: 4 additions & 11 deletions src/app/ui/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,10 @@ impl Application
if port.is_empty() {
//Avoid panicking when trying to display a Notification
//This is very rare but can still happen
match self.toasts.lock() {
Ok(mut toasts) => {
display_error_message(
"Invalid address to send the message on.",
self.toasts.clone(),
);
},
Err(err) => {
tracing::error!("{}", err);
},
}
display_error_message(
"Invalid address to send the message on.",
self.toasts.clone(),
);

return;
}
Expand Down
65 changes: 39 additions & 26 deletions src/app/ui/client_ui/message_instances/message_display.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{fs, path::PathBuf};

use egui::{vec2, Align, Align2, Area, Color32, Context, Layout, RichText, Sense, Ui};
use egui::{vec2, Align, Align2, Area, Color32, Context, LayerId, Layout, RichText, Sense, Ui};

use crate::app::backend::{
parse_incoming_message, write_file, Application, ClientMessage, MessageDisplay,
Expand Down Expand Up @@ -435,36 +435,49 @@ impl Application
picture: &ServerImageUpload,
)
{
//Image overlay
ui.painter().rect_filled(
egui::Rect::EVERYTHING,
0.,
Color32::from_rgba_premultiplied(0, 0, 0, 180),
);
Area::new("image_bg".into())
.movable(false)
.anchor(Align2::CENTER_CENTER, vec2(0., 0.))
.default_size(ctx.used_size())
.show(ctx, |ui| {
//Pain background
ui.painter()
.clone()
.with_layer_id(LayerId::background())
.rect_filled(
egui::Rect::EVERYTHING,
0.,
Color32::from_rgba_premultiplied(0, 0, 0, 170),
);

if ui
.allocate_response(ui.available_size(), Sense::click())
.clicked()
{
self.client_ui.image_overlay = false;
}
});

Area::new("image_overlay".into())
.movable(false)
.anchor(Align2::CENTER_CENTER, vec2(0., 0.))
.show(ctx, |ui| {
ui.allocate_ui(
vec2(ui.available_width() / 1.3, ui.available_height() / 1.3),
|ui| {
ui.add(egui::widgets::Image::from_bytes(
format!("bytes://{}", picture.signature),
image_bytes.clone(),
)) /*Add the same context menu as before*/
.context_menu(|ui| {
if ui.button("Save").clicked() {
//always name the file ".png"
let image_save = ServerFileReply {
bytes: image_bytes.clone(),
file_name: PathBuf::from(".png"),
};
let _ = write_file(image_save);
}
});
},
);
ui.allocate_ui(ui.available_size(), |ui| {
ui.add(egui::widgets::Image::from_bytes(
format!("bytes://{}", picture.signature),
image_bytes.clone(),
)) /*Add the same context menu as before*/
.context_menu(|ui| {
if ui.button("Save").clicked() {
//always name the file ".png"
let image_save = ServerFileReply {
bytes: image_bytes.clone(),
file_name: PathBuf::from(".png"),
};
let _ = write_file(image_save);
}
});
});
});

Area::new("image_overlay_exit".into())
Expand Down
Loading

0 comments on commit 65cb5b8

Please sign in to comment.