parsing: Remove bounds which weren't used anyway

This commit is contained in:
Dorota Czaplejewicz
2019-12-15 17:37:30 +00:00
parent 927f088027
commit 5e700219f9
20 changed files with 90 additions and 221 deletions

View File

@ -1,18 +1,11 @@
# Maintained by: Mark Müller <markmueller86@gmail.com> # Maintained by: Mark Müller <markmueller86@gmail.com>
--- ---
bounds: { x: 0, y: 1, width: 360, height: 208 }
outlines: outlines:
default: default: { width: 35.33, height: 52 }
bounds: { x: 0, y: 0, width: 35.33, height: 52 } altline: { width: 52.67, height: 52 }
altline: wide: { width: 62, height: 52 }
bounds: { x: 0, y: 0, width: 52.67, height: 52 } spaceline: { width: 99.67, height: 52 }
wide: special: { width: 35.33, height: 52 }
bounds: { x: 0, y: 0, width: 62, height: 52 }
spaceline:
bounds: { x: 0, y: 0, width: 99.67, height: 52 }
special:
bounds: { x: 0, y: 0, width: 35.33, height: 52 }
views: views:
base: base:

View File

@ -1,18 +1,11 @@
# Maintained by: Mark Müller <markmueller86@gmail.com> # Maintained by: Mark Müller <markmueller86@gmail.com>
--- ---
bounds: { x: 0, y: 1, width: 540, height: 168 }
outlines: outlines:
default: default: { width: 48, height: 42 }
bounds: { x: 0, y: 0, width: 48, height: 42 } altline: { width: 81, height: 42 }
altline: wide: { width: 108, height: 42 }
bounds: { x: 0, y: 0, width: 81, height: 42 } spaceline: { width: 216, height: 42 }
wide: special: { width: 48, height: 42 }
bounds: { x: 0, y: 0, width: 108, height: 42 }
spaceline:
bounds: { x: 0, y: 0, width: 216, height: 42 }
special:
bounds: { x: 0, y: 0, width: 48, height: 42 }
views: views:
base: base:

View File

@ -2,19 +2,12 @@
# University of the Aegean, Department of Mathematics, atsol@aegean.gr # University of the Aegean, Department of Mathematics, atsol@aegean.gr
# Sep 2019 # Sep 2019
--- ---
bounds: { x: 0, y: 0.33, width: 360, height: 210 }
outlines: outlines:
default: default: { width: 32, height: 52 }
bounds: { x: 0, y: 0, width: 32, height: 52 } altline: { width: 48.39024, height: 52 }
altline: wide: { width: 62, height: 52 }
bounds: { x: 0, y: 0, width: 48.39024, height: 52 } outline7: { width: 88.97561, height: 52 }
wide: spaceline: { width: 150.5853, height: 52 }
bounds: { x: 0, y: 0, width: 62, height: 52 }
outline7:
bounds: { x: 0, y: 0, width: 88.97561, height: 52 }
spaceline:
bounds: { x: 0, y: 0, width: 150.5853, height: 52 }
views: views:
base: base:

View File

@ -1,17 +1,10 @@
--- ---
bounds: { x: 0, y: 1, width: 360, height: 210 }
outlines: outlines:
default: default: { width: 35.33, height: 52 }
bounds: { x: 0, y: 0, width: 35.33, height: 52 } altline: { width: 52.67, height: 52 }
altline: wide: { width: 62, height: 52 }
bounds: { x: 0, y: 0, width: 52.67, height: 52 } spaceline: { width: 99.67, height: 52 }
wide: special: { width: 44, height: 52 }
bounds: { x: 0, y: 0, width: 62, height: 52 }
spaceline:
bounds: { x: 0, y: 0, width: 99.67, height: 52 }
special:
bounds: { x: 0, y: 0, width: 44, height: 52 }
views: views:
base: base:

View File

@ -1,17 +1,10 @@
--- ---
bounds: { x: 0, y: 0.33, width: 360, height: 210 }
outlines: outlines:
default: default: { width: 32, height: 52 }
bounds: { x: 0, y: 0, width: 32, height: 52 } altline: { width: 48.39024, height: 52 }
altline: wide: { width: 62, height: 52 }
bounds: { x: 0, y: 0, width: 48.39024, height: 52 } outline7: { width: 88.97561, height: 52 }
wide: spaceline: { width: 150.5853, height: 52 }
bounds: { x: 0, y: 0, width: 62, height: 52 }
outline7:
bounds: { x: 0, y: 0, width: 88.97561, height: 52 }
spaceline:
bounds: { x: 0, y: 0, width: 150.5853, height: 52 }
views: views:
base: base:

