icons

package
v0.0.0-...-fac7c40 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2019 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package icons provides a widget that displays a single icon from the Material Design Icons set. The size of the icon is fixed at 32x32 pixels.

To display an icon, the code-point needs to be determined. This information is available, but buried. The icon names and glyphs can be viewed at the material icons library site (https://www.google.com/design/icons/). To find the code-point, there is an index in the git repository (https://github.com/google/material-design-icons/blob/master/iconfont/codepoints).

License: The original icon files are distributed under the Apache License 2.0.

Reference: https://github.com/google/material-design-icons

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	ErrRuneNotAvailable = errors.New("rune not available")
)

Functions

func DrawImage

func DrawImage(index rune) (image.Image, error)

DrawImage returns a 32x32 image with the icon specifed by the rune.

Types

type Icon

type Icon rune

Icon describes a widget that shows an icon as an image.

Example
package main

import (
	"fmt"
	"time"

	"github.com/kjk/goey"
	"github.com/kjk/goey/base"
	"github.com/kjk/goey/loop"
)

const Build = rune(0xe869)
const Brightness1 = rune(0xe3a6)
const Brightness7 = rune(0xe3ac)

func main() {
	render := func(r rune) base.Widget {
		return &goey.Padding{
			Insets: goey.DefaultInsets(),
			Child: &goey.Align{
				Child: Icon(r),
			},
		}
	}

	createWindow := func() error {
		// Add the controls
		window, err := goey.NewWindow("Icons", render(Build))
		if err != nil {
			return err
		}

		go func() {
			for i := Brightness1; i <= Brightness7; i++ {
				time.Sleep(1 * time.Second)
				err := loop.Do(func() error {
					return window.SetChild(render(i))
				})
				if err != nil {
					panic(err)
				}
			}
			time.Sleep(1 * time.Second)

			err := loop.Do(func() error {
				window.Close()
				return nil
			})
			if err != nil {
				panic(err)
			}
		}()

		return nil
	}

	err := loop.Run(createWindow)
	if err != nil {
		fmt.Println("Error: ", err)
	}
	fmt.Println("OK")

}
Output:

OK

func New

func New(r rune) Icon

New returns a new widget description an image showing the icon with the specified rune.

func (Icon) Kind

func (i Icon) Kind() *base.Kind

Kind returns the concrete type for use in the Widget interface. Users should not need to use this method directly.

func (Icon) Mount

func (i Icon) Mount(parent base.Control) (base.Element, error)

Mount creates a control in the GUI to display the icon. The newly created widget will be a child of the widget specified by parent.

Jump to

Keyboard shortcuts

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