Bläddra i källkod

Don't reload filetree and smaller resource container when first view created, fullscreen

Tom SPIRA 6 år sedan
förälder
incheckning
1351f873d9
4 ändrade filer med 33 tillägg och 29 borttagningar
  1. 29 28
      hide/Ide.hx
  2. 1 0
      hide/ui/View.hx
  3. 1 1
      hide/view/FileTree.hx
  4. 2 0
      libs/nw/Window.hx

+ 29 - 28
hide/Ide.hx

@@ -33,6 +33,7 @@ class Ide {
 	var ideConfig(get, never) : hide.Config.HideConfig;
 
 	var window : nw.Window;
+	var saveMenu : nw.Menu;
 	var layout : golden.Layout;
 
 	var currentLayout : { name : String, state : Config.LayoutState };
@@ -351,6 +352,18 @@ class Ide {
 			f();
 	}
 
+	public function setFullscreen(b : Bool) {
+		if (b) {
+			window.maximize();
+			saveMenu = window.menu;
+			window.menu = null;
+			window.enterFullscreen();
+		} else {
+			window.menu = saveMenu;
+			window.leaveFullscreen();
+		}
+	}
+
 	function set_currentFullScreen(v) {
 		var old = currentFullScreen;
 		currentFullScreen = v;
@@ -885,38 +898,14 @@ class Ide {
 			}
 
 		var index : Null<Int> = null;
-		var width : Null<Int> = null;
 		var target;
 		if( bestTarget != null )
 			target = bestTarget.parent.parent;
 		else {
 			target = layout.root.contentItems[0];
-			var reqKind : golden.Config.ItemType = options.position == Bottom ? Column : Row;
 			if( target == null ) {
-				layout.root.addChild({ type : Row });
+				layout.root.addChild({ type : Row, isClosable: false });
 				target = layout.root.contentItems[0];
-			} else if( target.type != reqKind ) {
-				// a bit tricky : change the top 'stack' into a 'row'
-				// require closing all and reopening (sadly)
-				var config = layout.toConfig().content;
-				var items = target.getItemsByFilter(function(r) return r.type == Component);
-				var foundViews = [];
-				for( v in views.copy() )
-					if( items.remove(v.container.parent) ) {
-						foundViews.push(v);
-						v.container.close();
-					}
-				layout.root.addChild({ type : reqKind, content : config });
-				target = layout.root.contentItems[0];
-				if( options.position == Left ) index = 0;
-				width = options.width;
-
-				// when opening left/right
-				if( width == null && foundViews.length == 1 ) {
-					var opt = foundViews[0].defaultOptions.width;
-					if( opt != null )
-						width = Std.int(target.element.width()) - opt;
-				}
 			}
 		}
 		if( onCreate != null )
@@ -927,17 +916,29 @@ class Ide {
 		var config : golden.Config.ItemConfig = {
 			type : Component,
 			componentName : component,
-			componentState : state,
+			componentState : state
 		};
 
 		// not working... see https://github.com/deepstreamIO/golden-layout/issues/311
-		if( width != null )
-			config.width = Std.int(width * 100 / target.element.width());
+		if( options.width != null )
+			config.width = Std.int(options.width * 100 / target.element.width());
+
+		if( options.position == Left ) index = 0;
+
+		var needToResizeResourcePanel = false;
+
+		if (views.length == 1) {
+			needToResizeResourcePanel = true;
+		}
 
 		if( index == null )
 			target.addChild(config);
 		else
 			target.addChild(config, index);
+
+		if (needToResizeResourcePanel) {
+			views[0].container.setSize(views[0].defaultOptions.width, views[0].container.height);
+		}
 	}
 
 	public function message( text : String ) {

+ 1 - 0
hide/ui/View.hx

@@ -234,6 +234,7 @@ class View<T> extends hide.comp.Component {
 			new Element("body").toggleClass("fullScreenMode",v);
 		}
 		@:privateAccess if( v ) ide.currentFullScreen = this else ide.currentFullScreen = null;
+		ide.setFullscreen(v);
 		return v;
 	}
 

+ 1 - 1
hide/view/FileTree.hx

@@ -330,6 +330,6 @@ class FileTree extends FileView {
 		return null;
 	}
 
-	static var _ = hide.ui.View.register(FileTree, { width : 200, position : Left });
+	static var _ = hide.ui.View.register(FileTree, { width : 350, position : Left });
 
 }

+ 2 - 0
libs/nw/Window.hx

@@ -23,6 +23,8 @@ extern class Window {
 	public function maximize() : Void;
 	public function minimize() : Void;
 	public function restore() : Void;
+	public function enterFullscreen() : Void;
+	public function leaveFullscreen() : Void;
 	public function on( event : String, callb : Void -> Void ) : Void;
 
 	public function show( b : Bool ) : Void;