View File

@ -1,19 +1,12 @@
# Italian layout created by Antonio Pandolfo # Italian layout created by Antonio Pandolfo
# 03 october 2019 # 03 october 2019
--- ---
bounds: { x: 0, y: 1, width: 360, height: 210 }
outlines: outlines:
default: default: { width: 35.33, height: 52 }
bounds: { x: 0, y: 0, width: 35.33, height: 52 } altline: { width: 52.67, height: 52 }
altline: wide: { width: 62, height: 52 }
bounds: { x: 0, y: 0, width: 52.67, height: 52 } spaceline: { width: 99.67, height: 52 }
wide: special: { width: 44, height: 52 }
bounds: { x: 0, y: 0, width: 62, height: 52 }
spaceline:
bounds: { x: 0, y: 0, width: 99.67, height: 52 }
special:
bounds: { x: 0, y: 0, width: 44, height: 52 }
views: views:
base: base:

View File

@ -1,18 +1,11 @@
# Maintained by: Mark Müller <markmueller86@gmail.com> # Maintained by: Mark Müller <markmueller86@gmail.com>
--- ---
bounds: { x: 0, y: 1, width: 360, height: 208 }
outlines: outlines:
default: default: { width: 62, height: 52 }
bounds: { x: 0, y: 0, width: 62, height: 52 } default-wide: { width: 62, height: 52 }
default-wide: altline: { width: 62, height: 52 }
bounds: { x: 0, y: 0, width: 62, height: 52 } wide: { width: 62, height: 52 }
altline: special: { width: 62, height: 52 }
bounds: { x: 0, y: 0, width: 62, height: 52 }
wide:
bounds: { x: 0, y: 0, width: 62, height: 52 }
special:
bounds: { x: 0, y: 0, width: 62, height: 52 }
views: views:
base: # hiragana base: # hiragana

View File

@ -1,18 +1,11 @@
# Maintained by: Mark Müller <markmueller86@gmail.com> # Maintained by: Mark Müller <markmueller86@gmail.com>
--- ---
bounds: { x: 0, y: 1, width: 540, height: 168 }
outlines: outlines:
default: default: { width: 62, height: 42 }
bounds: { x: 0, y: 0, width: 62, height: 42 } default-wide: { width: 62, height: 42 }
default-wide: altline: { width: 62, height: 42 }
bounds: { x: 0, y: 0, width: 62, height: 42 } wide: { width: 62, height: 42 }
altline: special: { width: 62, height: 42 }
bounds: { x: 0, y: 0, width: 62, height: 42 }
wide:
bounds: { x: 0, y: 0, width: 62, height: 42 }
special:
bounds: { x: 0, y: 0, width: 62, height: 42 }
views: views:
base: # hiragana base: # hiragana

View File

@ -1,17 +1,10 @@
--- ---
bounds: { x: 0, y: 0.33, width: 360, height: 210 }
outlines: outlines:
default: default: { width: 32, height: 52 }
bounds: { x: 0, y: 0, width: 32, height: 52 } altline: { width: 48.39024, height: 52 }
altline: wide: { width: 62, height: 52 }
bounds: { x: 0, y: 0, width: 48.39024, height: 52 } outline7: { width: 88.97561, height: 52 }
wide: spaceline: { width: 150.5853, height: 52 }
bounds: { x: 0, y: 0, width: 62, height: 52 }
outline7:
bounds: { x: 0, y: 0, width: 88.97561, height: 52 }
spaceline:
bounds: { x: 0, y: 0, width: 150.5853, height: 52 }
views: views:
base: base:

View File

@ -1,15 +1,9 @@
--- ---
bounds: { x: 0, y: 0.33, width: 360, height: 210 }
outlines: outlines:
default: default: { width: 37.46341, height: 52 }
bounds: { x: 0, y: 0, width: 37.46341, height: 52 } altline: { width: 48.39024, height: 52 }
altline: outline7: { width: 88.97561, height: 52 }
bounds: { x: 0, y: 0, width: 48.39024, height: 52 } spaceline: { width: 120.5853, height: 52 }
outline7:
bounds: { x: 0, y: 0, width: 88.97561, height: 52 }
spaceline:
bounds: { x: 0, y: 0, width: 120.5853, height: 52 }
views: views:
base: base:

