exp: golang.org/x/exp/shiny/widget/theme Index | Files

package theme

import "golang.org/x/exp/shiny/widget/theme"

Package theme provides widget themes.

Index

Package Files

theme.go

Constants

const (
    // Light, Neutral and Dark are three color tones used to fill in widgets
    // such as buttons, menu bars and panels.
    Light   = PaletteIndex(0)
    Neutral = PaletteIndex(1)
    Dark    = PaletteIndex(2)

    // Accent is the color used to accentuate selections or suggestions.
    Accent = PaletteIndex(3)

    // Foreground is the color used for text, dividers and icons.
    Foreground = PaletteIndex(4)

    // Background is the color used behind large blocks of text. Short,
    // non-editable label text will typically be on the Neutral color.
    Background = PaletteIndex(5)

    PaletteLen = 6
)
const DefaultDPI = 72.0

DefaultDPI is the fallback value of a theme's DPI, if the underlying context does not provide a DPI value.

Variables

var (
    // DefaultFontFaceCatalog is a catalog for a basic font face.
    DefaultFontFaceCatalog FontFaceCatalog = defaultFontFaceCatalog{}

    // DefaultPalette is the default theme's palette.
    DefaultPalette = Palette{
        Light:      image.Uniform{C: color.RGBA{0xf5, 0xf5, 0xf5, 0xff}},
        Neutral:    image.Uniform{C: color.RGBA{0xee, 0xee, 0xee, 0xff}},
        Dark:       image.Uniform{C: color.RGBA{0xe0, 0xe0, 0xe0, 0xff}},
        Accent:     image.Uniform{C: color.RGBA{0x21, 0x96, 0xf3, 0xff}},
        Foreground: image.Uniform{C: color.RGBA{0x00, 0x00, 0x00, 0xff}},
        Background: image.Uniform{C: color.RGBA{0xff, 0xff, 0xff, 0xff}},
    }

    // Default uses the default DPI, FontFaceCatalog and Palette.
    //
    // The nil-valued pointer is a valid receiver for a Theme's methods.
    Default *Theme
)

type Color Uses

type Color interface {
    Color(*Theme) color.Color
    Uniform(*Theme) *image.Uniform
}

Color is a theme-dependent color, such as "the foreground color". Combining a Color with a Theme results in a color.Color in the sense of the standard library's image/color package. It can also result in an *image.Uniform, suitable for passing as the src argument to image/draw functions.

func StaticColor Uses

func StaticColor(c color.Color) Color

StaticColor adapts a color.Color to a theme Color.

type FontFaceCatalog Uses

type FontFaceCatalog interface {
    AcquireFontFace(FontFaceOptions) font.Face
    ReleaseFontFace(FontFaceOptions, font.Face)
}

FontFaceCatalog provides a theme's font faces.

AcquireFontFace returns a font.Face. ReleaseFontFace should be called, with the same options, once a widget's measure, layout or paint is done with the font.Face returned.

A FontFaceCatalog is safe for use by multiple goroutines simultaneously, but in general, a font.Face is not safe for concurrent use, as its methods may re-use implementation-specific caches and mask image buffers.

type FontFaceOptions Uses

type FontFaceOptions struct {
    Style  font.Style
    Weight font.Weight
}

FontFaceOptions allows asking for font face variants, such as style (e.g. italic) or weight (e.g. bold).

TODO: include font.Hinting and font.Stretch typed fields?

TODO: include font size? If so, directly as "12pt" or indirectly as an enum (Heading1, Heading2, Body, etc)?

type Palette Uses

type Palette [PaletteLen]image.Uniform

Palette provides a theme's color palette. The array is indexed by PaletteIndex constants such as Accent and Foreground.

The colors are expressed as image.Uniform values so that they can be easily passed as the src argument to image/draw functions.

func (*Palette) Accent Uses

func (p *Palette) Accent() *image.Uniform

func (*Palette) Background Uses

func (p *Palette) Background() *image.Uniform

func (*Palette) Dark Uses

func (p *Palette) Dark() *image.Uniform

func (*Palette) Foreground Uses

func (p *Palette) Foreground() *image.Uniform

func (*Palette) Light Uses

func (p *Palette) Light() *image.Uniform

func (*Palette) Neutral Uses

func (p *Palette) Neutral() *image.Uniform

type PaletteIndex Uses

type PaletteIndex int

PaletteIndex is both an integer index into a Palette array and a Color.

func (PaletteIndex) Color Uses

func (i PaletteIndex) Color(t *Theme) color.Color

func (PaletteIndex) Uniform Uses

func (i PaletteIndex) Uniform(t *Theme) *image.Uniform

type Theme Uses

type Theme struct {
    // DPI is the screen resolution, in dots (i.e. pixels) per inch.
    //
    // A zero value means to use the DefaultDPI.
    DPI float64

    // FontFaceCatalog provides a theme's font faces.
    //
    // A zero value means to use the DefaultFontFaceCatalog.
    FontFaceCatalog FontFaceCatalog

    // Palette provides a theme's color palette.
    //
    // A zero value means to use the DefaultPalette.
    Palette *Palette
}

Theme is used for measuring, laying out and painting widgets. It consists of a screen DPI resolution, a set of font faces and colors.

func (*Theme) AcquireFontFace Uses

func (t *Theme) AcquireFontFace(o FontFaceOptions) font.Face

AcquireFontFace calls the same method on the result of GetFontFaceCatalog.

func (*Theme) Convert Uses

func (t *Theme) Convert(v unit.Value, to unit.Unit) unit.Value

Convert implements the unit.Converter interface.

func (*Theme) GetDPI Uses

func (t *Theme) GetDPI() float64

GetDPI returns the theme's DPI, or the default DPI if the field value is zero.

func (*Theme) GetFontFaceCatalog Uses

func (t *Theme) GetFontFaceCatalog() FontFaceCatalog

GetFontFaceCatalog returns the theme's font face catalog, or the default catalog if the field value is zero.

func (*Theme) GetPalette Uses

func (t *Theme) GetPalette() *Palette

GetPalette returns the theme's palette, or the default palette if the field value is zero.

func (*Theme) Pixels Uses

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

Pixels implements the unit.Converter interface.

func (*Theme) ReleaseFontFace Uses

func (t *Theme) ReleaseFontFace(o FontFaceOptions, f font.Face)

ReleaseFontFace calls the same method on the result of GetFontFaceCatalog.

Package theme imports 6 packages (graph) and is imported by 4 packages. Updated 2017-11-19. Refresh now. Tools for package owners.