chiark / gitweb /
ui: Break out HTML_TEXT_LABEL_ELEM_START from clock.rs
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 18 Apr 2022 00:02:15 +0000 (01:02 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 18 Apr 2022 00:02:15 +0000 (01:02 +0100)
We actually need this in other places too.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/clock.rs
src/ui.rs

index aa4400265e346fb52ffca6965c781c8bbe4039c9..886a13b01428bb6f2e7836e18c9b88f7a1014cdf 100644 (file)
@@ -497,35 +497,36 @@ impl PieceTrait for Clock {
       let mins = mins.to_string();
       let mins_pad = Html::from_html_string("&nbsp;".repeat(3 - mins.len()));
 
-      let pointer = Html::lit(r##"
-  pointer-events="none"
-             "##);
       let font = monospace_font(6);
       hwrite!(f, r##"
-  <text x="1" y="{}" {} {} fill="{}" >{}{}{}</text>"##,
-             y, font, pointer, Html::lit(show.text),
+  <{} x="1" y="{}" {} fill="{}" >{}{}{}</text>"##,
+             HTML_TEXT_LABEL_ELEM_START,
+             y, font, Html::lit(show.text),
              mins_pad, HtmlStr::from_html_str(&mins), Html::lit(show.sigil)
       )?;
       hwrite!(f, r##"
-  <text x="14" y="{}" {} {} fill="{}" >{:02}</text>"##,
-             y, font, pointer, Html::lit(show.text),
+  <{} x="14" y="{}" {} fill="{}" >{:02}</text>"##,
+             HTML_TEXT_LABEL_ELEM_START,
+             y, font, Html::lit(show.text),
              secs
       )?;
       let nick_y = y - 0.5;
       if let Some(nick) = u.nick {
         hwrite!(f, r##"
-  <text x="21" y="{}" fill="{}" {} clip-path="url(#def.{}.cl)" 
+  <{} x="21" y="{}" fill="{}" clip-path="url(#def.{}.cl)" 
    font-size="4">{}</text>
               "##,
-               nick_y, show.text, pointer,
+               HTML_TEXT_LABEL_ELEM_START,
+               nick_y, show.text,
                vpid,
                nick,
         )?;
       } else {
         hwrite!(f, r##"
-  <text x="27" y="{}" fill="pink" stroke="red" {}
+  <{} x="27" y="{}" fill="pink" stroke="red"
    stroke-width="0.1" font-size="4">({})</text>"##,
-               nick_y, pointer, user,
+               HTML_TEXT_LABEL_ELEM_START,
+               nick_y, user,
         )?;
       }
     }
index a668f61f67ee13c981cae0c5be0caa622c4111b6..b5196fb651b9b24fbfed5a9e93700190c1b86501 100644 (file)
--- a/src/ui.rs
+++ b/src/ui.rs
@@ -23,6 +23,9 @@ pub const INVISIBLE_EDGE_SENSITIVE: f64 = 2.;
 
 pub const LABEL_FONT_SIZE: f64 = 4.0;
 
+pub const HTML_TEXT_LABEL_ELEM_START: HtmlLit =
+  Html::lit(r##"text pointer-events="none""##);
+
 /// Fudge factor
 ///
 /// When trying to centre text, we use text-align and/or text-anchor