theme

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2023 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

package theme defines custom theme for UI.

Index

Constants

View Source
const (
	DefaultFontSize = 12.0 // in pt
	DefaultDPI      = 72.0
)
View Source
const DefaultFontName = "GenShinGothic-Monospace-Normal.ttf"

DefaultFace returns this varints.

View Source
const UnitLh = unit.Unit(1 << 6)

UnitLh is 1 character cell height, same as sum of Ascent.Ceil and Descent.Ceil.

if use this as unit.Value v, v.String() method and theme.Pixels(v) will be occured panic. use this package theme's UnitString() and Pixels() insteadly.

Variables

View Source
var (
	// Default Palette for painting, Material Dark Theme.
	DefaultPalette = theme.Palette{

		theme.Dark:    image.Uniform{C: color.RGBA{0x00, 0x00, 0x00, 0xff}},
		theme.Neutral: image.Uniform{C: color.RGBA{0x21, 0x21, 0x21, 0xff}},
		theme.Light:   image.Uniform{C: color.RGBA{0x42, 0x42, 0x42, 0xff}},

		theme.Accent: image.Uniform{C: color.RGBA{0x29, 0xf6, 0xf6, 0xff}},

		theme.Foreground: image.Uniform{C: color.RGBA{0xff, 0xff, 0xff, 0xff}},

		theme.Background: image.Uniform{C: color.RGBA{0x30, 0x30, 0x30, 0xff}},
	}

	// Dark Divider color.
	DarkDivider = theme.StaticColor(color.RGBA{0xff, 0xff, 0xff, 0x1f})

	// Light Divider color.
	LightDivider = theme.StaticColor(color.RGBA{0x00, 0x00, 0x00, 0x1f})

	// Neutral Divider color.
	NeutralDivider = theme.StaticColor(color.RGBA{0xbd, 0xbd, 0xbd, 0xff})

	// Default theme for painting.
	Default = theme.Theme{
		DPI:             theme.DefaultDPI,
		FontFaceCatalog: defaultFontFaceCatalog,
		Palette:         &DefaultPalette,
	}
)

Functions

func Lhs

func Lhs(f float64) unit.Value

returns Lh as unit.Value.

func NewDefaultFace

func NewDefaultFace(opt *FontFaceOptions) font.Face

return default monospace font face.

func ParseTruetypeFileFace

func ParseTruetypeFileFace(file string, opt *FontFaceOptions) (font.Face, error)

parse truetype font file and return its font.Face.

func Pixels

func Pixels(t *theme.Theme, v unit.Value) fixed.Int26_6

Extension of theme.Pixels() which can treat Lh unit.Value. Otherwise, it returns same as theme.Pixels() Note that it call Theme.AcquireFontFace and ReleaseFontFace internaly.

Types

type FontFaceOptions

type FontFaceOptions struct {
	// font size in point. if set 0 then use 12.0pt instead.
	Size float64

	// Dot per inch. if set 0 then use 72 DPI.
	DPI float64
}

It is same as Options in golang.org/x/image/font/opentype but only DPI and Size fields exist to use easily.

func (*FontFaceOptions) TTFOptions

func (opt *FontFaceOptions) TTFOptions() *opentype.FaceOptions

return reciever as opentype.Options. because nil TTF Options is ok, it may return nil if reciever is nil.

type OneFontFaceCatalog

type OneFontFaceCatalog struct {
	// contains filtered or unexported fields
}

OneFontCatalog serves only one font object and its face.

func NewOneFontFaceCatalog

func NewOneFontFaceCatalog(fontfile string, o *FontFaceOptions) (*OneFontFaceCatalog, error)

return OneFontFaceCatalog which has only one font face specified by fontfile. return error if fontfile is not found

func (*OneFontFaceCatalog) AcquireFontFace

func (cat *OneFontFaceCatalog) AcquireFontFace(theme.FontFaceOptions) font.Face

Implements theme.FontFaceCatalog interface. Return its font face with lock resource to prevent from using other goroutine. The argument theme.FontFaceOptions does not affect to returned font.Face. Be sure of calling ReleaseFontFace after use font.Face.

func (*OneFontFaceCatalog) ReleaseFontFace

func (cat *OneFontFaceCatalog) ReleaseFontFace(theme.FontFaceOptions, font.Face)

Implements theme.FontFaceCatalog interface Make the font.Face returned from AcquireFontFace free to use. With any arguments, the use freed font.Face will not be changed, got by AcquireFontFace. Be sure of calling This after call AcquireFontFace.

func (*OneFontFaceCatalog) UpdateFontFaceOptions

func (cat *OneFontFaceCatalog) UpdateFontFaceOptions(opt *FontFaceOptions)

update its font face using options. if opt has empty value. use previous value for that field.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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