Skip to content

Commit

Permalink
add tabs ui
Browse files Browse the repository at this point in the history
  • Loading branch information
hikipuro committed Oct 23, 2018
1 parent aba9503 commit 66fe87a
Show file tree
Hide file tree
Showing 22 changed files with 376 additions and 61 deletions.
1 change: 1 addition & 0 deletions src/tea/components/BoxCollider.ts
Expand Up @@ -45,6 +45,7 @@ export class BoxCollider extends Collider {
return null;
}
var boxCollider = new BoxCollider(app);
boxCollider.enabled = json.enabled;
boxCollider.center = Tea.Vector3.fromArray(json.center);
boxCollider.size = Tea.Vector3.fromArray(json.size);
return boxCollider;
Expand Down
1 change: 1 addition & 0 deletions src/tea/components/Camera.ts
Expand Up @@ -430,6 +430,7 @@ export class Camera extends Component {
return null;
}
var camera = new Camera(app);
camera.enabled = json.enabled;
camera.depth = json.depth;
camera.clearFlags = Tea.CameraClearFlags[json.clearFlags as string];
camera.fieldOfView = json.fieldOfView;
Expand Down
1 change: 1 addition & 0 deletions src/tea/components/Light.ts
Expand Up @@ -61,6 +61,7 @@ export class Light extends Component {
return null;
}
var light = new Light(app);
light.enabled = json.enabled;
light.color = Tea.Color.fromArray(json.color);
light.intensity = json.intensity;
light.range = json.range;
Expand Down
1 change: 1 addition & 0 deletions src/tea/components/LineRenderer.ts
Expand Up @@ -84,6 +84,7 @@ export class LineRenderer extends Renderer {
return null;
}
var lineRenderer = new LineRenderer(app);
lineRenderer.enabled = json.enabled;
return lineRenderer;
}

Expand Down
1 change: 1 addition & 0 deletions src/tea/components/MeshFilter.ts
Expand Up @@ -31,6 +31,7 @@ export class MeshFilter extends Component {
return null;
}
var meshFilter = new MeshFilter(app);
meshFilter.enabled = json.enabled;
meshFilter.mesh = Tea.Mesh.fromJSON(app, json.mesh);
return meshFilter;
}
Expand Down
1 change: 1 addition & 0 deletions src/tea/components/MeshRenderer.ts
Expand Up @@ -181,6 +181,7 @@ export class MeshRenderer extends Renderer {
return null;
}
var meshRenderer = new MeshRenderer(app);
meshRenderer.enabled = json.enabled;
meshRenderer.receiveShadows = json.receiveShadows;
meshRenderer._wireframe = json.wireframe;
meshRenderer.material = Tea.Material.fromJSON(app, json.material);
Expand Down
1 change: 1 addition & 0 deletions src/tea/components/ParticleSystem.ts
Expand Up @@ -290,6 +290,7 @@ export class ParticleSystem extends Component {
return null;
}
var particleSystem = new ParticleSystem(app);
particleSystem.enabled = json.enabled;
return particleSystem;
}

Expand Down
1 change: 1 addition & 0 deletions src/tea/components/Rigidbody.ts
Expand Up @@ -319,6 +319,7 @@ export class Rigidbody extends Component {
return null;
}
var rigidbody = new Rigidbody(app);
rigidbody.enabled = json.enabled;
return rigidbody;
}

Expand Down
1 change: 1 addition & 0 deletions src/tea/components/ShadowMapCamera.ts
Expand Up @@ -39,6 +39,7 @@ export class ShadowMapCamera extends Camera {
return null;
}
var shadowMapCamera = new ShadowMapCamera(app);
shadowMapCamera.enabled = json.enabled;
return shadowMapCamera;
}
}
1 change: 1 addition & 0 deletions src/tea/components/TextMesh.ts
Expand Up @@ -225,6 +225,7 @@ export class TextMesh extends Component {
return null;
}
var textMesh = new TextMesh(app);
textMesh.enabled = json.enabled;
//textMesh.material = Tea.Material.fromJSON(json.material);
textMesh._characterSize = json.characterSize;
textMesh._lineSpacing = json.lineSpacing;
Expand Down
26 changes: 18 additions & 8 deletions src/tea/editor/Editor.ts
Expand Up @@ -30,6 +30,7 @@ import { VResizeBar } from "./basic/VResizeBar";
import { Panel } from "./containers/Panel";
import { HLayout } from "./containers/HLayout";
import { VLayout } from "./containers/VLayout";
import { Tabs, TabItem } from "./containers/Tabs";
import { Window } from "./containers/Window";

