401 lines
19 KiB
Go
401 lines
19 KiB
Go
package tomo
|
|
|
|
import "fmt"
|
|
import "git.tebibyte.media/tomo/tomo/data"
|
|
import "git.tebibyte.media/tomo/tomo/canvas"
|
|
|
|
// IconSize represents the size of an Icon.
|
|
type IconSize int; const (
|
|
IconSizeSmall IconSize = iota;
|
|
IconSizeMedium
|
|
IconSizeLarge
|
|
)
|
|
|
|
func (size IconSize) String () string {
|
|
switch size {
|
|
case IconSizeSmall: return "IconSizeSmall"
|
|
case IconSizeMedium: return "IconSizeMedium"
|
|
case IconSizeLarge: return "IconSizeLarge"
|
|
default: return fmt.Sprintf("IconSize(%d)", size)
|
|
}
|
|
}
|
|
|
|
// Icon represents an icon ID.
|
|
type Icon string
|
|
|
|
// A list of standard icon IDs. This is roughly based off of the XDG Icon Naming
|
|
// Specification (https://specifications.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html).
|
|
const (
|
|
// IconUnknown should be a blank space the size of a regular Icon.
|
|
IconUnknown Icon = ""
|
|
|
|
// actions
|
|
IconAddressBookNew Icon = "AddressBookNew"
|
|
IconApplicationExit Icon = "ApplicationExit"
|
|
IconAppointmentNew Icon = "AppointmentNew"
|
|
IconCallStart Icon = "CallStart"
|
|
IconCallStop Icon = "CallStop"
|
|
IconContactNew Icon = "ContactNew"
|
|
// actions: dialog
|
|
IconDialogOkay Icon = "DialogOkay"
|
|
IconDialogCancel Icon = "DialogCancel"
|
|
// actions: edit
|
|
IconEditClear Icon = "EditClear"
|
|
IconEditCopy Icon = "EditCopy"
|
|
IconEditCut Icon = "EditCut"
|
|
IconEditDelete Icon = "EditDelete"
|
|
IconEditFind Icon = "EditFind"
|
|
IconEditFindReplace Icon = "EditFindReplace"
|
|
IconEditPaste Icon = "EditPaste"
|
|
IconEditRedo Icon = "EditRedo"
|
|
IconEditSelectAll Icon = "EditSelectAll"
|
|
IconEditUndo Icon = "EditUndo"
|
|
// actions: file
|
|
IconFileNew Icon = "FileNew"
|
|
IconDirectoryNew Icon = "DirectoryNew"
|
|
IconFileOpen Icon = "FileOpen"
|
|
IconFileOpenRecent Icon = "FileOpenRecent"
|
|
IconFilePageSetup Icon = "FilePageSetup"
|
|
IconFilePrint Icon = "FilePrint"
|
|
IconFilePrintPreview Icon = "FilePrintPreview"
|
|
IconFilePermissions Icon = "FilePermissions"
|
|
IconFileProperties Icon = "FileProperties"
|
|
IconFileRename Icon = "FileRename"
|
|
IconFileRevert Icon = "FileRevert"
|
|
IconFileSave Icon = "FileSave"
|
|
IconFileSaveAs Icon = "FileSaveAs"
|
|
IconFileSend Icon = "FileSend"
|
|
// actions: format
|
|
IconFormatIndentLess Icon = "FormatIndentLess"
|
|
IconFormatIndentMore Icon = "FormatIndentMore"
|
|
IconFormatAlignCenter Icon = "FormatAlignCenter"
|
|
IconFormatAlignEven Icon = "FormatAlignEven"
|
|
IconFormatAlignLeft Icon = "FormatAlignLeft"
|
|
IconFormatAlignRight Icon = "FormatAlignRight"
|
|
IconFormatTextDirectionLtr Icon = "FormatTextDirectionLtr"
|
|
IconFormatTextDirectionRtl Icon = "FormatTextDirectionRtl"
|
|
IconFormatTextBold Icon = "FormatTextBold"
|
|
IconFormatTextItalic Icon = "FormatTextItalic"
|
|
IconFormatTextUnderline Icon = "FormatTextUnderline"
|
|
IconFormatTextStrikethrough Icon = "FormatTextStrikethrough"
|
|
// actions: go
|
|
IconGoBottom Icon = "GoBottom"
|
|
IconGoDown Icon = "GoDown"
|
|
IconGoFirst Icon = "GoFirst"
|
|
IconGoHome Icon = "GoHome"
|
|
IconGoJump Icon = "GoJump"
|
|
IconGoLast Icon = "GoLast"
|
|
IconGoNext Icon = "GoNext"
|
|
IconGoPrevious Icon = "GoPrevious"
|
|
IconGoTop Icon = "GoTop"
|
|
IconGoUp Icon = "GoUp"
|
|
// actions: help
|
|
IconHelpAbout Icon = "HelpAbout"
|
|
IconHelpContents Icon = "HelpContents"
|
|
IconHelpFaq Icon = "HelpFaq"
|
|
// actions: insert
|
|
IconInsertImage Icon = "InsertImage"
|
|
IconInsertLink Icon = "InsertLink"
|
|
IconInsertObject Icon = "InsertObject"
|
|
IconInsertText Icon = "InsertText"
|
|
// actions: list
|
|
IconListAdd Icon = "ListAdd"
|
|
IconListRemove Icon = "ListRemove"
|
|
IconListChoose Icon = "ListChoose"
|
|
IconListExpand Icon = "ListExpand"
|
|
IconListContract Icon = "ListContract"
|
|
// actions: mail
|
|
IconMailForward Icon = "MailForward"
|
|
IconMailMarkImportant Icon = "MailMarkImportant"
|
|
IconMailMarkJunk Icon = "MailMarkJunk"
|
|
IconMailMarkNotJunk Icon = "MailMarkNotJunk"
|
|
IconMailMarkRead Icon = "MailMarkRead"
|
|
IconMailMarkUnread Icon = "MailMarkUnread"
|
|
IconMailMessageNew Icon = "MailMessageNew"
|
|
IconMailReplyAll Icon = "MailReplyAll"
|
|
IconMailReplySender Icon = "MailReplySender"
|
|
IconMailSend Icon = "MailSend"
|
|
IconMailReceive Icon = "MailReceive"
|
|
// actions: media
|
|
IconMediaEject Icon = "MediaEject"
|
|
IconMediaPlaybackPause Icon = "MediaPlaybackPause"
|
|
IconMediaPlaybackStart Icon = "MediaPlaybackStart"
|
|
IconMediaPlaybackStop Icon = "MediaPlaybackStop"
|
|
IconMediaRecord Icon = "MediaRecord"
|
|
IconMediaSeekBackward Icon = "MediaSeekBackward"
|
|
IconMediaSeekForward Icon = "MediaSeekForward"
|
|
IconMediaSkipBackward Icon = "MediaSkipBackward"
|
|
IconMediaSkipForward Icon = "MediaSkipForward"
|
|
// actions: object
|
|
IconObjectFlipHorizontal Icon = "ObjectFlipHorizontal"
|
|
IconObjectFlipVertical Icon = "ObjectFlipVertical"
|
|
IconObjectRotateLeft Icon = "ObjectRotateLeft"
|
|
IconObjectRotateRight Icon = "ObjectRotateRight"
|
|
// actions: process
|
|
IconProcessStop Icon = "ProcessStop"
|
|
// actions: system
|
|
IconSystemLockScreen Icon = "SystemLockScreen"
|
|
IconSystemLogOut Icon = "SystemLogOut"
|
|
IconSystemRun Icon = "SystemRun"
|
|
IconSystemSearch Icon = "SystemSearch"
|
|
IconSystemReboot Icon = "SystemReboot"
|
|
IconSystemShutdown Icon = "SystemShutdown"
|
|
// actions: tools
|
|
IconToolsCheckSpelling Icon = "ToolsCheckSpelling"
|
|
// actions: value
|
|
IconValueIncrement Icon = "ValueIncrement"
|
|
IconValueDecrement Icon = "ValueDecrement"
|
|
IconValueReset Icon = "ValueReset"
|
|
// actions: view
|
|
IconViewFullscreen Icon = "ViewFullscreen"
|
|
IconViewRefresh Icon = "ViewRefresh"
|
|
IconViewRestore Icon = "ViewRestore"
|
|
IconViewSortAscending Icon = "ViewSortAscending"
|
|
IconViewSortDescending Icon = "ViewSortDescending"
|
|
// actions: window
|
|
IconWindowClose Icon = "WindowClose"
|
|
IconWindowNew Icon = "WindowNew"
|
|
// actions: zoom
|
|
IconZoomFitBest Icon = "ZoomFitBest"
|
|
IconZoomIn Icon = "ZoomIn"
|
|
IconZoomOriginal Icon = "ZoomOriginal"
|
|
IconZoomOut Icon = "ZoomOut"
|
|
|
|
// applications
|
|
// Keep these in sync with nasin.ApplicationRole!
|
|
IconApplication Icon = "Application" // generic
|
|
IconApplicationWebBrowser Icon = "ApplicationWebBrowser"
|
|
IconApplicationMesssanger Icon = "ApplicationMesssanger"
|
|
IconApplicationPhone Icon = "ApplicationPhone"
|
|
IconApplicationMail Icon = "ApplicationMail"
|
|
IconApplicationTerminalEmulator Icon = "ApplicationTerminalEmulator"
|
|
IconApplicationFileBrowser Icon = "ApplicationFileBrowser"
|
|
IconApplicationTextEditor Icon = "ApplicationTextEditor"
|
|
IconApplicationDocumentViewer Icon = "ApplicationDocumentViewer"
|
|
IconApplicationWordProcessor Icon = "ApplicationWordProcessor"
|
|
IconApplicationSpreadsheet Icon = "ApplicationSpreadsheet"
|
|
IconApplicationSlideshow Icon = "ApplicationSlideshow"
|
|
IconApplicationCalculator Icon = "ApplicationCalculator"
|
|
IconApplicationPreferences Icon = "ApplicationPreferences"
|
|
IconApplicationProcessManager Icon = "ApplicationProcessManager"
|
|
IconApplicationSystemInformation Icon = "ApplicationSystemInformation"
|
|
IconApplicationManual Icon = "ApplicationManual"
|
|
IconApplicationCamera Icon = "ApplicationCamera"
|
|
IconApplicationImageViewer Icon = "ApplicationImageViewer"
|
|
IconApplicationMediaPlayer Icon = "ApplicationMediaPlayer"
|
|
IconApplicationImageEditor Icon = "ApplicationImageEditor"
|
|
IconApplicationAudioEditor Icon = "ApplicationAudioEditor"
|
|
IconApplicationVideoEditor Icon = "ApplicationVideoEditor"
|
|
IconApplicationClock Icon = "ApplicationClock"
|
|
IconApplicationCalendar Icon = "ApplicationCalendar"
|
|
IconApplicationChecklist Icon = "ApplicationChecklist"
|
|
|
|
// categories: applications
|
|
IconApplications Icon = "Applications"
|
|
IconApplicationsAccessories Icon = "ApplicationsAccessories"
|
|
IconApplicationsDevelopment Icon = "ApplicationsDevelopment"
|
|
IconApplicationsEngineering Icon = "ApplicationsEngineering"
|
|
IconApplicationsGames Icon = "ApplicationsGames"
|
|
IconApplicationsGraphics Icon = "ApplicationsGraphics"
|
|
IconApplicationsInternet Icon = "ApplicationsInternet"
|
|
IconApplicationsMultimedia Icon = "ApplicationsMultimedia"
|
|
IconApplicationsOffice Icon = "ApplicationsOffice"
|
|
IconApplicationsScience Icon = "ApplicationsScience"
|
|
IconApplicationsSystem Icon = "ApplicationsSystem"
|
|
IconApplicationsUtilities Icon = "ApplicationsUtilities"
|
|
// categories: preferences
|
|
IconPreferences Icon = "Preferences"
|
|
IconPreferencesDesktop Icon = "PreferencesDesktop"
|
|
IconPreferencesPeripherals Icon = "PreferencesPeripherals"
|
|
IconPreferencesPersonal Icon = "PreferencesPersonal"
|
|
IconPreferencesSystem Icon = "PreferencesSystem"
|
|
IconPreferencesNetwork Icon = "PreferencesNetwork"
|
|
|
|
// devices
|
|
IconDevice Icon = "Device"
|
|
IconDeviceCamera Icon = "DeviceCamera"
|
|
IconDeviceWebCamera Icon = "DeviceWebCamera"
|
|
IconDeviceComputer Icon = "DeviceComputer"
|
|
IconDevicePda Icon = "DevicePda"
|
|
IconDevicePhone Icon = "DevicePhone"
|
|
IconDevicePrinter Icon = "DevicePrinter"
|
|
IconDeviceScanner Icon = "DeviceScanner"
|
|
IconDeviceMultimediaPlayer Icon = "DeviceMultimediaPlayer"
|
|
IconDeviceVideoDisplay Icon = "DeviceVideoDisplay"
|
|
IconDeviceAudioInput Icon = "DeviceAudioInput"
|
|
IconDeviceAudioOutput Icon = "DeviceAudioOutput"
|
|
// devices: hardware
|
|
IconHardware Icon = "Hardware"
|
|
IconHardwareCPU Icon = "HardwareCPU"
|
|
IconHardwareGPU Icon = "HardwareGPU"
|
|
IconHardwareRAM Icon = "HardwareRAM"
|
|
IconHardwareSoundCard Icon = "HardwareSoundCard"
|
|
IconHardwareNetworkAdapter Icon = "HardwareNetworkAdapter"
|
|
// devices: power
|
|
IconPowerBattery Icon = "PowerBattery"
|
|
// devices: storage
|
|
IconStorageHardDisk Icon = "StorageHardDisk"
|
|
IconStorageFloppyDisk Icon = "StorageFloppyDisk"
|
|
IconStorageSolidState Icon = "StorageSolidState"
|
|
IconStorageOptical Icon = "StorageOptical"
|
|
IconStorageFlashStick Icon = "StorageFlashStick"
|
|
IconStorageFlashCard Icon = "StorageFlashCard"
|
|
IconStorageMagneticTape Icon = "StorageMagneticTape"
|
|
// devices: input
|
|
IconInputGaming Icon = "InputGaming"
|
|
IconInputKeyboard Icon = "InputKeyboard"
|
|
IconInputMouse Icon = "InputMouse"
|
|
IconInputTablet Icon = "InputTablet"
|
|
// devices: network
|
|
IconNetworkWired Icon = "NetworkWired"
|
|
IconNetworkWireless Icon = "NetworkWireless"
|
|
IconNetworkCellular Icon = "NetworkCellular"
|
|
IconNetworkLocal Icon = "NetworkLocal"
|
|
IconNetworkInternet Icon = "NetworkInternet"
|
|
IconNetworkVPN Icon = "NetworkVPN"
|
|
IconNetworkServer Icon = "NetworkServer"
|
|
IconNetworkWorkgroup Icon = "NetworkWorkgroup"
|
|
|
|
// emblems
|
|
IconEmblemDefault Icon = "EmblemDefault"
|
|
IconEmblemEncrypted Icon = "EmblemEncrypted"
|
|
IconEmblemFavorite Icon = "EmblemFavorite"
|
|
IconEmblemImportant Icon = "EmblemImportant"
|
|
IconEmblemReadOnly Icon = "EmblemReadOnly"
|
|
IconEmblemShared Icon = "EmblemShared"
|
|
IconEmblemSymbolicLink Icon = "EmblemSymbolicLink"
|
|
IconEmblemSynchronized Icon = "EmblemSynchronized"
|
|
IconEmblemSystem Icon = "EmblemSystem"
|
|
IconEmblemUnreadable Icon = "EmblemUnreadable"
|
|
|
|
// places
|
|
IconPlaceDirectory Icon = "PlaceDirectory"
|
|
IconPlaceRemote Icon = "PlaceRemote"
|
|
IconPlaceHome Icon = "PlaceHome"
|
|
IconPlaceDownloads Icon = "PlaceDownloads"
|
|
IconPlaceDesktop Icon = "PlaceDesktop"
|
|
IconPlacePhotos Icon = "PlacePhotos"
|
|
IconPlaceBooks Icon = "PlaceBooks"
|
|
IconPlaceBookmarks Icon = "PlaceBookmarks"
|
|
IconPlaceTrash Icon = "PlaceTrash"
|
|
IconPlaceDocuments Icon = "PlaceDocuments"
|
|
IconPlaceRepositories Icon = "PlaceRepositories"
|
|
IconPlaceMusic Icon = "PlaceMusic"
|
|
IconPlaceArchives Icon = "PlaceArchives"
|
|
IconPlaceFonts Icon = "PlaceFonts"
|
|
IconPlaceBinaries Icon = "PlaceBinaries"
|
|
IconPlaceVideos Icon = "PlaceVideos"
|
|
IconPlace3DObjects Icon = "Place3DObjects"
|
|
IconPlaceHistory Icon = "PlaceHistory"
|
|
IconPlacePreferences Icon = "PlacePreferences"
|
|
|
|
// status: appointments
|
|
IconAppointmentMissed Icon = "AppointmentMissed"
|
|
IconAppointmentSoon Icon = "AppointmentSoon"
|
|
// status: dialogs
|
|
IconDialogError Icon = "DialogError"
|
|
IconDialogInformation Icon = "DialogInformation"
|
|
IconDialogPassword Icon = "DialogPassword"
|
|
IconDialogQuestion Icon = "DialogQuestion"
|
|
IconDialogWarning Icon = "DialogWarning"
|
|
// status: directories
|
|
IconDirectoryDragAccept Icon = "DirectoryDragAccept"
|
|
IconDirectoryFull Icon = "DirectoryFull"
|
|
IconDirectoryOpen Icon = "DirectoryOpen"
|
|
IconDirectoryVisiting Icon = "DirectoryVisiting"
|
|
// status: trash
|
|
IconTrashFull Icon = "TrashFull"
|
|
// status: resource
|
|
IconResourceLoading Icon = "ResourceLoading"
|
|
IconResourceMissing Icon = "ResourceMissing"
|
|
// status: mail
|
|
IconMailAttachment Icon = "MailAttachment"
|
|
IconMailUnread Icon = "MailUnread"
|
|
IconMailReplied Icon = "MailReplied"
|
|
IconMailSigned Icon = "MailSigned"
|
|
IconMailSignedVerified Icon = "MailSignedVerified"
|
|
// status: network
|
|
IconCellularSignal0 Icon = "CellularSignal0"
|
|
IconCellularSignal1 Icon = "CellularSignal1"
|
|
IconCellularSignal2 Icon = "CellularSignal2"
|
|
IconCellularSignal3 Icon = "CellularSignal3"
|
|
IconWirelessSignal0 Icon = "WirelessSignal0"
|
|
IconWirelessSignal1 Icon = "WirelessSignal1"
|
|
IconWirelessSignal2 Icon = "WirelessSignal2"
|
|
IconWirelessSignal3 Icon = "WirelessSignal3"
|
|
IconNetworkError Icon = "NetworkError"
|
|
IconNetworkIdle Icon = "NetworkIdle"
|
|
IconNetworkOffline Icon = "NetworkOffline"
|
|
IconNetworkReceive Icon = "NetworkReceive"
|
|
IconNetworkTransmit Icon = "NetworkTransmit"
|
|
IconNetworkTransmitReceive Icon = "NetworkTransmitReceive"
|
|
// status: print
|
|
IconPrintError Icon = "PrintError"
|
|
IconPrintPrinting Icon = "PrintPrinting"
|
|
// status: security
|
|
IconSecurityHigh Icon = "SecurityHigh"
|
|
IconSecurityMedium Icon = "SecurityMedium"
|
|
IconSecurityLow Icon = "SecurityLow"
|
|
// status: software
|
|
IconSoftwareUpdateAvailable Icon = "SoftwareUpdateAvailable"
|
|
IconSoftwareUpdateUrgent Icon = "SoftwareUpdateUrgent"
|
|
IconSoftwareInstalling Icon = "SoftwareInstalling"
|
|
// status: sync
|
|
IconSyncError Icon = "SyncError"
|
|
IconSyncSynchronizing Icon = "SyncSynchronizing"
|
|
// status: tasks
|
|
IconTaskDue Icon = "TaskDue"
|
|
IconTaskPastDue Icon = "TaskPastDue"
|
|
// status: users
|
|
IconUserAvailable Icon = "UserAvailable"
|
|
IconUserAway Icon = "UserAway"
|
|
IconUserIdle Icon = "UserIdle"
|
|
IconUserOffline Icon = "UserOffline"
|
|
// status: power
|
|
IconBattery0 Icon = "Battery0"
|
|
IconBattery1 Icon = "Battery1"
|
|
IconBattery2 Icon = "Battery2"
|
|
IconBattery3 Icon = "Battery3"
|
|
IconBrightness0 Icon = "Brightness0"
|
|
IconBrightness1 Icon = "Brightness1"
|
|
IconBrightness2 Icon = "Brightness2"
|
|
IconBrightness3 Icon = "Brightness3"
|
|
// status: media
|
|
IconVolume0 Icon = "Volume0"
|
|
IconVolume1 Icon = "Volume1"
|
|
IconVolume2 Icon = "Volume2"
|
|
IconVolume3 Icon = "Volume3"
|
|
IconPlaylistRepeat Icon = "PlaylistRepeat"
|
|
IconPlaylistShuffle Icon = "PlaylistShuffle"
|
|
// status: weather
|
|
IconWeatherClear Icon = "WeatherClear"
|
|
IconWeatherClearNight Icon = "WeatherClearNight"
|
|
IconWeatherFewClouds Icon = "WeatherFewClouds"
|
|
IconWeatherFewCloudsNight Icon = "WeatherFewCloudsNight"
|
|
IconWeatherFog Icon = "WeatherFog"
|
|
IconWeatherOvercast Icon = "WeatherOvercast"
|
|
IconWeatherSevereAlert Icon = "WeatherSevereAlert"
|
|
IconWeatherShowers Icon = "WeatherShowers"
|
|
IconWeatherShowersScattered Icon = "WeatherShowersScattered"
|
|
IconWeatherSnow Icon = "WeatherSnow"
|
|
IconWeatherStorm Icon = "WeatherStorm"
|
|
)
|
|
|
|
// Texture returns a canvas.Texture of the corresponding icon ID. It may be
|
|
// closed and therefore rendered invalid if the icon set changes, so it is
|
|
// necessary to subscribe to the IconSetChange event in order to get a new icon
|
|
// texture when this happens.
|
|
func (id Icon) Texture (size IconSize) canvas.Texture {
|
|
assertBackend()
|
|
return backend.IconTexture(id, size)
|
|
}
|
|
|
|
// MimeIconTexture returns a canvas.Texture of the icon corresponding to a MIME
|
|
// type. It may be closed and therefore rendered invalid if the icon set
|
|
// changes, so it is necessary to subscribe to the IconSetChange event in order
|
|
// to get a new icon texture when this happens.
|
|
func MimeIconTexture (mime data.Mime, size IconSize) canvas.Texture {
|
|
assertBackend()
|
|
return backend.MimeIconTexture(mime, size)
|
|
}
|