本文整理匯總了Golang中github.com/nelsam/gxui/math.Point.Add方法的典型用法代碼示例。如果您正苦於以下問題:Golang Point.Add方法的具體用法?Golang Point.Add怎麽用?Golang Point.Add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/nelsam/gxui/math.Point
的用法示例。
在下文中一共展示了Point.Add方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: ChildToParent
func ChildToParent(coord math.Point, from Control, to Parent) math.Point {
c := from
for {
p := c.Parent()
if p == nil {
panic(fmt.Errorf("Control detached: %s", Path(c)))
}
child := p.Children().Find(c)
if child == nil {
Dump(p)
panic(fmt.Errorf("Control's parent (%p %T) did not contain control (%p %T).", &p, p, &c, c))
}
coord = coord.Add(child.Offset)
if p == to {
return coord
}
if control, ok := p.(Control); ok {
c = control
} else {
Dump(p)
panic(fmt.Errorf("ChildToParent (%p %T) -> (%p %T) reached non-control parent (%p %T).",
&from, from, &to, to, &p, p))
}
}
}
示例2: PaintEditorSelections
func (l *CodeEditorLine) PaintEditorSelections(c gxui.Canvas, info CodeEditorLinePaintInfo) {
controller := l.textbox.controller
ls, le := uint64(controller.LineStart(l.lineIndex)), uint64(controller.LineEnd(l.lineIndex))
selections := controller.Selections()
if l.textbox.selectionDragging {
interval.Replace(&selections, l.textbox.selectionDrag)
}
interval.Visit(&selections, gxui.CreateTextSelection(int(ls), int(le), false), func(s, e uint64, _ int) {
if s < e {
var startOffset math.Point
if s > ls {
startOffset = l.endOfChar(info.GlyphOffsets[s-ls-1])
}
var endOffset math.Point
if e > ls {
endOffset = l.endOfChar(info.GlyphOffsets[e-ls-1])
}
width := endOffset.X - startOffset.X
m := l.outer.MeasureRunes(int(s), int(e))
m.W = width
top := math.Point{X: l.caretWidth + startOffset.X, Y: 0}
bottom := top.Add(m.Point())
l.outer.PaintSelection(c, top, bottom)
}
})
}
示例3: PaintCarets
func (t *DefaultTextBoxLine) PaintCarets(c gxui.Canvas) {
controller := t.textbox.controller
for i, cnt := 0, controller.SelectionCount(); i < cnt; i++ {
e := controller.Caret(i)
l := controller.LineIndex(e)
if l == t.lineIndex {
s := controller.LineStart(l)
m := t.outer.MeasureRunes(s, e)
top := math.Point{X: t.caretWidth + m.W, Y: 0}
bottom := top.Add(math.Point{X: 0, Y: t.Size().H})
t.outer.PaintCaret(c, top, bottom)
}
}
}
示例4: PaintEditorCarets
func (l *CodeEditorLine) PaintEditorCarets(c gxui.Canvas, info CodeEditorLinePaintInfo) {
controller := l.textbox.controller
for i, count := 0, controller.SelectionCount(); i < count; i++ {
caret := controller.Caret(i)
line := controller.LineIndex(caret)
if line == l.lineIndex {
var offset math.Point
start := controller.LineStart(line)
if len(info.GlyphOffsets) > 0 && caret > start {
caretOffsetIndex := caret - start - 1
offset = l.endOfChar(info.GlyphOffsets[caretOffsetIndex])
}
top := math.Point{X: l.caretWidth + offset.X, Y: 0}
bottom := top.Add(math.Point{X: 0, Y: l.Size().H})
l.outer.PaintCaret(c, top, bottom)
}
}
}
示例5: PaintSelections
func (t *DefaultTextBoxLine) PaintSelections(c gxui.Canvas) {
controller := t.textbox.controller
ls, le := controller.LineStart(t.lineIndex), controller.LineEnd(t.lineIndex)
selections := controller.Selections()
if t.textbox.selectionDragging {
interval.Replace(&selections, t.textbox.selectionDrag)
}
interval.Visit(&selections, gxui.CreateTextSelection(ls, le, false), func(s, e uint64, _ int) {
if s < e {
x := t.outer.MeasureRunes(ls, int(s)).W
m := t.outer.MeasureRunes(int(s), int(e))
top := math.Point{X: t.caretWidth + x, Y: 0}
bottom := top.Add(m.Point())
t.outer.PaintSelection(c, top, bottom)
}
})
}