Update gio version. Add side grid for year selection to cmd/cal.
This commit is contained in:
+17
-16
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"git.wow.st/gmp/giowrap"
|
||||
|
||||
"image"
|
||||
"image/color"
|
||||
"log"
|
||||
"os"
|
||||
@@ -13,7 +14,7 @@ import (
|
||||
|
||||
"gioui.org/ui"
|
||||
"gioui.org/ui/app"
|
||||
gdraw "gioui.org/ui/draw"
|
||||
"gioui.org/ui/paint"
|
||||
"gioui.org/ui/f32"
|
||||
"gioui.org/ui/gesture"
|
||||
"gioui.org/ui/layout"
|
||||
@@ -35,7 +36,7 @@ var (
|
||||
)
|
||||
|
||||
func NewButton(face text.Face, t string, c color.RGBA) giowrap.Clickable {
|
||||
lbl := giowrap.NewLabel(t, giowrap.Face(face), giowrap.Align(text.Center))
|
||||
lbl := giowrap.NewLabel(t, giowrap.Face(face), giowrap.Align(text.Middle))
|
||||
bg := giowrap.NewBackground(giowrap.Color(c), giowrap.Radius(ui.Dp(4)))
|
||||
return giowrap.AsClickable(bg(lbl))
|
||||
}
|
||||
@@ -79,7 +80,7 @@ hello [main1|main2]
|
||||
}
|
||||
|
||||
func main1() {
|
||||
w := app.NewWindow(nil)
|
||||
w := app.NewWindow()
|
||||
regular, err := sfnt.Parse(goregular.TTF)
|
||||
if err != nil {
|
||||
log.Fatal("Cannot parse font.")
|
||||
@@ -114,7 +115,7 @@ func main1() {
|
||||
switch e := e.(type) {
|
||||
case app.DestroyEvent:
|
||||
return
|
||||
case app.DrawEvent:
|
||||
case app.UpdateEvent:
|
||||
ctx.Reset(e)
|
||||
OuterInset(
|
||||
f1(
|
||||
@@ -128,7 +129,7 @@ func main1() {
|
||||
InnerInset(btn2),
|
||||
),
|
||||
)).Layout(ctx)
|
||||
ctx.Draw()
|
||||
ctx.Update()
|
||||
if btn1.Clicked(ctx) {
|
||||
log.Print("Clicked: " + e1.Text() )
|
||||
}
|
||||
@@ -161,7 +162,7 @@ func main1() {
|
||||
}
|
||||
|
||||
func main2() {
|
||||
w := app.NewWindow(nil)
|
||||
w := app.NewWindow()
|
||||
q := w.Queue()
|
||||
ops := new(ui.Ops)
|
||||
var faces measure.Faces
|
||||
@@ -216,7 +217,7 @@ func main2() {
|
||||
switch e := e.(type) {
|
||||
case app.DestroyEvent:
|
||||
return
|
||||
case app.DrawEvent:
|
||||
case app.UpdateEvent:
|
||||
c := &e.Config
|
||||
ops.Reset()
|
||||
faces.Reset(c)
|
||||
@@ -239,14 +240,14 @@ func main2() {
|
||||
cs = b1ins.Begin(c, ops, cs)
|
||||
dims = btn1.Layout(ops, cs)
|
||||
dims = b1ins.End(dims)
|
||||
pointer.RectAreaOp{Size: dims.Size}.Add(ops)
|
||||
pointer.RectAreaOp{image.Rect(0,0,dims.Size.X,dims.Size.Y)}.Add(ops)
|
||||
click1.Add(ops)
|
||||
bg1.Stop()
|
||||
wi, h := float32(dims.Size.X), float32(dims.Size.Y)
|
||||
r := float32(c.Px(ui.Dp(4)))
|
||||
giowrap.Rrect(ops, wi, h, r, r, r, r)
|
||||
gdraw.ColorOp{Color: color.RGBA{A: 0xff, R: 0x3c, G: 0x98, B: 0xc6}}.Add(ops)
|
||||
gdraw.DrawOp{Rect: f32.Rectangle{Max: f32.Point{X: wi, Y: h}}}.Add(ops)
|
||||
paint.ColorOp{Color: color.RGBA{A: 0xff, R: 0x3c, G: 0x98, B: 0xc6}}.Add(ops)
|
||||
paint.PaintOp{Rect: f32.Rectangle{Max: f32.Point{X: wi, Y: h}}}.Add(ops)
|
||||
bg1.Add(ops)
|
||||
dims = InnerInset.End(dims)
|
||||
f2c1 := f2.End(dims)
|
||||
@@ -256,13 +257,13 @@ func main2() {
|
||||
cs = b2ins.Begin(c, ops, cs)
|
||||
dims = btn2.Layout(ops, cs)
|
||||
dims = b2ins.End(dims)
|
||||
pointer.RectAreaOp{Size: dims.Size}.Add(ops)
|
||||
pointer.RectAreaOp{image.Rect(0,0,dims.Size.X,dims.Size.Y)}.Add(ops)
|
||||
click2.Add(ops)
|
||||
bg2.Stop()
|
||||
wi, h = float32(dims.Size.X), float32(dims.Size.Y)
|
||||
giowrap.Rrect(ops, wi, h, r, r, r, r)
|
||||
gdraw.ColorOp{Color: color.RGBA{A: 0xff, R: 0x3c, G: 0x98, B: 0xc6}}.Add(ops)
|
||||
gdraw.DrawOp{Rect: f32.Rectangle{Max: f32.Point{X: wi, Y: h}}}.Add(ops)
|
||||
paint.ColorOp{Color: color.RGBA{A: 0xff, R: 0x3c, G: 0x98, B: 0xc6}}.Add(ops)
|
||||
paint.PaintOp{Rect: f32.Rectangle{Max: f32.Point{X: wi, Y: h}}}.Add(ops)
|
||||
bg2.Add(ops)
|
||||
dims = InnerInset.End(dims)
|
||||
f2c2 := f2.End(dims)
|
||||
@@ -270,13 +271,13 @@ func main2() {
|
||||
f1c3 := f1.End(dims)
|
||||
dims = f1.Layout(f1c1, f1c2, f1c3)
|
||||
dims = OuterInset.End(dims)
|
||||
w.Draw(ops)
|
||||
for _,ev := range click1.Events(q) {
|
||||
w.Update(ops)
|
||||
for ev, ok := click1.Next(q); ok; ev, ok = click1.Next(q) {
|
||||
if ev.Type == gesture.TypeClick {
|
||||
log.Print("Clicked: " + e1.Text() )
|
||||
}
|
||||
}
|
||||
for _, ev := range click2.Events(q) {
|
||||
for ev, ok := click2.Next(q); ok; ev, ok = click2.Next(q) {
|
||||
if ev.Type == gesture.TypeClick {
|
||||
log.Print("Clicked: " + e2.Text() )
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user