View File

@ -1,17 +1,10 @@
--- ---
bounds: { x: 0, y: 0.33, width: 360, height: 210 }
outlines: outlines:
default: default: { width: 32, height: 52 }
bounds: { x: 0, y: 0, width: 32, height: 52 } altline: { width: 48.39024, height: 52 }
altline: wide: { width: 62, height: 52 }
bounds: { x: 0, y: 0, width: 48.39024, height: 52 } outline7: { width: 88.97561, height: 52 }
wide: spaceline: { width: 150.5853, height: 52 }
bounds: { x: 0, y: 0, width: 62, height: 52 }
outline7:
bounds: { x: 0, y: 0, width: 88.97561, height: 52 }
spaceline:
bounds: { x: 0, y: 0, width: 150.5853, height: 52 }
views: views:
base: base:

View File

@ -1,17 +1,10 @@
--- ---
bounds: { x: 0, y: 1, width: 360, height: 208 }
outlines: outlines:
default: default: { width: 35.33, height: 52 }
bounds: { x: 0, y: 0, width: 35.33, height: 52 } altline: { width: 52.67, height: 52 }
altline: wide: { width: 62, height: 52 }
bounds: { x: 0, y: 0, width: 52.67, height: 52 } spaceline: { width: 142, height: 52 }
wide: special: { width: 44, height: 52 }
bounds: { x: 0, y: 0, width: 62, height: 52 }
spaceline:
bounds: { x: 0, y: 0, width: 142, height: 52 }
special:
bounds: { x: 0, y: 0, width: 44, height: 52 }
views: views:
base: base:

View File

@ -1,17 +1,10 @@
--- ---
bounds: { x: 0, y: 1, width: 540, height: 168 }
outlines: outlines:
default: default: { width: 54, height: 42 }
bounds: { x: 0, y: 0, width: 54, height: 42 } altline: { width: 81, height: 42 }
altline: wide: { width: 108, height: 42 }
bounds: { x: 0, y: 0, width: 81, height: 42 } spaceline: { width: 216, height: 42 }
wide: special: { width: 54, height: 42 }
bounds: { x: 0, y: 0, width: 108, height: 42 }
spaceline:
bounds: { x: 0, y: 0, width: 216, height: 42 }
special:
bounds: { x: 0, y: 0, width: 54, height: 42 }
views: views:
base: base:

View File

