widgets

package
v0.0.0-...-3d82c56 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MarkdownImageLoadTimeout is the maximum time allowed for loading a markdown image.
	MarkdownImageLoadTimeout = 12 * time.Second
	// MaxMarkdownImageBytes is the maximum allowed size for markdown images (1MB).
	MaxMarkdownImageBytes = 1 << 20
	// MaxMarkdownImageWidth is the maximum display width for markdown images.
	MaxMarkdownImageWidth = 560
	// MaxMarkdownImageHeight is the maximum display height for markdown images.
	MaxMarkdownImageHeight = 320
	// MarkdownPlaceholderHeight is the height of the image loading placeholder.
	MarkdownPlaceholderHeight = 72
	// MarkdownPlaceholderBorderWidth is the border width of the image loading placeholder.
	MarkdownPlaceholderBorderWidth = 1
)
View Source
const TooltipHideDelay = 200 * time.Millisecond

TooltipHideDelay is the delay before hiding a tooltip after the mouse leaves the widget.

Variables

View Source
var ErrMarkdownImageTooLarge = bytes.ErrTooLarge

ErrMarkdownImageTooLarge is returned when a markdown image exceeds size limits.

View Source
var LazyMarkdownLogger = slog.With("component", "ui.lazy_markdown")

LazyMarkdownLogger is the structured logger for lazy markdown operations.

View Source
var MarkdownImageHTTPClient = &http.Client{Timeout: MarkdownImageLoadTimeout}

MarkdownImageHTTPClient is the HTTP client used for downloading markdown images.

View Source
var MarkdownImagePattern = regexp.MustCompile(`!\[([^]]*)]\(([^)]+)\)`)

MarkdownImagePattern matches markdown image syntax to extract alt text and URLs.

Functions

func AlignObject

func AlignObject(alignment fyne.TextAlign, object fyne.CanvasObject) (*fyne.Container, int)

AlignObject aligns an object according to the specified text alignment and returns the container and content index.

func CloneRichTextSegment

func CloneRichTextSegment(seg widget.RichTextSegment) widget.RichTextSegment

CloneRichTextSegment creates a deep copy of a single rich text segment.

func CloneRichTextSegments

func CloneRichTextSegments(segs []widget.RichTextSegment) []widget.RichTextSegment

CloneRichTextSegments creates a deep copy of rich text segments.

func CountMarkdownImageSegments

func CountMarkdownImageSegments(segments []widget.RichTextSegment) int

CountMarkdownImageSegments counts the number of image segments in rich text segments.

func ExtractMarkdownImageAltTexts

func ExtractMarkdownImageAltTexts(markdown string) map[string]string

ExtractMarkdownImageAltTexts extracts alt text for each image URL from markdown content.

func HideTooltipWidgets

func HideTooltipWidgets(objects []fyne.CanvasObject)

HideTooltipWidgets hides all tooltip widgets within the given canvas objects.

func LoadMarkdownImageObject

func LoadMarkdownImageObject(source fyne.URI) (fyne.CanvasObject, error)

LoadMarkdownImageObject loads an image from the source URI and returns it as a canvas object.

func LoadMarkdownImageResource

func LoadMarkdownImageResource(source fyne.URI) (fyne.Resource, []byte, error)

LoadMarkdownImageResource loads image bytes from the source URI and returns them as a fyne resource.

func MarkdownImageDisplaySize

func MarkdownImageDisplaySize(content []byte) fyne.Size

MarkdownImageDisplaySize calculates the display size for a markdown image based on its content.

func MarkdownImageSource

func MarkdownImageSource(source fyne.URI) string

MarkdownImageSource returns the string representation of the image source URI.

func NewLazyMarkdownRichText

func NewLazyMarkdownRichText(markdown string) *widget.RichText

NewLazyMarkdownRichText creates a RichText widget from markdown with lazy image loading.

func NewMarkdownImagePlaceholder

func NewMarkdownImagePlaceholder(title, status string) fyne.CanvasObject

NewMarkdownImagePlaceholder creates a placeholder widget shown while markdown images are loading.

func NewTooltipBubble

func NewTooltipBubble(content fyne.CanvasObject) *fyne.Container

NewTooltipBubble creates a tooltip bubble container with styled background for the given content.

func ReadLimitedBytes

func ReadLimitedBytes(reader io.Reader, source fyne.URI) ([]byte, error)

ReadLimitedBytes reads from a reader up to MaxMarkdownImageBytes to prevent excessive memory usage.

func ReadMarkdownImageBytes

func ReadMarkdownImageBytes(source fyne.URI) ([]byte, error)

ReadMarkdownImageBytes reads image bytes from the source URI, supporting both local and remote sources.

func RemoteMarkdownImageTooLarge

func RemoteMarkdownImageTooLarge(rawURL string) (bool, error)

RemoteMarkdownImageTooLarge checks if a remote image exceeds size limits via HTTP HEAD request.

