~eliasnaur/gio

6 3

list scrolling

Thomas Bellembois
Details
Message ID
<8640454b9e8deaaecc5bd10e874053ed2f13f751.camel@gmail.com>
DKIM signature
pass
Download raw message
Hello Giophers,

I can not  figure out how to make a list scrollable.

Here is my code:
https://github.com/tbellembois/gobkm-gio/blob/master/main.go

The most relevant part:

widgets = []layout.FlexChild{
    ...
    layout.Rigid(func(gtx C) D {
        return displayBreadcrum(gtx)
    }),
    ...
}
mainList.Layout(gtx, widgets...)


func displayBreadcrum(gtx layout.Context) D {
	bc := &layout.List{
		Axis:        layout.Horizontal,
		ScrollToEnd: true,
	}
	return bc.Layout(gtx, len(breadcrum), func(gtx layout.Context,
i int) D {
        ....
		return textButton{gui.Theme}.Layout(gtx,
			gui.Breadcrum[i],
			colorBreadcrum,
			breadcrum[i].Title)
	})
}

When I resize my main window some parts of the list disappear and I can
not scroll it.
I have the same issue with my other list.

What have I missed ?

Thanks

Thomas
Details
Message ID
<CAG3idScqA9gnHCn=QoW1XoCVeu_tCicOjN5Judtzknc-6=pJZQ@mail.gmail.com>
In-Reply-To
<8640454b9e8deaaecc5bd10e874053ed2f13f751.camel@gmail.com> (view parent)
DKIM signature
pass
Download raw message
I ran into the same issue and couldn't figure out how to do it as
well. This is because the list is *horizontal*. It works fine if you
set it as vertical.

Le jeu. 18 juin 2020 à 11:51, Thomas Bellembois
<thomas.bellembois@gmail.com> a écrit :
>
> Hello Giophers,
>
> I can not  figure out how to make a list scrollable.
>
> Here is my code:
> https://github.com/tbellembois/gobkm-gio/blob/master/main.go
>
> The most relevant part:
>
> widgets = []layout.FlexChild{
>     ...
>     layout.Rigid(func(gtx C) D {
>         return displayBreadcrum(gtx)
>     }),
>     ...
> }
> mainList.Layout(gtx, widgets...)
>
>
> func displayBreadcrum(gtx layout.Context) D {
>         bc := &layout.List{
>                 Axis:        layout.Horizontal,
>                 ScrollToEnd: true,
>         }
>         return bc.Layout(gtx, len(breadcrum), func(gtx layout.Context,
> i int) D {
>         ....
>                 return textButton{gui.Theme}.Layout(gtx,
>                         gui.Breadcrum[i],
>                         colorBreadcrum,
>                         breadcrum[i].Title)
>         })
> }
>
> When I resize my main window some parts of the list disappear and I can
> not scroll it.
> I have the same issue with my other list.
>
> What have I missed ?
>
> Thanks
>
> Thomas
Thomas Bellembois
Details
Message ID
<737707e3cc59145384a39a970c1c86999a51fa7b.camel@gmail.com>
In-Reply-To
<CAG3idScqA9gnHCn=QoW1XoCVeu_tCicOjN5Judtzknc-6=pJZQ@mail.gmail.com> (view parent)
DKIM signature
pass
Download raw message
Le jeudi 18 juin 2020 à 11:55 +0200, Pierre Curto a écrit :
> I ran into the same issue and couldn't figure out how to do it as
> well. This is because the list is *horizontal*. It works fine if you
> set it as vertical.
> 
> Le jeu. 18 juin 2020 à 11:51, Thomas Bellembois
> <thomas.bellembois@gmail.com> a écrit :
> > Hello Giophers,
> > 
> > I can not  figure out how to make a list scrollable.
> > 
> > Here is my code:
> > https://github.com/tbellembois/gobkm-gio/blob/master/main.go
> > 
> > The most relevant part:
> > 
> > widgets = []layout.FlexChild{
> >     ...
> >     layout.Rigid(func(gtx C) D {
> >         return displayBreadcrum(gtx)
> >     }),
> >     ...
> > }
> > mainList.Layout(gtx, widgets...)
> > 
> > 
> > func displayBreadcrum(gtx layout.Context) D {
> >         bc := &layout.List{
> >                 Axis:        layout.Horizontal,
> >                 ScrollToEnd: true,
> >         }
> >         return bc.Layout(gtx, len(breadcrum), func(gtx
> > layout.Context,
> > i int) D {
> >         ....
> >                 return textButton{gui.Theme}.Layout(gtx,
> >                         gui.Breadcrum[i],
> >                         colorBreadcrum,
> >                         breadcrum[i].Title)
> >         })
> > }
> > 
> > When I resize my main window some parts of the list disappear and I
> > can
> > not scroll it.
> > I have the same issue with my other list.
> > 
> > What have I missed ?
> > 
> > Thanks
> > 
> > Thomas

