Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
theclapp committed Jun 5, 2020
1 parent 3db1415 commit cd45163
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 2 deletions.
2 changes: 2 additions & 0 deletions app/internal/window/os_macos.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ func (w *window) SetAnimating(anim bool) {
}

func (w *window) setStage(stage system.Stage) {
// log.Printf("setStage starting: %v", stage)
// defer log.Printf("setStage done")
if stage == w.stage {
return
}
Expand Down
7 changes: 7 additions & 0 deletions app/internal/window/os_macos.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ - (void)windowDidResignKey:(NSNotification *)notification {
- (void)windowWillClose:(NSNotification *)notification {
gio_onTerminate((__bridge CFTypeRef)self.window.contentView);
self.window.delegate = nil;
// printf("windowWillClose 1\n");
[NSApp terminate:nil];
// printf("windowWillClose 2\n");
// for (int i = 0; i < 100; i++) {
// printf("windowWillClose 3 %d\n", i);
// usleep(1000);
// }
}
@end

Expand Down Expand Up @@ -152,5 +158,6 @@ void gio_main(CFTypeRef viewRef, const char *title, CGFloat width, CGFloat heigh
[window makeFirstResponder:view];

[NSApp run];
// printf("NSApp run finished\n");
}
}
4 changes: 4 additions & 0 deletions app/window.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,12 @@ func (w *Window) run(opts *window.Options) {
w.driver = e2.driver
case system.DestroyEvent:
w.destroyGPU()
// log.Printf("Window.run sending DestroyEvent")
w.out <- e2
// log.Printf("Window.run sent DestroyEvent")
time.Sleep(100 * time.Millisecond)
w.ack <- struct{}{}
// log.Printf("Window.run sent ack")
return
case event.Event:
if w.queue.q.Add(e2) {
Expand Down
1 change: 1 addition & 0 deletions gesture/gesture.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ func (s *Scroll) Scroll(cfg unit.Converter, q event.Queue, t time.Time, axis Axi
if !ok {
continue
}
// log.Printf("gesture.Scroll.Scroll event: %+v", e)
switch e.Type {
case pointer.Press:
if s.dragging || e.Source != pointer.Touch {
Expand Down
4 changes: 4 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ module gioui.org
go 1.13

require (
github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7 // indirect
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200420212212-258d9bec320e // indirect
github.com/google/go-github/v24 v24.0.1 // indirect
golang.org/x/exp v0.0.0-20191002040644-a1355ae1e2c3
golang.org/x/image v0.0.0-20190802002840-cff245a6509b
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d // indirect
golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9
)
28 changes: 28 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7 h1:SCYMcCJ89LjRGwEa0tRluNRiMjZHalQZrVrvTbPh+qw=
github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7/go.mod h1:482civXOzJJCPzJ4ZOX/pwvXBWSnzD4OKMdH4ClKGbk=
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1 h1:QbL/5oDUmRBzO9/Z7Seo6zf912W/a6Sr4Eu0G/3Jho0=
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
github.com/go-gl/glfw v0.0.0-20200420212212-258d9bec320e h1:d/6iiszw8nt7mrUmkD/zaMj2I4mOcKYsxmkL+vTGWYc=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200420212212-258d9bec320e h1:8ywu4ELC/6owgOZlZx75CyYS5AYwUT2L+hzPModKvag=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200420212212-258d9bec320e/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/google/go-github v17.0.0+incompatible h1:N0LgJ1j65A7kfXrZnUDaYCs/Sf4rEjNlfyDHW9dolSY=
github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ=
github.com/google/go-github/v24 v24.0.1 h1:KCt1LjMJEey1qvPXxa9SjaWxwTsCWSq6p2Ju57UR4Q4=
github.com/google/go-github/v24 v24.0.1/go.mod h1:CRqaW1Uns1TCkP0wqTpxYyRxRjxwvKU/XSS44u6X74M=
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
golang.org/x/crypto v0.0.0-20180820150726-614d502a4dac/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
Expand All @@ -11,9 +26,19 @@ golang.org/x/image v0.0.0-20190802002840-cff245a6509b h1:+qEpEAPhDZ1o0x3tHzZTQDA
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d h1:TzXSXBo42m9gQenoE3b9BGiEpg5IG2JkU5FkPIawgtw=
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180824143301-4910a1d54f87/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI=
Expand All @@ -22,5 +47,8 @@ golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9 h1:1/DFK4b7JH8DmkqhUk48onnSf
golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20190927191325-030b2cf1153e h1:1xWUkZQQ9Z9UuZgNaIR6OQOE7rUFglXUUBZlO+dGg6I=
golang.org/x/tools v0.0.0-20190927191325-030b2cf1153e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
27 changes: 27 additions & 0 deletions layout/flex.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,25 @@ func Flexed(weight float32, widget Widget) FlexChild {
}
}

var Profile = false

// Layout a list of children. The position of the children are
// determined by the specified order, but Rigid children are laid out
// before Flexed children.
func (f Flex) Layout(gtx Context, children ...FlexChild) Dimensions {
size := 0
// start := time.Now()
// numDrawn := 0
// Lay out Rigid children.
for i, child := range children {
if child.flex {
continue
}
// start2 := time.Now()
// if Profile {
// log.Printf("start2: %v; %d children",
// start2, len(children))
// }
cs := gtx.Constraints
_, mainMax := axisMainConstraint(f.Axis, cs)
mainMax -= size
Expand All @@ -98,7 +107,17 @@ func (f Flex) Layout(gtx Context, children ...FlexChild) Dimensions {
size += sz
children[i].call = c
children[i].dims = dims
// if Profile {
// log.Printf("rigid child %d: %v; start2: %v, %d children", i, time.Now().Sub(start2),
// start2, len(children))
// }
// numDrawn++
}
// if Profile {
// total := time.Now().Sub(start)
// log.Printf("after rigids: %d children: %v, avg: %v", numDrawn, total,
// time.Duration(int64(total)/int64(numDrawn)))
// }
rigidSize := size
// fraction is the rounding error from a Flex weighting.
var fraction float32
Expand Down Expand Up @@ -133,6 +152,7 @@ func (f Flex) Layout(gtx Context, children ...FlexChild) Dimensions {
children[i].call = c
children[i].dims = dims
}
// start = time.Now()
var maxCross int
var maxBaseline int
for _, child := range children {
Expand All @@ -143,6 +163,10 @@ func (f Flex) Layout(gtx Context, children ...FlexChild) Dimensions {
maxBaseline = b
}
}
// if Profile {
// log.Printf("maxCross calc: %v", time.Now().Sub(start))
// }
// start = time.Now()
cs := gtx.Constraints
mainMin, _ := axisMainConstraint(f.Axis, cs)
var space int
Expand Down Expand Up @@ -190,6 +214,9 @@ func (f Flex) Layout(gtx Context, children ...FlexChild) Dimensions {
}
}
}
// if Profile {
// log.Printf("layout all: %v", time.Now().Sub(start))
// }
switch f.Spacing {
case SpaceSides:
mainSize += space / 2
Expand Down
10 changes: 10 additions & 0 deletions layout/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,23 @@ func (l *List) ScrollTo(i int) {
}

func (l *List) PageUp() {
// If already at the top, do nothing
if l.Position.BeforeEnd && l.Position.First == 0 && l.Position.Offset == 0 {
return
}

l.Position.Offset -= l.height
// If you don't do this and l.ScrollToEnd == true, Position.Offset is
// ignored.
l.Position.BeforeEnd = true
}

func (l *List) PageDown() {
// If already at the end, do nothing.
if !l.Position.BeforeEnd {
return
}

l.Position.Offset += l.height
l.Position.BeforeEnd = true
}
Expand Down
2 changes: 1 addition & 1 deletion text/lru.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type pathKey struct {
str string
}

const maxSize = 1000
const maxSize = 10000

func (l *layoutCache) Get(k layoutKey) ([]Line, bool) {
if lt, ok := l.m[k]; ok {
Expand Down
2 changes: 1 addition & 1 deletion widget/material/checkable.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (c *checkable) layout(gtx layout.Context, checked bool) layout.Dimensions {

layout.Rigid(func(gtx layout.Context) layout.Dimensions {
if c.Label == "" {
return
return layout.Dimensions{}
}
gtx.Constraints.Min = min
return layout.W.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
Expand Down

0 comments on commit cd45163

Please sign in to comment.