func RewriteMarkdownImageSegments

func RewriteMarkdownImageSegments(segments []widget.RichTextSegment, altTexts map[string]string) []widget.RichTextSegment

RewriteMarkdownImageSegments replaces ImageSegment with LazyMarkdownImageSegment for lazy loading.

func RichTextSegmentsPlainText

func RichTextSegmentsPlainText(segs []widget.RichTextSegment) string

RichTextSegmentsPlainText extracts plain text from rich text segments.

Types

type HoverTooltipManager

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

HoverTooltipManager manages the display and positioning of hover tooltips.

func NewHoverTooltipManager

func NewHoverTooltipManager(layer *fyne.Container) *HoverTooltipManager

NewHoverTooltipManager creates a new HoverTooltipManager with the specified overlay layer.

func (*HoverTooltipManager) Hide

func (m *HoverTooltipManager) Hide(owner fyne.CanvasObject)

func (*HoverTooltipManager) Show

func (m *HoverTooltipManager) Show(owner fyne.CanvasObject, content fyne.CanvasObject)

type IconNavButton

type IconNavButton struct {
	widget.DisableableWidget
	// contains filtered or unexported fields
}

IconNavButton is a navigation button with an icon and optional text label.

func NewIconNavButton

func NewIconNavButton(icon fyne.Resource, onTap func()) *IconNavButton

func (*IconNavButton) CreateRenderer

func (b *IconNavButton) CreateRenderer() fyne.WidgetRenderer

func (*IconNavButton) Icon

func (b *IconNavButton) Icon() fyne.Resource

func (*IconNavButton) MinSize

func (b *IconNavButton) MinSize() fyne.Size

func (*IconNavButton) MouseIn

func (b *IconNavButton) MouseIn(_ *desktop.MouseEvent)

func (*IconNavButton) MouseMoved

func (b *IconNavButton) MouseMoved(_ *desktop.MouseEvent)

func (*IconNavButton) MouseOut

func (b *IconNavButton) MouseOut()

func (*IconNavButton) SetIcon

func (b *IconNavButton) SetIcon(icon fyne.Resource)

func (*IconNavButton) SetSelected

func (b *IconNavButton) SetSelected(selected bool)

func (*IconNavButton) SetText

func (b *IconNavButton) SetText(text string)

func (*IconNavButton) Tapped

func (b *IconNavButton) Tapped(_ *fyne.PointEvent)

func (*IconNavButton) TappedSecondary

func (b *IconNavButton) TappedSecondary(_ *fyne.PointEvent)

func (*IconNavButton) Text

func (b *IconNavButton) Text() string

type LazyMarkdownImageSegment

type LazyMarkdownImageSegment struct {
	Source    fyne.URI
	Title     string
	Alignment fyne.TextAlign
}

LazyMarkdownImageSegment is a rich text segment that loads images asynchronously.

func (*LazyMarkdownImageSegment) Inline

func (s *LazyMarkdownImageSegment) Inline() bool

func (*LazyMarkdownImageSegment) Select

func (s *LazyMarkdownImageSegment) Select(_, _ fyne.Position)

func (*LazyMarkdownImageSegment) SelectedText

func (s *LazyMarkdownImageSegment) SelectedText() string

func (*LazyMarkdownImageSegment) Textual

func (s *LazyMarkdownImageSegment) Textual() string

func (*LazyMarkdownImageSegment) Unselect

func (s *LazyMarkdownImageSegment) Unselect()

func (*LazyMarkdownImageSegment) Update

func (*LazyMarkdownImageSegment) Visual

type TooltipWidget

type TooltipWidget struct {
	widget.BaseWidget
	// contains filtered or unexported fields
}

TooltipWidget is a widget that displays a tooltip on hover.

func NewTooltipLabel

func NewTooltipLabel(text, tooltip string, manager *HoverTooltipManager) *TooltipWidget

NewTooltipLabel creates a new TooltipWidget with a label and tooltip text.

func NewTooltipRichText

func NewTooltipRichText(segments []widget.RichTextSegment, tooltip []widget.RichTextSegment, manager *HoverTooltipManager) *TooltipWidget

NewTooltipRichText creates a new TooltipWidget with rich text content and tooltip segments.

func (*TooltipWidget) CreateRenderer

func (w *TooltipWidget) CreateRenderer() fyne.WidgetRenderer

func (*TooltipWidget) MouseIn

func (w *TooltipWidget) MouseIn(*desktop.MouseEvent)

func (*TooltipWidget) MouseMoved

func (w *TooltipWidget) MouseMoved(*desktop.MouseEvent)

func (*TooltipWidget) MouseOut

func (w *TooltipWidget) MouseOut()

func (*TooltipWidget) SetBadge

func (w *TooltipWidget) SetBadge(text, tooltip string)

func (*TooltipWidget) SetBadgeWithContent

func (w *TooltipWidget) SetBadgeWithContent(text string, tooltip fyne.CanvasObject)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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