3 Commits

4 changed files with 22 additions and 12 deletions

View File

@@ -23,13 +23,23 @@ func newContainer (layout tomo.Layout, children ...tomo.Object) *Container {
return this 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 { func NewOuterContainer (layout tomo.Layout, children ...tomo.Object) *Container {
this := newContainer(layout, children...) this := newContainer(layout, children...)
theme.Apply(this, theme.R("objects", "Container", "outer")) theme.Apply(this, theme.R("objects", "Container", "outer"))
return this 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. // NewInnerContainer creates a new container that has no padding around it.
func NewInnerContainer (layout tomo.Layout, children ...tomo.Object) *Container { func NewInnerContainer (layout tomo.Layout, children ...tomo.Object) *Container {
this := newContainer(layout, children...) this := newContainer(layout, children...)

View File

@@ -12,10 +12,10 @@ type Heading struct {
} }
// NewHeading creates a new section heading. The level can be from 0 to 2. // 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 < 0 { level = 0 }
if level > 2 { level = 2 } 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))) theme.Apply(this, theme.R("objects", "Heading", fmt.Sprint(level)))
this.SetText(text) this.SetText(text)
return this return this

View File

@@ -98,9 +98,9 @@ func (this *Scrollbar) SetValue (value float64) {
position := trackLength * value position := trackLength * value
point := this.layout.linked.ContentBounds().Min point := this.layout.linked.ContentBounds().Min
if this.layout.vertical { if this.layout.vertical {
point.Y = int(position) point.Y = -int(position)
} else { } else {
point.X = int(position) point.X = -int(position)
} }
this.layout.linked.ScrollTo(point) this.layout.linked.ScrollTo(point)
@@ -173,15 +173,15 @@ func (this *Scrollbar) handleMouseDown (button input.Button) {
} }
case input.ButtonMiddle: case input.ButtonMiddle:
if above { if above {
this.scrollBy(-this.pageSize())
} else {
this.scrollBy(this.pageSize()) this.scrollBy(this.pageSize())
} else {
this.scrollBy(-this.pageSize())
} }
case input.ButtonRight: case input.ButtonRight:
if above { if above {
this.scrollBy(-this.stepSize())
} else {
this.scrollBy(this.stepSize()) 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 } if this.layout.linked == nil { return }
this.layout.linked.ScrollTo ( this.layout.linked.ScrollTo (
this.layout.linked.ContentBounds().Min. this.layout.linked.ContentBounds().Min.
Add(image.Pt(int(x), int(y)))) Sub(image.Pt(int(x), int(y))))
} }
func (this *Scrollbar) drag () { func (this *Scrollbar) drag () {
@@ -327,7 +327,7 @@ func (this scrollbarLayout) Arrange (hints tomo.LayoutHints, boxes []tomo.Box) {
} else { } else {
handleOffset = image.Pt(int(handlePosition), 0) handleOffset = image.Pt(int(handlePosition), 0)
} }
handle = handle.Add(handleOffset).Add(gutter.Min) handle = handle.Sub(handleOffset).Add(gutter.Min)
// place handle // place handle
boxes[0].SetBounds(handle) boxes[0].SetBounds(handle)

View File

@@ -108,7 +108,7 @@ func (this *ScrollContainer) handleScroll (x, y float64) {
if this.layout.root == nil { return } if this.layout.root == nil { return }
this.layout.root.ScrollTo ( this.layout.root.ScrollTo (
this.layout.root.ContentBounds().Min. this.layout.root.ContentBounds().Min.
Add(image.Pt(int(x), int(y)))) Sub(image.Pt(int(x), int(y))))
} }
type scrollContainerLayout struct { type scrollContainerLayout struct {