diff --git a/data/keyboards/el.yaml b/data/keyboards/el.yaml index dcef2938..437c6bb0 100644 --- a/data/keyboards/el.yaml +++ b/data/keyboards/el.yaml @@ -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: "å" diff --git a/data/keyboards/es.yaml b/data/keyboards/es.yaml index db400f31..7628e982 100644 --- a/data/keyboards/es.yaml +++ b/data/keyboards/es.yaml @@ -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" \ No newline at end of file + keysym: "quotedbl" diff --git a/data/keyboards/it.yaml b/data/keyboards/it.yaml index 0ae00072..9884e77a 100644 --- a/data/keyboards/it.yaml +++ b/data/keyboards/it.yaml @@ -1,22 +1,19 @@ # Italian layout created by Antonio Pandolfo # 03 october 2019 --- -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: @@ -97,4 +94,4 @@ buttons: colon: label: ":" "\"": - keysym: "quotedbl" \ No newline at end of file + keysym: "quotedbl" diff --git a/data/keyboards/nb.yaml b/data/keyboards/nb.yaml index 1b27e645..0fa6ea4f 100644 --- a/data/keyboards/nb.yaml +++ b/data/keyboards/nb.yaml @@ -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: "å" diff --git a/data/keyboards/number.yaml b/data/keyboards/number.yaml index 19b62600..07cc2531 100644 --- a/data/keyboards/number.yaml +++ b/data/keyboards/number.yaml @@ -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: diff --git a/data/keyboards/us.yaml b/data/keyboards/us.yaml index 6988fc62..47ecabb5 100644 --- a/data/keyboards/us.yaml +++ b/data/keyboards/us.yaml @@ -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: diff --git a/data/style.css b/data/style.css index d7cf4509..2ec94bc8 100644 --- a/data/style.css +++ b/data/style.css @@ -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 { diff --git a/eek/eek-renderer.c b/eek/eek-renderer.c index 8659bfba..93a32dcf 100644 --- a/eek/eek-renderer.c +++ b/eek/eek-renderer.c @@ -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, diff --git a/src/data.rs b/src/data.rs index d0631621..de73712d 100644 --- a/src/data.rs +++ b/src/data.rs @@ -194,8 +194,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>, #[serde(default)] @@ -382,10 +380,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, @@ -586,8 +580,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()), diff --git a/src/layout.rs b/src/layout.rs index 574b17c1..7958c0c8 100644 --- a/src/layout.rs +++ b/src/layout.rs @@ -321,8 +321,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); } } @@ -433,10 +432,6 @@ pub mod c { x: 0f64, y: 0f64, width: 0f64, height: 0f64 }, - spacing: Spacing { - button: 0f64, - row: 0f64, - }, rows: vec!(row), }; @@ -456,10 +451,6 @@ pub mod c { x: 0f64, y: 0f64, width: 0f64, height: 0f64 }, - spacing: Spacing { - button: 0f64, - row: 0f64, - }, rows: Vec::new(), }; assert_eq!( @@ -595,9 +586,7 @@ impl Row { } } - fn calculate_button_positions(outlines: Vec, button_spacing: f64) - -> Vec - { + fn calculate_button_positions(outlines: Vec) -> Vec { let mut x_offset = 0f64; outlines.iter().map(|outline| { x_offset += outline.x; // account for offset outlines @@ -605,7 +594,7 @@ impl Row { x: x_offset, ..outline.clone() }; - x_offset += outline.width + button_spacing; + x_offset += outline.width; position }).collect() } @@ -653,7 +642,6 @@ pub struct Spacing { pub struct View { /// Position relative to keyboard origin pub bounds: c::Bounds, - pub spacing: Spacing, pub rows: Vec>, } @@ -665,9 +653,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, row_spacing: f64) - -> Vec - { + fn calculate_row_positions(&self, sizes: Vec) -> Vec { let mut y_offset = self.bounds.y; sizes.into_iter().map(|size| { let position = c::Bounds { @@ -676,7 +662,7 @@ impl View { width: size.width, height: size.height, }; - y_offset += size.height + row_spacing; + y_offset += size.height; position }).collect() } @@ -686,13 +672,12 @@ impl View { fn place_buttons_with_sizes( &mut self, button_outlines: Vec>, - 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(); @@ -701,7 +686,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) diff --git a/tests/layout.yaml b/tests/layout.yaml index be25dc96..d7ccc7b9 100644 --- a/tests/layout.yaml +++ b/tests/layout.yaml @@ -1,7 +1,4 @@ --- -row_spacing: 0 -button_spacing: 0 - bounds: x: 0 y: 0 diff --git a/tests/layout2.yaml b/tests/layout2.yaml index ff37e73d..f8610ddb 100644 --- a/tests/layout2.yaml +++ b/tests/layout2.yaml @@ -1,8 +1,5 @@ --- # missing views -row_spacing: 0 -button_spacing: 0 - bounds: x: 0 y: 0 diff --git a/tests/layout3.yaml b/tests/layout3.yaml index 48d01740..8065d4d0 100644 --- a/tests/layout3.yaml +++ b/tests/layout3.yaml @@ -1,8 +1,5 @@ --- # extra field -row_spacing: 0 -button_spacing: 0 - bounds: x: 0 y: 0 diff --git a/tests/layout_key1.yaml b/tests/layout_key1.yaml index e33e0728..89de08c6 100644 --- a/tests/layout_key1.yaml +++ b/tests/layout_key1.yaml @@ -1,8 +1,5 @@ --- # punctuation -row_spacing: 0 -button_spacing: 0 - bounds: x: 0 y: 0 diff --git a/tests/layout_key2.yaml b/tests/layout_key2.yaml index d07c2853..a8372fc8 100644 --- a/tests/layout_key2.yaml +++ b/tests/layout_key2.yaml @@ -1,8 +1,5 @@ --- # punctuation -row_spacing: 0 -button_spacing: 0 - bounds: x: 0 y: 0