Scrollbar and ScrollContainer use ScrollTo correctly
This commit is contained in:
		
							parent
							
								
									224ca25000
								
							
						
					
					
						commit
						87e81c00d3
					
				
							
								
								
									
										16
									
								
								scrollbar.go
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								scrollbar.go
									
									
									
									
									
								
							@ -98,9 +98,9 @@ func (this *Scrollbar) SetValue (value float64) {
 | 
			
		||||
	position    := trackLength * value
 | 
			
		||||
	point       := this.layout.linked.ContentBounds().Min
 | 
			
		||||
	if this.layout.vertical {
 | 
			
		||||
		point.Y = int(position)
 | 
			
		||||
		point.Y = -int(position)
 | 
			
		||||
	} else {
 | 
			
		||||
		point.X = int(position)
 | 
			
		||||
		point.X = -int(position)
 | 
			
		||||
	}
 | 
			
		||||
	this.layout.linked.ScrollTo(point)
 | 
			
		||||
	
 | 
			
		||||
@ -173,15 +173,15 @@ func (this *Scrollbar) handleMouseDown (button input.Button) {
 | 
			
		||||
		}
 | 
			
		||||
	case input.ButtonMiddle:
 | 
			
		||||
		if above {
 | 
			
		||||
			this.scrollBy(-this.pageSize())
 | 
			
		||||
		} else {
 | 
			
		||||
			this.scrollBy(this.pageSize())
 | 
			
		||||
		} else {
 | 
			
		||||
			this.scrollBy(-this.pageSize())
 | 
			
		||||
		}
 | 
			
		||||
	case input.ButtonRight:
 | 
			
		||||
		if above {
 | 
			
		||||
			this.scrollBy(-this.stepSize())
 | 
			
		||||
		} else {
 | 
			
		||||
			this.scrollBy(this.stepSize())
 | 
			
		||||
		} else {
 | 
			
		||||
			this.scrollBy(-this.stepSize())
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@ -200,7 +200,7 @@ func (this *Scrollbar) handleScroll (x, y float64) {
 | 
			
		||||
	if this.layout.linked == nil { return }
 | 
			
		||||
	this.layout.linked.ScrollTo (
 | 
			
		||||
		this.layout.linked.ContentBounds().Min.
 | 
			
		||||
		Add(image.Pt(int(x), int(y))))
 | 
			
		||||
		Sub(image.Pt(int(x), int(y))))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (this *Scrollbar) drag () {
 | 
			
		||||
@ -327,7 +327,7 @@ func (this scrollbarLayout) Arrange (hints tomo.LayoutHints, boxes []tomo.Box) {
 | 
			
		||||
	} else {
 | 
			
		||||
		handleOffset = image.Pt(int(handlePosition), 0)
 | 
			
		||||
	}
 | 
			
		||||
	handle = handle.Add(handleOffset).Add(gutter.Min)
 | 
			
		||||
	handle = handle.Sub(handleOffset).Add(gutter.Min)
 | 
			
		||||
	
 | 
			
		||||
	// place handle
 | 
			
		||||
	boxes[0].SetBounds(handle)
 | 
			
		||||
 | 
			
		||||
@ -108,7 +108,7 @@ func (this *ScrollContainer) handleScroll (x, y float64) {
 | 
			
		||||
	if this.layout.root == nil { return }
 | 
			
		||||
	this.layout.root.ScrollTo (
 | 
			
		||||
		this.layout.root.ContentBounds().Min.
 | 
			
		||||
		Add(image.Pt(int(x), int(y))))
 | 
			
		||||
		Sub(image.Pt(int(x), int(y))))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type scrollContainerLayout struct {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user