gui-cs / TerminalGuiDesigner

Forms Designer for Terminal.Gui (aka gui.cs)
MIT License
423 stars 28 forks source link

Start working on updating to pre710 nuget package #289

Closed tznind closed 2 months ago

tznind commented 5 months ago

Updates Terminal.Gui v2 dependency to latest.

tznind commented 5 months ago

200 failing tests

BDisp commented 3 months ago

TestColorScheme_RoundTrip unit test fails because ColorScheme is initializing like this:

            this.button = new Terminal.Gui.Button();
            this.greyOnBlack = new Terminal.Gui.ColorScheme();
            this.greyOnBlack.Normal = new Terminal.Gui.Attribute(Terminal.Gui.Color.DarkGray, Terminal.Gui.Color.Black);
            this.greyOnBlack.HotNormal = new Terminal.Gui.Attribute(Terminal.Gui.Color.DarkGray, Terminal.Gui.Color.Black);
            this.greyOnBlack.Focus = new Terminal.Gui.Attribute(Terminal.Gui.Color.Black, Terminal.Gui.Color.DarkGray);
            this.greyOnBlack.HotFocus = new Terminal.Gui.Attribute(Terminal.Gui.Color.Black, Terminal.Gui.Color.DarkGray);
            this.greyOnBlack.Disabled = new Terminal.Gui.Attribute(Terminal.Gui.Color.DarkGray, Terminal.Gui.Color.Black);

And must be initialized like this:

            this.button = new Terminal.Gui.Button();
            this.greyOnBlack = new Terminal.Gui.ColorScheme()
            {
                Normal = new Terminal.Gui.Attribute(Terminal.Gui.Color.DarkGray, Terminal.Gui.Color.Black),
                HotNormal = new Terminal.Gui.Attribute(Terminal.Gui.Color.DarkGray, Terminal.Gui.Color.Black),
                Focus = new Terminal.Gui.Attribute(Terminal.Gui.Color.Black, Terminal.Gui.Color.DarkGray),
                HotFocus = new Terminal.Gui.Attribute(Terminal.Gui.Color.Black, Terminal.Gui.Color.DarkGray),
                Disabled = new Terminal.Gui.Attribute(Terminal.Gui.Color.DarkGray, Terminal.Gui.Color.Black)
            };
tznind commented 3 months ago

We cannot use initializer lists in code gen because it is not supported. Need to add the constructor call instead.

tznind commented 3 months ago

@BDisp fixed ColorSchemeToCode, should now use the new constructor in https://github.com/gui-cs/TerminalGuiDesigner/pull/289/commits/03a28768f9a6c34e4045802721682533d3f62c2c

215 tests to go 😢

BDisp commented 3 months ago

In the NullDim_ActsLikeAbsoluteZero unit test change to this, because View.Dim is never null now

Assert.That( v.Width, Is.Not.Null, "As of v1.7.0 a new View started getting null for its Width, if this assert fails it means that behaviour was reverted and this test can be altered or suppressed" );

BDisp commented 3 months ago

This did the trick.

            var fSide = posView.GetType().GetField("<side>P", BindingFlags.NonPublic | BindingFlags.Instance) ?? throw new Exception("PosView was missing expected field 'side'");
            var iSide = fSide.GetValue(posView)
BDisp commented 3 months ago

See how I got the field name.

image

BDisp commented 3 months ago

TabView isn't copying the Tab.DisplayText which now is a View and is TabRow subview.

tznind commented 3 months ago

Nice detective work on "<side>P". I think I will hold off on that for now though as I have raised https://github.com/gui-cs/Terminal.Gui/issues/3482 which will likely let us get rid of the reflection entirely in the pos/dim helpers.

tznind commented 3 months ago

Ok think I got all the DisplayText bits fixed

BDisp commented 3 months ago

You need also change from Text to DisplayText in the PasteOperations.cs.

image

BDisp commented 3 months ago

You'll need to create a Auto item to the DimType enum, otherwise it will assume the null for the Width property. I don't know if it will have many changes when be merged.

BDisp commented 3 months ago

You'll need to create a Auto item to the DimType enum, otherwise it will assume the null for the Width property. I don't know if it will have many changes when be merged.

I was thinking about this and came to the conclusion that using DimType and common functions is not the best option because Pos/Dim is changing radically and with many references that are not common. I think the best way is to use Pos/Dim itself in a switch block and manipulate the different calculations in the options, you can use some common functions but it is not possible in all cases.

tznind commented 3 months ago

Yes, I agree. Previously these were internal classes and TGD did not have visibles attribute (hence the methods and enums).

Now it should be more possible to use is and query properties on them.

But I think it will have to wait till that refactoring is done in https://github.com/gui-cs/Terminal.Gui/issues/3482.

BDisp commented 3 months ago

Another problem I'm encountering is with resizing a view because on the sides and bottom, as long as there is a border, it will just move the view instead of resizing it. I think the TG should rethink this behavior. Movement should only be possible from the top and sides and at the bottom it should only allow resizing.

tznind commented 3 months ago

Movement should only be possible from the top and sides and at the bottom it should only allow resizing.

This is how it is supposed to work. Bottom right few cells are for resizing, the rest are for moving. This allows a 1xN view to be resized (regardless of whether or not it has a frame).

I think there is a bug in the mouse handling code of TGD. It worked before in v1 and v2 before all the mouse changes. Possibly in the migration to the new mouse API something is not translating positions correctly.

This is probably why all the mouse click and drag tests are now failing

BDisp commented 3 months ago

I got some improvements but not enough :-)

WindowsTerminal_d60zKPSjUF

tznind commented 3 months ago

Only 1 failing test now.

I think it might be around screen/local coordinates of views. I need to do more manual testing to understand any gaps. I especially need to test multiple nested views that are not at origin of parent view to ensure coordinates are all resolving correctly.

Other outstanding issues: