Quellcode durchsuchen

Fix the Fill computations for layout, by only special casing the Pos.Center scenarios and unrolling the rest

miguel vor 7 Jahren
Ursprung
Commit
6fbccd6659
7 geänderte Dateien mit 161 neuen und 21 gelöschten Zeilen
  1. 51 0
      Designer/Designer.csproj
  2. 45 0
      Designer/Program.cs
  3. 26 0
      Designer/Properties/AssemblyInfo.cs
  4. 4 0
      Designer/packages.config
  5. 1 1
      Example/demo.cs
  6. 27 19
      Terminal.Gui/Core.cs
  7. 7 1
      Terminal.sln

+ 51 - 0
Designer/Designer.csproj

@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+    <ProjectGuid>{1228D992-C801-49BB-839A-7BD28A3FFF0A}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <RootNamespace>Designer</RootNamespace>
+    <AssemblyName>Designer</AssemblyName>
+    <TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug</OutputPath>
+    <DefineConstants>DEBUG;</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <ExternalConsole>true</ExternalConsole>
+    <PlatformTarget>x86</PlatformTarget>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release</OutputPath>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <ExternalConsole>true</ExternalConsole>
+    <PlatformTarget>x86</PlatformTarget>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="NStack">
+      <HintPath>..\packages\NStack.Core.0.11.0\lib\netstandard1.5\NStack.dll</HintPath>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Program.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\Terminal.Gui\Terminal.Gui.csproj">
+      <Project>{00F366F8-DEE4-482C-B9FD-6DB0200B79E5}</Project>
+      <Name>Terminal.Gui</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="packages.config" />
+  </ItemGroup>
+  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+</Project>

+ 45 - 0
Designer/Program.cs

@@ -0,0 +1,45 @@
+using System;
+using Terminal.Gui;
+
+namespace Designer {
+	class Surface : Window {
+		public Surface () : base ("Designer")
+		{
+		}
+	}
+
+	class MainClass {
+		public static void Main (string [] args)
+		{
+			Application.Init ();
+
+			var menu = new MenuBar (new MenuBarItem [] {
+				new MenuBarItem ("_File", new MenuItem [] {
+					new MenuItem ("_Quit", "", () => { Application.RequestStop (); })
+				}),
+				new MenuBarItem ("_Edit", new MenuItem [] {
+					new MenuItem ("_Copy", "", null),
+					new MenuItem ("C_ut", "", null),
+					new MenuItem ("_Paste", "", null)
+				}),
+			});
+
+			var login = new Label ("Login: ") { X = 3, Y = 6 };
+			var password = new Label ("Password: ") {
+				X = Pos.Left (login),
+				Y = Pos.Bottom (login) + 1
+			};
+
+			var surface = new Surface () {
+				X = 0,
+				Y = 1,
+				Width = Dim.Percent (80),
+				Height = Dim.Fill ()
+			};
+
+			//Application.Top.Add (menu);
+			Application.Top.Add (login, password);
+			Application.Run ();
+		}
+	}
+}

+ 26 - 0
Designer/Properties/AssemblyInfo.cs

@@ -0,0 +1,26 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+// Information about this assembly is defined by the following attributes. 
+// Change them to the values specific to your project.
+
+[assembly: AssemblyTitle ("Designer")]
+[assembly: AssemblyDescription ("")]
+[assembly: AssemblyConfiguration ("")]
+[assembly: AssemblyCompany ("")]
+[assembly: AssemblyProduct ("")]
+[assembly: AssemblyCopyright ("${AuthorCopyright}")]
+[assembly: AssemblyTrademark ("")]
+[assembly: AssemblyCulture ("")]
+
+// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
+// The form "{Major}.{Minor}.*" will automatically update the build and revision,
+// and "{Major}.{Minor}.{Build}.*" will update just the revision.
+
+[assembly: AssemblyVersion ("1.0.*")]
+
+// The following attributes are used to specify the signing key for the assembly, 
+// if desired. See the Mono documentation for more information about signing.
+
+//[assembly: AssemblyDelaySign(false)]
+//[assembly: AssemblyKeyFile("")]

+ 4 - 0
Designer/packages.config

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="NStack.Core" version="0.11.0" targetFramework="net47" />
+</packages>

+ 1 - 1
Example/demo.cs

@@ -217,7 +217,7 @@ static class Demo {
 			X = 0,
 			X = 0,
 			Y = 1,
 			Y = 1,
 			Width = Dim.Fill (),
 			Width = Dim.Fill (),
-			Height = Dim.Fill () - 1
+			Height = Dim.Fill ()
 		};
 		};
 #else
 #else
 		var win = new Window (new Rect (0, 1, tframe.Width, tframe.Height - 1), "Hello");
 		var win = new Window (new Rect (0, 1, tframe.Width, tframe.Height - 1), "Hello");

+ 27 - 19
Terminal.Gui/Core.cs

