@@ -37,26 +41,30 @@
@@ -64,11 +72,14 @@
+ [class.btn-primary]="mouseActionParam === MouseActionParam.leftClick"
+ (click)="setMouseActionParam(MouseActionParam.leftClick)">Left
+ [class.btn-primary]="mouseActionParam === MouseActionParam.middleClick"
+ (click)="setMouseActionParam(MouseActionParam.middleClick)">Middle
+ [class.btn-primary]="mouseActionParam === MouseActionParam.rightClick"
+ (click)="setMouseActionParam(MouseActionParam.rightClick)">Right
@@ -78,9 +89,11 @@
+ [class.btn-primary]="mouseActionParam === MouseActionParam.decelerate"
+ (click)="setMouseActionParam(MouseActionParam.decelerate)">-
+ [class.btn-primary]="mouseActionParam === MouseActionParam.acelerate"
+ (click)="setMouseActionParam(MouseActionParam.accelerate)">+
diff --git a/src/components/popover/tab/mouse/mouse-tab.component.ts b/src/components/popover/tab/mouse/mouse-tab.component.ts
index 0e8b1264..fbbef662 100644
--- a/src/components/popover/tab/mouse/mouse-tab.component.ts
+++ b/src/components/popover/tab/mouse/mouse-tab.component.ts
@@ -1,7 +1,8 @@
-import { Component, OnInit, Renderer} from '@angular/core';
+import {Component, OnInit, Input} from '@angular/core';
import {NgSwitch, NgSwitchCase, NgSwitchDefault} from '@angular/common';
-import { KeyActionSaver } from '../../key-action-saver';
+import {Tab} from '../tab';
+import {KeyAction} from '../../../../../config-serializer/config-items/KeyAction';
import {MouseAction, MouseActionParam} from '../../../../../config-serializer/config-items/MouseAction';
@Component({
@@ -11,20 +12,61 @@ import {MouseAction, MouseActionParam} from '../../../../../config-serializer/co
styles: [require('./mouse-tab.component.scss')],
directives: [NgSwitch, NgSwitchCase, NgSwitchDefault]
})
-export class MouseTabComponent implements OnInit, KeyActionSaver {
+export class MouseTabComponent implements OnInit, Tab {
+ @Input() defaultKeyAction: KeyAction;
+
private mouseActionParam: MouseActionParam;
- private selectedIndex: number;
- private selectedButton: HTMLButtonElement;
+ private selectedPageIndex: number;
private MouseActionParam = MouseActionParam;
- constructor(private renderer: Renderer) {
- this.selectedIndex = 0;
+ constructor() {
+ this.selectedPageIndex = 0;
}
- ngOnInit() { }
+ ngOnInit() {
+ this.fromKeyAction(this.defaultKeyAction);
+ }
keyActionValid(): boolean {
- return !!this.mouseActionParam;
+ return this.mouseActionParam !== undefined;
+ }
+
+ fromKeyAction(keyAction: KeyAction): boolean {
+ if (!(keyAction instanceof MouseAction)) {
+ return false;
+ }
+ let mouseAction: MouseAction =
keyAction;
+ this.mouseActionParam = mouseAction.mouseAction;
+
+ if (mouseAction.mouseAction === MouseActionParam.moveUp) {
+ this.selectedPageIndex = 0;
+ }
+ switch (mouseAction.mouseAction) {
+ case MouseActionParam.moveDown:
+ case MouseActionParam.moveUp:
+ case MouseActionParam.moveLeft:
+ case MouseActionParam.moveRight:
+ this.selectedPageIndex = 0;
+ break;
+ case MouseActionParam.scrollDown:
+ case MouseActionParam.scrollUp:
+ case MouseActionParam.scrollLeft:
+ case MouseActionParam.scrollRight:
+ this.selectedPageIndex = 1;
+ break;
+ case MouseActionParam.leftClick:
+ case MouseActionParam.middleClick:
+ case MouseActionParam.rightClick:
+ this.selectedPageIndex = 2;
+ break;
+ case MouseActionParam.decelerate:
+ case MouseActionParam.accelerate:
+ this.selectedPageIndex = 3;
+ break;
+ default:
+ return false;
+ }
+ return true;
}
toKeyAction(): MouseAction {
@@ -41,17 +83,11 @@ export class MouseTabComponent implements OnInit, KeyActionSaver {
console.error(`Invalid index error: ${index}`);
return;
}
- this.selectedIndex = index;
+ this.selectedPageIndex = index;
this.mouseActionParam = undefined;
- this.selectedButton = undefined;
}
- onMouseActionClick(target: HTMLButtonElement, mouseActionParam: MouseActionParam) {
- if (this.selectedButton) {
- this.renderer.setElementClass(this.selectedButton, 'btn-primary', false);
- }
- this.selectedButton = target;
- this.renderer.setElementClass(target, 'btn-primary', true);
+ setMouseActionParam(mouseActionParam: MouseActionParam) {
this.mouseActionParam = mouseActionParam;
}
diff --git a/src/components/popover/tab/none/none-tab.component.ts b/src/components/popover/tab/none/none-tab.component.ts
index a9c2d725..cba0e7cf 100644
--- a/src/components/popover/tab/none/none-tab.component.ts
+++ b/src/components/popover/tab/none/none-tab.component.ts
@@ -1,7 +1,8 @@
-import { Component, OnInit } from '@angular/core';
+import {Component, OnInit } from '@angular/core';
-import { KeyActionSaver } from '../../key-action-saver';
-import { NoneAction } from '../../../../../config-serializer/config-items/NoneAction';
+import {Tab} from '../tab';
+import {KeyAction} from '../../../../../config-serializer/config-items/KeyAction';
+import {NoneAction} from '../../../../../config-serializer/config-items/NoneAction';
@Component({
moduleId: module.id,
@@ -9,7 +10,7 @@ import { NoneAction } from '../../../../../config-serializer/config-items/NoneAc
template: require('./none-tab.component.html'),
styles: [require('./none-tab.component.scss')]
})
-export class NoneTabComponent implements OnInit, KeyActionSaver {
+export class NoneTabComponent implements OnInit, Tab {
constructor() { }
ngOnInit() { }
@@ -18,6 +19,10 @@ export class NoneTabComponent implements OnInit, KeyActionSaver {
return true;
}
+ fromKeyAction(keyAction: KeyAction): boolean {
+ return false;
+ }
+
toKeyAction(): NoneAction {
return new NoneAction();
}
diff --git a/src/components/popover/tab/tab.ts b/src/components/popover/tab/tab.ts
new file mode 100644
index 00000000..908538f8
--- /dev/null
+++ b/src/components/popover/tab/tab.ts
@@ -0,0 +1,7 @@
+import {KeyAction} from '../../../../config-serializer/config-items/KeyAction';
+
+export interface Tab {
+ keyActionValid(): boolean;
+ fromKeyAction(keyAction: KeyAction): boolean;
+ toKeyAction(): KeyAction;
+}
diff --git a/src/components/svg/keys/svg-keyboard-key.component.ts b/src/components/svg/keys/svg-keyboard-key.component.ts
index 3fb31044..c09f4a36 100644
--- a/src/components/svg/keys/svg-keyboard-key.component.ts
+++ b/src/components/svg/keys/svg-keyboard-key.component.ts
@@ -124,6 +124,8 @@ export class SvgKeyboardKeyComponent implements OnInit, OnChanges {
break;
}
this.labelSource = newLabelSource;
+ } else {
+ this.labelSource = undefined;
}
} else if (this.keyAction instanceof SwitchLayerAction) {
let keyAction: SwitchLayerAction = this.keyAction as SwitchLayerAction;
diff --git a/src/components/svg/popover/svg-keyboard-popover.component.html b/src/components/svg/popover/svg-keyboard-popover.component.html
index f138df59..19c7b515 100644
--- a/src/components/svg/popover/svg-keyboard-popover.component.html
+++ b/src/components/svg/popover/svg-keyboard-popover.component.html
@@ -1,4 +1,4 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/src/components/svg/popover/svg-keyboard-popover.component.ts b/src/components/svg/popover/svg-keyboard-popover.component.ts
index 57d6272c..030233ce 100644
--- a/src/components/svg/popover/svg-keyboard-popover.component.ts
+++ b/src/components/svg/popover/svg-keyboard-popover.component.ts
@@ -16,6 +16,7 @@ export class SvgKeyboardPopoverComponent implements OnInit {
private popoverEnabled: boolean;
private keyEditConfig: { moduleId: number, keyId: number };
+ private popoverInitKeyAction: KeyAction;
constructor() {
this.keyEditConfig = {
@@ -32,7 +33,9 @@ export class SvgKeyboardPopoverComponent implements OnInit {
moduleId,
keyId
};
- this.showPopover();
+
+ let keyActionToEdit: KeyAction = this.moduleConfig[moduleId].keyActions.elements[keyId];
+ this.showPopover(keyActionToEdit);
}
}
@@ -41,12 +44,14 @@ export class SvgKeyboardPopoverComponent implements OnInit {
this.hidePopover();
}
- showPopover(): void {
+ showPopover(keyAction?: KeyAction): void {
+ this.popoverInitKeyAction = keyAction;
this.popoverEnabled = true;
}
hidePopover(): void {
this.popoverEnabled = false;
+ this.popoverInitKeyAction = undefined;
}
changeKeyAction(keyAction: KeyAction): void {