Actually my other lists are vertical and I have the same issue. :(
I think I have something wrong in my global layout.

Thomas
Details
Message ID
<CAG3idSfPwoLx09TZudS3nSfV85gYPVWK6zfAf1mrz6ZjNPbfyg@mail.gmail.com>
In-Reply-To
<737707e3cc59145384a39a970c1c86999a51fa7b.camel@gmail.com> (view parent)
DKIM signature
pass
Download raw message
OK. I had that issue if the list pointer was garbage collected, so I
made it part of my UI struct.

Le jeu. 18 juin 2020 à 12:15, Thomas Bellembois
<thomas.bellembois@gmail.com> a écrit :
>
> Le jeudi 18 juin 2020 à 11:55 +0200, Pierre Curto a écrit :
> > I ran into the same issue and couldn't figure out how to do it as
> > well. This is because the list is *horizontal*. It works fine if you
> > set it as vertical.
> >
> > Le jeu. 18 juin 2020 à 11:51, Thomas Bellembois
> > <thomas.bellembois@gmail.com> a écrit :
> > > Hello Giophers,
> > >
> > > I can not  figure out how to make a list scrollable.
> > >
> > > Here is my code:
> > > https://github.com/tbellembois/gobkm-gio/blob/master/main.go
> > >
> > > The most relevant part:
> > >
> > > widgets = []layout.FlexChild{
> > >     ...
> > >     layout.Rigid(func(gtx C) D {
> > >         return displayBreadcrum(gtx)
> > >     }),
> > >     ...
> > > }
> > > mainList.Layout(gtx, widgets...)
> > >
> > >
> > > func displayBreadcrum(gtx layout.Context) D {
> > >         bc := &layout.List{
> > >                 Axis:        layout.Horizontal,
> > >                 ScrollToEnd: true,
> > >         }
> > >         return bc.Layout(gtx, len(breadcrum), func(gtx
> > > layout.Context,
> > > i int) D {
> > >         ....
> > >                 return textButton{gui.Theme}.Layout(gtx,
> > >                         gui.Breadcrum[i],
> > >                         colorBreadcrum,
> > >                         breadcrum[i].Title)
> > >         })
> > > }
> > >
> > > When I resize my main window some parts of the list disappear and I
> > > can
> > > not scroll it.
> > > I have the same issue with my other list.
> > >
> > > What have I missed ?
> > >
> > > Thanks
> > >
> > > Thomas
>
> Actually my other lists are vertical and I have the same issue. :(
> I think I have something wrong in my global layout.
>
> Thomas
Thomas Bellembois
Details
Message ID
<7fd175f767e5fe8cda5dbbcab4e6fd08615c77af.camel@gmail.com>
In-Reply-To
<CAG3idSfPwoLx09TZudS3nSfV85gYPVWK6zfAf1mrz6ZjNPbfyg@mail.gmail.com> (view parent)
DKIM signature
pass
Download raw message
Le jeudi 18 juin 2020 à 12:19 +0200, Pierre Curto a écrit :
> OK. I had that issue if the list pointer was garbage collected, so I
> made it part of my UI struct.
> 
> Le jeu. 18 juin 2020 à 12:15, Thomas Bellembois
> <thomas.bellembois@gmail.com> a écrit :
> > Le jeudi 18 juin 2020 à 11:55 +0200, Pierre Curto a écrit :
> > > I ran into the same issue and couldn't figure out how to do it as
> > > well. This is because the list is *horizontal*. It works fine if
> > > you
> > > set it as vertical.
> > > 
> > > Le jeu. 18 juin 2020 à 11:51, Thomas Bellembois
> > > <thomas.bellembois@gmail.com> a écrit :
> > > > Hello Giophers,
> > > > 
> > > > I can not  figure out how to make a list scrollable.
> > > > 
> > > > Here is my code:
> > > > https://github.com/tbellembois/gobkm-gio/blob/master/main.go
> > > > 
> > > > The most relevant part:
> > > > 
> > > > widgets = []layout.FlexChild{
> > > >     ...
> > > >     layout.Rigid(func(gtx C) D {
> > > >         return displayBreadcrum(gtx)
> > > >     }),
> > > >     ...
> > > > }
> > > > mainList.Layout(gtx, widgets...)
> > > > 
> > > > 
> > > > func displayBreadcrum(gtx layout.Context) D {
> > > >         bc := &layout.List{
> > > >                 Axis:        layout.Horizontal,
> > > >                 ScrollToEnd: true,
> > > >         }
> > > >         return bc.Layout(gtx, len(breadcrum), func(gtx
> > > > layout.Context,
> > > > i int) D {
> > > >         ....
> > > >                 return textButton{gui.Theme}.Layout(gtx,
> > > >                         gui.Breadcrum[i],
> > > >                         colorBreadcrum,
> > > >                         breadcrum[i].Title)
> > > >         })
> > > > }
> > > > 
> > > > When I resize my main window some parts of the list disappear
> > > > and I
> > > > can
> > > > not scroll it.
> > > > I have the same issue with my other list.
> > > > 
> > > > What have I missed ?
> > > > 
> > > > Thanks
> > > > 
> > > > Thomas
> > 
> > Actually my other lists are vertical and I have the same issue. :(
> > I think I have something wrong in my global layout.
> > 
> > Thomas

Thanks ! It works now. Only verticaly.

Thomas
Details
Message ID
<C3K8G7793JXS.32CXPPJBBY7QG@testmac>
In-Reply-To
<8640454b9e8deaaecc5bd10e874053ed2f13f751.camel@gmail.com> (view parent)
DKIM signature
pass
Download raw message
On Thu Jun 18, 2020 at 1:51 PM CEST, Thomas Bellembois wrote:
> Hello Giophers,
>
> I can not  figure out how to make a list scrollable.
>
> Here is my code:
> https://github.com/tbellembois/gobkm-gio/blob/master/main.go
>
> The most relevant part:
>
> widgets = []layout.FlexChild{
>     ...
>     layout.Rigid(func(gtx C) D {
>         return displayBreadcrum(gtx)
>     }),
>     ...
> }
> mainList.Layout(gtx, widgets...)
>
>
> func displayBreadcrum(gtx layout.Context) D {
> 	bc := &layout.List{
> 		Axis:        layout.Horizontal,
> 		ScrollToEnd: true,
> 	}

As you already figured out, the layout.List instances must be stored
somewhere and not created every frame. If you don't, the scrolling
information is reset, effectively disabling it.

-- elias
Details
Message ID
<C3K8L3S6WDRC.RRWZNHNLPLHH@testmac>
In-Reply-To
<7fd175f767e5fe8cda5dbbcab4e6fd08615c77af.camel@gmail.com> (view parent)
DKIM signature
pass
Download raw message
On Thu Jun 18, 2020 at 3:57 PM CEST, Thomas Bellembois wrote:
> Le jeudi 18 juin 2020 à 12:19 +0200, Pierre Curto a écrit :
> > OK. I had that issue if the list pointer was garbage collected, so I
> > made it part of my UI struct.
> > 
> > Le jeu. 18 juin 2020 à 12:15, Thomas Bellembois
> > <thomas.bellembois@gmail.com> a écrit :
> > > Le jeudi 18 juin 2020 à 11:55 +0200, Pierre Curto a écrit :
> > > > I ran into the same issue and couldn't figure out how to do it as
> > > > well. This is because the list is *horizontal*. It works fine if
> > > > you
> > > > set it as vertical.
> > > > 
> > > > Le jeu. 18 juin 2020 à 11:51, Thomas Bellembois
> > > > <thomas.bellembois@gmail.com> a écrit :
> > > > > Hello Giophers,
> > > > > 
> > > > > I can not  figure out how to make a list scrollable.
> > > > > 
> > > > > Here is my code:
> > > > > https://github.com/tbellembois/gobkm-gio/blob/master/main.go
> > > > > 
> > > > > The most relevant part:
> > > > > 
> > > > > widgets = []layout.FlexChild{
> > > > >     ...
> > > > >     layout.Rigid(func(gtx C) D {
> > > > >         return displayBreadcrum(gtx)
> > > > >     }),
> > > > >     ...
> > > > > }
> > > > > mainList.Layout(gtx, widgets...)
> > > > > 
> > > > > 
> > > > > func displayBreadcrum(gtx layout.Context) D {
> > > > >         bc := &layout.List{
> > > > >                 Axis:        layout.Horizontal,
> > > > >                 ScrollToEnd: true,
> > > > >         }
> > > > >         return bc.Layout(gtx, len(breadcrum), func(gtx
> > > > > layout.Context,
> > > > > i int) D {
> > > > >         ....
> > > > >                 return textButton{gui.Theme}.Layout(gtx,
> > > > >                         gui.Breadcrum[i],
> > > > >                         colorBreadcrum,
> > > > >                         breadcrum[i].Title)
> > > > >         })
> > > > > }
> > > > > 
> > > > > When I resize my main window some parts of the list disappear
> > > > > and I
> > > > > can
> > > > > not scroll it.
> > > > > I have the same issue with my other list.
> > > > > 
> > > > > What have I missed ?
> > > > > 
> > > > > Thanks
> > > > > 
> > > > > Thomas
> > > 
> > > Actually my other lists are vertical and I have the same issue. :(
> > > I think I have something wrong in my global layout.
> > > 
> > > Thomas
>
> Thanks ! It works now. Only verticaly.
>

But not horizontally? I'd like to see example code that demonstrates
horizontal scrolling not working.

-- elias
Export thread (mbox)