Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mr-september opened this issue Jun 6, 2022 · 6 comments

Comments

@mr-september
Copy link

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", "", "<", "", "", "", "⤒"],
];
@Ashgar225
Copy link

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.

@mr-september
Copy link
Author

mr-september commented Jul 16, 2022

@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.

@Ashgar225
Copy link

Ashgar225 commented Jul 16, 2022

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.

@mr-september
Copy link
Author

mr-september commented Jul 17, 2022

@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

@rsheldiii
Copy link
Owner

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

@mr-september
Copy link
Author

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants