feat(renderer): show icon when possible even if the keystroke action has modifier (#533)
Closes #513
This commit is contained in:
committed by
László Monda
parent
721a4dc6e7
commit
5ceca41e0f
@@ -1,5 +1,10 @@
|
|||||||
<svg [attr.viewBox]="viewBox" [attr.width]="textContainer.width" [attr.height]="textContainer.height"
|
<svg [attr.viewBox]="viewBox" [attr.width]="textContainer.width" [attr.height]="textContainer.height"
|
||||||
[attr.x]="textContainer.x" [attr.y]="textContainer.y" [ngSwitch]="labelType">
|
[attr.x]="textContainer.x" [attr.y]="textContainer.y" [ngSwitch]="labelType">
|
||||||
|
<svg:g svg-single-icon-key *ngSwitchCase="'icon'"
|
||||||
|
[height]="height"
|
||||||
|
[width]="width"
|
||||||
|
[icon]="labelSource">
|
||||||
|
</svg:g>
|
||||||
<svg:g svg-one-line-text-key *ngSwitchCase="'one-line'"
|
<svg:g svg-one-line-text-key *ngSwitchCase="'one-line'"
|
||||||
[height]="height"
|
[height]="height"
|
||||||
[width]="width"
|
[width]="width"
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 2.0 KiB |
@@ -127,21 +127,23 @@ export class SvgKeystrokeKeyComponent implements OnInit, OnChanges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges() {
|
ngOnChanges() {
|
||||||
let newLabelSource: string[];
|
|
||||||
if (this.keystrokeAction.hasScancode()) {
|
if (this.keystrokeAction.hasScancode()) {
|
||||||
const scancode: number = this.keystrokeAction.scancode;
|
const scancode: number = this.keystrokeAction.scancode;
|
||||||
newLabelSource = this.mapper.scanCodeToText(scancode, this.keystrokeAction.type);
|
this.labelSource = this.mapper.scanCodeToSvgImagePath(scancode, this.keystrokeAction.type);
|
||||||
if (newLabelSource) {
|
if (this.labelSource) {
|
||||||
if (newLabelSource.length === 1) {
|
|
||||||
this.labelSource = newLabelSource[0];
|
|
||||||
this.labelType = 'one-line';
|
|
||||||
} else {
|
|
||||||
this.labelSource = newLabelSource;
|
|
||||||
this.labelType = 'two-line';
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.labelSource = this.mapper.scanCodeToSvgImagePath(scancode, this.keystrokeAction.type);
|
|
||||||
this.labelType = 'icon';
|
this.labelType = 'icon';
|
||||||
|
} else {
|
||||||
|
let newLabelSource: string[];
|
||||||
|
newLabelSource = this.mapper.scanCodeToText(scancode, this.keystrokeAction.type);
|
||||||
|
if (newLabelSource) {
|
||||||
|
if (newLabelSource.length === 1) {
|
||||||
|
this.labelSource = newLabelSource[0];
|
||||||
|
this.labelType = 'one-line';
|
||||||
|
} else {
|
||||||
|
this.labelSource = newLabelSource;
|
||||||
|
this.labelType = 'two-line';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.labelType = 'empty';
|
this.labelType = 'empty';
|
||||||
|
|||||||
@@ -71,7 +71,11 @@ export class MapperService {
|
|||||||
default:
|
default:
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
return 'assets/compiled_sprite.svg#' + map.get(scanCode);
|
const id = map.get(scanCode);
|
||||||
|
if (!id) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return `assets/compiled_sprite.svg#${id}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getIcon(iconName: string): string {
|
public getIcon(iconName: string): string {
|
||||||
|
|||||||
Reference in New Issue
Block a user