2
0
Эх сурвалжийг харах

Fixes #2216. MessageBox default width should be proportional for smaller screens.

BDisp 2 жил өмнө
parent
commit
828ab61ff0

+ 4 - 1
Terminal.Gui/Windows/MessageBox.cs

@@ -238,7 +238,10 @@ namespace Terminal.Gui {
 		static int QueryFull (bool useErrorColors, int width, int height, ustring title, ustring message,
 		static int QueryFull (bool useErrorColors, int width, int height, ustring title, ustring message,
 			int defaultButton = 0, Border border = null, params ustring [] buttons)
 			int defaultButton = 0, Border border = null, params ustring [] buttons)
 		{
 		{
-			const int defaultWidth = 50;
+			int defaultWidth = 50;
+			if (defaultWidth > Application.Driver.Cols / 2) {
+				defaultWidth = (int)(Application.Driver.Cols * 0.60f);
+			}
 			int maxWidthLine = TextFormatter.MaxWidthLine (message);
 			int maxWidthLine = TextFormatter.MaxWidthLine (message);
 			if (maxWidthLine > Application.Driver.Cols) {
 			if (maxWidthLine > Application.Driver.Cols) {
 				maxWidthLine = Application.Driver.Cols;
 				maxWidthLine = Application.Driver.Cols;

+ 5 - 5
UnitTests/MessageBoxTests.cs

@@ -30,11 +30,11 @@ namespace Terminal.Gui.Views {
 				} else if (iterations == 1) {
 				} else if (iterations == 1) {
 					Application.Top.Redraw (Application.Top.Bounds);
 					Application.Top.Redraw (Application.Top.Bounds);
 					TestHelpers.AssertDriverContentsWithFrameAre (@"
 					TestHelpers.AssertDriverContentsWithFrameAre (@"
-               ┌ Title ─────────────────────────────────────────┐
-                                   Message 
-               
-               
-               └────────────────────────────────────────────────┘
+                ┌ Title ───────────────────────────────────────┐
+                                   Message                    │
+               
+               
+                └──────────────────────────────────────────────┘
 ", output);
 ", output);
 
 
 					Application.RequestStop ();
 					Application.RequestStop ();