From: Ian Jackson Date: Sun, 17 Apr 2022 22:26:55 +0000 (+0100) Subject: ui.rs: Bring a number of constants etc. together here X-Git-Tag: otter-1.1.0~500 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=92459c21a7cffa465a9fd407b046fc4b01c0ce04;p=otter.git ui.rs: Bring a number of constants etc. together here Signed-off-by: Ian Jackson --- diff --git a/src/gamestate.rs b/src/gamestate.rs index e8c7fffb..9f2f3399 100644 --- a/src/gamestate.rs +++ b/src/gamestate.rs @@ -23,9 +23,6 @@ visible_slotmap_key!{ VisiblePieceId(b'.') } #[serde(transparent)] pub struct Timestamp(pub u64); /* time_t */ -pub const DEFAULT_TABLE_SIZE: Pos = PosC::new( 300, 200 ); -pub const DEFAULT_TABLE_COLOUR: &str = "green"; - #[derive(Copy,Clone,Debug,Eq,Ord,PartialEq,PartialOrd)] pub struct SpecDepth(u16); diff --git a/src/pieces.rs b/src/pieces.rs index f41fadc7..56e3dc74 100644 --- a/src/pieces.rs +++ b/src/pieces.rs @@ -22,24 +22,6 @@ pub struct GenericSimpleShape { } pub type SimpleShape = GenericSimpleShape; -pub const SELECT_SCALE: f64 = 1.1; - -// also in script.ts:redisplay_ancillaries ("halo") -// nelem.setAttributeNS(null,'stroke-width','2px'); -pub const SELECT_STROKE_WIDTH: f64 = 2.0; - -pub const DEFAULT_EDGE_WIDTH: f64 = 0.2; -pub const INVISIBLE_EDGE_SENSITIVE: f64 = 2.; - -// When trying to centre text, we use text-align and/or text-anchor -// to do the horizontal positioning, but vertical positioning is -// troublesome. We bodge it. Multiple the font size (in pixels) -// by this, and add it to the SVG y coordinate (ie, shufting the text -// down). -pub const SVG_FONT_Y_ADJUST_OF_FONT_SIZE: f64 = 0.35; - -fn default_edge_width() -> f64 { DEFAULT_EDGE_WIDTH } - #[derive(Copy,Clone,Debug,Error,Serialize,Deserialize)] pub enum SVGProcessingError { UnknownOperator, diff --git a/src/ui.rs b/src/ui.rs index 855099cd..7f2a6a8d 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -9,6 +9,27 @@ pub const HELD_SURROUND_COLOUR: &str = "black"; const MONOSPACE: HtmlLit = Html::lit( r#"font-family="Latin Modern Mono, monospace" font-weight="700""#); +pub const DEFAULT_TABLE_SIZE: Pos = PosC::new( 300, 200 ); +pub const DEFAULT_TABLE_COLOUR: &str = "green"; + +pub const SELECT_SCALE: f64 = 1.1; + +// also in script.ts:redisplay_ancillaries ("halo") +// nelem.setAttributeNS(null,'stroke-width','2px'); +pub const SELECT_STROKE_WIDTH: f64 = 2.0; + +pub const DEFAULT_EDGE_WIDTH: f64 = 0.2; +pub const INVISIBLE_EDGE_SENSITIVE: f64 = 2.; + +// When trying to centre text, we use text-align and/or text-anchor +// to do the horizontal positioning, but vertical positioning is +// troublesome. We bodge it. Multiple the font size (in pixels) +// by this, and add it to the SVG y coordinate (ie, shufting the text +// down). +pub const SVG_FONT_Y_ADJUST_OF_FONT_SIZE: f64 = 0.35; + +pub fn default_edge_width() -> f64 { DEFAULT_EDGE_WIDTH } + pub fn monospace_font(size: u32) -> Html { hformat!(r##"{} font-size="{}""##, MONOSPACE, size) }