Re-organized module structure

This commit is contained in:
2023-03-30 23:19:04 -04:00
parent 719b7b99ac
commit 53bfc8df68
62 changed files with 458 additions and 532 deletions

View File

@@ -1,8 +1,8 @@
package basicLayouts
package layouts
import "image"
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/artist"
import "git.tebibyte.media/sashakoshka/tomo/layouts"
// Dialog arranges elements in the form of a dialog box. The first element is
// positioned above as the main focus of the dialog, and is set to expand
@@ -20,7 +20,7 @@ type Dialog struct {
// Arrange arranges a list of entries into a dialog.
func (layout Dialog) Arrange (
entries []layouts.LayoutEntry,
entries []tomo.LayoutEntry,
margin image.Point,
padding artist.Inset,
bounds image.Rectangle,
@@ -101,7 +101,7 @@ func (layout Dialog) Arrange (
// MinimumSize returns the minimum width and height that will be needed to
// arrange the given list of entries.
func (layout Dialog) MinimumSize (
entries []layouts.LayoutEntry,
entries []tomo.LayoutEntry,
margin image.Point,
padding artist.Inset,
) (
@@ -132,7 +132,7 @@ func (layout Dialog) MinimumSize (
}
func (layout Dialog) minimumSizeOfControlRow (
entries []layouts.LayoutEntry,
entries []tomo.LayoutEntry,
margin image.Point,
padding artist.Inset,
) (

View File

@@ -1,9 +1,9 @@
package basicLayouts
package layouts
import "image"
import "golang.org/x/image/math/fixed"
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/artist"
import "git.tebibyte.media/sashakoshka/tomo/layouts"
import "git.tebibyte.media/sashakoshka/tomo/fixedutil"
// Horizontal arranges elements horizontally. Elements at the start of the entry
@@ -20,7 +20,7 @@ type Horizontal struct {
// Arrange arranges a list of entries horizontally.
func (layout Horizontal) Arrange (
entries []layouts.LayoutEntry,
entries []tomo.LayoutEntry,
margin image.Point,
padding artist.Inset,
bounds image.Rectangle,
@@ -55,7 +55,7 @@ func (layout Horizontal) Arrange (
// MinimumSize returns the minimum width and height that will be needed to
// arrange the given list of entries.
func (layout Horizontal) MinimumSize (
entries []layouts.LayoutEntry,
entries []tomo.LayoutEntry,
margin image.Point,
padding artist.Inset,
) (
@@ -80,7 +80,7 @@ func (layout Horizontal) MinimumSize (
}
func (layout Horizontal) expandingElementWidth (
entries []layouts.LayoutEntry,
entries []tomo.LayoutEntry,
margin image.Point,
padding artist.Inset,
freeSpace int,

View File

@@ -1,43 +0,0 @@
// Package layouts defines a layout interface which a container element can
// accept to have its child elements automatically arranged by any layout that
// satisfies it.
//
// Sub-packages of layouts contain several pre-made ones.
package layouts
import "image"
import "git.tebibyte.media/sashakoshka/tomo/artist"
import "git.tebibyte.media/sashakoshka/tomo/elements"
// LayoutEntry associates an element with layout and positioning information so
// it can be arranged by a Layout.
type LayoutEntry struct {
elements.Element
Bounds image.Rectangle
Expand bool
}
// Layout is capable of arranging elements within a container. It is also able
// to determine the minimum amount of room it needs to do so.
type Layout interface {
// Arrange takes in a slice of entries and a bounding width and height,
// and changes the position of the entiries in the slice so that they
// are properly laid out. The given width and height should not be less
// than what is returned by MinimumSize.
Arrange (
entries []LayoutEntry,
margin image.Point,
padding artist.Inset,
bounds image.Rectangle,
)
// MinimumSize returns the minimum width and height that the layout
// needs to properly arrange the given slice of layout entries.
MinimumSize (
entries []LayoutEntry,
margin image.Point,
padding artist.Inset,
) (
width, height int,
)
}

View File

@@ -1,9 +1,9 @@
package basicLayouts
package layouts
import "image"
import "golang.org/x/image/math/fixed"
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/artist"
import "git.tebibyte.media/sashakoshka/tomo/layouts"
import "git.tebibyte.media/sashakoshka/tomo/fixedutil"
// Vertical arranges elements vertically. Elements at the start of the entry
@@ -20,7 +20,7 @@ type Vertical struct {
// Arrange arranges a list of entries vertically.
func (layout Vertical) Arrange (
entries []layouts.LayoutEntry,
entries []tomo.LayoutEntry,
margin image.Point,
padding artist.Inset,
bounds image.Rectangle,
@@ -55,7 +55,7 @@ func (layout Vertical) Arrange (
// MinimumSize returns the minimum width and height that will be needed to
// arrange the given list of entries.
func (layout Vertical) MinimumSize (
entries []layouts.LayoutEntry,
entries []tomo.LayoutEntry,
margin image.Point,
padding artist.Inset,
) (
@@ -80,7 +80,7 @@ func (layout Vertical) MinimumSize (
}
func (layout Vertical) expandingElementHeight (
entries []layouts.LayoutEntry,
entries []tomo.LayoutEntry,
margin image.Point,
padding artist.Inset,
freeSpace int,