Skip to content

What is required to add designer support for ScrollView #114

@tznind

Description

@tznind

To use ScrollView you must set ContentSize. Editor support will require:

  • A designer for Size struct
  • A sensible default in ViewFactory
  • Possibly some drag and drop adjustment so that when dropping controls into the ScrollView when it is scrolled down works.
  • Code generation for Size (ContentSize)
  • All the tests
  • A way to drag and resize the view when it doesn't have any borders (already solved in Support for selecting and resizing 'View' basic class #106)

Here is the minimum code to produce a ScrollView. Setting ContentSize is absolutely vital. Without it stuff just doesn't work properly.

using Terminal.Gui;

Application.Init();
var win = new Window("Example App (Ctrl+Q to quit)");

var scr = new ScrollView()
{
    Width = Dim.Fill(),
    Height = Dim.Fill(),
    ShowVerticalScrollIndicator = true
};
scr.ContentSize = new Size(30, 500);
scr.Add(new BigView());

win.Add(scr);
Application.Run(win);
Application.Shutdown();

class BigView : View
{
    public BigView()
    {
        Height = 500;
        Width = 30;
    }
    public override void Redraw(Rect bounds)
    {
        base.Redraw(bounds);

        for(int x=0;x<30;x++)
        {
            for (int y = 0; y < 500; y++)
            {
                var digit = y % 10;
                AddRune(x, y, digit.ToString()[0]);
            }
        }
    }
}

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