import { BoxCollider } from "./components/BoxCollider";
Expand Down Expand Up @@ -68,6 +69,8 @@ Vue.component("VResizeBar", VResizeBar);
Vue.component("Panel", Panel);
Vue.component("HLayout", HLayout);
Vue.component("VLayout", VLayout);
Vue.component("Tabs", Tabs);
Vue.component("TabItem", TabItem);
Vue.component("Window", Window);

Vue.component("BoxCollider", BoxCollider);
Expand Down Expand Up @@ -115,15 +118,22 @@ Vue.component("TextMesh", TextMesh);
</VLayout>
</Panel>
</HLayout>
<HLayout class="BottomLayout">
<Panel class="BottomPanel">
<TreeView ref="project" tabindex="1"></TreeView>
</Panel>
<Panel class="FileList">
<TreeView ref="fileList" tabindex="2"></TreeView>
</Panel>
<Tabs class="Bottom">
<TabItem name="Project">
<HLayout class="BottomLayout">
<Panel class="BottomPanel">
<TreeView ref="project" tabindex="1"></TreeView>
</Panel>
<Panel class="FileList">
<TreeView ref="fileList" tabindex="2"></TreeView>
</Panel>
</HLayout>
</TabItem>
<TabItem>
test
</TabItem>
<VResizeBar ref="projectResize" :isTop="true"></VResizeBar>
</HLayout>
</Tabs>
</VLayout>
<Panel ref="right" class="RightPanel">
<InspectorView ref="inspector"></InspectorView>
Expand Down
42 changes: 21 additions & 21 deletions src/tea/editor/EditorBehavior.ts
Expand Up @@ -157,21 +157,24 @@ export class EditorBehavior {
var inspectorView = this.editor.inspectorView;

inspectorView._commands = this.commands;
inspectorView.$on("update", (key: string, value: any) => {
if (hierarchyView.getSelectedItem() == null) {
return;
}
var object3d = this.hierarchyViewCommand.getSelectedObject();
if (object3d == null) {
return;
}
switch (key) {
case "name":
hierarchyView.getSelectedItem().model.text = value;
break;
case "rotation":
this.objectInspectorCommand.snoozeUpdateTimer(1000);
break;
inspectorView.$on("update", (type: string, key: string, value: any) => {
if (type === "ObjectInspector") {
if (hierarchyView.getSelectedItem() == null) {
return;
}
var object3d = this.hierarchyViewCommand.getSelectedObject();
if (object3d == null) {
return;
}
this.editorCommand.isChanged = true;
switch (key) {
case "name":
hierarchyView.getSelectedItem().model.text = value;
break;
case "rotation":
this.objectInspectorCommand.snoozeUpdateTimer(1000);
break;
}
}
});
inspectorView.$on("change", (type: any, property: string, value: any) => {
Expand Down Expand Up @@ -273,12 +276,9 @@ export class EditorBehavior {
}

setScene(scene: Tea.Scene) {
var onResize = () => {
this.updateScreenSize();
};
var renderer = scene.app.renderer;
renderer.removeListener("resize", onResize);
renderer.on("resize", onResize);
renderer.off("resize", this.updateScreenSize);
renderer.on("resize", this.updateScreenSize);
renderer.once("update", () => {
this.hierarchyViewCommand.update(true);
});
Expand All @@ -291,7 +291,7 @@ export class EditorBehavior {
this.objectInspectorCommand.scene = scene;
}

updateScreenSize(): void {
updateScreenSize = (): void => {
var app = this.scene.app;
var aspect = this.editor.$refs.aspect as SelectAspect;
var canvas = this.editor.$refs.canvas as HTMLCanvasElement;
Expand Down
14 changes: 10 additions & 4 deletions src/tea/editor/ObjectInspector.ts
Expand Up @@ -2,7 +2,6 @@ import Vue from "vue";
import Component from "vue-class-component";
import * as Tea from "../Tea";
import { ComponentPanel } from "./components/ComponentPanel";
import { UICommands } from "./commands/UICommands";

@Component({
template: `
Expand Down Expand Up @@ -38,6 +37,7 @@ import { UICommands } from "./commands/UICommands";
v-for="(item, index) in components"
:type="item"
:key="index"
@update="onUpdateComponent"
@change="onChangeComponent"
@config="onComponentMenu">
</ComponentPanel>
Expand All @@ -64,7 +64,6 @@ import { UICommands } from "./commands/UICommands";
}
})
export class ObjectInspector extends Vue {
_commands: UICommands;
_object3d: Tea.Object3D;
name: string;
isActive: boolean;
Expand Down Expand Up @@ -160,6 +159,7 @@ export class ObjectInspector extends Vue {
if (this._object3d != null) {
this._object3d.isActive = bValue;
}
this.$emit("update", "ObjectInspector", "isActive", bValue);
break;
case "name":
var sValue = value as string;
Expand All @@ -178,7 +178,7 @@ export class ObjectInspector extends Vue {
if (this._object3d != null) {
this._object3d.name = sValue;
}
this.$emit("update", "name", sValue);
this.$emit("update", "ObjectInspector", "name", sValue);
break;
}
}
Expand All @@ -191,6 +191,7 @@ export class ObjectInspector extends Vue {
if (this._object3d != null) {
this._object3d.localPosition.set(x, y, z);
}
this.$emit("update", "ObjectInspector", "position", position);
}

protected onUpdateRotation(x: number, y: number, z: number): void {
Expand All @@ -201,7 +202,7 @@ export class ObjectInspector extends Vue {
if (this._object3d != null) {
this._object3d.localRotation.setEuler(x, y, z);
}
this.$emit("update", "rotation");
this.$emit("update", "ObjectInspector", "rotation", rotation);
}

protected onUpdateScale(x: number, y: number, z: number): void {
Expand All @@ -212,6 +213,7 @@ export class ObjectInspector extends Vue {
if (this._object3d != null) {
this._object3d.localScale.set(x, y, z);
}
this.$emit("update", "ObjectInspector", "rotation", scale);
}

protected onChangePosition(x: number, y: number, z: number): void {
Expand Down Expand Up @@ -241,6 +243,10 @@ export class ObjectInspector extends Vue {
});
}

protected onUpdateComponent(property: string, value: any): void {
this.$emit("update", "ObjectInspector", property, value);
}

protected onChangeComponent(type: any, property: string, value: any): void {
this.$emit("change", type, property, value);
}
Expand Down
53 changes: 41 additions & 12 deletions src/tea/editor/commands/EditorCommand.ts
Expand Up @@ -16,18 +16,29 @@ export class EditorCommand {
inspectorView: InspectorView;

filename: string;
isChanged: boolean;

protected _isChanged: boolean;
protected eventHandler: EventDispatcher;

constructor() {
this.filename = null;
this.isChanged = false;
this._isChanged = false;
this.eventHandler = new EventDispatcher();
this.updateWindowTitle();
}

get isChanged(): boolean {
return this._isChanged;
}
set isChanged(value: boolean) {
if (this._isChanged === value) {
return;
}
this._isChanged = value;
this.updateWindowTitle();
}

newScene(): void {
if (this.isChanged) {
newScene(force: boolean = false): void {
if (force === false && this._isChanged) {
this.showConfirmSaveDialog((response: string) => {
switch (response) {
case "Save":
Expand All @@ -39,8 +50,7 @@ export class EditorCommand {
this.saveScene();
break;
case "Don't Save":
this.isChanged = false;
this.newScene();
this.newScene(true);
break;
}
});
Expand All @@ -59,9 +69,9 @@ export class EditorCommand {
this.editor.setScene(scene);
}

openScene(): void {
openScene(force: boolean = false): void {
console.log("openScene");
if (this.isChanged) {
if (force === false && this._isChanged) {
this.showConfirmSaveDialog((response: string) => {
switch (response) {
case "Save":
Expand All @@ -73,8 +83,7 @@ export class EditorCommand {
this.saveScene();
break;
case "Don't Save":
this.isChanged = false;
this.openScene();
this.openScene(true);
break;
}
});
Expand All @@ -96,7 +105,7 @@ export class EditorCommand {

saveScene(): void {
console.log("saveScene");
if (this.isChanged === false) {
if (this._isChanged === false) {
this.eventHandler.emit("save", null);
return;
}
Expand Down Expand Up @@ -143,6 +152,26 @@ export class EditorCommand {
);
}

protected updateWindowTitle(): void {
if (remote == null || remote.getCurrentWindow == null) {
return;
}
var window = remote.getCurrentWindow();
var title = window.getTitle();
var suffix = title.substr(-2);
if (this._isChanged) {
if (suffix !== " *") {
title += " *";
window.setTitle(title);
}
} else {
if (suffix === " *") {
title = title.substr(0, title.length - 2);
window.setTitle(title);
}
}
}

protected save(): void {
var filename = this.filename;
var json = this.scene.toJSON();
Expand Down
6 changes: 3 additions & 3 deletions src/tea/editor/commands/UICommands.ts
Expand Up @@ -152,15 +152,15 @@ export class UICommands {
}
inspectorView.hide();
//setTimeout(() => {
var commands = this;
//var commands = this;
inspectorView.component = ObjectInspector.extend({
created: function () {
//(this as any)._object3d = object3d;
var self = this as ObjectInspector;
self._commands = commands;
//self._commands = commands;
self.setObject3D(object3d);
object3d = undefined;
commands = undefined;
//commands = undefined;
}
});
//inspectorView.setObject3D(object3d);
Expand Down

0 comments on commit 66fe87a

Please sign in to comment.