Skip to content

Commit

Permalink
go.*,include/files/architecture: upgrade to latest Gio
Browse files Browse the repository at this point in the history
Signed-off-by: Elias Naur <[email protected]>
  • Loading branch information
elias-orijtech committed Jun 7, 2022
1 parent 28a0089 commit f1940f3
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 37 deletions.
4 changes: 2 additions & 2 deletions .builds/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ tasks:
- install_go: |
mkdir -p /home/build/sdk
cd /home/build/sdk
curl -Lso go.tar.gz https://golang.org/dl/go1.16.8.linux-amd64.tar.gz
echo "f32501aeb8b7b723bc7215f6c373abb6981bbc7e1c7b44e9f07317e1a300dce2 go.tar.gz" | sha256sum -c -
curl -Lso go.tar.gz https://golang.org/dl/go1.17.11.linux-amd64.tar.gz
echo "d69a4fe2694f795d8e525c72b497ededc209cb7185f4c3b62d7a98dd6227b3fe go.tar.gz" | sha256sum -c -
tar xzf go.tar.gz
- generate: |
cd giouiorg
Expand Down
13 changes: 7 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
module gioui.org/website

go 1.14
go 1.16

require (
gioui.org v0.0.0-20220213191812-0d32ab3f62dc
gioui.org/cmd v0.0.0-20220213191812-0d32ab3f62dc
gioui.org/example v0.0.0-20220202182520-592118406a9f
gioui.org v0.0.0-20220607102828-5cf916c0753c
gioui.org/cmd v0.0.0-20220508120214-35e56c5af956
gioui.org/example v0.0.0-20220607102948-b8e926ba1ef2
github.com/gomarkdown/markdown v0.0.0-20190912180731-281270bc6d83
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac // indirect
golang.org/x/tools v0.1.0
gopkg.in/yaml.v2 v2.2.4
gopkg.in/yaml.v2 v2.3.0
)

require golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac // indirect
60 changes: 50 additions & 10 deletions go.sum

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions include/files/architecture/draw.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func drawRedRect(ops *op.Ops) {

// START TRANSFORMATION OMIT
func drawRedRect10PixelsRight(ops *op.Ops) {
defer op.Offset(f32.Pt(100, 0)).Push(ops).Pop()
defer op.Offset(image.Pt(100, 0)).Push(ops).Pop()
drawRedRect(ops)
}

Expand All @@ -44,7 +44,7 @@ func drawRedRect10PixelsRight(ops *op.Ops) {
// START CLIPPING OMIT
func redButtonBackground(ops *op.Ops) {
const r = 10 // roundness
bounds := f32.Rect(0, 0, 100, 100)
bounds := image.Rect(0, 0, 100, 100)
clip.RRect{Rect: bounds, SE: r, SW: r, NW: r, NE: r}.Push(ops)
drawRedRect(ops)
}
Expand All @@ -68,7 +68,7 @@ func redTriangle(ops *op.Ops) {
// START STROKE RECT OMIT
func strokeRect(ops *op.Ops) {
const r = 10
bounds := f32.Rect(20, 20, 80, 80)
bounds := image.Rect(20, 20, 80, 80)
rrect := clip.RRect{Rect: bounds, SE: r, SW: r, NW: r, NE: r}
paint.FillShape(ops, red,
clip.Stroke{
Expand Down Expand Up @@ -101,7 +101,7 @@ func strokeTriangle(ops *op.Ops) {
// START STACK OMIT
func redButtonBackgroundStack(ops *op.Ops) {
const r = 1 // roundness
bounds := f32.Rect(0, 0, 100, 100)
bounds := image.Rect(0, 0, 100, 100)
defer clip.RRect{Rect: bounds, SE: r, SW: r, NW: r, NE: r}.Push(ops).Pop()
drawRedRect(ops)
}
Expand Down Expand Up @@ -136,7 +136,7 @@ func drawFiveRectangles(ops *op.Ops) {
// translated vertically 20px and horizontally 110 pixels.
for i := 0; i < 5; i++ {
c.Add(ops)
op.Offset(f32.Pt(110, 20)).Add(ops)
op.Offset(image.Pt(110, 20)).Add(ops)
}
}

Expand Down
8 changes: 4 additions & 4 deletions include/files/architecture/external.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
package main

import (
"image"
"time"

"gioui.org/app"
"gioui.org/f32"
"gioui.org/io/system"
"gioui.org/op"
)
Expand All @@ -18,7 +18,7 @@ func externalChanges() error {
changes := time.NewTicker(time.Second)
defer changes.Stop()

buttonOffset := float32(0.0)
buttonOffset := 0

ops := new(op.Ops)
for {
Expand All @@ -31,7 +31,7 @@ func externalChanges() error {
ops.Reset()

// Offset the button based on state.
op.Offset(f32.Pt(buttonOffset, 0)).Add(ops)
op.Offset(image.Pt(buttonOffset, 0)).Add(ops)

// Handle button input and draw.
doButton(ops, e.Queue)
Expand All @@ -41,7 +41,7 @@ func externalChanges() error {
}

case t := <-changes.C:
buttonOffset = float32(t.Second()%3) * 100
buttonOffset = int((t.Second() % 3) * 100)
window.Invalidate()
}
}
Expand Down
11 changes: 5 additions & 6 deletions include/files/architecture/split-interactive.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"image"

"gioui.org/f32"
"gioui.org/io/pointer"
"gioui.org/layout"
"gioui.org/op"
Expand Down Expand Up @@ -32,7 +31,7 @@ type Split struct {
// 0 is center, -1 completely to the left, 1 completely to the right.
Ratio float32
// Bar is the width for resizing the layout
Bar unit.Value
Bar unit.Dp

drag bool
dragID pointer.ID
Expand All @@ -41,13 +40,13 @@ type Split struct {

// END INPUTSTATE OMIT

var defaultBarWidth = unit.Dp(10)
const defaultBarWidth = unit.Dp(10)

func (s *Split) Layout(gtx layout.Context, left, right layout.Widget) layout.Dimensions {
// START BAR OMIT
bar := gtx.Px(s.Bar)
bar := gtx.Dp(s.Bar)
if bar <= 1 {
bar = gtx.Px(defaultBarWidth)
bar = gtx.Dp(defaultBarWidth)
}

proportion := (s.Ratio + 1) / 2
Expand Down Expand Up @@ -110,7 +109,7 @@ func (s *Split) Layout(gtx layout.Context, left, right layout.Widget) layout.Dim
}

{
off := op.Offset(f32.Pt(float32(rightoffset), 0)).Push(gtx.Ops)
off := op.Offset(image.Pt(rightoffset, 0)).Push(gtx.Ops)
gtx := gtx
gtx.Constraints = layout.Exact(image.Pt(rightsize, gtx.Constraints.Max.Y))
right(gtx)
Expand Down
3 changes: 1 addition & 2 deletions include/files/architecture/split-ratio.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"image"

"gioui.org/f32"
"gioui.org/layout"
"gioui.org/op"
"gioui.org/widget/material"
Expand Down Expand Up @@ -41,7 +40,7 @@ func (s SplitRatio) Layout(gtx layout.Context, left, right layout.Widget) layout
}

{
trans := op.Offset(f32.Pt(float32(rightoffset), 0)).Push(gtx.Ops)
trans := op.Offset(image.Pt(rightoffset, 0)).Push(gtx.Ops)
gtx := gtx
gtx.Constraints = layout.Exact(image.Pt(rightsize, gtx.Constraints.Max.Y))
right(gtx)
Expand Down
3 changes: 1 addition & 2 deletions include/files/architecture/split-visual.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"image"
"image/color"

"gioui.org/f32"
"gioui.org/layout"
"gioui.org/op"
"gioui.org/widget/material"
Expand Down Expand Up @@ -42,7 +41,7 @@ func (s SplitVisual) Layout(gtx layout.Context, left, right layout.Widget) layou
{
gtx := gtx
gtx.Constraints = layout.Exact(image.Pt(rightsize, gtx.Constraints.Max.Y))
trans := op.Offset(f32.Pt(float32(leftsize), 0)).Push(gtx.Ops)
trans := op.Offset(image.Pt(leftsize, 0)).Push(gtx.Ops)
right(gtx)
trans.Pop()
}
Expand Down

0 comments on commit f1940f3

Please sign in to comment.