Merge branch 'targets' into 'master'
buttons: Buttons are next to each other, padding is visual only Closes #110 See merge request Librem5/squeekboard!209
This commit is contained in:
@ -2,16 +2,15 @@
|
|||||||
# University of the Aegean, Department of Mathematics, atsol@aegean.gr
|
# University of the Aegean, Department of Mathematics, atsol@aegean.gr
|
||||||
# Sep 2019
|
# Sep 2019
|
||||||
---
|
---
|
||||||
row_spacing: 11.33
|
bounds: { x: 0, y: 0.33, width: 360, height: 210 }
|
||||||
button_spacing: 4.67
|
|
||||||
|
|
||||||
bounds: { x: 0, y: 6.33, width: 426, height: 250 }
|
|
||||||
|
|
||||||
outlines:
|
outlines:
|
||||||
default:
|
default:
|
||||||
bounds: { x: 0, y: 0, width: 32, height: 52 }
|
bounds: { x: 0, y: 0, width: 32, height: 52 }
|
||||||
altline:
|
altline:
|
||||||
bounds: { x: 0, y: 0, width: 48.39024, height: 52 }
|
bounds: { x: 0, y: 0, width: 48.39024, height: 52 }
|
||||||
|
wide:
|
||||||
|
bounds: { x: 0, y: 0, width: 62, height: 52 }
|
||||||
outline7:
|
outline7:
|
||||||
bounds: { x: 0, y: 0, width: 88.97561, height: 52 }
|
bounds: { x: 0, y: 0, width: 88.97561, height: 52 }
|
||||||
spaceline:
|
spaceline:
|
||||||
@ -22,7 +21,7 @@ views:
|
|||||||
- "; ς ε ρ τ υ θ ι ο π !"
|
- "; ς ε ρ τ υ θ ι ο π !"
|
||||||
- "α σ δ φ γ η ξ κ λ show_accented"
|
- "α σ δ φ γ η ξ κ λ show_accented"
|
||||||
- "Shift_L ζ χ ψ ω β ν μ , BackSpace"
|
- "Shift_L ζ χ ψ ω β ν μ , BackSpace"
|
||||||
- "show_numbers preferences space . Return"
|
- "show_numbers preferences space period Return"
|
||||||
upper:
|
upper:
|
||||||
- ": EuroSign Ε Ρ Τ Υ Θ Ι Ο Π"
|
- ": EuroSign Ε Ρ Τ Υ Θ Ι Ο Π"
|
||||||
- "Α Σ Δ Φ Γ Η Ξ Κ Λ show_accented"
|
- "Α Σ Δ Φ Γ Η Ξ Κ Λ show_accented"
|
||||||
@ -86,13 +85,13 @@ buttons:
|
|||||||
outline: "altline"
|
outline: "altline"
|
||||||
label: "αι"
|
label: "αι"
|
||||||
period:
|
period:
|
||||||
outline: altline
|
outline: "altline"
|
||||||
label: "."
|
label: "."
|
||||||
space:
|
space:
|
||||||
outline: spaceline
|
outline: spaceline
|
||||||
label: " "
|
label: " "
|
||||||
Return:
|
Return:
|
||||||
outline: outline7
|
outline: "wide"
|
||||||
icon: "key-enter"
|
icon: "key-enter"
|
||||||
aring:
|
aring:
|
||||||
label: "å"
|
label: "å"
|
||||||
|
|||||||
@ -1,20 +1,17 @@
|
|||||||
---
|
---
|
||||||
row_spacing: 11.33
|
bounds: { x: 0, y: 1, width: 360, height: 210 }
|
||||||
button_spacing: 4.67
|
|
||||||
|
|
||||||
bounds: { x: 0, y: 1, width: 360, height: 198 }
|
|
||||||
|
|
||||||
outlines:
|
outlines:
|
||||||
default:
|
default:
|
||||||
bounds: { x: 0, y: 0, width: 30.67, height: 40.67 }
|
bounds: { x: 0, y: 0, width: 35.33, height: 52 }
|
||||||
altline:
|
altline:
|
||||||
bounds: { x: 0, y: 0, width: 48, height: 40.67 }
|
bounds: { x: 0, y: 0, width: 52.67, height: 52 }
|
||||||
wide:
|
wide:
|
||||||
bounds: { x: 0, y: 0, width: 57.33, height: 40.67 }
|
bounds: { x: 0, y: 0, width: 62, height: 52 }
|
||||||
spaceline:
|
spaceline:
|
||||||
bounds: { x: 0, y: 0, width: 95.00, height: 40.67 }
|
bounds: { x: 0, y: 0, width: 99.67, height: 52 }
|
||||||
special:
|
special:
|
||||||
bounds: { x: 0, y: 0, width: 39.33, height: 40.67 }
|
bounds: { x: 0, y: 0, width: 44, height: 52 }
|
||||||
|
|
||||||
views:
|
views:
|
||||||
base:
|
base:
|
||||||
|
|||||||
@ -1,22 +1,19 @@
|
|||||||
# Italian layout created by Antonio Pandolfo
|
# Italian layout created by Antonio Pandolfo
|
||||||
# 03 october 2019
|
# 03 october 2019
|
||||||
---
|
---
|
||||||
row_spacing: 11.33
|
bounds: { x: 0, y: 1, width: 360, height: 210 }
|
||||||
button_spacing: 4.67
|
|
||||||
|
|
||||||
bounds: { x: 0, y: 1, width: 360, height: 198 }
|
|
||||||
|
|
||||||
outlines:
|
outlines:
|
||||||
default:
|
default:
|
||||||
bounds: { x: 0, y: 0, width: 30.67, height: 40.67 }
|
bounds: { x: 0, y: 0, width: 35.33, height: 52 }
|
||||||
altline:
|
altline:
|
||||||
bounds: { x: 0, y: 0, width: 48, height: 40.67 }
|
bounds: { x: 0, y: 0, width: 52.67, height: 52 }
|
||||||
wide:
|
wide:
|
||||||
bounds: { x: 0, y: 0, width: 57.33, height: 40.67 }
|
bounds: { x: 0, y: 0, width: 62, height: 52 }
|
||||||
spaceline:
|
spaceline:
|
||||||
bounds: { x: 0, y: 0, width: 95.00, height: 40.67 }
|
bounds: { x: 0, y: 0, width: 99.67, height: 52 }
|
||||||
special:
|
special:
|
||||||
bounds: { x: 0, y: 0, width: 39.33, height: 40.67 }
|
bounds: { x: 0, y: 0, width: 44, height: 52 }
|
||||||
|
|
||||||
views:
|
views:
|
||||||
base:
|
base:
|
||||||
|
|||||||
@ -1,14 +1,13 @@
|
|||||||
---
|
---
|
||||||
row_spacing: 11.33
|
bounds: { x: 0, y: 0.33, width: 360, height: 210 }
|
||||||
button_spacing: 4.67
|
|
||||||
|
|
||||||
bounds: { x: 0, y: 6.33, width: 426, height: 250 }
|
|
||||||
|
|
||||||
outlines:
|
outlines:
|
||||||
default:
|
default:
|
||||||
bounds: { x: 0, y: 0, width: 32, height: 52 }
|
bounds: { x: 0, y: 0, width: 32, height: 52 }
|
||||||
altline:
|
altline:
|
||||||
bounds: { x: 0, y: 0, width: 48.39024, height: 52 }
|
bounds: { x: 0, y: 0, width: 48.39024, height: 52 }
|
||||||
|
wide:
|
||||||
|
bounds: { x: 0, y: 0, width: 62, height: 52 }
|
||||||
outline7:
|
outline7:
|
||||||
bounds: { x: 0, y: 0, width: 88.97561, height: 52 }
|
bounds: { x: 0, y: 0, width: 88.97561, height: 52 }
|
||||||
spaceline:
|
spaceline:
|
||||||
@ -73,7 +72,7 @@ buttons:
|
|||||||
outline: spaceline
|
outline: spaceline
|
||||||
label: " "
|
label: " "
|
||||||
Return:
|
Return:
|
||||||
outline: outline7
|
outline: "wide"
|
||||||
icon: "key-enter"
|
icon: "key-enter"
|
||||||
aring:
|
aring:
|
||||||
label: "å"
|
label: "å"
|
||||||
|
|||||||
@ -1,8 +1,5 @@
|
|||||||
---
|
---
|
||||||
row_spacing: 11.33
|
bounds: { x: 0, y: 0.33, width: 360, height: 210 }
|
||||||
button_spacing: 4.67
|
|
||||||
|
|
||||||
bounds: { x: 0, y: 6.33, width: 410, height: 250 }
|
|
||||||
|
|
||||||
outlines:
|
outlines:
|
||||||
default:
|
default:
|
||||||
|
|||||||
@ -1,20 +1,17 @@
|
|||||||
---
|
---
|
||||||
row_spacing: 11.33
|
bounds: { x: 0, y: 1, width: 360, height: 210 }
|
||||||
button_spacing: 4.67
|
|
||||||
|
|
||||||
bounds: { x: 0, y: 1, width: 360, height: 198 }
|
|
||||||
|
|
||||||
outlines:
|
outlines:
|
||||||
default:
|
default:
|
||||||
bounds: { x: 0, y: 0, width: 30.67, height: 40.67 }
|
bounds: { x: 0, y: 0, width: 35.33, height: 52 }
|
||||||
altline:
|
altline:
|
||||||
bounds: { x: 0, y: 0, width: 48, height: 40.67 }
|
bounds: { x: 0, y: 0, width: 52.67, height: 52 }
|
||||||
wide:
|
wide:
|
||||||
bounds: { x: 0, y: 0, width: 57.33, height: 40.67 }
|
bounds: { x: 0, y: 0, width: 62, height: 52 }
|
||||||
spaceline:
|
spaceline:
|
||||||
bounds: { x: 0, y: 0, width: 137.33, height: 40.67 }
|
bounds: { x: 0, y: 0, width: 142, height: 52 }
|
||||||
special:
|
special:
|
||||||
bounds: { x: 0, y: 0, width: 39.33, height: 40.67 }
|
bounds: { x: 0, y: 0, width: 44, height: 52 }
|
||||||
|
|
||||||
views:
|
views:
|
||||||
base:
|
base:
|
||||||
|
|||||||
@ -11,6 +11,7 @@ sq_button {
|
|||||||
border-width: 1px;
|
border-width: 1px;
|
||||||
border-color: #5e5c64;
|
border-color: #5e5c64;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
|
margin: 4px 2px 4px 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
sq_button:active {
|
sq_button:active {
|
||||||
@ -22,7 +23,7 @@ sq_button.altline,
|
|||||||
sq_button.special,
|
sq_button.special,
|
||||||
sq_button.wide {
|
sq_button.wide {
|
||||||
background: #2b292f;
|
background: #2b292f;
|
||||||
border-color: #3e3a44
|
border-color: #3e3a44;
|
||||||
}
|
}
|
||||||
|
|
||||||
sq_button.locked {
|
sq_button.locked {
|
||||||
@ -32,7 +33,7 @@ sq_button.locked {
|
|||||||
|
|
||||||
#Return {
|
#Return {
|
||||||
background: #1c71d8;
|
background: #1c71d8;
|
||||||
border-color: #1a5fb4
|
border-color: #1a5fb4;
|
||||||
}
|
}
|
||||||
|
|
||||||
#Return:active {
|
#Return:active {
|
||||||
|
|||||||
@ -174,8 +174,22 @@ render_outline (cairo_t *cr,
|
|||||||
GtkStyleContext *ctx,
|
GtkStyleContext *ctx,
|
||||||
EekBounds bounds)
|
EekBounds bounds)
|
||||||
{
|
{
|
||||||
gtk_render_background (ctx, cr, 0, 0, bounds.width, bounds.height);
|
GtkBorder margin, border;
|
||||||
gtk_render_frame (ctx, cr, 0, 0, bounds.width, bounds.height);
|
gtk_style_context_get_margin(ctx, GTK_STATE_FLAG_NORMAL, &margin);
|
||||||
|
gtk_style_context_get_border(ctx, GTK_STATE_FLAG_NORMAL, &border);
|
||||||
|
|
||||||
|
gdouble x = margin.left + border.left;
|
||||||
|
gdouble y = margin.top + border.top;
|
||||||
|
EekBounds position = {
|
||||||
|
.x = x,
|
||||||
|
.y = y,
|
||||||
|
.width = bounds.width - x - (margin.right + border.right),
|
||||||
|
.height = bounds.height - y - (margin.bottom + border.bottom),
|
||||||
|
};
|
||||||
|
gtk_render_background (ctx, cr,
|
||||||
|
position.x, position.y, position.width, position.height);
|
||||||
|
gtk_render_frame (ctx, cr,
|
||||||
|
position.x, position.y, position.width, position.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void render_button_in_context(EekRenderer *self,
|
static void render_button_in_context(EekRenderer *self,
|
||||||
|
|||||||
@ -194,8 +194,6 @@ fn load_layout_with_fallback(
|
|||||||
#[derive(Debug, Deserialize, PartialEq)]
|
#[derive(Debug, Deserialize, PartialEq)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct Layout {
|
pub struct Layout {
|
||||||
row_spacing: f64,
|
|
||||||
button_spacing: f64,
|
|
||||||
bounds: Bounds,
|
bounds: Bounds,
|
||||||
views: HashMap<String, Vec<ButtonIds>>,
|
views: HashMap<String, Vec<ButtonIds>>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
@ -382,10 +380,6 @@ impl Layout {
|
|||||||
width: self.bounds.width,
|
width: self.bounds.width,
|
||||||
height: self.bounds.height,
|
height: self.bounds.height,
|
||||||
},
|
},
|
||||||
spacing: ::layout::Spacing {
|
|
||||||
row: self.row_spacing,
|
|
||||||
button: self.button_spacing,
|
|
||||||
},
|
|
||||||
rows: view.iter().map(|row| {
|
rows: view.iter().map(|row| {
|
||||||
Box::new(::layout::Row {
|
Box::new(::layout::Row {
|
||||||
angle: 0,
|
angle: 0,
|
||||||
@ -586,8 +580,6 @@ 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 {
|
||||||
row_spacing: 0f64,
|
|
||||||
button_spacing: 0f64,
|
|
||||||
bounds: Bounds { x: 0f64, y: 0f64, width: 0f64, height: 0f64 },
|
bounds: Bounds { x: 0f64, y: 0f64, width: 0f64, height: 0f64 },
|
||||||
views: hashmap!(
|
views: hashmap!(
|
||||||
"base".into() => vec!("test".into()),
|
"base".into() => vec!("test".into()),
|
||||||
|
|||||||
@ -321,8 +321,7 @@ pub mod c {
|
|||||||
.map(|button| button.bounds.clone())
|
.map(|button| button.bounds.clone())
|
||||||
.collect()
|
.collect()
|
||||||
}).collect();
|
}).collect();
|
||||||
let spacing = view.spacing.clone();
|
view.place_buttons_with_sizes(sizes);
|
||||||
view.place_buttons_with_sizes(sizes, spacing);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -433,10 +432,6 @@ pub mod c {
|
|||||||
x: 0f64, y: 0f64,
|
x: 0f64, y: 0f64,
|
||||||
width: 0f64, height: 0f64
|
width: 0f64, height: 0f64
|
||||||
},
|
},
|
||||||
spacing: Spacing {
|
|
||||||
button: 0f64,
|
|
||||||
row: 0f64,
|
|
||||||
},
|
|
||||||
rows: vec!(row),
|
rows: vec!(row),
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -456,10 +451,6 @@ pub mod c {
|
|||||||
x: 0f64, y: 0f64,
|
x: 0f64, y: 0f64,
|
||||||
width: 0f64, height: 0f64
|
width: 0f64, height: 0f64
|
||||||
},
|
},
|
||||||
spacing: Spacing {
|
|
||||||
button: 0f64,
|
|
||||||
row: 0f64,
|
|
||||||
},
|
|
||||||
rows: Vec::new(),
|
rows: Vec::new(),
|
||||||
};
|
};
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@ -595,9 +586,7 @@ impl Row {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn calculate_button_positions(outlines: Vec<c::Bounds>, button_spacing: f64)
|
fn calculate_button_positions(outlines: Vec<c::Bounds>) -> Vec<c::Bounds> {
|
||||||
-> Vec<c::Bounds>
|
|
||||||
{
|
|
||||||
let mut x_offset = 0f64;
|
let mut x_offset = 0f64;
|
||||||
outlines.iter().map(|outline| {
|
outlines.iter().map(|outline| {
|
||||||
x_offset += outline.x; // account for offset outlines
|
x_offset += outline.x; // account for offset outlines
|
||||||
@ -605,7 +594,7 @@ impl Row {
|
|||||||
x: x_offset,
|
x: x_offset,
|
||||||
..outline.clone()
|
..outline.clone()
|
||||||
};
|
};
|
||||||
x_offset += outline.width + button_spacing;
|
x_offset += outline.width;
|
||||||
position
|
position
|
||||||
}).collect()
|
}).collect()
|
||||||
}
|
}
|
||||||
@ -653,7 +642,6 @@ pub struct Spacing {
|
|||||||
pub struct View {
|
pub struct View {
|
||||||
/// Position relative to keyboard origin
|
/// Position relative to keyboard origin
|
||||||
pub bounds: c::Bounds,
|
pub bounds: c::Bounds,
|
||||||
pub spacing: Spacing,
|
|
||||||
pub rows: Vec<Box<Row>>,
|
pub rows: Vec<Box<Row>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -665,9 +653,7 @@ impl View {
|
|||||||
/// and derive a scaling factor that lets contents fit into view)
|
/// and derive a scaling factor that lets contents fit into view)
|
||||||
/// (or TODO: blow up view bounds to match contents
|
/// (or TODO: blow up view bounds to match contents
|
||||||
/// and then scale the entire thing)
|
/// and then scale the entire thing)
|
||||||
fn calculate_row_positions(&self, sizes: Vec<Size>, row_spacing: f64)
|
fn calculate_row_positions(&self, sizes: Vec<Size>) -> Vec<c::Bounds> {
|
||||||
-> Vec<c::Bounds>
|
|
||||||
{
|
|
||||||
let mut y_offset = self.bounds.y;
|
let mut y_offset = self.bounds.y;
|
||||||
sizes.into_iter().map(|size| {
|
sizes.into_iter().map(|size| {
|
||||||
let position = c::Bounds {
|
let position = c::Bounds {
|
||||||
@ -676,7 +662,7 @@ impl View {
|
|||||||
width: size.width,
|
width: size.width,
|
||||||
height: size.height,
|
height: size.height,
|
||||||
};
|
};
|
||||||
y_offset += size.height + row_spacing;
|
y_offset += size.height;
|
||||||
position
|
position
|
||||||
}).collect()
|
}).collect()
|
||||||
}
|
}
|
||||||
@ -686,13 +672,12 @@ impl View {
|
|||||||
fn place_buttons_with_sizes(
|
fn place_buttons_with_sizes(
|
||||||
&mut self,
|
&mut self,
|
||||||
button_outlines: Vec<Vec<c::Bounds>>,
|
button_outlines: Vec<Vec<c::Bounds>>,
|
||||||
spacing: Spacing,
|
|
||||||
) {
|
) {
|
||||||
// Determine all positions
|
// Determine all positions
|
||||||
let button_positions: Vec<_>
|
let button_positions: Vec<_>
|
||||||
= button_outlines.into_iter()
|
= button_outlines.into_iter()
|
||||||
.map(|outlines| {
|
.map(|outlines| {
|
||||||
Row::calculate_button_positions(outlines, spacing.button)
|
Row::calculate_button_positions(outlines)
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
@ -701,7 +686,7 @@ impl View {
|
|||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let row_positions
|
let row_positions
|
||||||
= self.calculate_row_positions(row_sizes, spacing.row);
|
= self.calculate_row_positions(row_sizes);
|
||||||
|
|
||||||
// Apply all positions
|
// Apply all positions
|
||||||
for ((mut row, row_position), button_positions)
|
for ((mut row, row_position), button_positions)
|
||||||
|
|||||||
@ -1,7 +1,4 @@
|
|||||||
---
|
---
|
||||||
row_spacing: 0
|
|
||||||
button_spacing: 0
|
|
||||||
|
|
||||||
bounds:
|
bounds:
|
||||||
x: 0
|
x: 0
|
||||||
y: 0
|
y: 0
|
||||||
|
|||||||
@ -1,8 +1,5 @@
|
|||||||
---
|
---
|
||||||
# missing views
|
# missing views
|
||||||
row_spacing: 0
|
|
||||||
button_spacing: 0
|
|
||||||
|
|
||||||
bounds:
|
bounds:
|
||||||
x: 0
|
x: 0
|
||||||
y: 0
|
y: 0
|
||||||
|
|||||||
@ -1,8 +1,5 @@
|
|||||||
---
|
---
|
||||||
# extra field
|
# extra field
|
||||||
row_spacing: 0
|
|
||||||
button_spacing: 0
|
|
||||||
|
|
||||||
bounds:
|
bounds:
|
||||||
x: 0
|
x: 0
|
||||||
y: 0
|
y: 0
|
||||||
|
|||||||
@ -1,8 +1,5 @@
|
|||||||
---
|
---
|
||||||
# punctuation
|
# punctuation
|
||||||
row_spacing: 0
|
|
||||||
button_spacing: 0
|
|
||||||
|
|
||||||
bounds:
|
bounds:
|
||||||
x: 0
|
x: 0
|
||||||
y: 0
|
y: 0
|
||||||
|
|||||||
@ -1,8 +1,5 @@
|
|||||||
---
|
---
|
||||||
# punctuation
|
# punctuation
|
||||||
row_spacing: 0
|
|
||||||
button_spacing: 0
|
|
||||||
|
|
||||||
bounds:
|
bounds:
|
||||||
x: 0
|
x: 0
|
||||||
y: 0
|
y: 0
|
||||||
|
|||||||
Reference in New Issue
Block a user