Widget catalog
Effects and painting
Widgets that change how their child looks, and the ones that paint on their own. None changes the layout.
Paints its child with a uniform transparency. At 0 the pointer, the focus and assistive technology skip it.
Package github.com/bankai-tensei/gowaku/widgets/basic
accent := geom . Hex ( 0x2f5fd0 )
return basic . Row { Size : layout . MainMin , Spacing : theme . Space12 , Children : [] core . Widget {
swatch ( "1.0" , accent ),
basic . Opacity { Opacity : 0.6 , Child : swatch ( "0.6" , accent )},
basic . Opacity { Opacity : 0.3 , Child : swatch ( "0.3" , accent )},
}}
Combines its child as one picture with what is below, as mix-blend-mode does in CSS.
Package github.com/bankai-tensei/gowaku/widgets/basic
backdrop := basic . Container { Width : 280 , Height : 80 , Radius : 12 , Gradient : & paint . Gradient {
End : geom . Offset { X : 280 }, StartColor : geom . Hex ( 0xfde047 ), EndColor : geom . Hex ( 0x10b981 ),
}}
return basic . Stack { Children : [] core . Widget {
backdrop ,
basic . Positioned { Left : 10 , Child : rings ()},
basic . Positioned { Left : 150 , Child : basic . Blend { Mode : paint . BlendMultiply , Child : rings ()}},
}}
Blurs what is painted below its box, then paints its child: frosted glass.
Package github.com/bankai-tensei/gowaku/widgets/basic
basic . Stack { Children : [] core . Widget {
busy ( 320 , 120 ),
basic . Positioned { Left : 40 , Top : 20 , Child : basic . BackdropFilter { Sigma : 12 , Radius : 16 , Child : basic . Container {
Width : 240 , Height : 80 , Radius : 16 , Color : geom . RGBA ( 1 , 1 , 1 , 0.4 ), Padding : geom . All ( 16 ),
Child : basic . Text { Content : "Frosted glass" , Style : text . Style { Size : 16 , Weight : 600 , Color : geom . Hex ( 0x111111 )}},
}}},
}}
Draws its child blurred, as filter: blur() does in CSS.
Package github.com/bankai-tensei/gowaku/widgets/basic
basic . Row { Size : layout . MainMin , Spacing : theme . Space24 , Children : [] core . Widget {
basic . Image { Source : photo (), Width : 140 },
basic . ImageFiltered { Sigma : 3 , Child : basic . Image { Source : photo (), Width : 140 }},
}}
Draws its child through a custom shader: shimmers, ripples, tints.
Package github.com/bankai-tensei/gowaku/widgets/basic
// shaders.Shimmer is a shader of examples/shader, made by cmd/gowaku-shader.
shimmer := paint . ShaderParams { 0.5 , 0.2 , 0.35 , 0 , 1 , 1 , 1 , 0.85 }
return basic . ShaderMask { Shader : shaders . Shimmer , Params : shimmer , Time : 1250 * time . Millisecond , Animate : true ,
Child : basic . Text { Content : "gowaku" , Style : text . Style { Size : 56 , Weight : 700 , Color : geom . Hex ( 0x2f5fd0 )}},
}
Turns, slants or stretches its child with an affine transform. The pointer and assistive technology follow the picture.
Package github.com/bankai-tensei/gowaku/widgets/basic
basic . Row { Size : layout . MainMin , Spacing : theme . Space28 , Children : [] core . Widget {
basic . Rotate ( 0.2 , swatch ( "Rotate" , geom . Hex ( 0x2f5fd0 ))),
basic . Skew ( 0.3 , 0 , swatch ( "Skew" , geom . Hex ( 0x10a37f ))),
basic . Transform { Transform : geom . Scaling ( 1.2 , 0.8 ), Origin : layout . AlignCenter , Child : swatch ( "Scale" , geom . Hex ( 0xd04a2f ))},
}}
Paints its child moved by a fraction of its size: the cheap move of a transition.
Package github.com/bankai-tensei/gowaku/widgets/basic
basic . Column { Size : layout . MainMin , Cross : layout . CrossStart , Spacing : theme . Space8 , Children : [] core . Widget {
tile ( "In place" , 140 , 32 ),
basic . Translate { X : 0.3 , Child : tile ( "X: 0.3 of its width" , 140 , 32 )},
}}
Cuts what its child paints to its box; ClipRRect rounds the corners, to the theme's card corners when Radius is 0. The pointer reaches the child only inside the cut shape.
Package github.com/bankai-tensei/gowaku/widgets/basic · Also basic.ClipRect
basic . Row { Size : layout . MainMin , Spacing : 40 , Children : [] core . Widget {
picture ,
basic . ClipRect { Child : picture },
basic . ClipRRect { Child : picture },
}}
Paints its child scaled around Origin: the cheap zoom of a transition.
Package github.com/bankai-tensei/gowaku/widgets/basic
basic . Row { Size : layout . MainMin , Spacing : theme . Space24 , Children : [] core . Widget {
tile ( "1.0" , 80 , 48 ),
basic . Scale { Scale : 0.8 , Origin : layout . AlignCenter , Child : tile ( "0.8" , 80 , 48 )},
basic . Scale { Scale : 1.2 , Origin : layout . AlignCenter , Child : tile ( "1.2" , 80 , 48 )},
}}
Paints with a layout.Painter, for charts, meters and other shapes no widget offers.
Package github.com/bankai-tensei/gowaku/widgets/control
control . CustomPaint { Width : 240 , Height : 100 , Painter : layout . PainterFunc ( func ( cv * paint . Canvas , sz geom . Size ) {
bars := [] float32 { 0.4 , 0.7 , 0.5 , 0.9 , 0.6 , 0.8 }
w := sz . W / float32 ( len ( bars ))
for i , v := range bars {
r := geom . Rect { X : float32 ( i ) * w + 4 , Y : sz . H * ( 1 - v ), W : w - 8 , H : sz . H * v }
cv . DrawRRect ( geom . RRectAll ( r , 4 ), paint . Paint { Color : geom . Hex ( 0x2f5fd0 ). WithAlpha ( 0.4 + v * 0.6 )})
}
var line paint . Path
line . MoveTo ( 0 , sz . H * 0.7 )
line . QuadTo ( sz . W / 2 , 0 , sz . W , sz . H * 0.4 )
cv . DrawPath ( & line , paint . Paint { Stroke : & paint . Stroke { Width : 2 , Color : geom . Hex ( 0xd04a2f )}})
})}
Keeps the picture of its child apart, so a change on one side does not repaint the other.
Package github.com/bankai-tensei/gowaku/widgets/basic
// A meter that changes on every frame keeps its repaints to itself.
return basic . RepaintBoundary { Child : basic . SizedBox { Width : 200 , Child : control . ProgressBar { Value : 0.45 , Label : "Level" }}}
Draws the pale 3px focus ring of the standard controls, for controls of your own.
Package github.com/bankai-tensei/gowaku/widgets/interact
themed ( func ( th * theme . Theme ) core . Widget {
return interact . FocusRing { Visible : true , Radius : th . Radius . Control , Child : basic . Container {
Width : 140 , Height : 36 , Radius : th . Radius . Control , Color : th . Color . AccentTint ,
Child : basic . Center { Child : basic . Text { Content : "Focus ring" , Style : colored ( th . Text . Control , th . Color . AccentInk )}},
}}
})