KeyV2 icon indicating copy to clipboard operation
KeyV2 copied to clipboard

Is there a better way to do multiline legends across a whole keyboard?

Open mr-september opened this issue 3 years ago • 6 comments

Related to issue #21. The provided example, while very helpful for understanding the basics, does not seem to scale up for generating most of a keyboard in one go.

Is there an better way to implement multiline legends in a similar way to how normal legends are generated? For example, with "dataframes" like this:

top_left_legends = [
  ["", "!", "@", "#", "_", "", "~", "{", "}", "|", ""],
  ["", "$", "%", "^", "+", "", ":", "J", " ", "⎙", ""],
  ["", "&", "*", "(", ")", "", ">", "", "", "", "⤓"],
];

bot_left_legends = [
  ["", "1", "2", "3", "4", "", "`", "[", "]", "\", ""],
  ["", "4", "5", "6", "=", "", ";", "'", "", "⎀", ""],
  ["", "7", "8", "9", "0", "", "<", "", "", "", "⤒"],
];

mr-september avatar Jun 06 '22 12:06 mr-september

If you add another legend() entry in the call to key_profile() in layout.scad, you can get it to generate a second set of legends.

i.e. replace legend(legends ? legends[row][column] : "") with something like legend(legends ? legends[row][column] : "", [0,-1]) legend(alt_legends ? alt_legends[row][column] : "", [0,1]) and pass in an appropriately named array to the call to layout(). You also need to specify a position for each of these if you don't want them on top of each other. There are some less-hacky ways to do this, but tweaking the positions gave good results for me.

Ashgar225 avatar Jul 14 '22 17:07 Ashgar225

@Ashgar225 Thank you! That works great. Currently, in my layout.scad, there's a whole series of alt_legends_x. Then it would get loaded in properly as long as a corresponding alt_legends_x variable exists in keys.scad.

Would you also happen to know how the font size could be specified individually for each legend? In my keys.scad, only $font_size = x; works, but it applies to all fonts. In this documentation, there's a mention of an argument for legend(), but this does not appear to work for me.

mr-september avatar Jul 16 '22 06:07 mr-september

Supplying size=4 or similar as an argument (or just as a third argument, when also providing a position) to legend() does seem to work for me, and even overrides any earlier declaration of $font_size and works with different legends on the same key. Not sure what you're running into on that one.

Also, I think your link is not quite going to the right place.

Ashgar225 avatar Jul 16 '22 17:07 Ashgar225

@Ashgar225 Oops, that was embarrassing! Fixed.

There's a good chance I've done something wrong, been very jankily copy pasting parts of code from all over the place. I'll just upload the code here, and if you (or anyone else) is free to take a look, please let me know how it could be resolved/what's the best practice.

So there's 3 files I've changed from a fresh github pull: keys.scad, layout.scad (the workaround suggested above), and skeletyl_legends.scad (frankensteined from another contributor's dactyl manuform layout. The generating/rendering is done in keys.scad.

So, currently, even with no legends() call in keys.scad, the corresponding legends still get generated.

Adding a legends() or legends(topleft_legends, size=5), etc, appear to have no effect on the generation.

(zipped because github doesn't accept .scad files) changed_files.zip

mr-september avatar Jul 17 '22 13:07 mr-september

The layout functionality does too much in this repo, and I want to switch everything over to using simple_layout. This use case is a perfect example of why, here's how you'd solve this with simple_layout:

top_left_legends = [
  ["", "!", "@", "#", "_", "", "~", "{", "}", "|", ""],
  ["", "$", "%", "^", "+", "", ":", "J", " ", "⎙", ""],
  ["", "&", "*", "(", ")", "", ">", "", "", "", "⤓"],
];

bot_left_legends = [
  ["", "1", "2", "3", "4", "", "`", "[", "]", "\\", ""],
  ["", "4", "5", "6", "=", "", ";", "'", "", "⎀", ""],
  ["", "7", "8", "9", "0", "", "<", "", "", "", "⤒"],
];

$font_size = 4;

simple_layout(preonic_default_layout) {
  oem_row($row, $column){
    legend(top_left_legends[$row][$column], [-0.8, -0.8]) {
      legend(bot_left_legends[$row][$column], [-0.8, 0.8]) {
        key();
      }
    }
  }
}

image

rsheldiii avatar Oct 14 '22 23:10 rsheldiii

@rsheldiii Thank you! This is indeed working and very simple to implement.

Just wondering, with simple_layout, is there anything like a font size override? For example, to have different sizes in the different corners.

mr-september avatar Nov 07 '22 11:11 mr-september