buttons: Buttons are next to each other, padding is visual only
This commit is contained in:
@ -2,16 +2,15 @@
|
||||
# University of the Aegean, Department of Mathematics, atsol@aegean.gr
|
||||
# Sep 2019
|
||||
---
|
||||
row_spacing: 11.33
|
||||
button_spacing: 4.67
|
||||
|
||||
bounds: { x: 0, y: 6.33, width: 426, height: 250 }
|
||||
bounds: { x: 0, y: 0.33, width: 360, height: 210 }
|
||||
|
||||
outlines:
|
||||
default:
|
||||
bounds: { x: 0, y: 0, width: 32, height: 52 }
|
||||
altline:
|
||||
bounds: { x: 0, y: 0, width: 48.39024, height: 52 }
|
||||
wide:
|
||||
bounds: { x: 0, y: 0, width: 62, height: 52 }
|
||||
outline7:
|
||||
bounds: { x: 0, y: 0, width: 88.97561, height: 52 }
|
||||
spaceline:
|
||||
@ -22,7 +21,7 @@ views:
|
||||
- "; ς ε ρ τ υ θ ι ο π !"
|
||||
- "α σ δ φ γ η ξ κ λ show_accented"
|
||||
- "Shift_L ζ χ ψ ω β ν μ , BackSpace"
|
||||
- "show_numbers preferences space . Return"
|
||||
- "show_numbers preferences space period Return"
|
||||
upper:
|
||||
- ": EuroSign Ε Ρ Τ Υ Θ Ι Ο Π"
|
||||
- "Α Σ Δ Φ Γ Η Ξ Κ Λ show_accented"
|
||||
@ -86,13 +85,13 @@ buttons:
|
||||
outline: "altline"
|
||||
label: "αι"
|
||||
period:
|
||||
outline: altline
|
||||
outline: "altline"
|
||||
label: "."
|
||||
space:
|
||||
outline: spaceline
|
||||
label: " "
|
||||
Return:
|
||||
outline: outline7
|
||||
outline: "wide"
|
||||
icon: "key-enter"
|
||||
aring:
|
||||
label: "å"
|
||||
|
||||
@ -1,20 +1,17 @@
|
||||
---
|
||||
row_spacing: 11.33
|
||||
button_spacing: 4.67
|
||||
|
||||
bounds: { x: 0, y: 1, width: 360, height: 198 }
|
||||
bounds: { x: 0, y: 1, width: 360, height: 210 }
|
||||
|
||||
outlines:
|
||||
default:
|
||||
bounds: { x: 0, y: 0, width: 30.67, height: 40.67 }
|
||||
bounds: { x: 0, y: 0, width: 35.33, height: 52 }
|
||||
altline:
|
||||
bounds: { x: 0, y: 0, width: 48, height: 40.67 }
|
||||
bounds: { x: 0, y: 0, width: 52.67, height: 52 }
|
||||
wide:
|
||||
bounds: { x: 0, y: 0, width: 57.33, height: 40.67 }
|
||||
bounds: { x: 0, y: 0, width: 62, height: 52 }
|
||||
spaceline:
|
||||
bounds: { x: 0, y: 0, width: 95.00, height: 40.67 }
|
||||
bounds: { x: 0, y: 0, width: 99.67, height: 52 }
|
||||
special:
|
||||
bounds: { x: 0, y: 0, width: 39.33, height: 40.67 }
|
||||
bounds: { x: 0, y: 0, width: 44, height: 52 }
|
||||
|
||||
views:
|
||||
base:
|
||||
@ -93,4 +90,4 @@ buttons:
|
||||
colon:
|
||||
label: ":"
|
||||
"\"":
|
||||
keysym: "quotedbl"
|
||||
keysym: "quotedbl"
|
||||
|
||||
@ -1,20 +1,17 @@
|
||||
---
|
||||
row_spacing: 11.33
|
||||
button_spacing: 4.67
|
||||
|
||||
bounds: { x: 0, y: 1, width: 360, height: 198 }
|
||||
bounds: { x: 0, y: 1, width: 360, height: 210 }
|
||||
|
||||
outlines:
|
||||
default:
|
||||
bounds: { x: 0, y: 0, width: 30.67, height: 40.67 }
|
||||
bounds: { x: 0, y: 0, width: 35.33, height: 52 }
|
||||
altline:
|
||||
bounds: { x: 0, y: 0, width: 48, height: 40.67 }
|
||||
bounds: { x: 0, y: 0, width: 52.67, height: 52 }
|
||||
wide:
|
||||
bounds: { x: 0, y: 0, width: 57.33, height: 40.67 }
|
||||
bounds: { x: 0, y: 0, width: 62, height: 52 }
|
||||
spaceline:
|
||||
bounds: { x: 0, y: 0, width: 95.00, height: 40.67 }
|
||||
bounds: { x: 0, y: 0, width: 99.67, height: 52 }
|
||||
special:
|
||||
bounds: { x: 0, y: 0, width: 39.33, height: 40.67 }
|
||||
bounds: { x: 0, y: 0, width: 44, height: 52 }
|
||||
|
||||
views:
|
||||
base:
|
||||
@ -95,4 +92,4 @@ buttons:
|
||||
colon:
|
||||
label: ":"
|
||||
"\"":
|
||||
keysym: "quotedbl"
|
||||
keysym: "quotedbl"
|
||||
|
||||
@ -1,14 +1,13 @@
|
||||
---
|
||||
row_spacing: 11.33
|
||||
button_spacing: 4.67
|
||||
|
||||
bounds: { x: 0, y: 6.33, width: 426, height: 250 }
|
||||
bounds: { x: 0, y: 0.33, width: 360, height: 210 }
|
||||
|
||||
outlines:
|
||||
default:
|
||||
bounds: { x: 0, y: 0, width: 32, height: 52 }
|
||||
altline:
|
||||
bounds: { x: 0, y: 0, width: 48.39024, height: 52 }
|
||||
wide:
|
||||
bounds: { x: 0, y: 0, width: 62, height: 52 }
|
||||
outline7:
|
||||
bounds: { x: 0, y: 0, width: 88.97561, height: 52 }
|
||||
spaceline:
|
||||
@ -73,7 +72,7 @@ buttons:
|
||||
outline: spaceline
|
||||
label: " "
|
||||
Return:
|
||||
outline: outline7
|
||||
outline: "wide"
|
||||
icon: "key-enter"
|
||||
aring:
|
||||
label: "å"
|
||||
|
||||
@ -1,8 +1,5 @@
|
||||
---
|
||||
row_spacing: 11.33
|
||||
button_spacing: 4.67
|
||||
|
||||
bounds: { x: 0, y: 6.33, width: 410, height: 250 }
|
||||
bounds: { x: 0, y: 0.33, width: 360, height: 210 }
|
||||
|
||||
outlines:
|
||||
default:
|
||||
|
||||
@ -1,20 +1,17 @@
|
||||
---
|
||||
row_spacing: 11.33
|
||||
button_spacing: 4.67
|
||||
|
||||
bounds: { x: 0, y: 1, width: 360, height: 198 }
|
||||
bounds: { x: 0, y: 1, width: 360, height: 210 }
|
||||
|
||||
outlines:
|
||||
default:
|
||||
bounds: { x: 0, y: 0, width: 30.67, height: 40.67 }
|
||||
bounds: { x: 0, y: 0, width: 35.33, height: 52 }
|
||||
altline:
|
||||
bounds: { x: 0, y: 0, width: 48, height: 40.67 }
|
||||
bounds: { x: 0, y: 0, width: 52.67, height: 52 }
|
||||
wide:
|
||||
bounds: { x: 0, y: 0, width: 57.33, height: 40.67 }
|
||||
bounds: { x: 0, y: 0, width: 62, height: 52 }
|
||||
spaceline:
|
||||
bounds: { x: 0, y: 0, width: 137.33, height: 40.67 }
|
||||
bounds: { x: 0, y: 0, width: 142, height: 52 }
|
||||
special:
|
||||
bounds: { x: 0, y: 0, width: 39.33, height: 40.67 }
|
||||
bounds: { x: 0, y: 0, width: 44, height: 52 }
|
||||
|
||||
views:
|
||||
base:
|
||||
|
||||
@ -11,6 +11,7 @@ sq_button {
|
||||
border-width: 1px;
|
||||
border-color: #5e5c64;
|
||||
border-radius: 3px;
|
||||
margin: 4px 2px 4px 2px;
|
||||
}
|
||||
|
||||
sq_button:active {
|
||||
@ -22,7 +23,7 @@ sq_button.altline,
|
||||
sq_button.special,
|
||||
sq_button.wide {
|
||||
background: #2b292f;
|
||||
border-color: #3e3a44
|
||||
border-color: #3e3a44;
|
||||
}
|
||||
|
||||
sq_button.locked {
|
||||
@ -32,7 +33,7 @@ sq_button.locked {
|
||||
|
||||
#Return {
|
||||
background: #1c71d8;
|
||||
border-color: #1a5fb4
|
||||
border-color: #1a5fb4;
|
||||
}
|
||||
|
||||
#Return:active {
|
||||
|
||||
@ -174,8 +174,22 @@ render_outline (cairo_t *cr,
|
||||
GtkStyleContext *ctx,
|
||||
EekBounds bounds)
|
||||
{
|
||||
gtk_render_background (ctx, cr, 0, 0, bounds.width, bounds.height);
|
||||
gtk_render_frame (ctx, cr, 0, 0, bounds.width, bounds.height);
|
||||
GtkBorder margin, border;
|
||||
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,
|
||||
|
||||
@ -189,8 +189,6 @@ fn load_layout_with_fallback(
|
||||
#[derive(Debug, Deserialize, PartialEq)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct Layout {
|
||||
row_spacing: f64,
|
||||
button_spacing: f64,
|
||||
bounds: Bounds,
|
||||
views: HashMap<String, Vec<ButtonIds>>,
|
||||
#[serde(default)]
|
||||
@ -345,10 +343,6 @@ impl Layout {
|
||||
width: self.bounds.width,
|
||||
height: self.bounds.height,
|
||||
},
|
||||
spacing: ::layout::Spacing {
|
||||
row: self.row_spacing,
|
||||
button: self.button_spacing,
|
||||
},
|
||||
rows: view.iter().map(|row| {
|
||||
Box::new(::layout::Row {
|
||||
angle: 0,
|
||||
@ -545,8 +539,6 @@ mod tests {
|
||||
assert_eq!(
|
||||
Layout::from_file(PathBuf::from("tests/layout.yaml")).unwrap(),
|
||||
Layout {
|
||||
row_spacing: 0f64,
|
||||
button_spacing: 0f64,
|
||||
bounds: Bounds { x: 0f64, y: 0f64, width: 0f64, height: 0f64 },
|
||||
views: hashmap!(
|
||||
"base".into() => vec!("test".into()),
|
||||
|
||||
@ -330,8 +330,7 @@ pub mod c {
|
||||
.map(|button| button.bounds.clone())
|
||||
.collect()
|
||||
}).collect();
|
||||
let spacing = view.spacing.clone();
|
||||
view.place_buttons_with_sizes(sizes, spacing);
|
||||
view.place_buttons_with_sizes(sizes);
|
||||
}
|
||||
}
|
||||
|
||||
@ -442,10 +441,6 @@ pub mod c {
|
||||
x: 0f64, y: 0f64,
|
||||
width: 0f64, height: 0f64
|
||||
},
|
||||
spacing: Spacing {
|
||||
button: 0f64,
|
||||
row: 0f64,
|
||||
},
|
||||
rows: vec!(row),
|
||||
};
|
||||
|
||||
@ -465,10 +460,6 @@ pub mod c {
|
||||
x: 0f64, y: 0f64,
|
||||
width: 0f64, height: 0f64
|
||||
},
|
||||
spacing: Spacing {
|
||||
button: 0f64,
|
||||
row: 0f64,
|
||||
},
|
||||
rows: Vec::new(),
|
||||
};
|
||||
assert_eq!(
|
||||
@ -606,9 +597,7 @@ impl Row {
|
||||
}
|
||||
}
|
||||
|
||||
fn calculate_button_positions(outlines: Vec<c::Bounds>, button_spacing: f64)
|
||||
-> Vec<c::Bounds>
|
||||
{
|
||||
fn calculate_button_positions(outlines: Vec<c::Bounds>) -> Vec<c::Bounds> {
|
||||
let mut x_offset = 0f64;
|
||||
outlines.iter().map(|outline| {
|
||||
x_offset += outline.x; // account for offset outlines
|
||||
@ -616,7 +605,7 @@ impl Row {
|
||||
x: x_offset,
|
||||
..outline.clone()
|
||||
};
|
||||
x_offset += outline.width + button_spacing;
|
||||
x_offset += outline.width;
|
||||
position
|
||||
}).collect()
|
||||
}
|
||||
@ -664,7 +653,6 @@ pub struct Spacing {
|
||||
pub struct View {
|
||||
/// Position relative to keyboard origin
|
||||
pub bounds: c::Bounds,
|
||||
pub spacing: Spacing,
|
||||
pub rows: Vec<Box<Row>>,
|
||||
}
|
||||
|
||||
@ -676,9 +664,7 @@ impl View {
|
||||
/// and derive a scaling factor that lets contents fit into view)
|
||||
/// (or TODO: blow up view bounds to match contents
|
||||
/// and then scale the entire thing)
|
||||
fn calculate_row_positions(&self, sizes: Vec<Size>, row_spacing: f64)
|
||||
-> Vec<c::Bounds>
|
||||
{
|
||||
fn calculate_row_positions(&self, sizes: Vec<Size>) -> Vec<c::Bounds> {
|
||||
let mut y_offset = self.bounds.y;
|
||||
sizes.into_iter().map(|size| {
|
||||
let position = c::Bounds {
|
||||
@ -687,7 +673,7 @@ impl View {
|
||||
width: size.width,
|
||||
height: size.height,
|
||||
};
|
||||
y_offset += size.height + row_spacing;
|
||||
y_offset += size.height;
|
||||
position
|
||||
}).collect()
|
||||
}
|
||||
@ -697,13 +683,12 @@ impl View {
|
||||
fn place_buttons_with_sizes(
|
||||
&mut self,
|
||||
button_outlines: Vec<Vec<c::Bounds>>,
|
||||
spacing: Spacing,
|
||||
) {
|
||||
// Determine all positions
|
||||
let button_positions: Vec<_>
|
||||
= button_outlines.into_iter()
|
||||
.map(|outlines| {
|
||||
Row::calculate_button_positions(outlines, spacing.button)
|
||||
Row::calculate_button_positions(outlines)
|
||||
})
|
||||
.collect();
|
||||
|
||||
@ -712,7 +697,7 @@ impl View {
|
||||
.collect();
|
||||
|
||||
let row_positions
|
||||
= self.calculate_row_positions(row_sizes, spacing.row);
|
||||
= self.calculate_row_positions(row_sizes);
|
||||
|
||||
// Apply all positions
|
||||
for ((mut row, row_position), button_positions)
|
||||
|
||||
@ -1,7 +1,4 @@
|
||||
---
|
||||
row_spacing: 0
|
||||
button_spacing: 0
|
||||
|
||||
bounds:
|
||||
x: 0
|
||||
y: 0
|
||||
|
||||
@ -1,8 +1,5 @@
|
||||
---
|
||||
# missing views
|
||||
row_spacing: 0
|
||||
button_spacing: 0
|
||||
|
||||
bounds:
|
||||
x: 0
|
||||
y: 0
|
||||
|
||||
@ -1,8 +1,5 @@
|
||||
---
|
||||
# extra field
|
||||
row_spacing: 0
|
||||
button_spacing: 0
|
||||
|
||||
bounds:
|
||||
x: 0
|
||||
y: 0
|
||||
|
||||
@ -1,8 +1,5 @@
|
||||
---
|
||||
# punctuation
|
||||
row_spacing: 0
|
||||
button_spacing: 0
|
||||
|
||||
bounds:
|
||||
x: 0
|
||||
y: 0
|
||||
|
||||
@ -1,8 +1,5 @@
|
||||
---
|
||||
# punctuation
|
||||
row_spacing: 0
|
||||
button_spacing: 0
|
||||
|
||||
bounds:
|
||||
x: 0
|
||||
y: 0
|
||||
|
||||
Reference in New Issue
Block a user