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

Macro UI #87

Merged
merged 206 commits into from Sep 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
206 commits
Select commit Hold shift + click to select a range
74c9e3d
Changed: Select 2 z-index to 1
Aug 25, 2016
2509a28
Merge branch 'master' of https://github.com/UltimateHackingKeyboard/a…
Aug 25, 2016
fa28404
Added: clone method to MacroAction
Aug 28, 2016
b0b151c
Added: angular/forms and ng2-slider-component to package.json
Aug 28, 2016
e1fd445
Added: Adding new macro (WIP, does not work as should)
Aug 28, 2016
0f2f483
Added: Edit action to macro item component
Aug 28, 2016
0a15dea
Changed: List real macro data in MacroComponent, implement adding and…
Aug 28, 2016
f3c55d1
Changed: Ignore Sublime Text projects in .gitignore
Aug 28, 2016
046546f
Added: Macro popover component
Aug 28, 2016
c7e3282
Added: Macro popover delay tab component
Aug 28, 2016
cacb397
Added: Macro popover macro mouse tab component (extended mouse tab co…
Aug 28, 2016
9788c5c
Added: Macro text tab component
Aug 28, 2016
a583bcf
Added: Ignore sublime text project workspace file
Aug 28, 2016
7e582b4
Changed: Use macroAction data directly in macro text component
Aug 28, 2016
2c6b45a
Changed: Fix saving edited changes, change how MacroPopoverComponent …
Aug 28, 2016
d69a4ed
Fixed: Macro name editing
Aug 28, 2016
dc93758
Fixed: Macro action icon hover states
Aug 28, 2016
cbeea59
Added: Delete macro action functionality
Aug 28, 2016
de59feb
Fixed: Macro delay editing
Aug 28, 2016
bdaad15
Added: More icons to icon component
Aug 28, 2016
030f130
Added: Placeholders for all macro types to MacroItemComponent
Aug 28, 2016
4899f1e
Added: ContenteditableModel component
Aug 28, 2016
ebd8cd0
Fixed: Handle showing delay in seconds in MacroDelayTabComponent
Aug 28, 2016
9a647aa
Removed: Unnecessary directive imports from MacroComponent and MacroP…
Aug 28, 2016
d0d7ca8
Removed: Ng2SliderComponent
Aug 30, 2016
7d2ffcc
Changed: Move some imports to app.module.ts
Aug 30, 2016
667bf07
Changed: Move MacroItemComponent under macro folder and lots of chang…
Aug 30, 2016
3c819cd
Fixed: MacroItemComponent import in MacroTabComponent
Aug 30, 2016
69e46b0
Changed: Rename MacroPopoverComponent to MacroActionEditorComponent a…
Aug 30, 2016
0825500
Changed: Various changes to MacroComponent to accommodate new structu…
Aug 30, 2016
633fe1d
Changed: Title of macro text
Aug 30, 2016
c720870
Changed: Title of macro delay
Aug 30, 2016
2ace247
Added: Dotted underline for editable macro name
Aug 30, 2016
beb546a
Changed: Some action titles in MacroItemComponent
Aug 30, 2016
ddf4ece
Added: Macro mouse tab to macro action editor
Aug 30, 2016
c143f8e
Added: Macro Mouse tab (WIP)
Aug 30, 2016
4dd6801
Added: Macro mouse action tab styles
Aug 30, 2016
3356926
Changed: Make preset buttons in macro delay
Aug 30, 2016
08491fb
Changed: Order of macro action editor tabs
Aug 30, 2016
edf73b4
Changed: Type of new action to TextMacroAction
Aug 30, 2016
f54e3f9
Changed: Small text changes
Aug 30, 2016
10ca5fb
Changed: Improve macro mouse component visuals
Aug 30, 2016
5d2b7ce
Changed: Fix macro actions list ID
Aug 30, 2016
a464e66
Changed: Improve macro item styles
Aug 30, 2016
8732200
Changed: Improve macro action editor styles
Aug 30, 2016
9d7dd35
Changed: Add UhkConfigurationService as provider in app.module.ts and…
Aug 31, 2016
11702e7
Added: Key press macro component to macro action editor
Aug 31, 2016
f8d5056
Removed: UhkConfigurationService provider from macro component
Aug 31, 2016
9adf0ed
Removed: FORM_DIRECTIVES from macro mouse component
Aug 31, 2016
f344aca
Changed: Improve macro mouse styles
Aug 31, 2016
b1f251c
Merge remote-tracking branch 'upstream/master'
Sep 1, 2016
631bff3
Fixed: Paths to components
Sep 1, 2016
34caf8a
Changed: New macro action title
Sep 1, 2016
4c7a96b
Added: Highlight macro item when editing
Sep 1, 2016
e702641
Fixed: Remove macro item highlight when canceling edit
Sep 1, 2016
cf1d15a
Added: Dragula drag and drop component to package.json
Sep 1, 2016
9906933
Added: Sorting macro actions
Sep 1, 2016
d518aaa
Fixed: Some SCSS file indents
Sep 1, 2016
db39209
Fixed: More linting issues
Sep 1, 2016
7dbf147
Fixed: Even more linting errors
Sep 1, 2016
8af5c83
Changed: Add pixels text to mouse move and scroll form
Sep 1, 2016
22cd0a0
Changed: Remove "ward" text from macro item component titles to make …
Sep 1, 2016
628f3eb
Fixed: Support negative values in MacroItemComponent titles for mouse…
Sep 1, 2016
e94aabb
Fixed: Changing macro name
Sep 1, 2016
b8913e7
Added: Ability to set custom title for macro action
Sep 1, 2016
dd19610
Merge remote-tracking branch 'upstream/master'
Sep 1, 2016
d285b82
Added: Various index.ts files
Sep 1, 2016
3628206
Changed: Rename contenteditable folder
Sep 1, 2016
498ada3
Removed: moduleId from macro components
Sep 1, 2016
8bb5aaf
Added: Macro components to app.module.ts
Sep 1, 2016
8610214
Fixed: Even more linting issues
Sep 1, 2016
4414dc2
Fixed: New macro action initial title
Sep 1, 2016
2a91b32
Changed: Use renderer.invokeElementmethod in contenteditableModel
Sep 1, 2016
eff03e3
Changed: Rename some variables
Sep 1, 2016
fbd6512
Added: Focus delay field when selecting the tab in macro action editor
Sep 1, 2016
0aa361c
Changed: Disable linting for several parameters used in templates etc.
Sep 1, 2016
4931a5a
Removed: Some unused imports
Sep 1, 2016
7204ae1
Fixed: Removed import that should've been there
Sep 1, 2016
5ed2e29
Changed: Some z-indexes to more reasonable values in line with bootstrap
Sep 1, 2016
9becd28
Added: longPressEnabled variable to KeypressTabComponent
Sep 2, 2016
aa1f354
Changed: Rename tabName variable to TabName
Sep 2, 2016
0c9a71a
Changed: Render macro mouse buttons as a loop and handle them as array
Sep 2, 2016
ff7bcae
Changed: Improve mouse macro click/hold/release UI visuals a bit
Sep 2, 2016
618bcff
Changed: Add some variable types in MacroAction
Sep 3, 2016
f6045c1
Added: KeyMacroAction class
Sep 3, 2016
3debd46
Added: MouseButtonMacroAction class
Sep 3, 2016
446a0bf
Changed: Refactor MacroAction handling for key and mouse buttons, add…
Sep 3, 2016
0539d36
Added: Setting keypress macro action selections
Sep 3, 2016
5afe1b9
Added: Adding mouse button macro action selected buttons
Sep 3, 2016
c555f46
Changed: Render selected keys and mouse buttons in MacroItemComponent…
Sep 3, 2016
7645146
Removed: Macro action custom title
Sep 4, 2016
8343e77
Changed: Make flattening scancodes JSON in macro item component more …
Sep 4, 2016
44a84de
Changed: Simplify button handling when creating macro item title
Sep 4, 2016
904314b
Added: lodash library
Sep 4, 2016
65f8458
Changed: Replace MacroAction.clone with lodash cloneDeep
Sep 4, 2016
a509145
Added: Remember to save box if changes to macro have been made, disca…
Sep 4, 2016
171541a
Changed: Replace macro item getScancodeLabel method with lodash find
Sep 4, 2016
f1056f5
Changed: Use lodash clonedeep in macro action editor
Sep 4, 2016
85b30b3
Fixed: Getting key scancode for macro item title
Sep 4, 2016
9ca1d24
Changed: Type of setDelay param in MacroDelayComponent
Sep 4, 2016
0954e55
Added: Converting macro action to the correct type when saving
Sep 4, 2016
541daca
Fixed: Some linting issues
Sep 4, 2016
4dcac59
Added: EditableMacroAction class
Sep 4, 2016
07f1f89
Changed: Use EditableMacroAction class in macro action editor
Sep 4, 2016
5a4a924
Changed: Mark macro as changed when its name is changed
Sep 5, 2016
1ea4038
Changed: Use EditableMacroAction in macro delay component
Sep 5, 2016
a5538c1
Changed: Use EditableMacroAction in macro text component
Sep 5, 2016
bcb9922
Changed: Use getMouseButtons method in macro item component
Sep 5, 2016
e977438
Changed: Rearrange EditableMacroAction methods, add to and fromKeyAct…
Sep 5, 2016
e43dbcf
Changed: Use EditableMacroAction in macro key component
Sep 5, 2016
ae03dc3
Changed: Use EditableMacroAction in mouse macro component
Sep 5, 2016
4682bcc
Changed: Change KeyMacroAction fromBinary and fromJsObject output typ…
Sep 5, 2016
2da6530
Changed: Match EditableMacroAction mouse button setting methods in Mo…
Sep 5, 2016
3a03ca3
Fixed: Sorting macro actions was not enabled on init
Sep 5, 2016
878e263
Merge remote-tracking branch 'upstream/master'
Sep 5, 2016
87d479f
Fixed: app module imports
Sep 5, 2016
cdc0a16
Changed: Disable tslint ordered imports - grouping for readability is…
Sep 5, 2016
dabe5b2
Changed: Move macro component higher in app.module.ts
Sep 5, 2016
5c92c50
Changed: Sort contenteditable imports
Sep 5, 2016
30dc1fe
Fixed: Macro action editor imports
Sep 5, 2016
908bf2b
Fixed: Macro delay imports
Sep 5, 2016
6d0473a
Fixed: Macro key component imports
Sep 5, 2016
01e0b30
Fixed: Macro mouse component imports
Sep 5, 2016
bcd57fa
Fixed: Macro text component imports
Sep 5, 2016
1f1d6ef
Fixed: Macro item component imports
Sep 5, 2016
1d0ff4f
Fixed: Macro component imports
Sep 5, 2016
d84e400
Changed: Remove some empty lines from mouse tab component
Sep 5, 2016
43c92d5
Fixed: MacroActions imports
Sep 5, 2016
cd9acf9
Changed: Remove unused imports from Press and ReleaseMouseButtonsMacr…
Sep 5, 2016
688055a
Changed: Move EditableMacroAction, KeyMacroAction and MouseButtonMacr…
Sep 5, 2016
8461949
Changed: Some EventEmitter types
Sep 6, 2016
a432661
Changed: Macro Item Component EventEmitter types
Sep 6, 2016
506b101
Changed: Get macro from config by its ID instead of index
Sep 6, 2016
c624f30
Changed: Use native ES6 find to get scancode in MacroItemComponent
Sep 6, 2016
cee957d
Merge remote-tracking branch 'upstream/master'
Sep 7, 2016
50f937d
Fixed: Small typo in MapperService.scanCodeToText method
Sep 7, 2016
0a70e67
Removed: Unnecessary mouse button macro action classes
Sep 7, 2016
83baee1
Removed: lodash library
Sep 7, 2016
86e4d2b
Changed: Change the way macro is cloned for editing
Sep 7, 2016
38bc89e
Removed: Unnecessary constructor operations from Delay, Scroll and Te…
Sep 7, 2016
e71cf1a
Changed: Use MouseButtonMacroAction in MacroActions
Sep 7, 2016
a9a67ac
Changed: Export MacroSubAction, add MouseButtonMacroAction support to…
Sep 7, 2016
f91a740
Removed: Unnecessary constructor operations from MoveMouseMacroAction
Sep 7, 2016
37b19d9
Changed: Use MacroSubAction in KeyMacroAction
Sep 7, 2016
4ab02d5
Changed: Remove non-existing classes and add new ones to macro action…
Sep 7, 2016
d54440a
Removed: lodash from tsconfig.json
Sep 7, 2016
6275023
Changed: Update Dragula version
Sep 7, 2016
8aecd0c
Changed: MouseButtonMacroAction to work similar to KeyMacroAction
Sep 7, 2016
87a8e42
Changed: EditableMacroAction to work with new KeyMacroAction and Mous…
Sep 7, 2016
7778a6e
Changed: How macro item data is created in MacroItemComponent
Sep 7, 2016
60471eb
Changed: uhk-config.json to work with new mouse button macro data format
Sep 7, 2016
d6edf90
Changed: Make MacroMouseTabComponent work with new MacroMouseButton d…
Sep 7, 2016
098f397
Changed: Make macro key component work with new KeyMacroAction
Sep 7, 2016
8bd4100
Changed: Make macro action editor work with new KeyMacroAction and Mo…
Sep 7, 2016
f3b044e
Fixed: Some linting issues
Sep 7, 2016
7c11292
Added: Missing Num lock key to MapperService
Sep 8, 2016
9dc0c5c
Fixed: Don't use Object.values in EditableMacroAction
Sep 8, 2016
31ab5e5
Removed: Some unnecessary console.logs
Sep 8, 2016
3b76a46
Changed: Restore tslint order imports rule
Sep 10, 2016
0f11c49
Fixed: Imports ordering
Sep 10, 2016
acedc85
Changed: Rearrange some imports
Sep 10, 2016
d3e52de
Changed: Grouping of macro component imports
Sep 10, 2016
4d79cb2
Changed: Use includes and set params type in macro component
Sep 10, 2016
32df395
Removed: Unused constructor and ngInit from macro action editor
Sep 10, 2016
b7d9c51
Removed: A comment from macro action editor
Sep 10, 2016
7df4bdf
Removed: Unused constructor from macro key component
Sep 10, 2016
c431a39
Changed: Move click to end of element HTML in side menu
Sep 10, 2016
0bf1738
Changed: Rearrange imports of macro item component
Sep 10, 2016
046f51c
Changed: Rearrange imports of macro text component and remove unused …
Sep 10, 2016
a8a2c85
Changed: Make macro item component title property public
Sep 10, 2016
91872a9
Changed: type of asserMacroActionType in EditableMacroAction and use …
Sep 10, 2016
2508a91
Changed: Use Array.includes in macro mouse component
Sep 10, 2016
30bbbff
Changed: Type of data in macro component macroItemsSub
Sep 10, 2016
b1273d0
Changed: Use SimpleChanges in contenteditable component
Sep 10, 2016
91fb7fe
Changed: Use SimpleChanges in macro item component
Sep 10, 2016
89d8dd1
Changed: Rename macro press/hold/release check methods in MouseButton…
Sep 10, 2016
94bf12f
Changed: Rename press/hold/release check methods in EditableMacroAction
Sep 10, 2016
64188dc
Changed: Move contenteditable directive to another folder and rename it
Sep 10, 2016
6a66441
Refactor
fjozsef Sep 10, 2016
532e3fc
Merge pull request #1 from fjozsef/refactor/macro
laxu Sep 10, 2016
9d5ad67
Removed: Unnecessary propert addedNewAction in macro component
Sep 10, 2016
a8878fd
Change: Minor changes to a bunch of imports
Sep 11, 2016
3b66130
Added: Return type for macro action editor getTabName method
Sep 11, 2016
62b2bee
Added: Return types to macro delay component
Sep 11, 2016
035c890
Changed: Add return types for all macro mouse component methods and u…
Sep 11, 2016
3ecfcbe
Changed: Use switch in macro action editor getTabMacroActionType method
Sep 11, 2016
b3e9dd9
Changed: Small changes to EditableMacroAction and macro key component
Sep 11, 2016
10701be
Changed: Add return types to macro key component methods and use swit…
Sep 11, 2016
7b89636
Added: Return types to MouseButtonMacroAction
Sep 11, 2016
db8c8be
Fixed: Styling of macro items in macro popover
Sep 11, 2016
65f46e0
Fixed: Linting errors
Sep 11, 2016
2f6d26c
Changed: Remove some unnecessary styles from macro item component
Sep 11, 2016
705f817
Changed: Remove extra empty line from macro action editor html
Sep 11, 2016
e75123b
Changed: Allow editing macro action by clicking its title only if it …
Sep 11, 2016
d230637
Changed: Add and remove some comments from macro item component
Sep 11, 2016
b1ffd54
Fixed: Macro item styles
Sep 11, 2016
97be07f
Added: Return types for macro item component methods
Sep 11, 2016
45635b5
Fixed: Some import paths
Sep 11, 2016
c7d97f9
Changed: Improve styles of macro actions
Sep 11, 2016
821c50c
Added: missing return type
fjozsef Sep 11, 2016
d20aaf8
Added: Breakpoints for scrollable macro actions list height
Sep 12, 2016
c2f8ad5
Merge pull request #2 from fjozsef/refactor/macro
laxu Sep 12, 2016
86ca150
Changed: Breakpoints for handling macro action list height
Sep 12, 2016
427867b
Fixed: Extra space :p
Sep 12, 2016
7ee7bff
Fix: Macro list scrolling
fjozsef Sep 12, 2016
59b3c2c
Merge pull request #3 from fjozsef/refactor/macro
laxu Sep 13, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -4,3 +4,5 @@ npm-debug.log
dist
.idea
*.iml
*.sublime-project
*.sublime-workspace
3 changes: 3 additions & 0 deletions package.json
Expand Up @@ -36,16 +36,19 @@
"@angular/common": "2.0.0-rc.6",
"@angular/compiler": "2.0.0-rc.6",
"@angular/core": "2.0.0-rc.6",
"@angular/forms": "2.0.0-rc.6",
"@angular/platform-browser": "2.0.0-rc.6",
"@angular/platform-browser-dynamic": "2.0.0-rc.6",
"@angular/router": "3.0.0-rc.2",
"bootstrap": "^3.3.7",
"browser-stdout": "^1.3.0",
"core-js": "2.4.1",
"dragula": "^3.7.1",
"font-awesome": "^4.6.3",
"handlebars": "^4.0.5",
"jquery": "3.1.0",
"json-loader": "^0.5.4",
"ng2-dragula": "^1.2.0",
"ng2-select2": "0.4.2",
"rxjs": "5.0.0-beta.11",
"select2": "^4.0.3",
Expand Down
30 changes: 24 additions & 6 deletions src/app.module.ts
@@ -1,14 +1,24 @@
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { BrowserModule } from '@angular/platform-browser';

import { DragulaModule } from 'ng2-dragula/ng2-dragula';
import { Select2Component } from 'ng2-select2/ng2-select2';

import { MainAppComponent, appRoutingProviders, routing } from './main-app';
import { ContenteditableDirective } from './directives/contenteditable';

import { KeymapAddComponent, KeymapComponent } from './components/keymap';
import { LayersComponent } from './components/layers';
import { LegacyLoaderComponent } from './components/legacy-loader';
import { MacroComponent } from './components/macro';
import {
MacroActionEditorComponent,
MacroComponent,
MacroDelayTabComponent,
MacroItemComponent,
MacroKeyTabComponent,
MacroMouseTabComponent,
MacroTextTabComponent
} from './components/macro';
import { NotificationComponent } from './components/notification';
import { PopoverComponent } from './components/popover';
import {
Expand All @@ -19,7 +29,6 @@ import {
MouseTabComponent,
NoneTabComponent
} from './components/popover/tab';
import { MacroItemComponent } from './components/popover/tab/macro';
import { CaptureKeystrokeButtonComponent } from './components/popover/widgets/capture-keystroke';
import { IconComponent } from './components/popover/widgets/icon';
import { SideMenuComponent } from './components/side-menu';
Expand All @@ -36,17 +45,17 @@ import {
} from './components/svg/keys';
import { SvgModuleComponent } from './components/svg/module';
import { SvgKeyboardWrapComponent } from './components/svg/wrap';
import { MainAppComponent, appRoutingProviders, routing } from './main-app';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a new line before services.


import { DataProviderService } from './services/data-provider.service';
import { MapperService } from './services/mapper.service';
import {UhkConfigurationService} from './services/uhk-configuration.service';
import { UhkConfigurationService } from './services/uhk-configuration.service';

@NgModule({
declarations: [
Select2Component,
MainAppComponent,
KeymapComponent,
MacroComponent,
LegacyLoaderComponent,
NotificationComponent,
SvgIconTextKeyComponent,
Expand All @@ -73,10 +82,19 @@ import {UhkConfigurationService} from './services/uhk-configuration.service';
NoneTabComponent,
CaptureKeystrokeButtonComponent,
IconComponent,
MacroItemComponent
MacroComponent,
MacroItemComponent,
MacroActionEditorComponent,
MacroDelayTabComponent,
MacroKeyTabComponent,
MacroMouseTabComponent,
MacroTextTabComponent,
ContenteditableDirective
],
imports: [
BrowserModule,
FormsModule,
DragulaModule,
routing
],
providers: [
Expand Down
3 changes: 3 additions & 0 deletions src/components/macro/index.ts
@@ -1,2 +1,5 @@
export * from './macro.component';
export * from './macro.routes';
export * from './macro-item';
export * from './macro-action-editor';
export * from './macro-action-editor/tab';
1 change: 1 addition & 0 deletions src/components/macro/macro-action-editor/index.ts
@@ -0,0 +1 @@
export { MacroActionEditorComponent } from './macro-action-editor.component';
@@ -0,0 +1,46 @@
<div class="action--editor">
<div class="row">
<div class="col-xs-4 editor__tab-links">
<ul class="nav nav-pills nav-stacked">
<li #macroText [class.active]="activeTab === TabName.Text" (click)="selectTab(TabName.Text)">
<a>
<i class="fa fa-font"></i>
<span>Type text</span>
</a>
</li>
<li #macroKeypress [class.active]="activeTab === TabName.Keypress" (click)="selectTab(TabName.Keypress)">
<a>
<i class="fa fa-keyboard-o"></i>
<span>Key action</span>
</a>
</li>
<li #macroMouse [class.active]="activeTab === TabName.Mouse" (click)="selectTab(TabName.Mouse)">
<a>
<i class="fa fa-mouse-pointer"></i>
<span>Mouse action</span>
</a>
</li>
<li #macroDelay [class.active]="activeTab === TabName.Delay" (click)="selectTab(TabName.Delay)">
<a>
<i class="fa fa-clock-o"></i>
<span>Delay</span>
</a>
</li>
</ul>
</div>
<div class="col-xs-8 editor__tabs" [ngSwitch]="activeTab">
<macro-text-tab #tab *ngSwitchCase="TabName.Text" [macroAction]="editableMacroAction"></macro-text-tab>
<macro-key-tab #tab *ngSwitchCase="TabName.Keypress" [macroAction]="editableMacroAction"></macro-key-tab>
<macro-mouse-tab #tab *ngSwitchCase="TabName.Mouse" [macroAction]="editableMacroAction"></macro-mouse-tab>
<macro-delay-tab #tab *ngSwitchCase="TabName.Delay" [macroAction]="editableMacroAction"></macro-delay-tab>
</div>
</div>
<div class="row">
<div class="col-xs-12 flex-button-wrapper editor__actions-container">
<div class="editor__actions">
<button class="btn btn-sm btn-default flex-button" type="button" (click)="onCancelClick()"> Cancel </button>
<button class="btn btn-sm btn-primary flex-button" type="button" (click)="onSaveClick()"> Save </button>
</div>
</div>
</div>
</div>
@@ -0,0 +1,80 @@
.action--editor {
padding-top: 0;
padding-bottom: 0;
border-radius: 0;
border: 0;
}

.nav {
padding-bottom: 1rem;

li {
a {
border-top-right-radius: 0;
border-bottom-right-radius: 0;

&.selected {
font-style: italic;
}

&:hover {
cursor: pointer;
}
}

&.active {
z-index: 2;

a {
&.selected {
font-style: normal;
}

&: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;
}
}
}
}
}

.editor {
&__tabs,
&__tab-links {
padding-top: 1rem;
}

&__tabs {
border-left: 1px solid #ddd;
margin-left: -1.6rem;
padding-left: 3rem;
}

&__actions {
float: right;

&-container {
background: #f5f5f5;
border-top: 1px solid #ddd;
padding: 1rem 1.5rem;
}
}
}

.flex-button-wrapper {
display: flex;
flex-direction: row-reverse;
}

.flex-button {
align-self: flex-end;
}
@@ -0,0 +1,107 @@
import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core';

import {
EditableMacroAction,
MacroAction,
TextMacroAction,
macroActionType
} from '../../../config-serializer/config-items/macro-action';
import { MacroKeyTabComponent } from './tab/macro-key';

enum TabName {
Keypress,
Text,
Mouse,
Delay
};

@Component({
selector: 'macro-action-editor',
template: require('./macro-action-editor.component.html'),
styles: [require('./macro-action-editor.component.scss')],
host: { 'class': 'macro-action-editor' }
})
export class MacroActionEditorComponent implements OnInit {
@Input() macroAction: MacroAction;

@Output() save = new EventEmitter<MacroAction>();
@Output() cancel = new EventEmitter<void>();

@ViewChild('tab') selectedTab: any;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use/create the proper type instead of any.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any is fine here because each tab is quite unique, only some of them implement Tab and I didn't want to create a completely redundant class or interface for these as there are no shared properties or methods.


private editableMacroAction: EditableMacroAction;
private activeTab: TabName;
/* tslint:disable:variable-name: It is an enum type. So it can start with uppercase. */
/* tslint:disable:no-unused-variable: It is used in the template. */
private TabName = TabName;
/* tslint:enable:no-unused-variable */
/* tslint:enable:variable-name */

ngOnInit() {
let macroAction: MacroAction = this.macroAction ? this.macroAction : new TextMacroAction();
this.editableMacroAction = new EditableMacroAction(macroAction.toJsObject());
let tab: TabName = this.getTabName(this.editableMacroAction);
this.activeTab = tab;
}

onCancelClick(): void {
this.cancel.emit();
}

onSaveClick(): void {
try {
const action = this.editableMacroAction;
if (action.isKeyAction()) {
// Could updating the saved keys be done in a better way?
const tab = this.selectedTab as MacroKeyTabComponent;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The selected tab isn't always MacroKeyTabComponent.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should work fine because of the isKeyAction check as changing the tab means also changing EditableMacroAction.macroActionType. So it should not be possible to select a different tab and have isKeyAction pass.

The real solution would be to update the EditableMacroAction every time something is changed in the key press component by providing an output event that gets run every time you change something in it. The reason I didn't do this is because I wanted to keep my changes in the macro components as much as possible and not mess with the other stuff.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, now I understand, it is fine.

action.fromKeyAction(tab.getKeyAction());
}
this.save.emit(action.toClass());
} catch (e) {
// TODO: show error dialog
console.error(e);
}
}

selectTab(tab: TabName): void {
this.activeTab = tab;
this.editableMacroAction.macroActionType = this.getTabMacroActionType(tab);
}

getTabName(action: EditableMacroAction): TabName {
switch (action.macroActionType) {
// Delay action
case macroActionType.DelayMacroAction:
return TabName.Delay;
// Text action
case macroActionType.TextMacroAction:
return TabName.Text;
// Keypress actions
case macroActionType.KeyMacroAction:
return TabName.Keypress;
// Mouse actions
case macroActionType.MouseButtonMacroAction:
case macroActionType.MoveMouseMacroAction:
case macroActionType.ScrollMouseMacroAction:
return TabName.Mouse;
default:
return TabName.Keypress;
}
}

getTabMacroActionType(tab: TabName): string {
switch (tab) {
case TabName.Delay:
return macroActionType.DelayMacroAction;
case TabName.Keypress:
return macroActionType.KeyMacroAction;
case TabName.Mouse:
return macroActionType.MouseButtonMacroAction;
case TabName.Text:
return macroActionType.TextMacroAction;
default:
throw new Error('Could not get macro action type');
}
}

}
4 changes: 4 additions & 0 deletions src/components/macro/macro-action-editor/tab/index.ts
@@ -0,0 +1,4 @@
export { MacroDelayTabComponent } from './macro-delay';
export { MacroKeyTabComponent } from './macro-key';
export { MacroMouseTabComponent } from './macro-mouse';
export { MacroTextTabComponent } from './macro-text';
@@ -0,0 +1 @@
export { MacroDelayTabComponent } from './macro-delay.component';
@@ -0,0 +1,26 @@
<div class="macro-delay">
<div class="row">
<div class="col-xs-12">
<h4>Enter delay in seconds</h4>
</div>
</div>
<div class="row">
<div class="col-xs-4">
<input #macroDelayInput
type="number"
min="0"
max="1000"
step="0.1"
placeholder="Delay amount"
class="form-control"
[(ngModel)]="delay"
(ngModelChange)="setDelay($event)">
</div>
</div>
<div class="row macro-delay__presets">
<div class="col-xs-12">
<h6>Choose a preset</h6>
<button *ngFor="let delay of presets" class="btn btn-sm btn-default"(click)="setDelay(delay)">{{delay}}s</button>
</div>
</div>
</div>
@@ -0,0 +1,16 @@
:host {
display: flex;
flex-direction: column;
position: relative;
}

.macro-delay {
&__presets {
margin-top: 1rem;

button {
margin-right: 0.25rem;
margin-bottom: 0.25rem;
}
}
}