Просмотр исходного кода

multitab cdb edition ok + fixes style hide-tabs

Nicolas Cannasse 6 лет назад
Родитель
Сommit
5e62073406
6 измененных файлов с 137 добавлено и 32 удалено
  1. 37 3
      bin/style.css
  2. 11 3
      bin/style.less
  3. 12 5
      hide/Ide.hx
  4. 22 3
      hide/comp/Tabs.hx
  5. 1 1
      hide/comp/cdb/Cell.hx
  6. 54 17
      hide/view/CdbTable.hx

+ 37 - 3
bin/style.css

@@ -380,6 +380,8 @@ input[type=checkbox]:checked:after {
 }
 .hide-tabs {
   flex: 0 0 320px;
+  position: relative;
+  height: 100%;
 }
 .hide-tabs > .tabs-header {
   background-color: #111;
@@ -389,22 +391,28 @@ input[type=checkbox]:checked:after {
 .hide-tabs > .tabs-header > div {
   cursor: pointer;
   display: inline-block;
-  background-color: #202020;
-  padding: 2px 5px;
+  color: #888;
+  background-color: #151515;
+  padding: 3px 8px;
   border: 1px solid #444;
   margin-left: -1px;
+  border-top-right-radius: 5px;
+  user-select: none;
 }
 .hide-tabs > .tabs-header > div.active {
   background-color: #222;
+  color: #ccc;
   border-bottom-color: #222;
+  border-top-right-radius: 0px;
 }
 .hide-tabs > .tabs-header > div:hover {
   background-color: #282828;
 }
 .hide-tabs .tab {
-  height: 100%;
+  max-height: 100%;
   display: flex;
   flex-direction: column;
+  position: absolute;
 }
 .searchBox {
   display: none;
@@ -631,6 +639,19 @@ input[type=checkbox]:checked:after {
   opacity: 50%;
 }
 /* FX Editor */
+.fx-script {
+  height: 500px;
+  width: 500px;
+}
+.fx-scriptParams {
+  margin: 10px;
+}
+.fx-scriptParams .slider {
+  margin: 10px;
+}
+.fx-scriptParams .checkBox {
+  margin: 10px;
+}
 .fx-animpanel {
   position: relative;
 }
@@ -1043,3 +1064,16 @@ div.sp-container input {
 div.sp-container input:hover {
   border-color: white;
 }
+/* Animation Event Editor */
+.event-editor .title {
+  text-align: center;
+  font-weight: bold;
+  font-size: 12px;
+  margin: 4px;
+  background-color: #1e1e1e;
+}
+.event-editor .event .label {
+  text-align: center;
+  display: inline-block;
+  width: 50%;
+}

+ 11 - 3
bin/style.less

@@ -405,6 +405,8 @@ input[type=checkbox] {
 
 .hide-tabs {
 	flex : 0 0 320px;
+	position: relative;
+	height: 100%;
 	&>.tabs-header {
 		background-color : #111;
 		padding : 2px;
@@ -412,13 +414,18 @@ input[type=checkbox] {
 		&>div {
 			cursor : pointer;
 			display : inline-block;
-			background-color : #202020;
-			padding : 2px 5px;
+			color: #888;
+			background-color : #151515;
+			padding : 3px 8px;
 			border : 1px solid #444;
 			margin-left : -1px;
+			border-top-right-radius: 5px;
+			user-select: none;
 			&.active {
 				background-color : #222;
+				color : #ccc;
 				border-bottom-color : #222;
+				border-top-right-radius: 0px;
 			}
 			&:hover {
 				background-color : #282828;
@@ -428,9 +435,10 @@ input[type=checkbox] {
 	}
 
 	.tab {
-		height: 100%;
+		max-height: 100%;
 		display: flex;
 		flex-direction: column;
+		position: absolute;
 	}
 }
 

+ 12 - 5
hide/Ide.hx

@@ -8,7 +8,7 @@ class Ide {
 	public var projectDir(get,never) : String;
 	public var resourceDir(get,never) : String;
 	public var initializing(default,null) : Bool;
-	public var appPath(get, never): String;
+	public var appPath(get, null): String;
 
 	public var mouseX : Int = 0;
 	public var mouseY : Int = 0;
@@ -308,7 +308,7 @@ class Ide {
 					for( f in found )
 						if( haxe.Json.stringify(f.state) == haxe.Json.stringify(fs.state) ) {
 							f.fullScreen = true;
-							return;
+							break;
 						}
 				}
 			}
@@ -359,22 +359,25 @@ class Ide {
 
 	function get_ideConfig() return config.global.source.hide;
 	function get_currentConfig() return config.user;
+
 	function get_appPath() {
+		if( appPath != null )
+			return appPath;
 		var path = js.Node.process.argv[0].split("\\").join("/").split("/");
 		path.pop();
 		var hidePath = path.join("/");
 		if( !sys.FileSystem.exists(hidePath + "/package.json") ) {
 			var prevPath = new haxe.io.Path(hidePath).dir;
 			if( sys.FileSystem.exists(prevPath + "/hide.js") )
-				return prevPath;
+				return appPath = prevPath;
 			// nwjs launch
 			var path = Sys.getCwd();
 			if( sys.FileSystem.exists(path+"/hide.js") )
-				return path;
+				return appPath = path;
 			message("Hide application path was not found");
 			Sys.exit(0);
 		}
-		return hidePath;
+		return appPath = hidePath;
 	}
 
 	public function setClipboard( text : String ) {
@@ -753,6 +756,10 @@ class Ide {
 
 		// database
 		var db = menu.find(".database");
+		if( database.sheets.length > 0 )
+			new Element("<menu label='All'>").appendTo(db.find(".dbview")).click(function(_) {
+				open("hide.view.CdbTable", {});
+			});
 		for( s in database.sheets ) {
 			if( s.props.hide ) continue;
 			new Element("<menu>").attr("label", s.name).appendTo(db.find(".dbview")).click(function(_) {

+ 22 - 3
hide/comp/Tabs.hx

@@ -10,20 +10,37 @@ class Tabs extends Component {
 		element.addClass("hide-tabs");
 		header = new Element("<div>").addClass("tabs-header").prependTo(element);
 		syncTabs();
-		currentTab = new Element(getTabs()[0]);
+		var t = getTabs()[0];
+		if( t != null ) currentTab = new Element(t);
+	}
+
+	public function createTab( title : String, ?icon : String ) {
+		var e = new Element('<div class="tab" name="$title">');
+		if( icon != null ) e.attr("icon",icon);
+		e.appendTo(element);
+		syncTabs();
+		if( currentTab == null )
+			currentTab = e;
+		return e;
 	}
 
 	function set_currentTab( e : Element ) {
+		var index = Std.parseInt(e.attr("index"));
 		getTabs().hide();
 		e.show();
-		header.children().removeClass("active").filter("[index=" + e.attr("index") + "]").addClass("active");
-		return currentTab = e;
+		header.children().removeClass("active").filter("[index=" + index + "]").addClass("active");
+		currentTab = e;
+		onTabChange(index);
+		return e;
 	}
 
 	public function getTabs() : Element {
 		return element.children(".tab");
 	}
 
+	public dynamic function onTabChange( index : Int ) {
+	}
+
 	function syncTabs() {
 		header.html("");
 		var index = 0;
@@ -37,6 +54,8 @@ class Tabs extends Component {
 			tab.appendTo(header);
 			tab.click(function(_) currentTab = t);
 		}
+		if( currentTab != null )
+			this.currentTab = currentTab;
 	}
 
 }

+ 1 - 1
hide/comp/cdb/Cell.hx

@@ -113,7 +113,7 @@ class Cell extends Component {
 				out.push(v);
 			}
 			if( out.length == 0 )
-				return "[]";
+				return "";
 			return out.join(", ");
 		case TProperties:
 			var ps = sheet.getSub(c);

+ 54 - 17
hide/view/CdbTable.hx

@@ -2,39 +2,76 @@ package hide.view;
 
 class CdbTable extends hide.ui.View<{ path : String }> {
 
-	var sheet : cdb.Sheet;
+	var sheets : Array<cdb.Sheet>;
+	var tabContents : Array<Element>;
 	var editor : hide.comp.cdb.Editor;
 
-	public function new(state) {
+	public function new( ?state ) {
 		super(state);
-		for( s in ide.database.sheets )
-			if( s.name == state.path ) {
-				sheet = s;
-				break;
-			}
+		updateSheet();
+	}
+
+	function updateSheet() {
+		if( state.path == null )
+			sheets = [for( s in ide.database.sheets ) if( !s.props.hide ) s];
+		else {
+			for( s in ide.database.sheets )
+				if( s.name == state.path ) {
+					sheets = [s];
+					break;
+				}
+		}
 	}
 
 	override function onActivate() {
-		editor.focus();
+		if( editor != null ) editor.focus();
+		chromeFix();
+	}
+
+	function setEditor(index:Int) {
+		if( editor != null )
+			editor.remove();
+		editor = new hide.comp.cdb.Editor(sheets[index],config,ide.databaseApi,tabContents[index]);
+		editor.onFocus = activate;
+		editor.undo = undo;
+	}
+
+	function chromeFix() {
+		// bugfix chrome : for some reason, the tabs does not appear
+		// doing this will turn them back...
+		if( sheets != null && sheets.length > 1 ) {
+			var tabs = element.find(".hide-tabs");
+			tabs.css({ height : "100px" });
+			haxe.Timer.delay(function() tabs.css({ height : "" }), 100);
+		}
 	}
 
 	override function onDisplay() {
-		if( sheet == null ) {
-			element.text("Sheet not found '" + state.path + "'");
+		if( sheets == null ) {
+			element.text("CDB sheet not found '" + state.path + "'");
 			return;
 		}
-		element.addClass("hide-scroll");
-		editor = new hide.comp.cdb.Editor(sheet,config,ide.databaseApi,element);
-		editor.onFocus = activate;
+		var tabs = sheets.length == 1 ? null : new hide.comp.Tabs(element);
+		if( tabs != null )
+			tabs.onTabChange = setEditor;
+		tabContents = [];
+		for( sheet in sheets ) {
+			var tab = tabs == null ? element : tabs.createTab(sheet.name);
+			var sc = new hide.comp.Scrollable(tab);
+			tabContents.push(sc.element);
+		}
+		if( sheets.length > 0 )
+			setEditor(0);
+
 		watch(@:privateAccess ide.databaseFile, () -> {
-			editor.syncSheet(ide.database);
-			editor.refresh();
+			updateSheet();
+			rebuild();
 		});
-		undo = editor.undo;
-		new Element("<div style='width:100%; height:300px'></div>").appendTo(element);
 	}
 
 	override function getTitle() {
+		if( state.path == null )
+			return "CDB";
 		return state.path.charAt(0).toUpperCase() + state.path.substr(1);
 	}