theme

package
v0.31.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 3, 2024 License: GPL-3.0 Imports: 5 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(object tomo.Object, role Role) event.Cookie

Apply applies the current theme to the given object, according to the given role. This may register event listeners with the given object; closing the returned cookie will remove them.

func MimeIcon added in v0.24.0

func MimeIcon(mime data.Mime, size IconSize) canvas.Texture

MimeIcon returns an icon corresponding to a MIME type.

func SetTheme

func SetTheme(theme Theme)

SetTheme sets the theme.

Types

type Color added in v0.21.0

type Color int

Color represents a color ID.

const (
	ColorBackground Color = iota
	ColorForeground
	ColorRaised
	ColorSunken
	ColorAccent
)

func (Color) RGBA added in v0.21.0

func (id Color) RGBA() (r, g, b, a uint32)

RGBA satisfies the color.Color interface.

func (Color) String added in v0.27.0

func (c Color) String() string

String satisfies the fmt.Stringer interface.

type Icon added in v0.24.0

type Icon string

Icon represents an icon ID.

const (
	IconUnknown Icon = ""

	// objects: files
	IconFile          Icon = "File" // generic
	IconDirectory     Icon = "Directory"
	IconDirectoryFull Icon = "DirectoryFull"

	// objects: places
	IconPlaceDownloads    Icon = "PlaceDownloads"
	IconPlacePhotos       Icon = "PlacePhotos"
	IconPlaceBooks        Icon = "PlaceBooks"
	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"

	// objects: storage
	IconStorage               Icon = "Storage" // generic
	IconStorageMagneticTape   Icon = "StorageMagneticTape"
	IconStorageFloppyDisk     Icon = "StorageFloppyDisk"
	IconStorageHardDisk       Icon = "StorageHardDisk"
	IconStorageSolidStateDisk Icon = "StorageSolidState"
	IconStorageFlashStick     Icon = "StorageFlashStick"
	IconStorageFlashCard      Icon = "StorageFlashCard"
	IconStorageROM            Icon = "StorageROM"
	IconStorageRAM            Icon = "StorageRAM"
	IconStorageCD             Icon = "StorageCD"
	IconStorageDVD            Icon = "StorageDVD"

	// objects: 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"

	// objects: networks
	IconNetwork          Icon = "Network" // generic
	IconNetworkLocal     Icon = "NetworkLocal"
	IconNetworkInternet  Icon = "NetworkInternet"
	IconNetworkEthernet  Icon = "NetworkEthernet"
	IconNetworkWireless  Icon = "NetworkWireless"
	IconNetworkCell      Icon = "NetworkCell"
	IconNetworkBluetooth Icon = "NetworkBluetooth"
	IconNetworkRadio     Icon = "NetworkRadio"

	// objects: devices
	IconDevice        Icon = "Device" // generic
	IconDeviceRouter  Icon = "DeviceRouter"
	IconDeviceServer  Icon = "DeviceServer"
	IconDeviceDesktop Icon = "DeviceDesktop"
	IconDeviceLaptop  Icon = "DeviceLaptop"
	IconDeviceTablet  Icon = "DeviceTablet"
	IconDevicePhone   Icon = "DevicePhone"
	IconDeviceWatch   Icon = "DeviceWatch"
	IconDeviceCamera  Icon = "DeviceCamera"

	// objects: peripherals
	IconPeripheral           Icon = "Peripheral" // generic
	IconPeripheralKeyboard   Icon = "PeripheralKeyboard"
	IconPeripheralMouse      Icon = "PeripheralMouse"
	IconPeripheralMonitor    Icon = "PeripheralMonitor"
	IconPeripheralWebcam     Icon = "PeripheralWebcam"
	IconPeripheralMicrophone Icon = "PeripheralMicrophone"
	IconPeripheralSpeaker    Icon = "PeripheralSpeaker"
	IconPeripheralPenTablet  Icon = "PeripheralPenTablet"
	IconPeripheralTrackpad   Icon = "PeripheralTrackpad"
	IconPeripheralController Icon = "PeripheralController"

	// objects: i/o
	IconPort            Icon = "Port" // generic
	IconPortEthernet    Icon = "PortEthernet"
	IconPortUSB         Icon = "PortUSB"
	IconPortParallel    Icon = "PortParallel"
	IconPortSerial      Icon = "PortSerial"
	IconPortPS2         Icon = "PortPS2"
	IconPortDisplay     Icon = "PortDisplay"
	IconPortCGA         Icon = "PortCGA"
	IconPortVGA         Icon = "PortVGA"
	IconPortHDMI        Icon = "PortHDMI"
	IconPortDisplayPort Icon = "PortDisplayPort"
	IconPortInfrared    Icon = "PortInfrared"

	// actions: files
	IconActionOpen              Icon = "ActionOpen"
	IconActionOpenIn            Icon = "ActionOpenIn"
	IconActionSave              Icon = "ActionSave"
	IconActionSaveAs            Icon = "ActionSaveAs"
	IconActionPrint             Icon = "ActionPrint"
	IconActionNew               Icon = "ActionNew"
	IconActionNewDirectory      Icon = "ActionNewDirectory"
	IconActionDelete            Icon = "ActionDelete"
	IconActionRename            Icon = "ActionRename"
	IconActionGetInformation    Icon = "ActionGetInformation"
	IconActionChangePermissions Icon = "ActionChangePermissions"
	IconActionRevert            Icon = "ActionRevert"

	// actions: list management
	IconActionAdd            Icon = "ActionAdd"
	IconActionRemove         Icon = "ActionRemove"
	IconActionAddBookmark    Icon = "ActionAddBookmark"
	IconActionRemoveBookmark Icon = "ActionRemoveBookmark"
	IconActionAddFavorite    Icon = "ActionAddFavorite"
	IconActionRemoveFavorite Icon = "ActionRemoveFavorite"

	// actions: media
	IconActionPlay        Icon = "ActionPlay"
	IconActionPause       Icon = "ActionPause"
	IconActionStop        Icon = "ActionStop"
	IconActionFastForward Icon = "ActionFastForward"
	IconActionRewind      Icon = "ActionRewind"
	IconActionToBeginning Icon = "ActionToBeginning"
	IconActionToEnd       Icon = "ActionToEnd"
	IconActionRecord      Icon = "ActionRecord"
	IconActionVolumeUp    Icon = "ActionVolumeUp"
	IconActionVolumeDown  Icon = "ActionVolumeDown"
	IconActionMute        Icon = "ActionMute"

	// actions: editing
	IconActionUndo       Icon = "ActionUndo"
	IconActionRedo       Icon = "ActionRedo"
	IconActionCut        Icon = "ActionCut"
	IconActionCopy       Icon = "ActionCopy"
	IconActionPaste      Icon = "ActionPaste"
	IconActionFind       Icon = "ActionFind"
	IconActionReplace    Icon = "ActionReplace"
	IconActionSelectAll  Icon = "ActionSelectAll"
	IconActionSelectNone Icon = "ActionSelectNone"
	IconActionIncrement  Icon = "ActionIncrement"
	IconActionDecrement  Icon = "ActionDecrement"

	// actions: window management
	IconActionClose      Icon = "ActionClose"
	IconActionQuit       Icon = "ActionQuit"
	IconActionIconify    Icon = "ActionIconify"
	IconActionShade      Icon = "ActionShade"
	IconActionMaximize   Icon = "ActionMaximize"
	IconActionFullScreen Icon = "ActionFullScreen"
	IconActionRestore    Icon = "ActionRestore"

	// actions: view
	IconActionExpand    Icon = "ActionExpand"
	IconActionContract  Icon = "ActionContract"
	IconActionBack      Icon = "ActionBack"
	IconActionForward   Icon = "ActionForward"
	IconActionUp        Icon = "ActionUp"
	IconActionDown      Icon = "ActionDown"
	IconActionReload    Icon = "ActionReload"
	IconActionZoomIn    Icon = "ActionZoomIn"
	IconActionZoomOut   Icon = "ActionZoomOut"
	IconActionZoomReset Icon = "ActionZoomReset"
	IconActionMove      Icon = "ActionMove"
	IconActionResize    Icon = "ActionResize"
	IconActionGoTo      Icon = "ActionGoTo"

	// actions: tools
	IconActionTransform       Icon = "ActionTransform"
	IconActionTranslate       Icon = "ActionTranslate"
	IconActionRotate          Icon = "ActionRotate"
	IconActionScale           Icon = "ActionScale"
	IconActionWarp            Icon = "ActionWarp"
	IconActionCornerPin       Icon = "ActionCornerPin"
	IconActionSelectRectangle Icon = "ActionSelectRectangle"
	IconActionSelectEllipse   Icon = "ActionSelectEllipse"
	IconActionSelectLasso     Icon = "ActionSelectLasso"
	IconActionSelectGeometric Icon = "ActionSelectGeometric"
	IconActionSelectAuto      Icon = "ActionSelectAuto"
	IconActionCrop            Icon = "ActionCrop"
	IconActionFill            Icon = "ActionFill"
	IconActionGradient        Icon = "ActionGradient"
	IconActionPencil          Icon = "ActionPencil"
	IconActionBrush           Icon = "ActionBrush"
	IconActionEraser          Icon = "ActionEraser"
	IconActionText            Icon = "ActionText"
	IconActionEyedropper      Icon = "ActionEyedropper"

	// status: dialog
	IconStatusInformation Icon = "StatusInformation"
	IconStatusQuestion    Icon = "StatusQuestion"
	IconStatusWarning     Icon = "StatusWarning"
	IconStatusError       Icon = "StatusError"
	IconStatusCancel      Icon = "StatusCancel"
	IconStatusOkay        Icon = "StatusOkay"

	// status: network
	IconStatusCellSignal0     Icon = "StatusCellSignal0"
	IconStatusCellSignal1     Icon = "StatusCellSignal1"
	IconStatusCellSignal2     Icon = "StatusCellSignal2"
	IconStatusCellSignal3     Icon = "StatusCellSignal3"
	IconStatusWirelessSignal0 Icon = "StatusWirelessSignal0"
	IconStatusWirelessSignal1 Icon = "StatusWirelessSignal1"
	IconStatusWirelessSignal2 Icon = "StatusWirelessSignal2"
	IconStatusWirelessSignal3 Icon = "StatusWirelessSignal3"

	// status: power
	IconStatusBattery0    Icon = "StatusBattery0"
	IconStatusBattery1    Icon = "StatusBattery1"
	IconStatusBattery2    Icon = "StatusBattery2"
	IconStatusBattery3    Icon = "StatusBattery3"
	IconStatusBrightness0 Icon = "StatusBrightness0"
	IconStatusBrightness1 Icon = "StatusBrightness1"
	IconStatusBrightness2 Icon = "StatusBrightness2"
	IconStatusBrightness3 Icon = "StatusBrightness3"

	// status: media
	IconStatusVolume0 Icon = "StatusVolume0"
	IconStatusVolume1 Icon = "StatusVolume1"
	IconStatusVolume2 Icon = "StatusVolume2"
	IconStatusVolume3 Icon = "StatusVolume3"
)

