aboutsummaryrefslogtreecommitdiff
path: root/src/stores
diff options
context:
space:
mode:
Diffstat (limited to 'src/stores')
-rw-r--r--src/stores/NodeCollectionStore.ts21
-rw-r--r--src/stores/NodeStore.ts24
-rw-r--r--src/stores/RootStore.ts16
-rw-r--r--src/stores/StaticTextNodeStore.ts16
-rw-r--r--src/stores/VideoNodeStore.ts17
5 files changed, 94 insertions, 0 deletions
diff --git a/src/stores/NodeCollectionStore.ts b/src/stores/NodeCollectionStore.ts
new file mode 100644
index 000000000..8c7f7623b
--- /dev/null
+++ b/src/stores/NodeCollectionStore.ts
@@ -0,0 +1,21 @@
+import { computed, observable, action } from "mobx";
+import { NodeStore } from "./NodeStore";
+
+export class NodeCollectionStore extends NodeStore {
+
+ @observable
+ public Scale: number = 1;
+
+ @observable
+ public Nodes: NodeStore[] = new Array<NodeStore>();
+
+ @computed
+ public get Transform(): string {
+ return "translate(" + this.X + "px," + this.Y + "px) scale(" + this.Scale + "," + this.Scale + ")";
+ }
+
+ @action
+ public AddNodes(stores: NodeStore[]): void {
+ stores.forEach(store => this.Nodes.push(store));
+ }
+} \ No newline at end of file
diff --git a/src/stores/NodeStore.ts b/src/stores/NodeStore.ts
new file mode 100644
index 000000000..6a734cf44
--- /dev/null
+++ b/src/stores/NodeStore.ts
@@ -0,0 +1,24 @@
+import { computed, observable } from "mobx";
+import { Utils } from "../Utils";
+
+export class NodeStore {
+
+ public Id: string = Utils.GenerateGuid();
+
+ @observable
+ public X: number = 0;
+
+ @observable
+ public Y: number = 0;
+
+ @observable
+ public Width: number = 0;
+
+ @observable
+ public Height: number = 0;
+
+ @computed
+ public get Transform(): string {
+ return "translate(" + this.X + "px, " + this.Y + "px)";
+ }
+} \ No newline at end of file
diff --git a/src/stores/RootStore.ts b/src/stores/RootStore.ts
new file mode 100644
index 000000000..fa551c1d1
--- /dev/null
+++ b/src/stores/RootStore.ts
@@ -0,0 +1,16 @@
+import { action, observable } from "mobx";
+import { NodeStore } from "./NodeStore";
+
+// This globally accessible store might come in handy, although you may decide that you don't need it.
+export class RootStore {
+
+ private constructor() {
+ // initialization code
+ }
+
+ private static _instance: RootStore;
+
+ public static get Instance():RootStore {
+ return this._instance || (this._instance = new this());
+ }
+} \ No newline at end of file
diff --git a/src/stores/StaticTextNodeStore.ts b/src/stores/StaticTextNodeStore.ts
new file mode 100644
index 000000000..7c342a7a2
--- /dev/null
+++ b/src/stores/StaticTextNodeStore.ts
@@ -0,0 +1,16 @@
+import { observable } from "mobx";
+import { NodeStore } from "./NodeStore";
+
+export class StaticTextNodeStore extends NodeStore {
+
+ constructor(initializer: Partial<StaticTextNodeStore>) {
+ super();
+ Object.assign(this, initializer);
+ }
+
+ @observable
+ public Title: string = "";
+
+ @observable
+ public Text: string = "";
+} \ No newline at end of file
diff --git a/src/stores/VideoNodeStore.ts b/src/stores/VideoNodeStore.ts
new file mode 100644
index 000000000..41fae2aff
--- /dev/null
+++ b/src/stores/VideoNodeStore.ts
@@ -0,0 +1,17 @@
+import { observable } from "mobx";
+import { NodeStore } from "./NodeStore";
+
+export class VideoNodeStore extends NodeStore {
+
+ constructor(initializer: Partial<VideoNodeStore>) {
+ super();
+ Object.assign(this, initializer);
+ }
+
+ @observable
+ public Title: string;
+
+ @observable
+ public Url: string;
+
+} \ No newline at end of file