func (o *BubbleOverlay) LayoutChildren() { for _, child := range o.outer.Children() { bounds := o.outer.Size().Rect().Contract(o.outer.Padding()) arrowPadding := math.CreateSpacing(o.arrowLength) cm := child.Control.Margin() cs := child.Control.DesiredSize(math.ZeroSize, bounds.Size().Contract(cm).Max(math.ZeroSize)) cr := cs.Expand(arrowPadding).EdgeAlignedFit(bounds, o.targetPoint).Contract(arrowPadding) child.Layout(cr) } }
func CreateList(theme *Theme) gxui.List { l := &List{} l.Init(l, theme) l.OnGainedFocus(l.Redraw) l.OnLostFocus(l.Redraw) l.SetPadding(math.CreateSpacing(2)) l.SetBorderPen(gxui.TransparentPen) l.theme = theme return l }
func (i *Image) DesiredSize(min, max math.Size) math.Size { s := max switch i.scalingMode { case gxui.ScalingExplicitSize: s = i.explicitSize case gxui.Scaling1to1: switch { case i.texture != nil: s = i.texture.Size() case i.canvas != nil: s = i.canvas.Size() } } return s.Expand(math.CreateSpacing(int(i.BorderPen().Width))).Clamp(min, max) }
func CreateDropDownList(theme *Theme) gxui.DropDownList { l := &DropDownList{} l.Init(l, theme) l.OnGainedFocus(l.Redraw) l.OnLostFocus(l.Redraw) l.List().OnAttach(l.Redraw) l.List().OnDetach(l.Redraw) l.OnMouseEnter(func(gxui.MouseEvent) { l.SetBorderPen(theme.DropDownListOverStyle.Pen) }) l.OnMouseExit(func(gxui.MouseEvent) { l.SetBorderPen(theme.DropDownListDefaultStyle.Pen) }) l.SetPadding(math.CreateSpacing(2)) l.SetBorderPen(theme.DropDownListDefaultStyle.Pen) l.SetBackgroundBrush(theme.DropDownListDefaultStyle.Brush) l.theme = theme return l }