Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| dca1eaefb5 | |||
| 87e81c00d3 | |||
| 224ca25000 |
12
container.go
12
container.go
@@ -23,13 +23,23 @@ func newContainer (layout tomo.Layout, children ...tomo.Object) *Container {
|
||||
return this
|
||||
}
|
||||
|
||||
// NewOuterContainer creates a new container that has padding around it.
|
||||
// NewOuterContainer creates a new container that has padding around it, as well
|
||||
// as a solid background color. It is meant to be used as a root container for a
|
||||
// window, tab pane, etc.
|
||||
func NewOuterContainer (layout tomo.Layout, children ...tomo.Object) *Container {
|
||||
this := newContainer(layout, children...)
|
||||
theme.Apply(this, theme.R("objects", "Container", "outer"))
|
||||
return this
|
||||
}
|
||||
|
||||
// NewSunkenContainer creates a new container with a sunken style and padding
|
||||
// around it. It is meant to be used as a root container for a ScrollContainer.
|
||||
func NewSunkenContainer (layout tomo.Layout, children ...tomo.Object) *Container {
|
||||
this := newContainer(layout, children...)
|
||||
theme.Apply(this, theme.R("objects", "Container", "sunken"))
|
||||
return this
|
||||
}
|
||||
|
||||
// NewInnerContainer creates a new container that has no padding around it.
|
||||
func NewInnerContainer (layout tomo.Layout, children ...tomo.Object) *Container {
|
||||
this := newContainer(layout, children...)
|
||||
|
||||
@@ -12,10 +12,10 @@ type Heading struct {
|
||||
}
|
||||
|
||||
// NewHeading creates a new section heading. The level can be from 0 to 2.
|
||||
func NewHeading (level int, text string) *Label {
|
||||
func NewHeading (level int, text string) *Heading {
|
||||
if level < 0 { level = 0 }
|
||||
if level > 2 { level = 2 }
|
||||
this := &Label { TextBox: tomo.NewTextBox() }
|
||||
this := &Heading { TextBox: tomo.NewTextBox() }
|
||||
theme.Apply(this, theme.R("objects", "Heading", fmt.Sprint(level)))
|
||||
this.SetText(text)
|
||||
return this
|
||||
|
||||
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 {
|
||||
|
||||
Reference in New Issue
Block a user