Skip to content

Label not display fully when resizing terminal. #2717

@kacperpikacz

Description

@kacperpikacz

Screenshots
label

Desktop:

  • OS: Windows 10
  • TerminalGui Version: 1.12.1

To Reproduce

using System.Text;
using Terminal.Gui;

namespace Test
{
    public class Program
    {
        static readonly Label debugLabel = new ();
        static void Main()
        {
            Application.Init();
            var container = new View() { Id = "Container", X = Pos.Center(), Y = Pos.Center(), Width = 16, Height = 16 };
            var top = new FrameView() { Id = "Top", Width = Dim.Fill(), Height = 12 };
            var bottom = new FrameView() { Id = "Bottom", Y = Pos.Bottom(top), Width = Dim.Fill(), Height = 4 };
            var label = new Label() {
                Id = "Label",
                X = Pos.Center(),
                Y = Pos.Center(),
                Text = "1\n2\n3\n4\n5\n6\n7\n8\n9\n10"
            };
            top.Add(label);
            container.Add(top, bottom);
            Application.Top.Add(container, debugLabel);

            Application.RootMouseEvent += (me) => Top_Resized(null, top, bottom, label, me);
            Application.Top.Resized += (obj) => Top_Resized(obj, top, bottom, label);
            Application.Run();

            return;
        }

        private static void Top_Resized(Size? obj, View top, View bottom, View label, MouseEvent? me = null)
        {
            top.GetCurrentWidth(out int topWidth);
            top.GetCurrentHeight(out int topHeight);
            bottom.GetCurrentWidth(out int bottomWidth);
            bottom.GetCurrentHeight(out int bottomHeight);
            label.GetCurrentWidth(out int labelWidth);
            label.GetCurrentHeight(out int labelHeight);
                       
            var sb = new StringBuilder();
            sb.AppendLine("Mouse");
            sb.AppendLine("###############");
            sb.AppendLine($"X: {me?.X}, Y: {me?.Y}");
            sb.AppendLine($"Under cursor: {me?.View.Id}");
            sb.AppendLine();
            sb.AppendLine("Size");
            sb.AppendLine("###############");
            sb.AppendLine($"Top: [{topHeight}, {topHeight}]");
            sb.AppendLine($"Bottom: [{bottomHeight}, {bottomHeight}]");
            sb.AppendLine($"Label: [{labelHeight}, {labelHeight}]");

            debugLabel.Text = sb.ToString();
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions