mod.rs (1902B)
1 pub mod account_login_view; 2 pub mod accounts; 3 pub mod add_column; 4 pub mod anim; 5 pub mod column; 6 pub mod configure_deck; 7 pub mod edit_deck; 8 pub mod mention; 9 pub mod note; 10 pub mod preview; 11 pub mod profile; 12 pub mod relay; 13 pub mod relay_debug; 14 pub mod side_panel; 15 pub mod support; 16 pub mod thread; 17 pub mod timeline; 18 pub mod username; 19 20 pub use accounts::AccountsView; 21 pub use mention::Mention; 22 pub use note::{NoteResponse, NoteView, PostReplyView, PostView}; 23 pub use preview::{Preview, PreviewApp, PreviewConfig}; 24 pub use profile::{ProfilePic, ProfilePreview}; 25 pub use relay::RelayView; 26 pub use side_panel::{DesktopSidePanel, SidePanelAction}; 27 pub use thread::ThreadView; 28 pub use timeline::TimelineView; 29 pub use username::Username; 30 31 use egui::Margin; 32 33 /// This is kind of like the Widget trait but is meant for larger top-level 34 /// views that are typically stateful. 35 /// 36 /// The Widget trait forces us to add mutable 37 /// implementations at the type level, which screws us when generating Previews 38 /// for a Widget. I would have just Widget instead of making this Trait otherwise. 39 /// 40 /// There is some precendent for this, it looks like there's a similar trait 41 /// in the egui demo library. 42 pub trait View { 43 fn ui(&mut self, ui: &mut egui::Ui); 44 } 45 46 pub fn padding<R>( 47 amount: impl Into<Margin>, 48 ui: &mut egui::Ui, 49 add_contents: impl FnOnce(&mut egui::Ui) -> R, 50 ) -> egui::InnerResponse<R> { 51 egui::Frame::none() 52 .inner_margin(amount) 53 .show(ui, add_contents) 54 } 55 56 pub fn hline(ui: &egui::Ui) { 57 // pixel perfect horizontal line 58 let rect = ui.available_rect_before_wrap(); 59 let resize_y = ui.painter().round_to_pixel(rect.top()) - 0.5; 60 let stroke = ui.style().visuals.widgets.noninteractive.bg_stroke; 61 ui.painter().hline(rect.x_range(), resize_y, stroke); 62 } 63 64 pub fn show_pointer(ui: &egui::Ui) { 65 ui.ctx().set_cursor_icon(egui::CursorIcon::PointingHand); 66 }