notedeck

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

mod.rs (1881B)


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