From a2a9af3311fba4a59dd5fd02c6e31c55457f4e32 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Sun, 30 Apr 2023 13:47:36 -0400 Subject: [PATCH] Updated default theme --- default/theme/default.go | 14 +++---- default/theme/parse.go | 9 ----- default/theme/wrapped.go | 82 ---------------------------------------- 3 files changed, 7 insertions(+), 98 deletions(-) delete mode 100644 default/theme/parse.go delete mode 100644 default/theme/wrapped.go diff --git a/default/theme/default.go b/default/theme/default.go index 3c9f750..0c0754a 100644 --- a/default/theme/default.go +++ b/default/theme/default.go @@ -9,13 +9,13 @@ import "golang.org/x/image/font" import "git.tebibyte.media/sashakoshka/tomo" import "git.tebibyte.media/sashakoshka/tomo/data" import "git.tebibyte.media/sashakoshka/tomo/artist" -import "git.tebibyte.media/sashakoshka/tomo/canvas" +import "git.tebibyte.media/sashakoshka/tomo/artist/artutil" import defaultfont "git.tebibyte.media/sashakoshka/tomo/default/font" import "git.tebibyte.media/sashakoshka/tomo/artist/patterns" //go:embed assets/wintergreen.png var defaultAtlasBytes []byte -var defaultAtlas canvas.Canvas +var defaultAtlas artist.Canvas var defaultTextures [17][9]artist.Pattern //go:embed assets/wintergreen-icons-small.png var defaultIconsSmallAtlasBytes []byte @@ -27,7 +27,7 @@ var defaultIconsLarge [640]binaryIcon func atlasCell (col, row int, border artist.Inset) { bounds := image.Rect(0, 0, 16, 16).Add(image.Pt(col, row).Mul(16)) defaultTextures[col][row] = patterns.Border { - Canvas: canvas.Cut(defaultAtlas, bounds), + Canvas: artist.Cut(defaultAtlas, bounds), Inset: border, } } @@ -43,7 +43,7 @@ type binaryIcon struct { stride int } -func (icon binaryIcon) Draw (destination canvas.Canvas, color color.RGBA, at image.Point) { +func (icon binaryIcon) Draw (destination artist.Canvas, color color.RGBA, at image.Point) { bounds := icon.Bounds().Add(at).Intersect(destination.Bounds()) point := image.Point { } data, stride := destination.Buffer() @@ -85,7 +85,7 @@ func binaryIconFrom (source image.Image, clip image.Rectangle) (icon binaryIcon) func init () { defaultAtlasImage, _, _ := image.Decode(bytes.NewReader(defaultAtlasBytes)) - defaultAtlas = canvas.FromImage(defaultAtlasImage) + defaultAtlas = artist.FromImage(defaultAtlasImage) // PatternDead atlasCol(0, artist.Inset { }) @@ -241,9 +241,9 @@ func (Default) Pattern (id tomo.Pattern, state tomo.State, c tomo.Case) artist.P } func (Default) Color (id tomo.Color, state tomo.State, c tomo.Case) color.RGBA { - if state.Disabled { return artist.Hex(0x444444FF) } + if state.Disabled { return artutil.Hex(0x444444FF) } - return artist.Hex (map[tomo.Color] uint32 { + return artutil.Hex (map[tomo.Color] uint32 { tomo.ColorBlack: 0x272d24FF, tomo.ColorRed: 0x8c4230FF, tomo.ColorGreen: 0x69905fFF, diff --git a/default/theme/parse.go b/default/theme/parse.go deleted file mode 100644 index 990246d..0000000 --- a/default/theme/parse.go +++ /dev/null @@ -1,9 +0,0 @@ -package theme - -// import "io" - -// Parse parses one or more theme files and returns them as a Theme. -// func Parse (sources ...io.Reader) (Theme) { - // // TODO - // return Default { } -// } diff --git a/default/theme/wrapped.go b/default/theme/wrapped.go deleted file mode 100644 index 24a72fd..0000000 --- a/default/theme/wrapped.go +++ /dev/null @@ -1,82 +0,0 @@ -package theme - -import "image" -import "image/color" -import "golang.org/x/image/font" -import "git.tebibyte.media/sashakoshka/tomo" -import "git.tebibyte.media/sashakoshka/tomo/data" -import "git.tebibyte.media/sashakoshka/tomo/artist" - -// Wrapped wraps any theme and injects a case into it automatically so that it -// doesn't need to be specified for each query. Additionally, if the underlying -// theme is nil, it just uses the default theme instead. -type Wrapped struct { - tomo.Theme - tomo.Case -} - -// FontFace returns the proper font for a given style and size. -func (wrapped Wrapped) FontFace (style tomo.FontStyle, size tomo.FontSize) font.Face { - real := wrapped.ensure() - return real.FontFace(style, size, wrapped.Case) -} - -// Icon returns an appropriate icon given an icon name. -func (wrapped Wrapped) Icon (id tomo.Icon, size tomo.IconSize) artist.Icon { - real := wrapped.ensure() - return real.Icon(id, size, wrapped.Case) -} - -// MimeIcon returns an appropriate icon given file mime type. -func (wrapped Wrapped) MimeIcon (mime data.Mime, size tomo.IconSize) artist.Icon { - real := wrapped.ensure() - return real.MimeIcon(mime, size, wrapped.Case) -} - -// Pattern returns an appropriate pattern given a pattern name and state. -func (wrapped Wrapped) Pattern (id tomo.Pattern, state tomo.State) artist.Pattern { - real := wrapped.ensure() - return real.Pattern(id, state, wrapped.Case) -} - -// Color returns an appropriate color given a color name and state. -func (wrapped Wrapped) Color (id tomo.Color, state tomo.State) color.RGBA { - real := wrapped.ensure() - return real.Color(id, state, wrapped.Case) -} - -// Padding returns how much space should be between the bounds of a -// pattern whatever an element draws inside of it. -func (wrapped Wrapped) Padding (id tomo.Pattern) artist.Inset { - real := wrapped.ensure() - return real.Padding(id, wrapped.Case) -} - -// Margin returns the left/right (x) and top/bottom (y) margins that -// should be put between any self-contained objects drawn within this -// pattern (if applicable). -func (wrapped Wrapped) Margin (id tomo.Pattern) image.Point { - real := wrapped.ensure() - return real.Margin(id, wrapped.Case) -} - -// Sink returns a vector that should be added to an element's inner content when -// it is pressed down (if applicable) to simulate a 3D sinking effect. -func (wrapped Wrapped) Sink (id tomo.Pattern) image.Point { - real := wrapped.ensure() - return real.Sink(id, wrapped.Case) -} - -// Hints returns rendering optimization hints for a particular pattern. -// These are optional, but following them may result in improved -// performance. -func (wrapped Wrapped) Hints (id tomo.Pattern) tomo.Hints { - real := wrapped.ensure() - return real.Hints(id, wrapped.Case) -} - -func (wrapped Wrapped) ensure () (real tomo.Theme) { - real = wrapped.Theme - if real == nil { real = Default { } } - return -}