@ -1,5 +1,7 @@
/**! The parsing of the data files for layouts */ /**! The parsing of the data files for layouts */
// TODO: find a nice way to make sure non-positive sizes don't break layouts
use std::cell::RefCell; use std::cell::RefCell;
use std::collections::{ HashMap, HashSet }; use std::collections::{ HashMap, HashSet };
use std::env; use std::env;
@ -216,21 +218,20 @@ fn load_layout_data_with_fallback(
#[derive(Debug, Deserialize, PartialEq)] #[derive(Debug, Deserialize, PartialEq)]
#[serde(deny_unknown_fields)] #[serde(deny_unknown_fields)]
pub struct Layout { pub struct Layout {
/// FIXME: deprecate in favor of margins #[serde(default)]
bounds: Bounds, margins: Margins,
views: HashMap<String, Vec<ButtonIds>>, views: HashMap<String, Vec<ButtonIds>>,
#[serde(default)] #[serde(default)]
buttons: HashMap<String, ButtonMeta>, buttons: HashMap<String, ButtonMeta>,
outlines: HashMap<String, Outline> outlines: HashMap<String, Outline>
} }
#[derive(Debug, Clone, Deserialize, PartialEq)] #[derive(Debug, Clone, Deserialize, PartialEq, Default)]
#[serde(deny_unknown_fields)] #[serde(deny_unknown_fields)]
struct Bounds { struct Margins {
x: f64, top: f64,
y: f64, bottom: f64,
width: f64, side: f64,
height: f64,
} }
/// Buttons are embedded in a single string /// Buttons are embedded in a single string
@ -271,8 +272,8 @@ enum Action {
#[derive(Debug, Clone, Deserialize, PartialEq)] #[derive(Debug, Clone, Deserialize, PartialEq)]
#[serde(deny_unknown_fields)] #[serde(deny_unknown_fields)]
struct Outline { struct Outline {
/// FIXME: replace with Size width: f64,
bounds: Bounds, height: f64,
} }
/// Errors encountered loading the layout into yaml /// Errors encountered loading the layout into yaml
@ -460,10 +461,10 @@ impl Layout {
}, },
// FIXME: use a dedicated field // FIXME: use a dedicated field
margins: layout::Margins { margins: layout::Margins {
top: self.bounds.x, top: self.margins.top,
left: self.bounds.y, left: self.margins.side,
bottom: 0.0, bottom: self.margins.bottom,
right: self.bounds.y, right: self.margins.side,
}, },
}), }),
warning_handler, warning_handler,
@ -649,9 +650,7 @@ fn create_button<H: WarningHandler>(
warning_handler.handle( warning_handler.handle(
&format!("No default outline defined! Using 1x1!") &format!("No default outline defined! Using 1x1!")
); );
Outline { Outline { width: 1f64, height: 1f64 }
bounds: Bounds { x: 0f64, y: 0f64, width: 1f64, height: 1f64 },
}
}); });
layout::Button { layout::Button {
@ -659,8 +658,8 @@ fn create_button<H: WarningHandler>(
outline_name: CString::new(outline_name).expect("Bad outline"), outline_name: CString::new(outline_name).expect("Bad outline"),
// TODO: do layout before creating buttons // TODO: do layout before creating buttons
size: layout::Size { size: layout::Size {
width: outline.bounds.width, width: outline.width,
height: outline.bounds.height, height: outline.height,
}, },
label: label, label: label,
state: state, state: state,
@ -686,7 +685,7 @@ mod tests {
assert_eq!( assert_eq!(
Layout::from_file(PathBuf::from("tests/layout.yaml")).unwrap(), Layout::from_file(PathBuf::from("tests/layout.yaml")).unwrap(),
Layout { Layout {
bounds: Bounds { x: 0f64, y: 0f64, width: 0f64, height: 0f64 }, margins: Margins { top: 0f64, bottom: 0f64, side: 0f64 },
views: hashmap!( views: hashmap!(
"base".into() => vec!("test".into()), "base".into() => vec!("test".into()),
), ),
@ -701,11 +700,7 @@ mod tests {
} }
}, },
outlines: hashmap!{ outlines: hashmap!{
"default".into() => Outline { "default".into() => Outline { width: 0f64, height: 0f64 },
bounds: Bounds {
x: 0f64, y: 0f64, width: 0f64, height: 0f64
},
}
}, },
} }
); );

View File

@ -1,15 +1,9 @@
--- ---
bounds:
x: 0
y: 0
width: 0
height: 0
views: views:
base: base:
- "test" - "test"
outlines: outlines:
default: default: { width: 0, height: 0 }
bounds: { x: 0, y: 0, width: 0, height: 0 }
buttons: buttons:
test: test:

View File

@ -1,11 +1,5 @@
--- ---
# missing views # missing views
bounds:
x: 0
y: 0
width: 0
height: 0
outlines: outlines:
default: default: { width: 0, height: 0 }
bounds: { x: 0, y: 0, width: 0, height: 0 }

View File

@ -1,15 +1,9 @@
--- ---
# extra field # extra field
bounds:
x: 0
y: 0
width: 0
height: 0
views: views:
base: base:
- "test" - "test"
outlines: outlines:
default: default: { width: 0, height: 0 }
bounds: { x: 0, y: 0, width: 0, height: 0 }
bad_field: false bad_field: false

View File

@ -1,16 +1,10 @@
--- ---
# punctuation # punctuation
bounds:
x: 0
y: 0
width: 0
height: 0
views: views:
base: base:
- "." - "."
outlines: outlines:
default: default: { width: 0, height: 0 }
bounds: { x: 0, y: 0, width: 0, height: 0 }
buttons: buttons:
".": ".":

View File

@ -1,16 +1,10 @@
--- ---
# punctuation # punctuation
bounds:
x: 0
y: 0
width: 0
height: 0
views: views:
base: base:
- "å" - "å"
outlines: outlines:
default: default: { width: 0, height: 0 }
bounds: { x: 0, y: 0, width: 0, height: 0 }
buttons: buttons:
å: å:

View File

@ -1,14 +1,8 @@
--- ---
# punctuation # punctuation
bounds:
x: 0
y: 0
width: 0
height: 0
views: views:
base: base:
- "か゚" # 2 codepoints - "か゚" # 2 codepoints
outlines: outlines:
default: default: { width: 0, height: 0 }
bounds: { x: 0, y: 0, width: 0, height: 0 }