Define giowrap.Horizontal and giowrap.Vertical as AxisOpts.

This commit is contained in:
Greg 2019-08-28 11:54:32 -04:00
parent 83c9d40500
commit cf56e8c47e
4 changed files with 17 additions and 15 deletions

View File

@ -112,8 +112,8 @@ func eventloop() {
gio.Color(color.RGBA{A: 0xff, R: 0xf0, G: 0xf0, B: 0xe0}))
margin := gio.NewInset(gio.Size(ui.Dp(10)))
f1 := gio.NewFlex(gio.Axis(layout.Vertical))
f2 := gio.NewFlex(gio.Axis(layout.Horizontal))
f1 := gio.NewFlex(gio.Vertical)
f2 := gio.NewFlex(gio.Horizontal)
sidegrid := gio.NewGrid(1)
yrs := make([]gio.Widget, 6)
curyr := sm.Year
@ -125,7 +125,7 @@ func eventloop() {
var cal gio.Widget
f3 := gio.NewFlex(gio.Axis(layout.Vertical))
f3 := gio.NewFlex(gio.Vertical)
daygrid := gio.NewGrid(7)
sun := NewSLabel("Sun", &sm.Ws[time.Sunday], gio.Align(text.End))
mon := NewSLabel("Mon", &sm.Ws[time.Monday], gio.Align(text.End))

View File

@ -103,11 +103,11 @@ func main1() {
e2 := giowrap.NewEditor("text 2", giowrap.Face(ctx.Faces.For(regular, ui.Sp(24))))
f1 := giowrap.NewFlex(giowrap.Axis(layout.Vertical))
f1 := giowrap.NewFlex(giowrap.Vertical)
OuterInset := giowrap.NewInset(giowrap.Size(ui.Dp(10)))
InnerInset := giowrap.NewInset(giowrap.Size(ui.Dp(10)))
f2 := giowrap.NewFlex(giowrap.Axis(layout.Horizontal))
f2 := giowrap.NewFlex(giowrap.Horizontal)
btn1 := NewButton(ctx.Faces.For(regular, ui.Sp(24)),
"push1", color.RGBA{A: 0xff, R: 0x3c, G: 0x98, B: 0xc6})
@ -224,11 +224,11 @@ func main2() {
e2 := giowrap.NewEditor("text 2", giowrap.Face(ctx.Faces.For(regular, ui.Sp(24))))
f1 := giowrap.NewFlex(giowrap.Axis(layout.Vertical))
f1 := giowrap.NewFlex(giowrap.Vertical)
OuterInset := giowrap.NewInset(giowrap.Size(ui.Dp(10)))
InnerInset := giowrap.NewInset(giowrap.Size(ui.Dp(10)))
f2 := giowrap.NewFlex(giowrap.Axis(layout.Horizontal))
f2 := giowrap.NewFlex(giowrap.Horizontal)
btn1 := NewButton(ctx.Faces.For(regular, ui.Sp(24)),
"push1", color.RGBA{A: 0xff, R: 0x3c, G: 0x98, B: 0xc6})
@ -366,12 +366,12 @@ func main3() {
}
ctx.Reset(&e)
giowrap.NewInset(giowrap.Size(ui.Dp(10)))(
giowrap.NewFlex(giowrap.Axis(layout.Vertical))(
giowrap.NewFlex(giowrap.Vertical)(
e1,
//giowrap.Flexible(0.33),
giowrap.NewInset(giowrap.Size(ui.Dp(10)))(e2),
//giowrap.Flexible(0.67),
giowrap.NewFlex(giowrap.Axis(layout.Horizontal))(
giowrap.NewFlex(giowrap.Horizontal)(
giowrap.NewInset(giowrap.Size(ui.Dp(10)))(btn1),
//giowrap.Flexible(0.50),
giowrap.NewInset(giowrap.Size(ui.Dp(10)))(btn2),

View File

@ -97,15 +97,15 @@ func eventloop() {
bg := gio.NewBackground(gio.Color(gray2))
margin := gio.NewInset(gio.Size(ui.Dp(10)))
f1 := gio.NewFlex(gio.Axis(layout.Horizontal))
f1 := gio.NewFlex(gio.Horizontal)
lbar := gio.NewLabel(" ", gio.Face(face))
f2 := gio.NewFlex(gio.Axis(layout.Vertical))
f2 := gio.NewFlex(gio.Vertical)
topbar := gio.NewLabel("Scroll X and Y. Click to select", gio.Face(face))
f3 := gio.NewFlex(gio.Axis(layout.Horizontal))
f4 := gio.NewFlex(gio.Axis(layout.Vertical))
f3 := gio.NewFlex(gio.Horizontal)
f4 := gio.NewFlex(gio.Vertical)
sh := gio.HScroll(gio.NewFlex(gio.Axis(layout.Horizontal)))
sv := gio.VScroll(gio.NewFlex(gio.Axis(layout.Vertical)))
sh := gio.HScroll(gio.NewFlex(gio.Horizontal))
sv := gio.VScroll(gio.NewFlex(gio.Vertical))
numrows := 16
numcols := 50

View File

@ -204,6 +204,8 @@ type List = WidgetCombinator
type AxisOpt struct{ axis layout.Axis }
func Axis(x layout.Axis) AxisOpt { return AxisOpt{x} }
var Horizontal = AxisOpt{ layout.Horizontal }
var Vertical = AxisOpt{ layout.Vertical }
type ListOpts struct {
AxisOpt