roundimage

package
v0.0.0-...-6513b37 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2021 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TrySetText

func TrySetText(imager Imager, text string)

Types

type Avatar

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

Avatar is a static HdyAvatar container.

func NewAvatar

func NewAvatar(size int) *Avatar

func (*Avatar) GetAnimation

func (a *Avatar) GetAnimation() *gdk.PixbufAnimation

GetAnimation returns nil.

func (*Avatar) GetImage

func (a *Avatar) GetImage() *gtk.Image

GetImage returns nil.

func (*Avatar) GetPixbuf

func (a *Avatar) GetPixbuf() *gdk.Pixbuf

GetPixbuf returns the underlying pixbuf.

func (*Avatar) GetSizeRequest

func (a *Avatar) GetSizeRequest() (int, int)

GetSizeRequest returns the virtual size.

func (*Avatar) GetStorageType

func (a *Avatar) GetStorageType() gtk.ImageType

GetStorageType always returns IMAGE_PIXBUF.

func (*Avatar) SetFromAnimation

func (a *Avatar) SetFromAnimation(pa *gdk.PixbufAnimation)

SetFromAnimation sets the first frame of the animation.

func (*Avatar) SetFromPixbuf

func (a *Avatar) SetFromPixbuf(pb *gdk.Pixbuf)

SetFromPixbuf sets the pixbuf.

func (*Avatar) SetImageURL

func (a *Avatar) SetImageURL(url string)

SetImageURL sets the avatar's source URL and reloads it asynchronously.

func (*Avatar) SetRadius

func (a *Avatar) SetRadius(float64)

SetRadius is a no-op.

func (*Avatar) SetSizeRequest

func (a *Avatar) SetSizeRequest(w, h int)

SetSizeRequest sets the avatar size. The actual size is min(w, h).

type Button

type Button struct {
	*gtk.Button
	Image Imager
}

Button implements a rounded button with a rounded image. This widget only supports a full circle for rounding.

func NewButton

func NewButton() (*Button, error)

func NewCustomButton

func NewCustomButton(img Imager) (*Button, error)

NewCustomButton creates a new rounded button with the given Imager. If the given Imager implements the Connector interface (aka *StillImage), then the function will implicitly connect its handlers to the button.

func NewEmptyButton

func NewEmptyButton() *Button

func (*Button) SetImage

func (b *Button) SetImage(img Imager)

type Connector

type Connector interface {
	ConnectHandlers(connector primitives.Connector)
}

type Image

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

Image represents an image with abstractions for asynchronously fetching images from a URL as well as having interchangeable fallbacks.

func NewImage

func NewImage(radius float64) *Image

NewImage creates a new round image. If radius is 0, then it will be half the dimensions. If the radius is less than 0, then nothing is rounded.

func NewSizedImage

func NewSizedImage(radius float64, size int) *Image

NewSizedImage creates a new square image with the given square.

func (*Image) AddProcessor

func (i *Image) AddProcessor(procs ...imgutil.Processor)

AddProcessor adds image processors that will be processed on fetched images. Images generated internally, such as initials, won't use it.

func (*Image) GetImage

func (i *Image) GetImage() *gtk.Image

GetImage returns the underlying image widget.

func (*Image) GetImageURL

func (i *Image) GetImageURL() string

GetImageURL gets the image's URL. It returns an empty string if the image does not have a URL set.

func (*Image) SetIfNone

func (i *Image) SetIfNone(ifNone func(context.Context))

SetIfNone sets the callback to be used if an empty URL is given to the image. If nil is given, then a fallback icon is used.

func (*Image) SetImageURL

func (i *Image) SetImageURL(url string)

SetImageURL sets the image's URL. If the URL is empty, then the placeholder icon is used, or the IfNone callback is called, or the pixbuf is cleared.

func (*Image) SetImageURLInto

func (i *Image) SetImageURLInto(url string, otherImage httputil.ImageContainer)

SetImageURLInto is SetImageURL, but the image container is given as an argument. It is used by other widgets that extend on this Image.

func (*Image) SetPlaceholderIcon

func (i *Image) SetPlaceholderIcon(iconName string, iconPx int)

SetPlaceholderIcon sets the placeholder icon onto the image. The given icon size does not affect the image's physical size.

func (*Image) SetRadius

func (i *Image) SetRadius(r float64)

SetRadius sets the radius to be drawn with. If 0 is given, then a full circle is drawn, which only works best for images guaranteed to be square. Otherwise, the radius is either the number given or the minimum of either the width or height.

func (*Image) SetSize

func (i *Image) SetSize(size int)

SetSIze sets the iamge's physical size. It is a convenient function for SetSizeRequest.

func (*Image) Size

func (i *Image) Size() int

Size returns the minimum side's length. This method is used when Image is supposed to be a square/circle.

func (*Image) UpdateIfNone

func (i *Image) UpdateIfNone()

UpdateIfNone updates the image if the image currently does not have one fetched from the URL. It does nothing otherwise.

func (*Image) UseInitialsIfNone

func (i *Image) UseInitialsIfNone(initialsFn func() string)

UseInitialsIfNone sets the given image to render an initial image if the image doesn't have a URL.

type Imager

type Imager interface {
	gtk.IWidget
	RadiusSetter
	SetSizeRequest(w, h int)

	// Embed setters.
	httputil.ImageContainer

	GetPixbuf() *gdk.Pixbuf
	GetAnimation() *gdk.PixbufAnimation

	GetImage() *gtk.Image
}

type RadiusSetter

type RadiusSetter interface {
	SetRadius(float64)
}

type StillImage

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

StillImage is an image that only plays a GIF if it's hovered on top of.

func NewStillImage

func NewStillImage(parent primitives.Connector, radius float64) *StillImage

NewStillImage creates a new static that binds to the parent's handler so that the image only animates when parent is hovered over.

func (*StillImage) ConnectHandlers

func (s *StillImage) ConnectHandlers(connector primitives.Connector)

func (*StillImage) GetAnimation

func (s *StillImage) GetAnimation() *gdk.PixbufAnimation

func (*StillImage) SetFromAnimation

func (s *StillImage) SetFromAnimation(anim *gdk.PixbufAnimation)

func (*StillImage) SetFromPixbuf

func (s *StillImage) SetFromPixbuf(pb *gdk.Pixbuf)

func (*StillImage) SetFromSurface

func (s *StillImage) SetFromSurface(sf *cairo.Surface)

func (*StillImage) SetImageURL

func (s *StillImage) SetImageURL(url string)

SetImageURL sets the image's URL.

type TextSetter

type TextSetter interface {
	SetText(text string)
}

TextSetter is an interface for setting texts.

Jump to

Keyboard shortcuts

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