@@ -1006,38 +1006,46 @@ namespace Terminal.Gui {
 
 
 		/// <summary>
 		/// <summary>
 		/// Computes the RelativeLayout for the view, given the frame for its container.
 		/// Computes the RelativeLayout for the view, given the frame for its container.
+
 		/// </summary>
 		/// </summary>
 		/// <param name="hostFrame">The Frame for the host.</param>
 		/// <param name="hostFrame">The Frame for the host.</param>
 		internal void RelativeLayout (Rect hostFrame)
 		internal void RelativeLayout (Rect hostFrame)
 		{
 		{
 			int w, h, _x, _y;
 			int w, h, _x, _y;
-			if (width == null)
-				w = hostFrame.Width;
-			else
-				w = width.Anchor (hostFrame.Width);
 
 
-			if (x == null)
-				_x = 0;
-			else {
-				if (x is Pos.PosCenter)
-					_x = x.Anchor (hostFrame.Width - w);
+			if (x is Pos.PosCenter) {
+				if (width == null)
+					w = hostFrame.Width;
 				else
 				else
+					w = width.Anchor (hostFrame.Width);
+				_x = x.Anchor (hostFrame.Width - w);
+			} else {
+				if (x == null) 
+					_x = 0;
+				else 
 					_x = x.Anchor (hostFrame.Width);
 					_x = x.Anchor (hostFrame.Width);
+				if (width == null)
+					w = hostFrame.Width;
+				else
+					w = width.Anchor (hostFrame.Width - _x);
 			}
 			}
-			if (height == null)
-				h = hostFrame.Height;
-			else
-				h = height.Anchor (hostFrame.Height);
 
 
-			if (y == null)
-				_y = 0;
-			else {
-				if (y is Pos.PosCenter)
-					_y = y.Anchor (hostFrame.Height - h);
+			if (y is Pos.PosCenter) {
+				if (height == null)
+					h = hostFrame.Height;
+				else
+					h = height.Anchor (hostFrame.Height);
+				_y = y.Anchor (hostFrame.Height - h);
+			} else {
+				if (y == null)
+					_y = 0;
 				else
 				else
 					_y = y.Anchor (hostFrame.Height);
 					_y = y.Anchor (hostFrame.Height);
+				if (height == null)
+					h = hostFrame.Height;
+				else
+					h = height.Anchor (hostFrame.Height - _y);
 			}
 			}
-
 			Frame = new Rect (_x, _y, w, h);
 			Frame = new Rect (_x, _y, w, h);
 		}
 		}
 
 

+ 7 - 1
Terminal.sln

@@ -1,10 +1,12 @@
 
 
 Microsoft Visual Studio Solution File, Format Version 12.00
 Microsoft Visual Studio Solution File, Format Version 12.00
 # Visual Studio 2012
 # Visual Studio 2012
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Example\Example", "Example\Example.csproj", "{B0A602CD-E176-449D-8663-64238D54F857}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Example", "Example\Example.csproj", "{B0A602CD-E176-449D-8663-64238D54F857}"
 EndProject
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Terminal.Gui", "Terminal.Gui\Terminal.Gui.csproj", "{00F366F8-DEE4-482C-B9FD-6DB0200B79E5}"
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Terminal.Gui", "Terminal.Gui\Terminal.Gui.csproj", "{00F366F8-DEE4-482C-B9FD-6DB0200B79E5}"
 EndProject
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Designer", "Designer\Designer.csproj", "{1228D992-C801-49BB-839A-7BD28A3FFF0A}"
+EndProject
 Global
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|x86 = Debug|x86
 		Debug|x86 = Debug|x86
@@ -19,6 +21,10 @@ Global
 		{00F366F8-DEE4-482C-B9FD-6DB0200B79E5}.Debug|x86.Build.0 = Debug|Any CPU
 		{00F366F8-DEE4-482C-B9FD-6DB0200B79E5}.Debug|x86.Build.0 = Debug|Any CPU
 		{00F366F8-DEE4-482C-B9FD-6DB0200B79E5}.Release|x86.ActiveCfg = Release|Any CPU
 		{00F366F8-DEE4-482C-B9FD-6DB0200B79E5}.Release|x86.ActiveCfg = Release|Any CPU
 		{00F366F8-DEE4-482C-B9FD-6DB0200B79E5}.Release|x86.Build.0 = Release|Any CPU
 		{00F366F8-DEE4-482C-B9FD-6DB0200B79E5}.Release|x86.Build.0 = Release|Any CPU
+		{1228D992-C801-49BB-839A-7BD28A3FFF0A}.Debug|x86.ActiveCfg = Debug|x86
+		{1228D992-C801-49BB-839A-7BD28A3FFF0A}.Debug|x86.Build.0 = Debug|x86
+		{1228D992-C801-49BB-839A-7BD28A3FFF0A}.Release|x86.ActiveCfg = Release|x86
+		{1228D992-C801-49BB-839A-7BD28A3FFF0A}.Release|x86.Build.0 = Release|x86
 	EndGlobalSection
 	EndGlobalSection
 	GlobalSection(MonoDevelopProperties) = preSolution
 	GlobalSection(MonoDevelopProperties) = preSolution
 		Policies = $0
 		Policies = $0