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

Display rotated keys in the configuration screens #725

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions src/components/BaseKey.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ export default {
y: Number,
x: Number,
u: Number,
r: Number,
rx: Number,
ry: Number,
colorway: String,
displaySizes: {
type: Boolean,
Expand Down Expand Up @@ -144,11 +147,26 @@ export default {
if (this.h > 0) {
styles.push(`height: ${this.h}px;`);
}
if (this.y > 0) {
styles.push(`top: ${this.y}px;`);
}
if (this.x > 0) {
styles.push(`left: ${this.x}px;`);
if (this.r && this.r != 0) {
if (this.ry > 0) {
styles.push(`top: ${this.ry}px;`);
}
if (this.rx > 0) {
styles.push(`left: ${this.rx}px;`);
}
styles.push(
`transform: rotate(${this.r}deg) translateX(${Math.round(
this.x - this.rx,
3
)}px) translateY(${Math.round(this.y - this.ry, 3)}px);`
);
} else {
if (this.y > 0) {
styles.push(`top: ${this.y}px;`);
}
if (this.x > 0) {
styles.push(`left: ${this.x}px;`);
}
}
if (this.meta && this.meta.name.length >= 2) {
let keySize = 0.61;
Expand Down
19 changes: 14 additions & 5 deletions src/components/BaseKeymap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ export default {
u: h > w ? h : w
};
},
calcKeyKeymapPos(x, y) {
calcKeyKeymapPos(x, y, r, rx, ry) {
return {
x: x * this.config.KEY_X_SPACING,
y: y * this.config.KEY_Y_SPACING
y: y * this.config.KEY_Y_SPACING,
r: r,
rx: rx * this.config.KEY_X_SPACING,
ry: ry * this.config.KEY_Y_SPACING
};
},
setSize(max) {
Expand All @@ -27,10 +30,16 @@ export default {
const layoutArray = this.layouts[layout];
const max = layoutArray.reduce(
(acc, pos) => {
let _pos = Object.assign({ w: 1, h: 1 }, pos);
const coor = this.calcKeyKeymapPos(_pos.x, _pos.y);
let _pos = Object.assign({ w: 1, h: 1, r: 0, rx: 0, ry: 0 }, pos);
const coor = this.calcKeyKeymapPos(
_pos.x,
_pos.y,
_pos.r,
_pos.rx,
_pos.ry
);
const dims = this.calcKeyKeymapDims(_pos.w, _pos.h);
acc.x = Math.max(acc.x, coor.x + dims.w);
acc.x = Math.max(acc.x, coor.x + dims.w); // TODO: use sin,cos with coor.x,y (icluding w/h)
acc.y = Math.max(acc.y, coor.y + dims.h);
return acc;
},
Expand Down
10 changes: 8 additions & 2 deletions src/components/PrintKeymap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,14 @@ export default {
this.profile && console.time('currentLayer');
const colorway = this.colorway;
let curLayer = layout.map((pos, index) => {
let _pos = Object.assign({ w: 1, h: 1 }, pos);
const coor = this.calcKeyKeymapPos(_pos.x, _pos.y);
let _pos = Object.assign({ w: 1, h: 1, r: 0 }, pos);
const coor = this.calcKeyKeymapPos(
_pos.x,
_pos.y,
_pos.r,
_pos.rx,
_pos.ry
);
const dims = this.calcKeyKeymapDims(_pos.w, _pos.h);
return Object.assign(
{
Expand Down
10 changes: 8 additions & 2 deletions src/components/VisualKeymap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,14 @@ export default {
this.profile && console.time('currentLayer');
const colorway = this.colorway;
let curLayer = layout.map((pos, index) => {
let _pos = Object.assign({ w: 1, h: 1 }, pos);
const coor = this.calcKeyKeymapPos(_pos.x, _pos.y);
let _pos = Object.assign({ w: 1, h: 1, r: 0 }, pos);
const coor = this.calcKeyKeymapPos(
_pos.x,
_pos.y,
_pos.r,
_pos.rx,
_pos.ry
);
const dims = this.calcKeyKeymapDims(_pos.w, _pos.h);
return Object.assign(
{
Expand Down
10 changes: 8 additions & 2 deletions src/components/VisualTesterKeymap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,14 @@ export default {
// eslint-disable-next-line no-console
this.profile && console.time('currentLayer');
const curLayer = this.activeLayoutMeta.map((pos, index) => {
const _pos = Object.assign({ w: 1, h: 1 }, pos);
const coor = this.calcKeyKeymapPos(_pos.x, _pos.y);
const _pos = Object.assign({ w: 1, h: 1, r: 0 }, pos);
const coor = this.calcKeyKeymapPos(
_pos.x,
_pos.y,
_pos.r,
_pos.rx,
_pos.ry
);
const dims = this.calcKeyKeymapDims(_pos.w, _pos.h);
return Object.assign(
{
Expand Down