I am going insane

This commit is contained in:
2023-03-31 01:06:29 -04:00
parent 53bfc8df68
commit 7b300333cf
45 changed files with 527 additions and 508 deletions

View File

@@ -3,11 +3,11 @@ package containers
import "image"
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/input"
import "git.tebibyte.media/sashakoshka/tomo/theme"
import "git.tebibyte.media/sashakoshka/tomo/config"
import "git.tebibyte.media/sashakoshka/tomo/canvas"
import "git.tebibyte.media/sashakoshka/tomo/artist"
import "git.tebibyte.media/sashakoshka/tomo/elements/core"
import "git.tebibyte.media/sashakoshka/tomo/default/theme"
import "git.tebibyte.media/sashakoshka/tomo/default/config"
// Container is an element capable of containg other elements, and arranging
// them in a layout.
@@ -30,7 +30,7 @@ type Container struct {
// NewContainer creates a new container.
func NewContainer (layout tomo.Layout) (element *Container) {
element = &Container { }
element.theme.Case = theme.C("tomo", "container")
element.theme.Case = tomo.C("tomo", "container")
element.Core, element.core = core.NewCore(element, element.redoAll)
element.Propagator = core.NewPropagator(element, element.core)
element.SetLayout(layout)
@@ -190,8 +190,8 @@ func (element *Container) redoAll () {
rocks[index] = entry.Bounds
}
pattern := element.theme.Pattern (
theme.PatternBackground,
theme.State { })
tomo.PatternBackground,
tomo.State { })
artist.DrawShatter(element.core, pattern, element.Bounds(), rocks...)
// cut our canvas up and give peices to child elements
@@ -213,7 +213,7 @@ func (element *Container) NotifyMinimumSizeChange (child tomo.Element) {
}
// SetTheme sets the element's theme.
func (element *Container) SetTheme (new theme.Theme) {
func (element *Container) SetTheme (new tomo.Theme) {
if new == element.theme.Theme { return }
element.theme.Theme = new
element.Propagator.SetTheme(new)
@@ -222,7 +222,7 @@ func (element *Container) SetTheme (new theme.Theme) {
}
// SetConfig sets the element's configuration.
func (element *Container) SetConfig (new config.Config) {
func (element *Container) SetConfig (new tomo.Config) {
if new == element.config.Config { return }
element.Propagator.SetConfig(new)
element.updateMinimumSize()
@@ -230,16 +230,16 @@ func (element *Container) SetConfig (new config.Config) {
}
func (element *Container) updateMinimumSize () {
margin := element.theme.Margin(theme.PatternBackground)
padding := element.theme.Padding(theme.PatternBackground)
margin := element.theme.Margin(tomo.PatternBackground)
padding := element.theme.Padding(tomo.PatternBackground)
width, height := element.layout.MinimumSize (
element.children, margin, padding)
element.core.SetMinimumSize(width, height)
}
func (element *Container) doLayout () {
margin := element.theme.Margin(theme.PatternBackground)
padding := element.theme.Padding(theme.PatternBackground)
margin := element.theme.Margin(tomo.PatternBackground)
padding := element.theme.Padding(tomo.PatternBackground)
element.layout.Arrange (
element.children, margin,
padding, element.Bounds())

View File

@@ -2,11 +2,11 @@ package containers
import "image"
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/theme"
import "git.tebibyte.media/sashakoshka/tomo/config"
import "git.tebibyte.media/sashakoshka/tomo/canvas"
import "git.tebibyte.media/sashakoshka/tomo/artist"
import "git.tebibyte.media/sashakoshka/tomo/elements/core"
import "git.tebibyte.media/sashakoshka/tomo/default/theme"
import "git.tebibyte.media/sashakoshka/tomo/default/config"
type DocumentContainer struct {
*core.Core
@@ -27,7 +27,7 @@ type DocumentContainer struct {
// NewDocumentContainer creates a new document container.
func NewDocumentContainer () (element *DocumentContainer) {
element = &DocumentContainer { }
element.theme.Case = theme.C("tomo", "documentContainer")
element.theme.Case = tomo.C("tomo", "documentContainer")
element.Core, element.core = core.NewCore(element, element.redoAll)
element.Propagator = core.NewPropagator(element, element.core)
return
@@ -172,8 +172,8 @@ func (element *DocumentContainer) redoAll () {
rocks[index] = entry.Bounds
}
pattern := element.theme.Pattern (
theme.PatternBackground,
theme.State { })
tomo.PatternBackground,
tomo.State { })
artist.DrawShatter(element.core, pattern, element.Bounds(), rocks...)
element.partition()
@@ -219,7 +219,7 @@ func (element *DocumentContainer) NotifyFlexibleHeightChange (child tomo.Flexibl
}
// SetTheme sets the element's theme.
func (element *DocumentContainer) SetTheme (new theme.Theme) {
func (element *DocumentContainer) SetTheme (new tomo.Theme) {
if new == element.theme.Theme { return }
element.theme.Theme = new
element.Propagator.SetTheme(new)
@@ -227,7 +227,7 @@ func (element *DocumentContainer) SetTheme (new theme.Theme) {
}
// SetConfig sets the element's configuration.
func (element *DocumentContainer) SetConfig (new config.Config) {
func (element *DocumentContainer) SetConfig (new tomo.Config) {
if new == element.config.Config { return }
element.Propagator.SetConfig(new)
element.redoAll()
@@ -241,7 +241,7 @@ func (element *DocumentContainer) ScrollContentBounds () image.Rectangle {
// ScrollViewportBounds returns the size and position of the element's
// viewport relative to ScrollBounds.
func (element *DocumentContainer) ScrollViewportBounds () image.Rectangle {
padding := element.theme.Padding(theme.PatternBackground)
padding := element.theme.Padding(tomo.PatternBackground)
bounds := padding.Apply(element.Bounds())
bounds = bounds.Sub(bounds.Min).Add(element.scroll)
return bounds
@@ -271,7 +271,7 @@ func (element *DocumentContainer) OnScrollBoundsChange (callback func ()) {
}
func (element *DocumentContainer) maxScrollHeight () (height int) {
padding := element.theme.Padding(theme.PatternSunken)
padding := element.theme.Padding(tomo.PatternSunken)
viewportHeight := element.Bounds().Dy() - padding.Vertical()
height = element.contentBounds.Dy() - viewportHeight
if height < 0 { height = 0 }
@@ -284,8 +284,8 @@ func (element *DocumentContainer) ScrollAxes () (horizontal, vertical bool) {
}
func (element *DocumentContainer) doLayout () {
margin := element.theme.Margin(theme.PatternBackground)
padding := element.theme.Padding(theme.PatternBackground)
margin := element.theme.Margin(tomo.PatternBackground)
padding := element.theme.Padding(tomo.PatternBackground)
bounds := padding.Apply(element.Bounds())
element.contentBounds = image.Rectangle { }
@@ -315,7 +315,7 @@ func (element *DocumentContainer) doLayout () {
}
func (element *DocumentContainer) updateMinimumSize () {
padding := element.theme.Padding(theme.PatternBackground)
padding := element.theme.Padding(tomo.PatternBackground)
minimumWidth := 0
for _, entry := range element.children {
width, _ := entry.MinimumSize()

View File

@@ -3,11 +3,11 @@ package containers
import "image"
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/input"
import "git.tebibyte.media/sashakoshka/tomo/theme"
import "git.tebibyte.media/sashakoshka/tomo/config"
import "git.tebibyte.media/sashakoshka/tomo/canvas"
import "git.tebibyte.media/sashakoshka/tomo/elements"
import "git.tebibyte.media/sashakoshka/tomo/elements/core"
import "git.tebibyte.media/sashakoshka/tomo/default/theme"
import "git.tebibyte.media/sashakoshka/tomo/default/config"
// ScrollContainer is a container that is capable of holding a scrollable
// element.
@@ -31,7 +31,7 @@ type ScrollContainer struct {
// bars.
func NewScrollContainer (horizontal, vertical bool) (element *ScrollContainer) {
element = &ScrollContainer { }
element.theme.Case = theme.C("tomo", "scrollContainer")
element.theme.Case = tomo.C("tomo", "scrollContainer")
element.Core, element.core = core.NewCore(element, element.redoAll)
element.Propagator = core.NewPropagator(element, element.core)
@@ -132,7 +132,7 @@ func (element *ScrollContainer) NotifyScrollBoundsChange (child tomo.Scrollable)
}
// SetTheme sets the element's theme.
func (element *ScrollContainer) SetTheme (new theme.Theme) {
func (element *ScrollContainer) SetTheme (new tomo.Theme) {
if new == element.theme.Theme { return }
element.theme.Theme = new
element.Propagator.SetTheme(new)
@@ -141,7 +141,7 @@ func (element *ScrollContainer) SetTheme (new theme.Theme) {
}
// SetConfig sets the element's configuration.
func (element *ScrollContainer) SetConfig (new config.Config) {
func (element *ScrollContainer) SetConfig (new tomo.Config) {
if new == element.config.Config { return }
element.Propagator.SetConfig(new)
element.updateMinimumSize()
@@ -258,8 +258,8 @@ func (element *ScrollContainer) draw () {
bounds.Min = image.Pt (
bounds.Max.X - element.vertical.Bounds().Dx(),
bounds.Max.Y - element.horizontal.Bounds().Dy())
state := theme.State { }
deadArea := element.theme.Pattern(theme.PatternDead, state)
state := tomo.State { }
deadArea := element.theme.Pattern(tomo.PatternDead, state)
deadArea.Draw(canvas.Cut(element.core, bounds), bounds)
}
}