Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 05f3ebc9e5 | |||
| 996d747d45 | |||
| cd72ae5bdd | |||
| a64c27953a | |||
| 8f555f82ee | |||
| 79f81688bb | |||
| b926881233 | |||
| b9092eae87 | |||
| 96fa7b5623 | |||
| 664ce5f556 | |||
| c409bc1a1e | |||
| 6a2dc36140 | |||
| 0e2ad5bb4f | |||
| 78e13ed045 | |||
| 0c540d0e41 |
38
box.go
38
box.go
@@ -117,14 +117,34 @@ func (this *box) SetColor (c color.Color) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *box) SetTexture (texture canvas.Texture) {
|
func (this *box) SetTexture (texture canvas.Texture) {
|
||||||
|
if this.texture == texture { return }
|
||||||
this.texture = xcanvas.AssertTexture(texture)
|
this.texture = xcanvas.AssertTexture(texture)
|
||||||
this.invalidateDraw()
|
this.invalidateDraw()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *box) SetBorder (border ...tomo.Border) {
|
func (this *box) SetBorder (borders ...tomo.Border) {
|
||||||
this.border = border
|
previousBorderSum := this.borderSum()
|
||||||
this.invalidateLayout()
|
previousBorders := this.border
|
||||||
this.invalidateMinimum()
|
this.border = borders
|
||||||
|
|
||||||
|
// only invalidate the layout if the border is sized differently
|
||||||
|
if this.borderSum() != previousBorderSum {
|
||||||
|
this.invalidateLayout()
|
||||||
|
this.invalidateMinimum()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// if the border takes up the same amount of space, only invalidate the
|
||||||
|
// drawing if it looks different
|
||||||
|
for index, newBorder := range this.border {
|
||||||
|
different :=
|
||||||
|
index >= len(previousBorders) ||
|
||||||
|
newBorder != previousBorders[index]
|
||||||
|
if different {
|
||||||
|
this.invalidateDraw()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *box) SetMinimumSize (size image.Point) {
|
func (this *box) SetMinimumSize (size image.Point) {
|
||||||
@@ -285,7 +305,7 @@ func (this *box) Draw (can canvas.Canvas) {
|
|||||||
if this.transparent() && this.parent != nil {
|
if this.transparent() && this.parent != nil {
|
||||||
this.parent.drawBackgroundPart(can)
|
this.parent.drawBackgroundPart(can)
|
||||||
}
|
}
|
||||||
pen.Rectangle(can.Bounds())
|
pen.Rectangle(this.Bounds())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *box) drawBorders (can canvas.Canvas) {
|
func (this *box) drawBorders (can canvas.Canvas) {
|
||||||
@@ -356,7 +376,11 @@ func (this *box) doMinimumSize () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// var drawcnt int
|
||||||
func (this *box) doDraw () {
|
func (this *box) doDraw () {
|
||||||
|
// println("DRAW", drawcnt)
|
||||||
|
// drawcnt ++
|
||||||
|
|
||||||
if this.canvas == nil { return }
|
if this.canvas == nil { return }
|
||||||
if this.drawer != nil {
|
if this.drawer != nil {
|
||||||
this.drawBorders(this.canvas)
|
this.drawBorders(this.canvas)
|
||||||
@@ -364,7 +388,11 @@ func (this *box) doDraw () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// var laycnt int
|
||||||
func (this *box) doLayout () {
|
func (this *box) doLayout () {
|
||||||
|
// println("LAYOUT", laycnt)
|
||||||
|
// laycnt ++
|
||||||
|
|
||||||
this.innerClippingBounds = this.borderSum().Apply(this.bounds)
|
this.innerClippingBounds = this.borderSum().Apply(this.bounds)
|
||||||
if this.parent == nil { this.canvas = nil; return }
|
if this.parent == nil { this.canvas = nil; return }
|
||||||
parentCanvas := this.parent.canvas()
|
parentCanvas := this.parent.canvas()
|
||||||
|
|||||||
@@ -31,11 +31,13 @@ func (backend *Backend) NewContainerBox() tomo.ContainerBox {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *containerBox) SetColor (c color.Color) {
|
func (this *containerBox) SetColor (c color.Color) {
|
||||||
|
if this.color == c { return }
|
||||||
this.box.SetColor(c)
|
this.box.SetColor(c)
|
||||||
this.invalidateTransparentChildren()
|
this.invalidateTransparentChildren()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *containerBox) SetTexture (texture canvas.Texture) {
|
func (this *containerBox) SetTexture (texture canvas.Texture) {
|
||||||
|
if this.texture == texture { return }
|
||||||
this.box.SetTexture(texture)
|
this.box.SetTexture(texture)
|
||||||
this.invalidateTransparentChildren()
|
this.invalidateTransparentChildren()
|
||||||
}
|
}
|
||||||
@@ -59,7 +61,7 @@ func (this *containerBox) ContentBounds () image.Rectangle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *containerBox) ScrollTo (point image.Point) {
|
func (this *containerBox) ScrollTo (point image.Point) {
|
||||||
// TODO: constrain scroll
|
if this.scroll == point { return }
|
||||||
this.scroll = point
|
this.scroll = point
|
||||||
this.invalidateLayout()
|
this.invalidateLayout()
|
||||||
}
|
}
|
||||||
@@ -68,19 +70,19 @@ func (this *containerBox) OnContentBoundsChange (callback func()) event.Cookie {
|
|||||||
return this.on.contentBoundsChange.Connect(callback)
|
return this.on.contentBoundsChange.Connect(callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *containerBox) CaptureDND (capture bool) {
|
func (this *containerBox) CaptureDND (capture bool) {
|
||||||
this.capture[eventCategoryDND] = capture
|
this.capture[eventCategoryDND] = capture
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *containerBox) CaptureMouse (capture bool) {
|
func (this *containerBox) CaptureMouse (capture bool) {
|
||||||
this.capture[eventCategoryMouse] = capture
|
this.capture[eventCategoryMouse] = capture
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *containerBox) CaptureScroll (capture bool) {
|
func (this *containerBox) CaptureScroll (capture bool) {
|
||||||
this.capture[eventCategoryScroll] = capture
|
this.capture[eventCategoryScroll] = capture
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *containerBox) CaptureKeyboard (capture bool) {
|
func (this *containerBox) CaptureKeyboard (capture bool) {
|
||||||
this.capture[eventCategoryKeyboard] = capture
|
this.capture[eventCategoryKeyboard] = capture
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,10 +121,14 @@ func (this *containerBox) Insert (child, before tomo.Object) {
|
|||||||
|
|
||||||
beforeBox := assertAnyBox(before.GetBox())
|
beforeBox := assertAnyBox(before.GetBox())
|
||||||
index := indexOf(this.children, tomo.Box(beforeBox))
|
index := indexOf(this.children, tomo.Box(beforeBox))
|
||||||
if index < 0 { return }
|
|
||||||
|
if index < 0 {
|
||||||
|
this.children = append(this.children, tomo.Box(box))
|
||||||
|
} else {
|
||||||
|
this.children = insert(this.children, index, tomo.Box(box))
|
||||||
|
}
|
||||||
box.setParent(this)
|
box.setParent(this)
|
||||||
this.children = insert(this.children, index, tomo.Box(box))
|
|
||||||
this.invalidateLayout()
|
this.invalidateLayout()
|
||||||
this.invalidateMinimum()
|
this.invalidateMinimum()
|
||||||
}
|
}
|
||||||
@@ -222,9 +228,7 @@ func (this *containerBox) notifyMinimumSizeChange (child anyBox) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *containerBox) layoutHints () tomo.LayoutHints {
|
func (this *containerBox) layoutHints () tomo.LayoutHints {
|
||||||
innerBounds := this.InnerBounds().Sub(this.scroll)
|
|
||||||
return tomo.LayoutHints {
|
return tomo.LayoutHints {
|
||||||
Bounds: innerBounds,
|
|
||||||
OverflowX: this.hOverflow,
|
OverflowX: this.hOverflow,
|
||||||
OverflowY: this.vOverflow,
|
OverflowY: this.vOverflow,
|
||||||
AlignX: this.hAlign,
|
AlignX: this.hAlign,
|
||||||
@@ -236,10 +240,12 @@ func (this *containerBox) layoutHints () tomo.LayoutHints {
|
|||||||
func (this *containerBox) contentMinimum () image.Point {
|
func (this *containerBox) contentMinimum () image.Point {
|
||||||
minimum := this.box.contentMinimum()
|
minimum := this.box.contentMinimum()
|
||||||
if this.layout != nil {
|
if this.layout != nil {
|
||||||
minimum = minimum.Add (
|
layoutMinimum := this.layout.MinimumSize (
|
||||||
this.layout.MinimumSize (
|
this.layoutHints(),
|
||||||
this.layoutHints(),
|
this.children)
|
||||||
this.children))
|
if this.hOverflow { layoutMinimum.X = 0 }
|
||||||
|
if this.vOverflow { layoutMinimum.Y = 0 }
|
||||||
|
minimum = minimum.Add(layoutMinimum)
|
||||||
}
|
}
|
||||||
return minimum
|
return minimum
|
||||||
}
|
}
|
||||||
@@ -247,14 +253,73 @@ func (this *containerBox) contentMinimum () image.Point {
|
|||||||
func (this *containerBox) doLayout () {
|
func (this *containerBox) doLayout () {
|
||||||
this.box.doLayout()
|
this.box.doLayout()
|
||||||
previousContentBounds := this.contentBounds
|
previousContentBounds := this.contentBounds
|
||||||
|
|
||||||
|
// by default, use innerBounds (translated to 0, 0) for contentBounds.
|
||||||
|
// if a direction overflows, use the layout's minimum size for it.
|
||||||
|
var minimum image.Point
|
||||||
if this.layout != nil {
|
if this.layout != nil {
|
||||||
this.layout.Arrange(this.layoutHints(), this.children)
|
minimum = this.layout.MinimumSize (
|
||||||
|
this.layoutHints(),
|
||||||
|
this.children)
|
||||||
}
|
}
|
||||||
|
innerBounds := this.InnerBounds()
|
||||||
|
this.contentBounds = innerBounds.Sub(innerBounds.Min)
|
||||||
|
if this.hOverflow { this.contentBounds.Max.X = this.contentBounds.Min.X + minimum.X }
|
||||||
|
if this.vOverflow { this.contentBounds.Max.Y = this.contentBounds.Min.Y + minimum.Y }
|
||||||
|
|
||||||
|
// arrange children
|
||||||
|
if this.layout != nil {
|
||||||
|
layoutHints := this.layoutHints()
|
||||||
|
layoutHints.Bounds = this.contentBounds
|
||||||
|
this.layout.Arrange(layoutHints, this.children)
|
||||||
|
}
|
||||||
|
|
||||||
|
// build an accurate contentBounds by unioning the bounds of all child
|
||||||
|
// boxes
|
||||||
|
this.contentBounds = image.Rectangle { }
|
||||||
|
for _, box := range this.children {
|
||||||
|
bounds := box.Bounds()
|
||||||
|
this.contentBounds = this.contentBounds.Union(bounds)
|
||||||
|
}
|
||||||
|
|
||||||
|
// constrain the scroll
|
||||||
|
this.constrainScroll()
|
||||||
|
|
||||||
|
// offset children and contentBounds by scroll
|
||||||
|
for _, box := range this.children {
|
||||||
|
box.SetBounds(box.Bounds().Add(this.scroll).Add(innerBounds.Min))
|
||||||
|
}
|
||||||
|
this.contentBounds = this.contentBounds.Add(this.scroll)
|
||||||
|
|
||||||
if previousContentBounds != this.contentBounds {
|
if previousContentBounds != this.contentBounds {
|
||||||
this.on.contentBoundsChange.Broadcast()
|
this.on.contentBoundsChange.Broadcast()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *containerBox) constrainScroll () {
|
||||||
|
innerBounds := this.InnerBounds()
|
||||||
|
width := this.contentBounds.Dx()
|
||||||
|
height := this.contentBounds.Dy()
|
||||||
|
|
||||||
|
// X
|
||||||
|
if width <= innerBounds.Dx() {
|
||||||
|
this.scroll.X = 0
|
||||||
|
} else if this.scroll.X > 0 {
|
||||||
|
this.scroll.X = 0
|
||||||
|
} else if this.scroll.X < innerBounds.Dx() - width {
|
||||||
|
this.scroll.X = innerBounds.Dx() - width
|
||||||
|
}
|
||||||
|
|
||||||
|
// Y
|
||||||
|
if height <= innerBounds.Dy() {
|
||||||
|
this.scroll.Y = 0
|
||||||
|
} else if this.scroll.Y > 0 {
|
||||||
|
this.scroll.Y = 0
|
||||||
|
} else if this.scroll.Y < innerBounds.Dy() - height {
|
||||||
|
this.scroll.Y = innerBounds.Dy() - height
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (this *containerBox) recursiveRedo () {
|
func (this *containerBox) recursiveRedo () {
|
||||||
this.doLayout()
|
this.doLayout()
|
||||||
this.doDraw()
|
this.doDraw()
|
||||||
@@ -264,6 +329,8 @@ func (this *containerBox) recursiveRedo () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *containerBox) boxUnder (point image.Point, category eventCategory) anyBox {
|
func (this *containerBox) boxUnder (point image.Point, category eventCategory) anyBox {
|
||||||
|
if !point.In(this.bounds) { return nil }
|
||||||
|
|
||||||
if !this.capture[category] {
|
if !this.capture[category] {
|
||||||
for _, box := range this.children {
|
for _, box := range this.children {
|
||||||
candidate := box.(anyBox).boxUnder(point, category)
|
candidate := box.(anyBox).boxUnder(point, category)
|
||||||
@@ -271,7 +338,7 @@ func (this *containerBox) boxUnder (point image.Point, category eventCategory) a
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.box.boxUnder(point, category)
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *containerBox) propagate (callback func (anyBox) bool) bool {
|
func (this *containerBox) propagate (callback func (anyBox) bool) bool {
|
||||||
|
|||||||
23
event.go
23
event.go
@@ -161,16 +161,17 @@ func (window *window) handleConfigureNotify (
|
|||||||
if window.root == nil { return }
|
if window.root == nil { return }
|
||||||
|
|
||||||
configureEvent := *event.ConfigureNotifyEvent
|
configureEvent := *event.ConfigureNotifyEvent
|
||||||
|
configureEvent = window.compressConfigureNotify(configureEvent)
|
||||||
|
|
||||||
newWidth := int(configureEvent.Width)
|
oldBounds := window.metrics.bounds
|
||||||
newHeight := int(configureEvent.Height)
|
|
||||||
sizeChanged :=
|
|
||||||
window.metrics.bounds.Dx() != newWidth ||
|
|
||||||
window.metrics.bounds.Dy() != newHeight
|
|
||||||
window.updateBounds()
|
window.updateBounds()
|
||||||
|
newBounds := window.metrics.bounds
|
||||||
|
|
||||||
|
sizeChanged :=
|
||||||
|
oldBounds.Dx() != newBounds.Dx() ||
|
||||||
|
oldBounds.Dy() != newBounds.Dy()
|
||||||
|
|
||||||
if sizeChanged {
|
if sizeChanged {
|
||||||
configureEvent = window.compressConfigureNotify(configureEvent)
|
|
||||||
window.reallocateCanvas()
|
window.reallocateCanvas()
|
||||||
|
|
||||||
// TODO figure out what to do with this
|
// TODO figure out what to do with this
|
||||||
@@ -339,11 +340,13 @@ func (window *window) handleMotionNotify (
|
|||||||
}
|
}
|
||||||
|
|
||||||
underneath := window.boxUnder(image.Pt(x, y), eventCategoryMouse)
|
underneath := window.boxUnder(image.Pt(x, y), eventCategoryMouse)
|
||||||
window.hover(underneath)
|
if underneath != nil {
|
||||||
|
window.hover(underneath)
|
||||||
if !handled {
|
if !handled {
|
||||||
underneath.handleMouseMove()
|
underneath.handleMouseMove()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (window *window) compressExpose (
|
func (window *window) compressExpose (
|
||||||
|
|||||||
4
go.mod
4
go.mod
@@ -3,8 +3,8 @@ module git.tebibyte.media/tomo/x
|
|||||||
go 1.20
|
go 1.20
|
||||||
|
|
||||||
require (
|
require (
|
||||||
git.tebibyte.media/tomo/tomo v0.30.0
|
git.tebibyte.media/tomo/tomo v0.31.0
|
||||||
git.tebibyte.media/tomo/typeset v0.7.0
|
git.tebibyte.media/tomo/typeset v0.7.1
|
||||||
git.tebibyte.media/tomo/xgbkb v1.0.1
|
git.tebibyte.media/tomo/xgbkb v1.0.1
|
||||||
github.com/jezek/xgb v1.1.0
|
github.com/jezek/xgb v1.1.0
|
||||||
github.com/jezek/xgbutil v0.0.0-20230603163917-04188eb39cf0
|
github.com/jezek/xgbutil v0.0.0-20230603163917-04188eb39cf0
|
||||||
|
|||||||
8
go.sum
8
go.sum
@@ -1,8 +1,8 @@
|
|||||||
git.tebibyte.media/sashakoshka/xgbkb v1.0.0/go.mod h1:pNcE6TRO93vHd6q42SdwLSTTj25L0Yzggz7yLe0JV6Q=
|
git.tebibyte.media/sashakoshka/xgbkb v1.0.0/go.mod h1:pNcE6TRO93vHd6q42SdwLSTTj25L0Yzggz7yLe0JV6Q=
|
||||||
git.tebibyte.media/tomo/tomo v0.30.0 h1:JoTklJ7yFVrzre4AwuKBMwzho9GomC9ySw354wDB4f4=
|
git.tebibyte.media/tomo/tomo v0.31.0 h1:LHPpj3AWycochnC8F441aaRNS6Tq6w6WnBrp/LGjyhM=
|
||||||
git.tebibyte.media/tomo/tomo v0.30.0/go.mod h1:C9EzepS9wjkTJjnZaPBh22YvVPyA4hbBAJVU20Rdmps=
|
git.tebibyte.media/tomo/tomo v0.31.0/go.mod h1:C9EzepS9wjkTJjnZaPBh22YvVPyA4hbBAJVU20Rdmps=
|
||||||
git.tebibyte.media/tomo/typeset v0.7.0 h1:JFpEuGmN6R2XSCvkINYxpH0AyYUqqs+dZYr6OSd91y0=
|
git.tebibyte.media/tomo/typeset v0.7.1 h1:aZrsHwCG5ZB4f5CruRFsxLv5ezJUCFUFsQJJso2sXQ8=
|
||||||
git.tebibyte.media/tomo/typeset v0.7.0/go.mod h1:PwDpSdBF3l/EzoIsa2ME7QffVVajnTHZN6l3MHEGe1g=
|
git.tebibyte.media/tomo/typeset v0.7.1/go.mod h1:PwDpSdBF3l/EzoIsa2ME7QffVVajnTHZN6l3MHEGe1g=
|
||||||
git.tebibyte.media/tomo/xgbkb v1.0.1 h1:b3HDUopjdQp1MZrb5Vpil4bOtk3NnNXtfQW27Blw2kE=
|
git.tebibyte.media/tomo/xgbkb v1.0.1 h1:b3HDUopjdQp1MZrb5Vpil4bOtk3NnNXtfQW27Blw2kE=
|
||||||
git.tebibyte.media/tomo/xgbkb v1.0.1/go.mod h1:P5Du0yo5hUsojchW08t+Mds0XPIJXwMi733ZfklzjRw=
|
git.tebibyte.media/tomo/xgbkb v1.0.1/go.mod h1:P5Du0yo5hUsojchW08t+Mds0XPIJXwMi733ZfklzjRw=
|
||||||
github.com/BurntSushi/freetype-go v0.0.0-20160129220410-b763ddbfe298 h1:1qlsVAQJXZHsaM8b6OLVo6muQUQd4CwkH/D3fnnbHXA=
|
github.com/BurntSushi/freetype-go v0.0.0-20160129220410-b763ddbfe298 h1:1qlsVAQJXZHsaM8b6OLVo6muQUQd4CwkH/D3fnnbHXA=
|
||||||
|
|||||||
23
textbox.go
23
textbox.go
@@ -222,7 +222,7 @@ func (this *textBox) drawDot (can canvas.Canvas) {
|
|||||||
|
|
||||||
func (this *textBox) textOffset () image.Point {
|
func (this *textBox) textOffset () image.Point {
|
||||||
return this.InnerBounds().Min.
|
return this.InnerBounds().Min.
|
||||||
Sub(this.scroll).
|
Add(this.scroll).
|
||||||
Sub(this.drawer.LayoutBoundsSpace().Min)
|
Sub(this.drawer.LayoutBoundsSpace().Min)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -294,6 +294,7 @@ func (this *textBox) doLayout () {
|
|||||||
this.contentBounds = this.normalizedLayoutBoundsSpace()
|
this.contentBounds = this.normalizedLayoutBoundsSpace()
|
||||||
this.constrainScroll()
|
this.constrainScroll()
|
||||||
this.contentBounds = this.contentBounds.Add(this.scroll)
|
this.contentBounds = this.contentBounds.Add(this.scroll)
|
||||||
|
// println(this.InnerBounds().String(), this.contentBounds.String())
|
||||||
|
|
||||||
if previousContentBounds != this.contentBounds {
|
if previousContentBounds != this.contentBounds {
|
||||||
this.on.contentBoundsChange.Broadcast()
|
this.on.contentBoundsChange.Broadcast()
|
||||||
@@ -308,19 +309,19 @@ func (this *textBox) constrainScroll () {
|
|||||||
// X
|
// X
|
||||||
if width <= innerBounds.Dx() {
|
if width <= innerBounds.Dx() {
|
||||||
this.scroll.X = 0
|
this.scroll.X = 0
|
||||||
} else if this.scroll.X < 0 {
|
} else if this.scroll.X > 0 {
|
||||||
this.scroll.X = 0
|
this.scroll.X = 0
|
||||||
} else if this.scroll.X > width - innerBounds.Dx() {
|
} else if this.scroll.X < innerBounds.Dx() - width {
|
||||||
this.scroll.X = width - innerBounds.Dx()
|
this.scroll.X = innerBounds.Dx() - width
|
||||||
}
|
}
|
||||||
|
|
||||||
// Y
|
// Y
|
||||||
if height <= innerBounds.Dy() {
|
if height <= innerBounds.Dy() {
|
||||||
this.scroll.Y = 0
|
this.scroll.Y = 0
|
||||||
} else if this.scroll.Y < 0 {
|
} else if this.scroll.Y > 0 {
|
||||||
this.scroll.Y = 0
|
this.scroll.Y = 0
|
||||||
} else if this.scroll.Y > height - innerBounds.Dy() {
|
} else if this.scroll.Y < innerBounds.Dy() - height {
|
||||||
this.scroll.Y = height - innerBounds.Dy()
|
this.scroll.Y = innerBounds.Dy() - height
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -333,16 +334,16 @@ func (this *textBox) scrollToDot () {
|
|||||||
|
|
||||||
// X
|
// X
|
||||||
if dot.X < innerBounds.Min.X + em {
|
if dot.X < innerBounds.Min.X + em {
|
||||||
scroll.X -= innerBounds.Min.X - dot.X + em
|
scroll.X += innerBounds.Min.X - dot.X + em
|
||||||
} else if dot.X > innerBounds.Max.X - em {
|
} else if dot.X > innerBounds.Max.X - em {
|
||||||
scroll.X += dot.X - innerBounds.Max.X + em
|
scroll.X -= dot.X - innerBounds.Max.X + em
|
||||||
}
|
}
|
||||||
|
|
||||||
// Y
|
// Y
|
||||||
if dot.Y < innerBounds.Min.Y + lineHeight {
|
if dot.Y < innerBounds.Min.Y + lineHeight {
|
||||||
scroll.Y -= innerBounds.Min.Y - dot.Y + lineHeight
|
scroll.Y += innerBounds.Min.Y - dot.Y + lineHeight
|
||||||
} else if dot.Y > innerBounds.Max.Y - lineHeight {
|
} else if dot.Y > innerBounds.Max.Y - lineHeight {
|
||||||
scroll.Y += dot.Y - innerBounds.Max.Y + lineHeight
|
scroll.Y -= dot.Y - innerBounds.Max.Y + lineHeight
|
||||||
}
|
}
|
||||||
|
|
||||||
this.ScrollTo(scroll)
|
this.ScrollTo(scroll)
|
||||||
|
|||||||
17
x/plugin.go
17
x/plugin.go
@@ -1,17 +0,0 @@
|
|||||||
// Plugin x provides the X11 backend as a plugin.
|
|
||||||
package main
|
|
||||||
|
|
||||||
import "git.tebibyte.media/tomo/x"
|
|
||||||
import "git.tebibyte.media/tomo/tomo"
|
|
||||||
|
|
||||||
func init () {
|
|
||||||
tomo.Register(0, tomo.Factory(x.NewBackend))
|
|
||||||
}
|
|
||||||
|
|
||||||
func Name () string {
|
|
||||||
return "X"
|
|
||||||
}
|
|
||||||
|
|
||||||
func Description () string {
|
|
||||||
return "Provides an X11 backend."
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user