A list of standard icon IDs.

func (Icon) Texture added in v0.24.0

func (id Icon) Texture(size IconSize) canvas.Texture

Texture returns a texture of the corresponding icon ID.

type IconSize added in v0.24.0

type IconSize int

IconSize represents the size of an icon.

const (
	IconSizeSmall IconSize = iota
	IconSizeMedium
	IconSizeLarge
)

func (IconSize) String added in v0.27.0

func (size IconSize) String() string

String satisfies the fmt.Stringer interface.

type Role

type Role struct {
	// Package is an optional namespace field. If specified, it should be
	// the package name or module name the object is from.
	Package string

	// Object specifies what type of object it is. For example:
	//   - TextInput
	//   - Table
	//   - Label
	//   - Dial
	// This should correspond directly to the type name of the object.
	Object string

	// Variant is an optional field to be used when an object has one or
	// more soft variants under one type. For example, an object "Slider"
	// may have variations "horizontal" and "vertical".
	Variant string
}

Role describes the role of an object.

func R added in v0.20.0

func R(pack, object, variant string) Role

R is shorthand for creating a Role structure.

func (Role) String added in v0.27.0

func (r Role) String() string

String satisfies the fmt.Stringer interface. It follows the format of: Package.Object[Variant]

type Theme

type Theme interface {

	// Apply applies the theme to the given object, according to the given
	// role. This may register event listeners with the given object;
	// closing the returned cookie must remove them.
	Apply(tomo.Object, Role) event.Cookie

	// RGBA returns the RGBA values of the corresponding color ID.
	RGBA(Color) (r, g, b, a uint32)

	// Icon returns a texture of the corresponding icon ID.
	Icon(Icon, IconSize) canvas.Texture

	// MimeIcon returns an icon corresponding to a MIME type.
	MimeIcon(data.Mime, IconSize) canvas.Texture
}

Theme is an object that can apply a visual style to different objects.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL