core: layout: omit bottom row when explicitly disabled by main layout

The main layout (e.g. latn_bone.xml and latn_neo2.xml) may disable the
bottom row by adding a property to the XML keyboard tag. Omit the bottom
row when this is the case.
This commit is contained in:
Richard Acayan 2024-09-26 19:36:51 -04:00
parent 1391589ce0
commit 57265544ab

View file

@ -519,6 +519,7 @@ const KEYSYMS: [(&str, Keysym, &str); 21] = [
struct LayoutFile {
rows: Vec<Vec<Key>>,
has_bottom_row: bool,
width: f64,
height: f64,
row_width: f64,
@ -581,12 +582,21 @@ impl LayoutFile {
self.row_width = 0.0;
}
fn start_keyboard(&mut self, attrs: &HashMap<&str, &str>)
{
if *attrs.get("bottom_row").unwrap_or(&"") == "false" {
self.has_bottom_row = false;
}
}
fn start_elem(&mut self, name: &str, attrs: &HashMap<&str, &str>)
{
if name == "key" {
self.start_key(attrs);
} else if name == "row" {
self.start_row();
} else if name == "keyboard" {
self.start_keyboard(attrs);
}
}
@ -612,6 +622,7 @@ impl LayoutFile {
{
let mut layout = LayoutFile {
rows: Vec::new(),
has_bottom_row: true,
width: 0.0,
height: 0.0,
row_width: 0.0,
@ -707,6 +718,7 @@ impl Layout {
text_supp: false,
};
if main_layout.has_bottom_row {
let path = dir.join("bottom_row.xml");
let bottom_row = LayoutFile::load(path)?;
@ -729,6 +741,7 @@ impl Layout {
layout.rows.push(new_row);
}
}
Ok(layout)
}