526 lines
13 KiB
Go
526 lines
13 KiB
Go
package theme
|
|
|
|
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
|
|
)
|
|
|
|
// String satisfies the fmt.Stringer interface.
|
|
func (size IconSize) String () string {
|
|
switch size {
|
|
case IconSizeSmall: return "small"
|
|
case IconSizeMedium: return "medium"
|
|
case IconSizeLarge: return "large"
|
|
default: return "unknown"
|
|
}
|
|
}
|
|
|
|
// TODO: the Icon type, along with its String method, needs to be codegen'd.
|
|
|
|
// Icon represents an icon ID.
|
|
type Icon int; const (
|
|
// --- Objects --- //
|
|
|
|
// files
|
|
IconFile Icon = iota
|
|
IconDirectory
|
|
IconDirectoryFull
|
|
|
|
// places
|
|
IconDownloads
|
|
IconPhotos
|
|
IconBooks
|
|
IconDocuments
|
|
IconRepositories
|
|
IconMusic
|
|
IconArchives
|
|
IconFonts
|
|
IconBinaries
|
|
IconVideos
|
|
Icon3DObjects
|
|
IconHistory
|
|
IconPreferences
|
|
|
|
// storage
|
|
IconStorage // generic
|
|
IconMagneticTape
|
|
IconFloppyDisk
|
|
IconHardDisk
|
|
IconSolidStateDrive
|
|
IconFlashDrive
|
|
IconMemoryCard
|
|
IconROMDisk
|
|
IconRAMDisk
|
|
IconCD
|
|
IconDVD
|
|
|
|
// network
|
|
IconNetwork // generic
|
|
IconLocalNetwork
|
|
IconInternet
|
|
IconEthernet
|
|
IconWireless
|
|
IconCell
|
|
IconBluetooth
|
|
IconRadio
|
|
|
|
// devices
|
|
IconDevice // generic
|
|
IconRouter
|
|
IconServer
|
|
IconDesktop
|
|
IconLaptop
|
|
IconTablet
|
|
IconPhone
|
|
IconWatch
|
|
IconCamera
|
|
|
|
// peripherals
|
|
IconPeripheral // generic
|
|
IconKeyboard
|
|
IconMouse
|
|
IconMonitor
|
|
IconWebcam
|
|
IconMicrophone
|
|
IconSpeaker
|
|
IconPenTablet
|
|
IconTrackpad
|
|
IconController
|
|
|
|
// i/o
|
|
IconPort // generic
|
|
IconEthernetPort
|
|
IconUSBPort
|
|
IconParallelPort
|
|
IconSerialPort
|
|
IconPS2Port
|
|
IconDisplayConnector
|
|
IconCGAPort
|
|
IconVGAPort
|
|
IconHDMIPort
|
|
IconDisplayPort
|
|
IconInfrared
|
|
|
|
// --- Actions --- //
|
|
|
|
// files
|
|
IconOpen
|
|
IconOpenIn
|
|
IconSave
|
|
IconSaveAs
|
|
IconPrint
|
|
IconNew
|
|
IconNewDirectory
|
|
IconDelete
|
|
IconRename
|
|
IconGetInformation
|
|
IconChangePermissions
|
|
IconRevert
|
|
|
|
// list management
|
|
IconAdd
|
|
IconRemove
|
|
IconAddBookmark
|
|
IconRemoveBookmark
|
|
IconAddFavorite
|
|
IconRemoveFavorite
|
|
|
|
// media
|
|
IconPlay
|
|
IconPause
|
|
IconStop
|
|
IconFastForward
|
|
IconRewind
|
|
IconToBeginning
|
|
IconToEnd
|
|
IconRecord
|
|
IconVolumeUp
|
|
IconVolumeDown
|
|
IconMute
|
|
|
|
// editing
|
|
IconUndo
|
|
IconRedo
|
|
IconCut
|
|
IconCopy
|
|
IconPaste
|
|
IconFind
|
|
IconReplace
|
|
IconSelectAll
|
|
IconSelectNone
|
|
IconIncrement
|
|
IconDecrement
|
|
|
|
// window management
|
|
IconClose
|
|
IconQuit
|
|
IconIconify
|
|
IconShade
|
|
IconMaximize
|
|
IconFullScreen
|
|
IconRestore
|
|
|
|
// view controls
|
|
IconExpand
|
|
IconContract
|
|
IconBack
|
|
IconForward
|
|
IconUp
|
|
IconDown
|
|
IconReload
|
|
IconZoomIn
|
|
IconZoomOut
|
|
IconZoomReset
|
|
IconMove
|
|
IconResize
|
|
IconGoTo
|
|
|
|
// tools
|
|
IconTransform
|
|
IconTranslate
|
|
IconRotate
|
|
IconScale
|
|
IconWarp
|
|
IconCornerPin
|
|
IconSelectRectangle
|
|
IconSelectEllipse
|
|
IconSelectLasso
|
|
IconSelectGeometric
|
|
IconSelectAuto
|
|
IconCrop
|
|
IconFill
|
|
IconGradient
|
|
IconPencil
|
|
IconBrush
|
|
IconEraser
|
|
IconText
|
|
IconEyedropper
|
|
|
|
// --- Status --- //
|
|
|
|
// dialogs
|
|
IconInformation
|
|
IconQuestion
|
|
IconWarning
|
|
IconError
|
|
IconCancel
|
|
IconOkay
|
|
|
|
// network
|
|
IconCellSignal0
|
|
IconCellSignal1
|
|
IconCellSignal2
|
|
IconCellSignal3
|
|
IconWirelessSignal0
|
|
IconWirelessSignal1
|
|
IconWirelessSignal2
|
|
IconWirelessSignal3
|
|
|
|
// power
|
|
IconBattery0
|
|
IconBattery1
|
|
IconBattery2
|
|
IconBattery3
|
|
IconBrightness0
|
|
IconBrightness1
|
|
IconBrightness2
|
|
IconBrightness3
|
|
|
|
// media
|
|
IconVolume0
|
|
IconVolume1
|
|
IconVolume2
|
|
IconVolume3
|
|
)
|
|
|
|
// String satisfies the fmt.Stringer interface.
|
|
func (id Icon) String () string {
|
|
switch id {
|
|
case IconFile: return "File"
|
|
case IconDirectory: return "Directory"
|
|
case IconDirectoryFull: return "DirectoryFull"
|
|
case IconDownloads: return "Downloads"
|
|
case IconPhotos: return "Photos"
|
|
case IconBooks: return "Books"
|
|
case IconDocuments: return "Documents"
|
|
case IconRepositories: return "Repositories"
|
|
case IconMusic: return "Music"
|
|
case IconArchives: return "Archives"
|
|
case IconFonts: return "Fonts"
|
|
case IconBinaries: return "Binaries"
|
|
case IconVideos: return "Videos"
|
|
case Icon3DObjects: return "3DObjects"
|
|
case IconHistory: return "History"
|
|
case IconPreferences: return "Preferences"
|
|
case IconStorage: return "Storage"
|
|
case IconMagneticTape: return "MagneticTape"
|
|
case IconFloppyDisk: return "FloppyDisk"
|
|
case IconHardDisk: return "HardDisk"
|
|
case IconSolidStateDrive: return "SolidStateDrive"
|
|
case IconFlashDrive: return "FlashDrive"
|
|
case IconMemoryCard: return "MemoryCard"
|
|
case IconROMDisk: return "ROMDisk"
|
|
case IconRAMDisk: return "RAMDisk"
|
|
case IconCD: return "CD"
|
|
case IconDVD: return "DVD"
|
|
case IconNetwork: return "Network"
|
|
case IconLocalNetwork: return "LocalNetwork"
|
|
case IconInternet: return "Internet"
|
|
case IconEthernet: return "Ethernet"
|
|
case IconWireless: return "Wireless"
|
|
case IconCell: return "Cell"
|
|
case IconBluetooth: return "Bluetooth"
|
|
case IconRadio: return "Radio"
|
|
case IconDevice: return "Device"
|
|
case IconRouter: return "Router"
|
|
case IconServer: return "Server"
|
|
case IconDesktop: return "Desktop"
|
|
case IconLaptop: return "Laptop"
|
|
case IconTablet: return "Tablet"
|
|
case IconPhone: return "Phone"
|
|
case IconWatch: return "Watch"
|
|
case IconCamera: return "Camera"
|
|
case IconPeripheral: return "Peripheral"
|
|
case IconKeyboard: return "Keyboard"
|
|
case IconMouse: return "Mouse"
|
|
case IconMonitor: return "Monitor"
|
|
case IconWebcam: return "Webcam"
|
|
case IconMicrophone: return "Microphone"
|
|
case IconSpeaker: return "Speaker"
|
|
case IconPenTablet: return "PenTablet"
|
|
case IconTrackpad: return "Trackpad"
|
|
case IconController: return "Controller"
|
|
case IconPort: return "Port"
|
|
case IconEthernetPort: return "EthernetPort"
|
|
case IconUSBPort: return "USBPort"
|
|
case IconParallelPort: return "ParallelPort"
|
|
case IconSerialPort: return "SerialPort"
|
|
case IconPS2Port: return "PS2Port"
|
|
case IconDisplayConnector: return "DisplayConnector"
|
|
case IconCGAPort: return "CGAPort"
|
|
case IconVGAPort: return "VGAPort"
|
|
case IconHDMIPort: return "HDMIPort"
|
|
case IconDisplayPort: return "DisplayPort"
|
|
case IconInfrared: return "Infrared"
|
|
case IconOpen: return "Open"
|
|
case IconOpenIn: return "OpenIn"
|
|
case IconSave: return "Save"
|
|
case IconSaveAs: return "SaveAs"
|
|
case IconPrint: return "Print"
|
|
case IconNew: return "New"
|
|
case IconNewDirectory: return "NewDirectory"
|
|
case IconDelete: return "Delete"
|
|
case IconRename: return "Rename"
|
|
case IconGetInformation: return "GetInformation"
|
|
case IconChangePermissions: return "ChangePermissions"
|
|
case IconRevert: return "Revert"
|
|
case IconAdd: return "Add"
|
|
case IconRemove: return "Remove"
|
|
case IconAddBookmark: return "AddBookmark"
|
|
case IconRemoveBookmark: return "RemoveBookmark"
|
|
case IconAddFavorite: return "AddFavorite"
|
|
case IconRemoveFavorite: return "RemoveFavorite"
|
|
case IconPlay: return "Play"
|
|
case IconPause: return "Pause"
|
|
case IconStop: return "Stop"
|
|
case IconFastForward: return "FastForward"
|
|
case IconRewind: return "Rewind"
|
|
case IconToBeginning: return "ToBeginning"
|
|
case IconToEnd: return "ToEnd"
|
|
case IconRecord: return "Record"
|
|
case IconVolumeUp: return "VolumeUp"
|
|
case IconVolumeDown: return "VolumeDown"
|
|
case IconMute: return "Mute"
|
|
case IconUndo: return "Undo"
|
|
case IconRedo: return "Redo"
|
|
case IconCut: return "Cut"
|
|
case IconCopy: return "Copy"
|
|
case IconPaste: return "Paste"
|
|
case IconFind: return "Find"
|
|
case IconReplace: return "Replace"
|
|
case IconSelectAll: return "SelectAll"
|
|
case IconSelectNone: return "SelectNone"
|
|
case IconIncrement: return "Increment"
|
|
case IconDecrement: return "Decrement"
|
|
case IconClose: return "Close"
|
|
case IconQuit: return "Quit"
|
|
case IconIconify: return "Iconify"
|
|
case IconShade: return "Shade"
|
|
case IconMaximize: return "Maximize"
|
|
case IconFullScreen: return "FullScreen"
|
|
case IconRestore: return "Restore"
|
|
case IconExpand: return "Expand"
|
|
case IconContract: return "Contract"
|
|
case IconBack: return "Back"
|
|
case IconForward: return "Forward"
|
|
case IconUp: return "Up"
|
|
case IconDown: return "Down"
|
|
case IconReload: return "Reload"
|
|
case IconZoomIn: return "ZoomIn"
|
|
case IconZoomOut: return "ZoomOut"
|
|
case IconZoomReset: return "ZoomReset"
|
|
case IconMove: return "Move"
|
|
case IconResize: return "Resize"
|
|
case IconGoTo: return "GoTo"
|
|
case IconTransform: return "Transform"
|
|
case IconTranslate: return "Translate"
|
|
case IconRotate: return "Rotate"
|
|
case IconScale: return "Scale"
|
|
case IconWarp: return "Warp"
|
|
case IconCornerPin: return "CornerPin"
|
|
case IconSelectRectangle: return "SelectRectangle"
|
|
case IconSelectEllipse: return "SelectEllipse"
|
|
case IconSelectLasso: return "SelectLasso"
|
|
case IconSelectGeometric: return "SelectGeometric"
|
|
case IconSelectAuto: return "SelectAuto"
|
|
case IconCrop: return "Crop"
|
|
case IconFill: return "Fill"
|
|
case IconGradient: return "Gradient"
|
|
case IconPencil: return "Pencil"
|
|
case IconBrush: return "Brush"
|
|
case IconEraser: return "Eraser"
|
|
case IconText: return "Text"
|
|
case IconEyedropper: return "Eyedropper"
|
|
case IconInformation: return "Information"
|
|
case IconQuestion: return "Question"
|
|
case IconWarning: return "Warning"
|
|
case IconError: return "Error"
|
|
case IconCancel: return "Cancel"
|
|
case IconOkay: return "Okay"
|
|
case IconCellSignal0: return "CellSignal0"
|
|
case IconCellSignal1: return "CellSignal1"
|
|
case IconCellSignal2: return "CellSignal2"
|
|
case IconCellSignal3: return "CellSignal3"
|
|
case IconWirelessSignal0: return "WirelessSignal0"
|
|
case IconWirelessSignal1: return "WirelessSignal1"
|
|
case IconWirelessSignal2: return "WirelessSignal2"
|
|
case IconWirelessSignal3: return "WirelessSignal3"
|
|
case IconBattery0: return "Battery0"
|
|
case IconBattery1: return "Battery1"
|
|
case IconBattery2: return "Battery2"
|
|
case IconBattery3: return "Battery3"
|
|
case IconBrightness0: return "Brightness0"
|
|
case IconBrightness1: return "Brightness1"
|
|
case IconBrightness2: return "Brightness2"
|
|
case IconBrightness3: return "Brightness3"
|
|
case IconVolume0: return "Volume0"
|
|
case IconVolume1: return "Volume1"
|
|
case IconVolume2: return "Volume2"
|
|
case IconVolume3: return "Volume3"
|
|
|
|
default: return "Unknown"
|
|
}
|
|
}
|
|
|
|
// Texture returns a texture of the corresponding icon ID.
|
|
func (id Icon) Texture (size IconSize) canvas.Texture {
|
|
if current == nil { return nil }
|
|
return current.Icon(id, size)
|
|
}
|
|
|
|
// MimeIcon returns an icon corresponding to a MIME type.
|
|
func MimeIcon (mime data.Mime, size IconSize) canvas.Texture {
|
|
if current == nil { return nil }
|
|
return current.MimeIcon(mime, size)
|
|
}
|
|
|
|
// ApplicationIcon describes the icon of the application.
|
|
type ApplicationIcon struct {
|
|
// The name or ID of the application. If applicable, this should
|
|
// correspond to the file name (without the path or extension) of the
|
|
// icon on the system. This field is optional.
|
|
Name string
|
|
|
|
// Role describes what the application does. If a specific icon file
|
|
// cannot be found, a generic one is picked using this field.
|
|
Role ApplicationRole
|
|
}
|
|
|
|
// String satisfies the fmt.Stringer interface.
|
|
func (application ApplicationIcon) String () string {
|
|
if application.Name == "" {
|
|
return application.Role.String()
|
|
} else {
|
|
return application.Name
|
|
}
|
|
}
|
|
|
|
// Texture returns a texture of the corresponding icon ID.
|
|
func (icon ApplicationIcon) Texture (size IconSize) canvas.Texture {
|
|
if current == nil { return nil }
|
|
return current.ApplicationIcon(icon, size)
|
|
}
|
|
|
|
// ApplicationRole describes what an application does.
|
|
type ApplicationRole int; const (
|
|
RoleUnknown ApplicationRole = iota
|
|
|
|
RoleWebBrowser
|
|
RoleMesssanger
|
|
RolePhone
|
|
RoleMail
|
|
|
|
RoleTerminalEmulator
|
|
RoleFileBrowser
|
|
RoleTextEditor
|
|
|
|
RoleDocumentViewer
|
|
RoleWordProcessor
|
|
RoleSpreadsheet
|
|
RoleSlideshow
|
|
RoleCalculator
|
|
|
|
RolePreferences
|
|
RoleProcessManager
|
|
RoleSystemInformation
|
|
RoleManual
|
|
|
|
RoleCamera
|
|
RoleImageViewer
|
|
RoleMediaPlayer
|
|
RoleImageEditor
|
|
RoleAudioEditor
|
|
RoleVideoEditor
|
|
|
|
RoleClock
|
|
RoleCalendar
|
|
RoleChecklist
|
|
)
|
|
|
|
// String satisfies the fmt.Stringer interface.
|
|
func (role ApplicationRole) String () string {
|
|
switch role {
|
|
case RoleWebBrowser: return "Web Browser"
|
|
case RoleMesssanger: return "Messsanger"
|
|
case RolePhone: return "Phone"
|
|
case RoleMail: return "Mail"
|
|
case RoleTerminalEmulator: return "Terminal Emulator"
|
|
case RoleFileBrowser: return "File Browser"
|
|
case RoleTextEditor: return "Text Editor"
|
|
case RoleDocumentViewer: return "Document Viewer"
|
|
case RoleWordProcessor: return "Word Processor"
|
|
case RoleSpreadsheet: return "Spreadsheet"
|
|
case RoleSlideshow: return "Slideshow"
|
|
case RoleCalculator: return "Calculator"
|
|
case RolePreferences: return "Preferences"
|
|
case RoleProcessManager: return "Process Manager"
|
|
case RoleSystemInformation: return "System Information"
|
|
case RoleManual: return "Manual"
|
|
case RoleCamera: return "Camera"
|
|
case RoleImageViewer: return "Image Viewer"
|
|
case RoleMediaPlayer: return "Media Player"
|
|
case RoleImageEditor: return "Image Editor"
|
|
case RoleAudioEditor: return "Audio Editor"
|
|
case RoleVideoEditor: return "Video Editor"
|
|
case RoleClock: return "Clock"
|
|
case RoleCalendar: return "Calendar"
|
|
case RoleChecklist: return "Checklist"
|
|
default: return "unknown"
|
|
}
|
|
}
|