diff --git a/artist/inset.go b/artist/inset.go index 196b29b..971a1be 100644 --- a/artist/inset.go +++ b/artist/inset.go @@ -15,6 +15,28 @@ type Side int; const ( // the left at index three. These values may be negative. type Inset [4]int +// I allows you to create an inset in a CSS-ish way: +// +// - One argument: all sides are set to this value +// - Two arguments: the top and bottom sides are set to the first value, and +// the left and right sides are set to the second value. +// - Three arguments: the top side is set by the first value, the left and +// right sides are set by the second vaue, and the bottom side is set by the +// third value. +// - Four arguments: each value corresponds to a side. +// +// This function will panic if an argument count that isn't one of these is +// given. +func I (sides ...int) Inset { + switch len(sides) { + case 1: return Inset { sides[0], sides[0], sides[0], sides[0] } + case 2: return Inset { sides[0], sides[1], sides[0], sides[1] } + case 3: return Inset { sides[0], sides[1], sides[2], sides[1] } + case 4: return Inset { sides[0], sides[1], sides[2], sides[3] } + default: panic("I: illegal argument count.") + } +} + // Apply returns the given rectangle, shrunk on all four sides by the given // inset. If a measurment of the inset is negative, that side will instead be // expanded outward. If the rectangle's dimensions cannot be reduced any diff --git a/elements/file/directory.go b/elements/file/directory.go index 3a7c785..2a2b567 100644 --- a/elements/file/directory.go +++ b/elements/file/directory.go @@ -56,7 +56,7 @@ func NewDirectory ( err error, ) { element = &Directory { } - element.theme.Case = theme.C("files", "Directory") + element.theme.Case = theme.C("files", "directory") element.Core, element.core = core.NewCore(element, element.redoAll) element.Propagator = core.NewPropagator(element, element.core) err = element.SetLocation(location, within) diff --git a/theme/default.go b/theme/default.go index e284207..dbfe765 100644 --- a/theme/default.go +++ b/theme/default.go @@ -254,28 +254,28 @@ func (Default) Padding (id Pattern, c Case) artist.Inset { switch id { case PatternRaised: if c.Match("basic", "listEntry", "") { - return artist.Inset { 4, 8, 4, 8 } + return artist.I(4, 8) } else { - return artist.Inset { 8, 8, 8, 8 } + return artist.I(8) } case PatternSunken: if c.Match("basic", "list", "") { - return artist.Inset { 4, 0, 3, 0 } + return artist.I(4, 0, 3) } else if c.Match("basic", "progressBar", "") { - return artist.Inset { 2, 1, 1, 2 } + return artist.I(2, 1, 1, 2) } else { - return artist.Inset { 8, 8, 8, 8 } + return artist.I(8) } case PatternPinboard: if c.Match("fun", "piano", "") { - return artist.Inset { 2, 2, 2, 2 } + return artist.I(2) } else { - return artist.Inset { 8, 8, 8, 8 } + return artist.I(8) } - case PatternGutter: return artist.Inset { } - case PatternLine: return artist.Inset { 1, 1, 1, 1 } - case PatternMercury: return artist.Inset { 5, 5, 5, 5 } - default: return artist.Inset { 8, 8, 8, 8 } + case PatternGutter: return artist.I(0) + case PatternLine: return artist.I(1) + case PatternMercury: return artist.I(5) + default: return artist.I(8) } }