Added a String method to a bunch of stuff
This commit is contained in:
parent
63a67e40d1
commit
4d157756eb
234
theme/icon.go
234
theme/icon.go
|
@ -10,6 +10,18 @@ type IconSize int; const (
|
||||||
IconSizeLarge
|
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.
|
// Icon represents an icon ID.
|
||||||
type Icon int; const (
|
type Icon int; const (
|
||||||
// --- Objects --- //
|
// --- Objects --- //
|
||||||
|
@ -101,7 +113,7 @@ type Icon int; const (
|
||||||
IconOpenIn
|
IconOpenIn
|
||||||
IconSave
|
IconSave
|
||||||
IconSaveAs
|
IconSaveAs
|
||||||
IconPrints
|
IconPrint
|
||||||
IconNew
|
IconNew
|
||||||
IconNewDirectory
|
IconNewDirectory
|
||||||
IconDelete
|
IconDelete
|
||||||
|
@ -226,6 +238,185 @@ type Icon int; const (
|
||||||
IconVolume3
|
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.
|
// Texture returns a texture of the corresponding icon ID.
|
||||||
func (id Icon) Texture (size IconSize) canvas.Texture {
|
func (id Icon) Texture (size IconSize) canvas.Texture {
|
||||||
if current == nil { return nil }
|
if current == nil { return nil }
|
||||||
|
@ -250,6 +441,15 @@ type ApplicationIcon struct {
|
||||||
Role ApplicationRole
|
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.
|
// Texture returns a texture of the corresponding icon ID.
|
||||||
func (icon ApplicationIcon) Texture (size IconSize) canvas.Texture {
|
func (icon ApplicationIcon) Texture (size IconSize) canvas.Texture {
|
||||||
if current == nil { return nil }
|
if current == nil { return nil }
|
||||||
|
@ -291,3 +491,35 @@ type ApplicationRole int; const (
|
||||||
RoleCalendar
|
RoleCalendar
|
||||||
RoleChecklist
|
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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package theme
|
package theme
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
import "git.tebibyte.media/tomo/tomo"
|
import "git.tebibyte.media/tomo/tomo"
|
||||||
import "git.tebibyte.media/tomo/tomo/data"
|
import "git.tebibyte.media/tomo/tomo/data"
|
||||||
import "git.tebibyte.media/tomo/tomo/event"
|
import "git.tebibyte.media/tomo/tomo/event"
|
||||||
|
@ -25,6 +26,13 @@ type Role struct {
|
||||||
Variant string
|
Variant string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// String satisfies the fmt.Stringer interface.
|
||||||
|
// It follows the format of:
|
||||||
|
// Package.Object[Variant]
|
||||||
|
func (r Role) String () string {
|
||||||
|
return fmt.Sprintf("%s.%s[%s]", r.Package, r.Object, r.Variant)
|
||||||
|
}
|
||||||
|
|
||||||
// R is shorthand for creating a Role structure.
|
// R is shorthand for creating a Role structure.
|
||||||
func R (pack, object, variant string) Role {
|
func R (pack, object, variant string) Role {
|
||||||
return Role { Package: pack, Object: object, Variant: variant }
|
return Role { Package: pack, Object: object, Variant: variant }
|
||||||
|
@ -39,6 +47,18 @@ type Color int; const (
|
||||||
ColorAccent
|
ColorAccent
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// String satisfies the fmt.Stringer interface.
|
||||||
|
func (c Color) String () string {
|
||||||
|
switch c {
|
||||||
|
case ColorBackground: return "background"
|
||||||
|
case ColorForeground: return "foreground"
|
||||||
|
case ColorRaised: return "raised"
|
||||||
|
case ColorSunken: return "sunken"
|
||||||
|
case ColorAccent: return "accent"
|
||||||
|
default: return "unknown"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// RGBA satisfies the color.Color interface.
|
// RGBA satisfies the color.Color interface.
|
||||||
func (id Color) RGBA () (r, g, b, a uint32) {
|
func (id Color) RGBA () (r, g, b, a uint32) {
|
||||||
if current == nil { return }
|
if current == nil { return }
|
||||||
|
|
Loading…
Reference in New Issue