From 1a0e232176b39b64431c2ea7738190d65c31bd5b Mon Sep 17 00:00:00 2001 From: kernelkind Date: Sun, 19 Jan 2025 20:37:20 -0500 Subject: [PATCH] upload media button Signed-off-by: kernelkind --- assets/icons/media_upload_dark_4x.png | Bin 0 -> 1501 bytes crates/notedeck_columns/src/ui/note/post.rs | 41 ++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 assets/icons/media_upload_dark_4x.png diff --git a/assets/icons/media_upload_dark_4x.png b/assets/icons/media_upload_dark_4x.png new file mode 100644 index 0000000000000000000000000000000000000000..e83168779f7838dd41291ac5bd0c7faa65221d33 GIT binary patch literal 1501 zcmV<31tR*1P)@~0drDELIAGL9O(c600d`2O+f$vv5yP9S2S~u2p2GZ!7w7CEWB%O76f%p*DIb9#XN^2lEr85u%=QL?o0aB#1 z-K5|S?%f$_|dlvfmoKdb$b;roEWN-J{7nI(thkOH{n^JV}YfruGh#w2?r_w=>O z70ETpYm#y>7`%p08B%zU;Yr@;?^QBTBf|rd5p0eU zK1z~rI~h4h`9}$Fhke3~WDJR*>RNM5>t2tcO;9j^?3wMKo1%P3gUi#1RaBF!WEi#j6%;D1PaOMl7sB+ zOOiwKzNJpjEr5-|p4_ws_V_PNnkI>?-vO0<1$96*#!3{r0%lHd7I-5$wlJsXXQJOP zTtXdCIUI>)Mfp$#?0k)P7hMOR@yC!#K&d00W)JI4gM)puMtzSwphF9cg%x|P{mO-yKR_2!=S%KE@K}uiK%oT-5(@Bk^Dw-Eu_hz1yD_)CBps( z_ScKad>j&-Y25Cp^;$Du>H&FJ<`r zUAX@ZcnXpx6JtkOpRuh4k0t$pypcfD}!ZNyS zlxI@8r-0BDRAL&a_*vw0E&|WVg?tl}rs@Nv{`E#GK(FvlA&qm&HF)_tkGFTqiPd8og%MMR%}OY#+}S!T3PKzX{pN;ia_iFotx zNWRzCCnPUCX+u6?gI*1gsJx+3BUF8W)L&Yev)5GK@I+sag}gUD0pwBO+I*-QpcE26 zfQH#pc|*_$Aivbr{h{loMFtJhkn)C5caU1|YIv*~U?C)KEPmIp@`jKRT$JX+$^d#+ z=V}EUW*Wnmw4}Tt#Ryl`U1WO{kY-L>g|b^#-VkeqH63jO{3&Frz0cN>@`e~Ati=h| zw#HC}i=^f6p^mgf)3NeZo{@Yl{I*}+rdw+Pdak|@GA3;~_ozH`U%0=p_b6R6!C%46 zIMx~VtUS*Pq&Vb8n9R95j4BG`8beD6?6&r-Jo68@4Zwljefy@g7LZy&2A;041Ilx( zPhzEbf5v{MLW*{4Q;j z1W$~qH1~5hTKKcwMOaB*#N5@_Sf!Z~x;idzK(#SC z$Nu3zZM1pXBxnc@K^NFP1-5uHJ(&&-!Q1gu*j2P4a%`R)dpMO|8&p2R7-O41PV%2G zTkGRp{&ki|jto9-o!eW~yj@j-T3;;MI9`9tEt`A*h+Oq^NadV000000NkvXXu0mjf DMHIP1 literal 0 HcmV?d00001 diff --git a/crates/notedeck_columns/src/ui/note/post.rs b/crates/notedeck_columns/src/ui/note/post.rs index cd6c3618..5ed7870e 100644 --- a/crates/notedeck_columns/src/ui/note/post.rs +++ b/crates/notedeck_columns/src/ui/note/post.rs @@ -203,6 +203,15 @@ impl<'a> PostView<'a> { }); } + ui.with_layout( + egui::Layout::left_to_right(egui::Align::BOTTOM), + |ui| { + if ui.add(media_upload_button()).clicked() { + // TODO: implement media upload + } + }, + ); + ui.with_layout(egui::Layout::right_to_left(egui::Align::BOTTOM), |ui| { if ui .add_sized( @@ -252,6 +261,38 @@ fn post_button(interactive: bool) -> impl egui::Widget { } } +fn media_upload_button() -> impl egui::Widget { + |ui: &mut egui::Ui| -> egui::Response { + let resp = ui.allocate_response(egui::vec2(32.0, 32.0), egui::Sense::click()); + let painter = ui.painter(); + let (fill_color, stroke) = if resp.hovered() { + ( + ui.visuals().widgets.hovered.bg_fill, + ui.visuals().widgets.hovered.bg_stroke, + ) + } else if resp.clicked() { + ( + ui.visuals().widgets.active.bg_fill, + ui.visuals().widgets.active.bg_stroke, + ) + } else { + ( + ui.visuals().widgets.inactive.bg_fill, + ui.visuals().widgets.inactive.bg_stroke, + ) + }; + + painter.rect_filled(resp.rect, 8.0, fill_color); + painter.rect_stroke(resp.rect, 8.0, stroke); + egui::Image::new(egui::include_image!( + "../../../../../assets/icons/media_upload_dark_4x.png" + )) + .max_size(egui::vec2(16.0, 16.0)) + .paint_at(ui, resp.rect.shrink(8.0)); + resp + } +} + mod preview { use super::*; use notedeck::{App, AppContext};