Created Icon interface

This commit is contained in:
Sasha Koshka 2023-03-04 20:48:46 -05:00
parent ecaad02c0b
commit ae6cf128f8
5 changed files with 21 additions and 8 deletions

14
artist/icon.go Normal file
View File

@ -0,0 +1,14 @@
package artist
import "image"
import "image/color"
import "git.tebibyte.media/sashakoshka/tomo/canvas"
type Icon interface {
// Draw draws the icon to the destination canvas at the specified point,
// using the specified color (if the icon is monochrome).
Draw (destination canvas.Canvas, color color.RGBA, at image.Point)
// Bounds returns the bounds of the icon.
Bounds () image.Rectangle
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -84,14 +84,14 @@ func (Default) FontFace (style FontStyle, size FontSize, c Case) font.Face {
} }
// Icon returns an icon from the default set corresponding to the given name. // Icon returns an icon from the default set corresponding to the given name.
func (Default) Icon (string, IconSize, Case) canvas.Image { func (Default) Icon (string, IconSize, Case) artist.Icon {
// TODO // TODO
return nil return nil
} }
// MimeIcon returns an icon from the default set corresponding to the given mime. // MimeIcon returns an icon from the default set corresponding to the given mime.
// type. // type.
func (Default) MimeIcon (data.Mime, IconSize, Case) canvas.Image { func (Default) MimeIcon (data.Mime, IconSize, Case) artist.Icon {
// TODO // TODO
return nil return nil
} }

View File

@ -5,7 +5,6 @@ import "image/color"
import "golang.org/x/image/font" import "golang.org/x/image/font"
import "git.tebibyte.media/sashakoshka/tomo/data" import "git.tebibyte.media/sashakoshka/tomo/data"
import "git.tebibyte.media/sashakoshka/tomo/artist" import "git.tebibyte.media/sashakoshka/tomo/artist"
import "git.tebibyte.media/sashakoshka/tomo/canvas"
// IconSize is a type representing valid icon sizes. // IconSize is a type representing valid icon sizes.
type IconSize int type IconSize int
@ -148,6 +147,7 @@ type Icon int; const (
IconRemoveBookmark IconRemoveBookmark
IconAddFavorite IconAddFavorite
IconRemoveFavorite IconRemoveFavorite
IconPlay IconPlay
IconPause IconPause
IconStop IconStop
@ -197,11 +197,11 @@ type Theme interface {
FontFace (FontStyle, FontSize, Case) font.Face FontFace (FontStyle, FontSize, Case) font.Face
// Icon returns an appropriate icon given an icon name, size, and case. // Icon returns an appropriate icon given an icon name, size, and case.
Icon (string, IconSize, Case) canvas.Image Icon (string, IconSize, Case) artist.Icon
// Icon returns an appropriate icon given a file mime type, size, and, // Icon returns an appropriate icon given a file mime type, size, and,
// case. // case.
MimeIcon (data.Mime, IconSize, Case) canvas.Image MimeIcon (data.Mime, IconSize, Case) artist.Icon
// Pattern returns an appropriate pattern given a pattern name, case, // Pattern returns an appropriate pattern given a pattern name, case,
// and state. // and state.

View File

@ -5,7 +5,6 @@ import "image/color"
import "golang.org/x/image/font" import "golang.org/x/image/font"
import "git.tebibyte.media/sashakoshka/tomo/data" import "git.tebibyte.media/sashakoshka/tomo/data"
import "git.tebibyte.media/sashakoshka/tomo/artist" import "git.tebibyte.media/sashakoshka/tomo/artist"
import "git.tebibyte.media/sashakoshka/tomo/canvas"
// Wrapped wraps any theme and injects a case into it automatically so that it // 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 // doesn't need to be specified for each query. Additionally, if the underlying
@ -22,13 +21,13 @@ func (wrapped Wrapped) FontFace (style FontStyle, size FontSize) font.Face {
} }
// Icon returns an appropriate icon given an icon name. // Icon returns an appropriate icon given an icon name.
func (wrapped Wrapped) Icon (name string, size IconSize) canvas.Image { func (wrapped Wrapped) Icon (name string, size IconSize) artist.Icon {
real := wrapped.ensure() real := wrapped.ensure()
return real.Icon(name, size, wrapped.Case) return real.Icon(name, size, wrapped.Case)
} }
// MimeIcon returns an appropriate icon given file mime type. // MimeIcon returns an appropriate icon given file mime type.
func (wrapped Wrapped) MimeIcon (mime data.Mime, size IconSize) canvas.Image { func (wrapped Wrapped) MimeIcon (mime data.Mime, size IconSize) artist.Icon {
real := wrapped.ensure() real := wrapped.ensure()
return real.MimeIcon(mime, size, wrapped.Case) return real.MimeIcon(mime, size, wrapped.Case)
} }