diff --git a/config-serializer/config-items/MouseAction.ts b/config-serializer/config-items/MouseAction.ts index ebd2c3d5..7e2ee4b3 100644 --- a/config-serializer/config-items/MouseAction.ts +++ b/config-serializer/config-items/MouseAction.ts @@ -2,7 +2,7 @@ import {keyActionType, KeyActionId, KeyAction} from './KeyAction'; import {UhkBuffer} from '../UhkBuffer'; import {assertEnum} from '../assert'; -enum MouseActionParam { +export enum MouseActionParam { leftClick, middleClick, rightClick, diff --git a/src/components/popover/popover.component.scss b/src/components/popover/popover.component.scss index 8f6d6783..7a94821f 100644 --- a/src/components/popover/popover.component.scss +++ b/src/components/popover/popover.component.scss @@ -27,4 +27,10 @@ .popover-content { padding: 10px 24px; +} + +mouse-tab.popover-content{ + padding: 10px; + display: flex; + align-items: center; } \ No newline at end of file diff --git a/src/components/popover/tab/mouse-tab.component.scss b/src/components/popover/tab/mouse-tab.component.scss index dec7d231..91e2e139 100644 --- a/src/components/popover/tab/mouse-tab.component.scss +++ b/src/components/popover/tab/mouse-tab.component.scss @@ -1,12 +1,38 @@ :host { display: flex; -} -.mouse-action { - flex: 1; - border-right: 1px solid black; -} + .mouse-action { + flex: 1; + ul{ + border-right: 1px solid #ccc; + li { + a { + border-top-right-radius: 0; + border-bottom-right-radius: 0; + } -.details { - flex: 2; + &.active { + a:after { + content: ''; + display: block; + position: absolute; + width: 0; + height: 0; + top: 0; + right: -4rem; + border-color: transparent transparent transparent #337ab7; + border-style: solid; + border-width: 2rem; + } + } + } + } + } + + .details { + flex: 2; + .btn-placeholder { + visibility: hidden; + } + } } \ No newline at end of file diff --git a/src/components/popover/tab/mouse-tab.component.ts b/src/components/popover/tab/mouse-tab.component.ts index 1acca65f..68aee46b 100644 --- a/src/components/popover/tab/mouse-tab.component.ts +++ b/src/components/popover/tab/mouse-tab.component.ts @@ -1,7 +1,8 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, Renderer} from '@angular/core'; +import {NgSwitch, NgSwitchWhen, NgSwitchDefault} from '@angular/common'; import { KeyActionSaver } from '../key-action-saver'; -import { KeyAction } from '../../../../config-serializer/config-items/KeyAction'; +import {MouseAction, MouseActionParam} from '../../../../config-serializer/config-items/MouseAction'; @Component({ moduleId: module.id, @@ -10,28 +11,134 @@ import { KeyAction } from '../../../../config-serializer/config-items/KeyAction' `
-
+
+
+
+ +
+
+ + + +
+
+ +
+
+
+
+ +
+
+ + + +
+
+ +
+
+
+
+ + + +
+
+
+
+ + +
+
+
+
`, - styles: [require('./mouse-tab.component.scss')] + styles: [require('./mouse-tab.component.scss')], + directives: [NgSwitch, NgSwitchWhen, NgSwitchDefault] }) export class MouseTabComponent implements OnInit, KeyActionSaver { - constructor() { } + private MouseActionParam = MouseActionParam; + private mouseActionParam: MouseActionParam; + private selectedIndex: number; + private selectedButton: HTMLButtonElement; + + constructor(private renderer: Renderer) { + this.selectedIndex = 0; + } ngOnInit() { } keyActionValid(): boolean { - return false; + return !!this.mouseActionParam; } - toKeyAction(): KeyAction { - return undefined; + toKeyAction(): MouseAction { + if (!this.keyActionValid()) { + throw new Error('KeyAction is not valid. No selected mouse action!'); + } + let mouseAction: MouseAction = new MouseAction(); + mouseAction.mouseAction = this.mouseActionParam; + return mouseAction; + } + + changePage(index: number) { + if (index < -1 || index > 3) { + console.error(`Invalid index error: ${index}`); + return; + } + this.selectedIndex = 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); + this.mouseActionParam = mouseActionParam; } }