picoe / Eto

Cross platform GUI framework for desktop and mobile applications in .NET
Other
3.64k stars 330 forks source link

Splitter again #857

Open TomQv opened 7 years ago

TomQv commented 7 years ago

I'm still having lots of problems with nested splitter. when a splitter is initially created with one invisible panel and then panel.visible is toggled.

For example, Eto.Wpf.Forms.Controls.SplitterHandler

SetPsition, SetRelative, UpdateRelative doesn't look right to me. Relative is supposed to be something between 0 and 1, right? But is also used in a way, that it can be pixels.

Pls have a look into this.

cwensley commented 7 years ago

Hey @TomQv, thanks for the issue report but I'm afraid I'll need a bit more detail to look into it.

What exactly are you trying to do, what is happening, and what do you expect? A repro or sample would be certainly helpful especially so that it doesn't break in the future.

There are many unit tests, manual tests, and samples in Eto.Test that test the numerous functionality of the Splitter and at least to my last knowledge passed on all platforms.

As for how the RelativePosition property works, take a look at the documentation.

TomQv commented 7 years ago

I need to be able to save and restore Panel.Visible and Panel.Position. When a Splitter is created with Panel1.Visible=false, the value of Position is not properly restored, when Panel1.Visible is set to true later.

With these little changes to Eto.Test\Sections\Controls\SplitterSection.cs we can simulate saving and restoring these settings with TestHiding:

static bool _statusVisible = false;
static int _statusPosition = 100;
static double  _statusRelativePosition = 0.3;

Button TestHiding()
{
    var control = new Button { Text = "Test Hiding" };
    control.Click += (sender, e) =>
    {
        var form = new Form();
        using (Context)
        {
            var rnd = new Random();
            var splitter = new Splitter
            {
                Orientation = Orientation.Horizontal,
                FixedPanel = SplitterFixedPanel.None,
                //Position = _statusPosition,
                RelativePosition = _statusRelativePosition,
                Panel1 = new Panel { Padding = 20, BackgroundColor = Colors.Red, Visible = _statusVisible, Content = new Panel { BackgroundColor = Colors.White, Size = new Size(200, 400) } },
                Panel2 = new Panel { Padding = 20, BackgroundColor = Colors.Blue, Content = new Panel { BackgroundColor = Colors.White, Size = new Size(200, 400) } },
            };

            splitter.PositionChanged += (s1, e1) =>
            {
                _statusPosition = splitter.Position;
                _statusRelativePosition = splitter.RelativePosition;
                Log.Write(this, $"splitter.Position = {_statusPosition}, splitter.RelativePosition = {_statusRelativePosition}");
            };

            form.Closing += (s2, e2) =>
            {
                _statusVisible = splitter.Panel1.Visible;
            };

            var showPanel1 = new CheckBox { Text = "Panel1.Visible" };
            showPanel1.CheckedBinding.Bind(splitter.Panel1, r => r.Visible);
TomQv commented 7 years ago

its not urgent. I realized, that nested splitters is not the best approach for that kind of layout we need. Trying TableLayout now and this looks much more promising.