[fractal] Add some doc comments



commit e7262499a97defcbee05dc2e51344241f14dcde7
Author: Kai A. Hiller <V02460 gmail com>
Date:   Tue Oct 27 11:14:12 2020 +0100

    Add some doc comments

 fractal-gtk/src/widgets/room_history.rs  | 10 ++++++++++
 fractal-gtk/src/widgets/scroll_widget.rs |  9 ++++++++-
 2 files changed, 18 insertions(+), 1 deletion(-)
---
diff --git a/fractal-gtk/src/widgets/room_history.rs b/fractal-gtk/src/widgets/room_history.rs
index 59fd6f45..91a59b92 100644
--- a/fractal-gtk/src/widgets/room_history.rs
+++ b/fractal-gtk/src/widgets/room_history.rs
@@ -62,12 +62,14 @@ impl List {
         self.list.insert(self.list.len() - index, element);
     }
 
+    /// Adds the element to the top of the history.
     pub fn add_top(&mut self, element: Element) {
         self.add_item(0, element);
         /* TODO: update the previous message:
          * we need to update the previous row because it could be that we have to remove the header */
     }
 
+    /// Adds the element to the bottom of the history.
     pub fn add_bottom(&mut self, element: Element) {
         if let Some(index) = self.new_divider_index {
             self.new_divider_index = Some(index + 1);
@@ -75,11 +77,19 @@ impl List {
         self.add_item(self.list.len(), element);
     }
 
+    /// Removes the element at the given position from the history.
+    ///
+    /// ### Panics
+    /// Panics if `index >= len`.
     fn remove_item(&mut self, index: usize) {
         self.list.remove(index);
         self.view.remove(self.list.len() - index - 1);
     }
 
+    /// Replaces the element at the given position in the history.
+    ///
+    /// ### Panics
+    /// Panics if `index >= len`.
     fn replace_item(&mut self, index: usize, element: Element) {
         self.view.remove(self.list.len() - index - 1);
         self.view
diff --git a/fractal-gtk/src/widgets/scroll_widget.rs b/fractal-gtk/src/widgets/scroll_widget.rs
index a3bc33b9..575fc868 100644
--- a/fractal-gtk/src/widgets/scroll_widget.rs
+++ b/fractal-gtk/src/widgets/scroll_widget.rs
@@ -16,11 +16,18 @@ enum Position {
     Bottom,
 }
 
+/// Holds all message widgets and keeps track of the scrolling position.
+///
+/// Additional duties include handling of the revealer button and displaying
+/// typing notifications.
 pub struct ScrollWidget {
+    /// The old scroll maximum
     upper: Rc<Cell<f64>>,
+    /// Position of incoming change relative to the view's bottom. Cleared after use.
     balance: Rc<Cell<Option<Position>>>,
+    /// Whether to stay at the bottom of the message history.
     autoscroll: Rc<Cell<bool>>,
-    /* whether a request for more messages has been send or not */
+    /// Whether a request for more messages has been send or not.
     request_sent: Rc<Cell<bool>>,
     widgets: Widgets,
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]