From ef59f465593064ec0e9ad5fdf0861efb69b99361 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Tue, 28 Feb 2023 19:00:34 -0500 Subject: [PATCH] Made the progress bar look nicer --- elements/basic/progressbar.go | 14 +++++++------- theme/assets/wintergreen.png | Bin 2938 -> 1964 bytes theme/default.go | 8 +++++++- theme/theme.go | 3 +++ 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/elements/basic/progressbar.go b/elements/basic/progressbar.go index 3b197c7..8e5ce32 100644 --- a/elements/basic/progressbar.go +++ b/elements/basic/progressbar.go @@ -3,7 +3,7 @@ package basicElements import "image" import "git.tebibyte.media/sashakoshka/tomo/theme" import "git.tebibyte.media/sashakoshka/tomo/config" -import "git.tebibyte.media/sashakoshka/tomo/artist/shapes" +import "git.tebibyte.media/sashakoshka/tomo/artist" import "git.tebibyte.media/sashakoshka/tomo/elements/core" // ProgressBar displays a visual indication of how far along a task is. @@ -52,10 +52,11 @@ func (element *ProgressBar) SetConfig (new config.Config) { } func (element (ProgressBar)) updateMinimumSize() { - padding := element.theme.Padding(theme.PatternSunken) + padding := element.theme.Padding(theme.PatternSunken) + innerPadding := element.theme.Padding(theme.PatternMercury) element.core.SetMinimumSize ( - padding[3] + padding[1], - padding[0] + padding[2]) + padding.Horizontal() + innerPadding.Horizontal(), + padding.Vertical() + innerPadding.Vertical()) } func (element *ProgressBar) redo () { @@ -76,7 +77,6 @@ func (element *ProgressBar) draw () { bounds.Min.X, bounds.Min.Y, bounds.Min.X + int(float64(bounds.Dx()) * element.progress), bounds.Max.Y) - // TODO: maybe dont use the accent color here... - accent := element.theme.Color(theme.ColorAccent, theme.State { }) - shapes.FillColorRectangle(element.core, accent, meterBounds) + mercury := element.theme.Pattern(theme.PatternMercury, theme.State { }) + artist.DrawBounds(element.core, mercury, meterBounds) } diff --git a/theme/assets/wintergreen.png b/theme/assets/wintergreen.png index ea67ed8bb08ef8eb8e8414fdd528e129ef496747..23657895556988aacd24123ed3d2b695f32950dc 100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git.tebibyte.media/sashakoshka/tomo/artist/patterns" //go:embed assets/wintergreen.png var defaultAtlasBytes []byte var defaultAtlas canvas.Canvas -var defaultTextures [13][9]artist.Pattern +var defaultTextures [14][9]artist.Pattern func atlasCell (col, row int, border artist.Inset) { bounds := image.Rect(0, 0, 16, 16).Add(image.Pt(col, row).Mul(16)) @@ -52,6 +52,8 @@ func init () { atlasCol(7, artist.Inset { 6, 6, 6, 6 }) // PatternLine atlasCol(8, artist.Inset { 1, 1, 1, 1 }) + // PatternMercury + atlasCol(13, artist.Inset { 2, 2, 2, 2 }) // PatternButton: basic.checkbox atlasCol(9, artist.Inset { 3, 3, 3, 3 }) @@ -122,6 +124,7 @@ func (Default) Pattern (id Pattern, state State, c Case) artist.Pattern { case PatternGutter: return defaultTextures[6][offset] case PatternHandle: return defaultTextures[7][offset] case PatternLine: return defaultTextures[8][offset] + case PatternMercury: return defaultTextures[13][offset] default: return patterns.Uhex(0xFF00FFFF) } } @@ -150,6 +153,8 @@ func (Default) Padding (id Pattern, c Case) artist.Inset { case PatternSunken: if c == C("basic", "list") { return artist.Inset { 4, 0, 3, 0 } + } else if c == C("basic", "progressBar") { + return artist.Inset { 2, 1, 1, 2 } } else { return artist.Inset { 8, 8, 8, 8 } } @@ -161,6 +166,7 @@ func (Default) Padding (id Pattern, c Case) artist.Inset { } 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 } } } diff --git a/theme/theme.go b/theme/theme.go index 64a70f5..840c599 100644 --- a/theme/theme.go +++ b/theme/theme.go @@ -50,6 +50,9 @@ type Pattern int; const ( // PatternLine is an engraved line that separates things. PatternLine + + // PatternMercury is a fill pattern for progress bars, meters, etc. + PatternMercury ) type Color int; const (