From 425ae8af346e1be67db2d09509d45ab5b84ba7e0 Mon Sep 17 00:00:00 2001 From: Bob Date: Sat, 11 Jan 2020 23:31:01 -0500 Subject: [PATCH] Layout allows children now you can do stuff like: ``` gherkin_bump_layout("g20") { upside_down() key(); }; ``` and it'll work! you still have to specify the profile in the layout itself because row and column are not special variables... hm --- src/layouts/gherkin/gherkin_bump.scad | 4 ++- src/layouts/layout.scad | 42 +++++++++++++++++++++++---- 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/src/layouts/gherkin/gherkin_bump.scad b/src/layouts/gherkin/gherkin_bump.scad index b82c435..779cc64 100644 --- a/src/layouts/gherkin/gherkin_bump.scad +++ b/src/layouts/gherkin/gherkin_bump.scad @@ -16,5 +16,7 @@ gherkin_bump_legends = [ ]; module gherkin_bump_layout(profile, row_sculpting_offset=1, column_override=undef) { - layout(gherkin_bump_mapping, profile, legends=gherkin_bump_legends, row_sculpting_offset=row_sculpting_offset, column_override=column_override, column_sculpt_profile="cresting_wave"); + layout(gherkin_bump_mapping, profile, legends=gherkin_bump_legends, row_sculpting_offset=row_sculpting_offset, column_override=column_override, column_sculpt_profile="cresting_wave") { + children(); + }; } diff --git a/src/layouts/layout.scad b/src/layouts/layout.scad index 7c58cd7..b5ba3f6 100644 --- a/src/layouts/layout.scad +++ b/src/layouts/layout.scad @@ -6,7 +6,7 @@ function abs_sum(list, x=0) = abs_sum([for (x = [1: len(list) - 1]) list[x]], x+abs(list[0])); function 2hands(index, total) = ((index+0.5) % (total/2)) - (total/4); -function cresting_wave(index, total, mod=5) = (index < total/2) ? (((index + 0.5) / total)*mod) : -(mod - ((index + 0.5) / total * mod)); +function cresting_wave(index, total, mod=4) = (index < total/2) ? (((index + 0.5) / total)*mod) : -(mod - ((index + 0.5) / total * mod)); function 1hand(index, total) = (index % (total)) - (total/2); @@ -38,15 +38,45 @@ module layout(list, profile="dcs", legends=undef, row_sculpting_offset=0, row_ov translate_u(column_distance - (key_length/2), -row) { key_profile(profile, row_sculpting, column_value) u(key_length) legend(legends ? legends[row][column] : "") cherry() { // (row+4) % 5 + 1 if (key_length == 6.25) { - spacebar() key(); + spacebar() { + if ($children) { + children(); + } else { + key(); + } + } } else if (key_length == 2.25) { - lshift() key(); + lshift() { + if ($children) { + children(); + } else { + key(); + } + } } else if (key_length == 2) { - backspace() key(); + backspace() { + if ($children) { + children(); + } else { + key(); + } + } } else if (key_length == 2.75) { - rshift() key(); + rshift() { + if ($children) { + children(); + } else { + key(); + } + } } else { - key(); + { + if ($children) { + children(); + } else { + key(); + } + } } } }