notedeck

One damus client to rule them all
git clone git://jb55.com/notedeck
Log | Files | Refs | README | LICENSE

mod.rs (1937B)


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