pharo-graphics / Toplo

A widget framework on top of Bloc
MIT License
17 stars 8 forks source link

Fixes on scrollbars #34

Closed tinchodias closed 1 year ago

tinchodias commented 1 year ago

This PR requires changes in other repos:

Commit comments have information

plantec commented 1 year ago

thanks again. is it possible to have the 2 scrollbars (H and V) on the same element ? InfiniteElement ?

tinchodias commented 1 year ago

Hi, in infinite element I didn't check, but in a regular element yes, this is my example:

largeElement := OBlElement new
    size: 1000 asPoint;
    background: (BlRadialGradientPaint new
        stops: { 0 -> Color blue . 1 -> Color red};
        center: 500 asPoint;
        radius: 500;
        yourself);
    yourself.
scrollableElement := largeElement asScrollableElement.

hBar :=
    OBlHorizontalScrollbarElement new
        constraintsDo: [ :c |
            c ignoreByLayout.
            c ignored vertical alignBottom ];
        attachTo: scrollableElement;
        yourself.

vBar :=
    OBlVerticalScrollbarElement new
        constraintsDo: [ :c |
            c ignoreByLayout.
            c ignored horizontal alignRight ];
        attachTo: scrollableElement;
        yourself.

scrollPane :=
    BlElement new
        addChild: scrollableElement;
        addChild: vBar;
        addChild: hBar;
        constraintsDo: [ :c |
            c horizontal matchParent.
            c vertical matchParent ];
        yourself.

space := OBlSpace new.
space root
    layout: BlLinearLayout new;
    padding: (BlInsets all: 10);
    background: Color blue muchDarker;
    addChild: scrollPane.
space
    extent: 500@500;
    show
plantec commented 1 year ago

in an infinite it works differently, scrolling is managed by the layout by updating the infinite children. In the case of a vertical infinite layout, the horizontal scrolling should work as in your example. In the case of horizontal infinite layout, the vertical scrolling should work as in your example.

tinchodias commented 1 year ago

@plantec The album editor has an infinite layout, or am I wrong? Do you have a snippet, to be sure? Thanks in advance