From 5f5b928528ffec1fceeefaf190c15a350facc69a Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Sun, 20 Aug 2023 18:28:30 -0400 Subject: [PATCH] Icons now use textures --- theme/icon.go | 15 +++++++-------- theme/theme.go | 20 +++++++++++--------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/theme/icon.go b/theme/icon.go index c7cbc4e..937d8fd 100644 --- a/theme/icon.go +++ b/theme/icon.go @@ -1,6 +1,6 @@ package theme -import "image" +import "git.tebibyte.media/tomo/tomo" import "git.tebibyte.media/tomo/tomo/data" // IconSize represents the size of an icon. @@ -226,16 +226,15 @@ type Icon int; const ( IconVolume3 ) -// Icon returns an image of the corresponding icon ID. -func (id Icon) Image (size IconSize) image.Image { - if current == nil { return image.Rect(0, 0, 16, 16) } +// Icon returns a texture of the corresponding icon ID. +func (id Icon) Image (size IconSize) tomo.Texture { + if current == nil { return nil } return current.Icon(id, size) } -// MimeIcon returns an icon corresponding to a MIME type. This must -// always return a non-nil value. -func MimeIcon (mime data.Mime, size IconSize) image.Image { - if current == nil { return image.Rect(0, 0, 16, 16) } +// MimeIcon returns an icon corresponding to a MIME type. +func MimeIcon (mime data.Mime, size IconSize) tomo.Texture { + if current == nil { return nil } return current.MimeIcon(mime, size) } diff --git a/theme/theme.go b/theme/theme.go index d80d8a5..a441af3 100644 --- a/theme/theme.go +++ b/theme/theme.go @@ -1,6 +1,5 @@ package theme -import "image" import "git.tebibyte.media/tomo/tomo" import "git.tebibyte.media/tomo/tomo/data" import "git.tebibyte.media/tomo/tomo/event" @@ -55,17 +54,20 @@ type Theme interface { // RGBA returns the RGBA values of the corresponding color ID. RGBA (Color) (r, g, b, a uint32) - // Icon returns an image of the corresponding icon ID. This must always - // return a non-nil value. - Icon (Icon, IconSize) image.Image + // Icon returns a texture of the corresponding icon ID. This texture + // should be protected, unless a new copy of it is returned with each + // subsequent call. + Icon (Icon, IconSize) tomo.Texture - // MimeIcon returns an icon corresponding to a MIME type. This must - // always return a non-nil value. - MimeIcon (data.Mime, IconSize) image.Image + // MimeIcon returns an icon corresponding to a MIME type. This texture + // should be protected, unless a new copy of it is returned with each + // subsequent call. + MimeIcon (data.Mime, IconSize) tomo.Texture // ApplicationIcon returns an icon corresponding to an application. This - // must always return a non-nil value. - ApplicationIcon (ApplicationIcon, IconSize) image.Image + // texture should be protected, unless a new copy of it is returned with + // each subsequent call. + ApplicationIcon (ApplicationIcon, IconSize) tomo.Texture } var current Theme