Browse Source

Some more comments

Getty Ritter 1 year ago
parent
commit
85f0c46620
3 changed files with 27 additions and 0 deletions
  1. 5 0
      src/app.rs
  2. 7 0
      src/dmc.rs
  3. 15 0
      src/view.rs

+ 5 - 0
src/app.rs

@@ -1,8 +1,13 @@
 use crate::dmc;
 use anyhow::{anyhow, bail, Result};
 
+/// The data necessary to represent a stich legend icon.
 pub struct Data {
+    /// The character we want to draw.
     pub symbol: char,
+    /// The DMC thread color we want to use. This will be `None` if
+    /// the user has not entered in a valid DMC thread, and we'll draw
+    /// a bland gray background in that case
     pub dmc: Option<dmc::DMC>,
 }
 

+ 7 - 0
src/dmc.rs

@@ -1,13 +1,19 @@
 use lazy_static::lazy_static;
 use std::collections::HashMap;
 
+/// A description of a DMC thread color
 #[derive(Copy, Clone, Debug)]
 pub struct DMC {
+    /// The "number" (which may not be) of the thread
     pub number: &'static str,
+    /// The human-readable color name
     pub name: &'static str,
+    /// The RGB values
     pub color: (f64, f64, f64),
 }
 
+/// This was scraped from the internet and can be re-scraped again if
+/// needed
 pub const COLORS: &[DMC] = &[
     DMC {
         number: "3713",
@@ -2457,6 +2463,7 @@ pub const COLORS: &[DMC] = &[
 ];
 
 lazy_static! {
+    /// A lookup table by DMC "number" to the DMC descriptions above
     pub static ref LOOKUP: HashMap<&'static str, &'static DMC> = {
         let mut map = HashMap::new();
         for dmc in COLORS {

+ 15 - 0
src/view.rs

@@ -9,6 +9,7 @@ use std::rc::Rc;
 
 use crate::{app, dmc};
 
+// The set of possible symbols for chart icons
 const SYMBOLS: &[char] = &['A', 'B', 'C', 'D'];
 
 #[derive(Clone)]
@@ -27,14 +28,28 @@ impl App {
     }
 }
 
+/// The name is a bit of a misnomer here, since it also contains the
+/// "model" (i.e. the `app` field) but this contains all the
+/// information necessary to refer to parts of the UI. Note that
+/// everything here is refcounted internally (the `App` via an `Rc`
+/// and everything else via the GTK machinery) so calling `.clone()`
+/// on this struct will just produce new copies that point at the same
+/// underlying data.
 #[derive(Clone)]
 pub struct View {
+    // the app data
     app: App,
+    // the overall window
     window: gtk::Window,
+    // a map from character to button that changes to that charater
     icon_buttons: HashMap<char, gtk::Button>,
+    // the text entry for the DMC color
     color_input: gtk::Entry,
+    // the textual name of that DMC color
     color_name: gtk::Label,
+    // the create-it button
     submit: gtk::Button,
+    // the drawing area
     canvas: gtk::DrawingArea,
 }