本文整理匯總了Golang中github.com/nelsam/gxui/math.Size.Max方法的典型用法代碼示例。如果您正苦於以下問題:Golang Size.Max方法的具體用法?Golang Size.Max怎麽用?Golang Size.Max使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/nelsam/gxui/math.Size
的用法示例。
在下文中一共展示了Size.Max方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Measure
func (f *font) Measure(fl *gxui.TextBlock) math.Size {
size := math.Size{W: 0, H: f.glyphMaxSizeDips.H}
var offset math.Point
for _, r := range fl.Runes {
if r == '\n' {
offset.X = 0
offset.Y += f.glyphMaxSizeDips.H
continue
}
offset.X += f.advanceDips(r)
size = size.Max(math.Size{W: offset.X, H: offset.Y + f.glyphMaxSizeDips.H})
}
return size
}
示例2: Layout
func (f *font) Layout(fl *gxui.TextBlock) (offsets []math.Point) {
sizeDips := math.Size{}
offsets = make([]math.Point, len(fl.Runes))
var offset math.Point
for i, r := range fl.Runes {
if r == '\n' {
offset.X = 0
offset.Y += f.glyphMaxSizeDips.H
continue
}
offsets[i] = offset
offset.X += f.advanceDips(r)
sizeDips = sizeDips.Max(math.Size{W: offset.X, H: offset.Y + f.glyphMaxSizeDips.H})
}
origin := f.align(fl.AlignRect, sizeDips, f.ascentDips, fl.H, fl.V)
for i, p := range offsets {
offsets[i] = p.Add(origin)
}
return offsets
}
示例3: SetSizeAsLargest
func (a *DefaultAdapter) SetSizeAsLargest(theme Theme) {
s := math.Size{}
font := theme.DefaultFont()
for i := 0; i < a.Count(); i++ {
switch t := a.ItemAt(i).(type) {
case Viewer:
s = s.Max(t.View(theme).DesiredSize(math.ZeroSize, math.MaxSize))
case Stringer:
s = s.Max(font.Measure(&TextBlock{
Runes: []rune(t.String()),
}))
default:
s = s.Max(font.Measure(&TextBlock{
Runes: []rune(fmt.Sprintf("%+v", t)),
}))
}
}
a.SetSize(s)
}