onlineimage

package
v0.0.0-...-bedf5c0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: MPL-2.0 Imports: 11 Imported by: 3

Documentation

Overview

Package onlineimage contains image widgets that can fetch from image providers, usually online ones. It provides lazy HiDPI scaling by automatically reloading images when the scale factor changes.

Index

Constants

View Source
const MaxFPS = 50

MaxFPS is the maximum FPS to play an animation (often a GIF) at. In reality, the actual frame rate heavily depends on the draw clock of GTK, but this duration determines the background ticker.

For more information, see https://wunkolo.github.io/post/2020/02/buttery-smooth-10fps/.

Variables

View Source
var CanAnimate = true

CanAnimate is true by default, which allows EnableAnimation to be called on certain images to allow animations to be played back.

Functions

This section is empty.

Types

type AnimationController

type AnimationController baseImage

func (*AnimationController) ConnectMotion

func (c *AnimationController) ConnectMotion(w gtk.Widgetter)

ConnectMotion connects a motion controller to the given widget that will activate the animation when it's hovered over (entered).

func (*AnimationController) OnHover

func (c *AnimationController) OnHover()

OnHover binds the controller to a motion controller attached to the image widget. When the user hovers over the image, the animation plays.

func (*AnimationController) Start

func (c *AnimationController) Start()

Start starts the animation playback in the background. The animation isn't stopped until it is either unmapped or Stop is called.

func (*AnimationController) Stop

func (c *AnimationController) Stop()

Stop stops the animation playback.

type Avatar

type Avatar struct {
	*adaptive.Avatar
	// contains filtered or unexported fields
}

Avatar is an online variant of adaptive.Avatar.

func NewAvatar

func NewAvatar(ctx context.Context, p imgutil.Provider, size int) *Avatar

NewAvatar creates a new avatar.

func (*Avatar) Disable

func (a *Avatar) Disable()

Disable disables the online capability of the avatar, and sets the avatar to the default avatar.

func (*Avatar) EnableAnimation

func (a *Avatar) EnableAnimation() *AnimationController

EnableAnimation enables animation for the avatar. The controller is returned for the user to determine when to play the animation.

func (*Avatar) SetFromURL

func (a *Avatar) SetFromURL(url string)

SetFromURL sets the Avatar's URL.

func (*Avatar) SetSizeRequest

func (a *Avatar) SetSizeRequest(size int)

SetSizeRequest sets the avatar size.

type Image

type Image struct {
	*gtk.Image
	// contains filtered or unexported fields
}

Image is an online variant of gtk.Image.

func NewImage

func NewImage(ctx context.Context, p imgutil.Provider) *Image

NewImage creates a new avatar.

func (*Image) Disable

func (i *Image) Disable()

Disable disables the online capability of the image, turning it into a normal gtk.Image. To re-enable it, call SetURL again.

func (*Image) EnableAnimation

func (i *Image) EnableAnimation() *AnimationController

EnableAnimation enables animation for the avatar. The controller is returned for the user to determine when to play the animation.

func (*Image) SetFromURL

func (i *Image) SetFromURL(url string)

SetFromURL sets the Image's URL.

func (*Image) SetSizeRequest

func (i *Image) SetSizeRequest(w, h int)

SetSizeRequest sets the minimum size of a widget.

type Picture

type Picture struct {
	*gtk.Picture
	// contains filtered or unexported fields
}

Picture is an online variant of gtk.Picture.

func NewPicture

func NewPicture(ctx context.Context, prov imgutil.Provider) *Picture

NewPicture creates a new Picture.

func (*Picture) Disable

func (p *Picture) Disable()

Disable disables the online capability of the picture, turning it into a normal gtk.Picture. To re-enable it, call SetURL again.

func (*Picture) EnableAnimation

func (p *Picture) EnableAnimation() *AnimationController

EnableAnimation enables animation for the avatar. The controller is returned for the user to determine when to play the animation.

func (*Picture) SetSizeRequest

func (p *Picture) SetSizeRequest(w, h int)

SetSizeRequest sets the minimum size of a widget.

func (*Picture) SetURL

func (p *Picture) SetURL(url string)

SetURL sets the Avatar's URL.

Jump to

Keyboard shortcuts

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