x/exp/shiny: changing window size

331 views
Skip to first unread message

Sebastien Binet

unread,
Nov 19, 2015, 10:44:49 AM11/19/15
to golang-nuts
hi there,

For fun, I started to play a bit with golang.org/x/exp/shiny, looking
at the examples and the doc.
To make things more concrete, I tried to reimplement parts of
github.com/BurntSushi/imgv using exp/shiny.

This solidified as: https://github.com/sbinet/iview

so far so good, but I hit 2 snags:
- how to programmatically resize an existing screen.Window? (ie: I'd
like for the window to take the dimensions of the current image when I
hit 'r')
- also connected to resizing: when I resize the window with the mouse,
the performances (time to redraw) are quite low...

I'd be also interested in comments on my code (or rather the result of
butchering BurntSushi's code) as GUI/graphics programming isn't my
strongest suit.

-s

Sebastien Binet

unread,
Nov 19, 2015, 3:50:49 PM11/19/15
to golang-nuts
On Thu, Nov 19, 2015 at 4:44 PM, Sebastien Binet <seb....@gmail.com> wrote:
> hi there,
>
> For fun, I started to play a bit with golang.org/x/exp/shiny, looking
> at the examples and the doc.
> To make things more concrete, I tried to reimplement parts of
> github.com/BurntSushi/imgv using exp/shiny.
>
> This solidified as: https://github.com/sbinet/iview
>
> so far so good, but I hit 2 snags:
> - how to programmatically resize an existing screen.Window? (ie: I'd
> like for the window to take the dimensions of the current image when I
> hit 'r')
> - also connected to resizing: when I resize the window with the mouse,
> the performances (time to redraw) are quite low...

somewhat related: looking at the documentation of event/paint.Event:
https://godoc.org/golang.org/x/mobile/event/paint

type Event struct {
// External is true for paint events sent by the screen driver.
//
// An external event may be sent at any time in response to an
// operating system event, for example the window opened, was
// resized, or the screen memory was lost.
//
// Programs actively drawing to the screen as fast as vsync allows
// should ignore external paint events to avoid a backlog of paint
// events building up.
External bool
}

I would have expected for e.g. the x11driver to send a
paint.Event{External:true} here:
https://github.com/golang/exp/blob/master/shiny/driver/x11driver/window.go#L102
https://github.com/golang/exp/blob/master/shiny/driver/gldriver/x11.go#L155

am I mistaken?

-s

Daniel Skinner

unread,
Nov 19, 2015, 4:02:56 PM11/19/15
to Sebastien Binet, golang-nuts
I may very well be mistaken but I believe the x11 stuff doesn't actually respond to external events (or at least very well) and only begins drawing due to a synthesized event injected somewhere (I forget where), though I'm unsure if this was only tied to gomobile or also affects shiny. I was looking for the TODO in the code related but couldn't find it.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Daniel Skinner

unread,
Nov 19, 2015, 4:09:00 PM11/19/15
to Sebastien Binet, golang-nuts
This is what I was thinking about,
and line 51 that follows, which are both irrelevant to exp/shiny :p

Sebastien Binet

unread,
Nov 19, 2015, 4:36:56 PM11/19/15
to Daniel Skinner, golang-nuts
On Thu, Nov 19, 2015 at 10:08 PM, Daniel Skinner <dan...@dasa.cc> wrote:
> This is what I was thinking about,
> https://github.com/golang/mobile/blob/master/app/x11.go#L48
> and line 51 that follows, which are both irrelevant to exp/shiny :p

thanks anyways :)
I see that https://golang.org/cl/17055 is preparing some fondations
for being able to change the window's size...
I'll try that CL tomorrow.

-s

Sebastien Binet

unread,
Nov 20, 2015, 9:48:09 AM11/20/15
to golang-nuts
On Thu, Nov 19, 2015 at 4:44 PM, Sebastien Binet <seb....@gmail.com> wrote:
> hi there,
>
> For fun, I started to play a bit with golang.org/x/exp/shiny, looking
> at the examples and the doc.
> To make things more concrete, I tried to reimplement parts of
> github.com/BurntSushi/imgv using exp/shiny.
>
> This solidified as: https://github.com/sbinet/iview
>
> so far so good, but I hit 2 snags:
> - how to programmatically resize an existing screen.Window? (ie: I'd
> like for the window to take the dimensions of the current image when I
> hit 'r')
it's simply not implemented :)
I have a CL for that though, but let's start with an issue:
https://golang.org/issues/13339

-s
Reply all
Reply to author
Forward
0 new messages