API Reference

Fugl.DEFAULT_FONT_PATHConstant
DEFAULT_FONT_PATH

Path to the default font file. Users can override this before calling load_default_font!() to use a custom font throughout their application.

Example

Fugl.DEFAULT_FONT_PATH[] = "/path/to/my/font.ttf"
Fugl.load_default_font!()
source
Fugl.ButtonStateType

Enum representing the state of a mouse button.

  • IsReleased: The button is currently released.
  • IsPressed: The button is currently pressed.
source
Fugl.CursorPositionType

Represents the position of a cursor in the editor.

  • line: Line number (1-based)
  • column: Column number (1-based, character position within the line)
source
Fugl.DPIScalingType

Simple DPI scaling state for the current rendering context. Only manual scaling - no automatic system DPI detection.

source
Fugl.EditorStateType

State for the code editor containing text, cursor position, and cached tokenization.

  • text: The full text content
  • cursor: Current cursor position
  • is_focused: Whether the editor is focused
  • selection_start: Start position of text selection (if any)
  • selection_end: End position of text selection (if any)
  • cached_lines: Cache of tokenized line data
  • text_hash: Hash of the text to detect changes
source
Fugl.EditorStateMethod

Create a new EditorState from an existing state with keyword-based modifications.

source
Fugl.EditorStateMethod

Create a new EditorState with old 5-parameter signature (for backward compatibility).

source
Fugl.GLContextStateType

OpenGL Context State Management

This module provides a simple state management system for OpenGL contexts, allowing for framebuffer management, caching, and tracking of current OpenGL state.

source
Fugl.GlyphAtlasType

A texture atlas that stores multiple glyphs in a single OpenGL texture. This dramatically speeds up text rendering by avoiding texture creation per glyph.

source
Fugl.GlyphBatchType

A structure to hold batched glyph data for efficient rendering. Each glyph becomes two triangles (6 vertices) in the batch. Inspired by Makie.jl's TextureAtlas approach.

source
Fugl.HorizontalColorbarType

HorizontalColorbar represents a horizontal colorbar plot element. Size is controlled by FixedHeight layout component.

source
Fugl.HorizontalSliderViewType

HorizontalSlider with state management and discrete step support.

  • state: SliderState containing current value, range, and interaction state
  • steps: Optional step snapping (Int for number of steps, Real for step size, nothing for continuous)
  • style: Style for the slider
  • on_state_change: Callback for state changes (required for state updates)
  • on_change: Callback for value changes only
source
Fugl.HorizontalSplitContainerViewType

A container that allows horizontal resizing by dragging a vertical splitter handle between left and right child components. Optimized version with no runtime direction checks for better performance.

source
Fugl.InteractionStateType

Interaction state management for GUI components.

Provides a common structure for tracking user interactions like hover, press, focus, etc.

source
Fugl.KeyEventType

Struct representing a keyboard event.

  • key: GLFW key code (e.g., GLFW.KEYA, GLFW.KEYENTER)
  • scancode: Hardware-specific scancode
  • action: GLFW action (GLFW.PRESS, GLFW.RELEASE, GLFW.REPEAT)
  • mods: Modifier key flags (GLFW.MODSHIFT, GLFW.MODCONTROL, etc.)
source
Fugl.LegendViewType

Legend component for displaying plot element labels with visual representations.

source
Fugl.LineTokenDataType

Cached tokenization data for a line of code.

  • line_number: The line number this data belongs to
  • line_text: The original line text
  • tokens: Vector of tokens for this line
  • token_data: Processed token data with positions and colors
source
Fugl.ModifierKeysType

Struct representing the current state of modifier keys. This provides a clean, explicit API that doesn't require knowledge of GLFW constants.

  • shift: Whether Shift key is pressed
  • control: Whether Control key is pressed
  • alt: Whether Alt key is pressed
  • super: Whether Super/Cmd/Windows key is pressed
  • caps_lock: Whether Caps Lock is active
  • num_lock: Whether Num Lock is active
source
Fugl.MouseButtonType

Enum representing the different mouse buttons.

  • LeftButton: The left mouse button.
  • RightButton: The right mouse button.
  • MiddleButton: The middle mouse button (scroll button).
source
Fugl.PeriodicCallbackType
PeriodicCallback(func::Function, interval::Int)
Experimental

This feature is experimental and the API may change in future versions.

Represents a periodic callback that executes every N frames.

Arguments

  • func::Function: Function to execute periodically
  • interval::Int: Execute every N frames

Examples

# Run every 60 frames (~1 second at 60fps)
callback = PeriodicCallback(() -> println("Hello!"), 60)
run(MyApp, periodic_callbacks=[callback])
source
Fugl.PlotStateType
PlotState(initial_bounds, current_bounds, auto_scale, cache_id)

Represents the state of a plot, including axis bounds, scaling, and cache information.

Fields:

  • initial_bounds: User-defined initial view bounds (preserved during drag operations). Can be Rectangle, PartialBounds, or Nothing.
  • current_bounds: Current view bounds (after zoom/pan). If nothing, falls back to initial_bounds or auto-scale.
  • auto_scale: Bool, whether to automatically scale axes to fit data when no bounds are specified.
  • cache_id: Unique identifier for plot cache. Not user managed.
  • drag_cursor_position: Plot coordinate where drag started. Not user managed.
  • is_dragging: Whether plot is being dragged. Not user managed.
source
Fugl.PlotStateMethod

Create a new PlotState from an existing state with keyword-based modifications.

source
Fugl.RotateViewType

A component that applies rotation transformation to any child component. Uses framebuffer rendering and GPU-based rotation for high quality results.

source
Fugl.SizedViewType

Abstract type for views that have constrained/intrinsic sizing behavior. These views know their preferred dimensions and can be used with alignment components. Examples: IntrinsicSize, FixedSize, IntrinsicWidth, IntrinsicHeight, etc.

source
Fugl.SliderStateMethod

Create a new SliderState from an existing state with keyword-based modifications.

source
Fugl.SliderStateMethod

Create a new SliderState with automatic type conversion to the specified output type. Useful for creating sliders that output specific types (e.g., Int for discrete values).

source
Fugl.TableStateType
TableState(column_widths, auto_size, cache_id)

Represents the state of a table, including column widths and sizing behavior.

Fields:

  • column_widths: Vector of column widths in pixels. If nothing, will be auto-calculated.
  • auto_size: Bool, whether to automatically size columns to fit content.
  • cache_id: Unique identifier for table cache. Not user managed.
source
Fugl.TableStateMethod

Create a new TableState from an existing state with keyword-based modifications.

source
Fugl.TextStyleMethod

Copy constructor for TextStyle that allows overriding specific fields.

source
Fugl.TextStyleMethod
TextStyle(; font_cache_key=DEFAULT_FONT_CACHE_KEY, size_points=16, color=Vec{4,Float32}(0.0, 0.0, 0.0, 1.0))

Create a TextStyle with the specified font cache key, size, and color.

The font referenced by the cache key should already be loaded into the font cache. By default, uses the default font cache key (a Symbol for optimal performance).

Example

# Use default font
style = TextStyle(size_points=20)

# Use a custom font
Fugl.get_font_by_path(:my_font, "/path/to/font.ttf")
style = TextStyle(font_cache_key=:my_font, size_points=20)
source
Fugl.TooltipStateMethod

Create a new TooltipState from an existing state with keyword-based modifications.

source
Fugl.TreeStateMethod

Create a new TreeState from an existing state with keyword-based modifications.

source
Fugl.VerticalColorbarType

VerticalColorbar represents a vertical colorbar plot element. Size is controlled by FixedWidth layout component.

source
Fugl.VerticalSplitContainerViewType

A container that allows vertical resizing by dragging a horizontal splitter handle between top and bottom child components. Optimized version with no runtime direction checks for better performance.

source
Fugl.AlignHorizontalFunction
AlignHorizontal(child::SizedView, alignment::Symbol)

Aligns a sized child component horizontally within its container.

Arguments

  • child: A SizedView component that has intrinsic dimensions
  • alignment: Horizontal alignment (:left, :center, :right)

Example

AlignHorizontal(IntrinsicSize(Image("logo.png")), :left)
AlignHorizontal(FixedSize(Text("Hello"), 100.0f0, 50.0f0), :right)
source
Fugl.AlignVerticalFunction
AlignVertical(child::SizedView, alignment::Symbol)

Aligns a sized child component vertically within its container.

Arguments

  • child: A SizedView component that has intrinsic dimensions
  • alignment: Vertical alignment (:top, :middle, :bottom)

Example

AlignVertical(IntrinsicSize(Image("logo.png")), :top)
AlignVertical(FixedSize(Text("Hello"), 100.0f0, 50.0f0), :middle)
source
Fugl.BaseContainerFunction

The BaseContainer is the most basic GUI component that can contain another component. It is the most basic building block of the GUI system.

source
Fugl.CardFunction

A simple card component that can be used to display a title and content in a styled container.

source
Fugl.CheckBoxMethod

Create a CheckBox component

Arguments

  • checked::Bool: Current checked state (user should pass checkbox_state[])
  • label::String: Optional text label next to the checkbox
  • style::CheckBoxStyle: Visual styling for the checkbox (includes label text style)
  • on_change::Function: Callback when checkbox value changes: (new_value::Bool) -> nothing
  • on_click::Function: Additional click callback

Example

# User-managed state
checkbox_state = Ref(false)

# Create checkbox with custom style
checkbox = CheckBox(
    checkbox_state[],  # Pass current value
    label="Enable feature",
    style=CheckBoxStyle(
        size=18.0f0,
        label_style=TextStyle(size_points=16, color=Vec4f(0.2, 0.2, 0.2, 1.0))
    ),
    on_change=(new_value) -> checkbox_state[] = new_value  # User updates state
)
source
Fugl.ContainerFunction

The Container is an interactive container component that extends BaseContainer with hover, pressed, and disabled states. It provides rich interaction handling including callbacks and state management. For simple non-interactive containers, use BaseContainer directly.

source
Fugl.FixedHeightMethod
FixedHeight(child::AbstractView, height::Real)

Creates a view that has a fixed height but uses the child's intrinsic width.

source
Fugl.FixedSizeMethod
FixedSize(child::AbstractView, width::Real, height::Real)

Creates a view that has a fixed size, regardless of the child's intrinsic size. The child will be rendered at the specified width and height.

source
Fugl.FixedWidthMethod
FixedWidth(child::AbstractView, width::Real)

Creates a view that has a fixed width but uses the child's intrinsic height.

source
Fugl.FocusMethod

Focus wraps a component to provide focus management. Focus is gained on left mouse button down inside the component. Focus is lost on left mouse button down outside the component.

Usage:

focus_state = Ref(false)

Focus(
    my_component;
    is_focused=focus_state[],
    on_focus_change=(focused) -> focus_state[] = focused
)
source
Fugl.FormattedTextFieldFunction
FormattedTextField(
    state::EditorState=EditorState();
    max_length::Union{Int, Nothing}=nothing,
    parser::Union{Function, Nothing}=nothing,
    validator::Union{Function, Nothing}=nothing,
    style::TextEditorStyle=TextBoxStyle(border_width=1.0f0),
    on_state_change::Function=(new_state::EditorState) -> nothing,
    on_change::Function=(parsed_value) -> nothing,
    on_focus::Function=() -> nothing,
    on_blur::Function=() -> nothing
)

Single-line form field with custom formatting, validation, and parsing.

Arguments

  • state::EditorState: Initial state of the text box.
  • max_length::Union{Int, Nothing}: Maximum number of characters allowed (default is nothing for unlimited).
  • parser::Union{Function, Nothing}: Function that takes text and returns (cleaned_text::String, parsed_value). Applied on focus loss and Enter.
  • validator::Union{Function, Nothing}: Function that filters input during typing. Takes text, returns filtered text.
  • style::TextEditorStyle: Style for the text field.
  • on_state_change::Function: Callback for when the state changes. Must update a state ref or similar.
  • on_change::Function: Optional callback for when parsing succeeds. Receives the parsed value.
  • on_focus::Function: Optional callback for when the component gains focus.
  • on_blur::Function: Optional callback for when the component loses focus.

Example: Hex Color Field

hex_parser(text) = begin
    # Remove # prefix if present, ensure uppercase
    clean = uppercase(replace(text, "#" => ""))
    # Validate hex format
    if match(r"^[0-9A-F]{6}$", clean) !== nothing
        return ("#" * clean, clean)
    else
        return ("#000000", "000000")  # Default to black
    end
end

hex_validator(text) = begin
    # Allow only valid hex characters and #
    replace(uppercase(text), r"[^#0-9A-F]" => "")
end

FormattedTextField(
    state,
    parser=hex_parser,
    validator=hex_validator,
    on_change=(hex_value) -> println("Valid hex: ", hex_value)
)
source
Fugl.HorizontalScrollAreaMethod

Create a HorizontalScrollArea component

Arguments

  • content::AbstractView: The content to be scrolled
  • scroll_state::HorizontalScrollState: Current scroll state
  • style::ScrollAreaStyle: Styling for the scroll area
  • show_scrollbar::Bool: Show visual scrollbar
  • on_scroll_change::Function: Callback when scroll state changes
  • on_click::Function: Callback for click events
source
Fugl.HorizontalSplitContainerMethod
HorizontalSplitContainer(left, right; kwargs...)

Create a horizontal split container with left and right child components.

Arguments

  • left::AbstractView: Left child component
  • right::AbstractView: Right child component
  • style::SplitContainerStyle=SplitContainerStyle(): Style configuration
  • state::SplitContainerState=SplitContainerState(): State including split position and interactions
  • on_state_change::Function=() -> nothing: Callback for state changes (including split position)
source
Fugl.IntrinsicSizeFunction
IntrinsicSize(child::AbstractView=EmptyView())

The IntrinsicSize component is used to wrap a child view and ensure that it uses its intrinsic size for layout. This is useful for components that should not stretch to fill their parent container, but rather use their natural size.

source
Fugl.KeyListenerMethod

KeyListener wraps another component and triggers callbacks when specific keys are pressed. This allows adding keyboard shortcuts to any component.

Usage:

  • KeyListener(my_component, GLFW.KEY_A, () -> println("A pressed")) Single key
  • KeyListener(my_component, GLFW.KEY_S, GLFW.MOD_CONTROL, () -> save_file()) Single key with modifier
  • KeyListener(my_component, [(GLFW.KEY_A, nothing, callback1), (GLFW.KEY_S, GLFW.MOD_CONTROL, callback2)]) Multiple keys
  • KeyListener(my_component, [(GLFW.KEY_A, callback1), (GLFW.KEY_B, callback2)]) Multiple simple keys
source
Fugl.NumberFieldFunction
NumberField(
    state::EditorState=EditorState();
    type::Type=Float64,
    style::TextEditorStyle=TextBoxStyle(border_width=1.0f0),
    on_state_change::Function=(new_state::EditorState) -> nothing,
    on_change::Function=(parsed_value) -> nothing,
    on_focus::Function=() -> nothing,
    on_blur::Function=() -> nothing
)

Form field for entering numbers. New values are parsed on focus loss.

Arguments

  • state::EditorState: Initial state of the text box.
  • type::Type: The numeric type to parse the input as (default is Float64).
  • style::TextEditorStyle: Style for the text field.
  • on_state_change::Function: Callback for when the state changes. Must update a state ref or similar.
  • on_change::Function: Optional callback for when parsing succeeds. Passes the parsed value in specified type.
  • on_focus::Function: Optional callback for when the component gains focus.
  • on_blur::Function: Optional callback for when the component loses focus.
source
Fugl.PaddingFunction

Padding component: adds padding around its child, but does not render any graphics.

source
Fugl.PolarLineMethod

Create a line plot element using polar coordinates.

In polar plots: xdata represents angle (θ), ydata represents radius (r)

Arguments

  • r_data: Radius values (will be stored in y_data)
  • theta_data: Angle values in radians (will be stored in x_data)
  • color: Line color (default: cyan-blue)
  • width: Line width in pixels (default: 2.0)
  • line_style: Line pattern (SOLID, DASH, DOT, etc.)
  • label: Label for legend (default: "")

Example

theta = range(0, 2π, length=100)
r = 1.0f0 .+ 0.5f0 .* cos.(5.0f0 .* theta)

polar_line = PolarLine(r, theta, 
    color=Vec4{Float32}(1.0, 0.0, 0.0, 1.0),
    width=2.5f0,
    label="Rose Curve"
)
source
Fugl.PolarPlotFunction

Create a polar plot component.

Arguments

  • elements: Vector of polar plot elements (lines, scatter, etc.)
  • style: PolarStyle for appearance customization
  • state: PolarState for coordinate system configuration
  • on_state_change: Callback function when state changes

Example

theta = range(0, 2π, length=100)
r = 1 .+ 0.5 .* cos.(5 .* theta)

polar_plot = PolarPlot(
    [PolarLine(r, theta, color=Vec4f(0.0, 0.5, 1.0, 1.0))],
    PolarStyle(),
    PolarState(theta_start=Float32(π/2))  # 0° points up
)
source
Fugl.PolarScatterMethod

Create a scatter plot element using polar coordinates.

In polar plots: xdata represents angle (θ), ydata represents radius (r)

Arguments

  • r_data: Radius values (will be stored in y_data)
  • theta_data: Angle values in radians (will be stored in x_data)
  • fill_color: Marker fill color (default: cyan-blue)
  • border_color: Marker border color (default: black)
  • marker_size: Marker size in pixels (default: 8.0)
  • border_width: Border width in pixels (default: 1.0)
  • marker_type: Marker shape (CIRCLE, SQUARE, TRIANGLE, etc.)
  • label: Label for legend (default: "")

Example

theta = range(0, 2π, length=16)
r = 0.6f0 .+ 0.3f0 .* rand(Float32, 16)

scatter = PolarScatter(r, theta,
    fill_color=Vec4{Float32}(1.0, 0.0, 0.0, 1.0),
    marker_size=10.0f0,
    label="Data Points"
)
source
Fugl.PolarStemMethod

Create a stem plot element using polar coordinates.

In polar plots: xdata represents angle (θ), ydata represents radius (r) Stems extend from baseline (radial value) to each data point.

Arguments

  • r_data: Radius values (will be stored in y_data)
  • theta_data: Angle values in radians (will be stored in x_data)
  • line_color: Stem line color (default: cyan-blue)
  • fill_color: Marker fill color (default: cyan-blue)
  • border_color: Marker border color (default: black)
  • line_width: Stem line width in pixels (default: 1.5)
  • marker_size: Marker size in pixels (default: 8.0)
  • border_width: Marker border width in pixels (default: 1.0)
  • marker_type: Marker shape (CIRCLE, SQUARE, TRIANGLE, etc.)
  • baseline: Radial baseline where stems originate (default: 0.0 = center)
  • label: Label for legend (default: "")

Example

theta = range(0, 2π, length=12)
r = 0.5f0 .+ 0.3f0 .* sin.(3.0f0 .* theta)

stem = PolarStem(r, theta,
    line_color=Vec4{Float32}(0.0, 1.0, 0.0, 1.0),
    fill_color=Vec4{Float32}(0.0, 1.0, 0.0, 1.0),
    baseline=0.2f0,  # Stems start at r=0.2
    label="Stem Data"
)
source
Fugl.RotateMethod
Rotate(child::AbstractView; rotation_degrees::Float32=0.0f0)

Create a rotated wrapper around any child component. Positive angles rotate counter-clockwise.

Uses a framebuffer approach: renders child to texture, then rotates the texture with a custom shader.

Arguments

  • child: The child component to rotate
  • rotation_degrees: Rotation angle in degrees (default: 0.0)
source
Fugl.SpinnerFunction

Create a Spinner component

Arguments

  • symbols::Vector{Char}: Array of Unicode characters to cycle through
  • interval_seconds::Float64: Time between symbol changes (default: 0.1)
  • text_style::TextStyle: Text styling for the spinner symbol
  • state::SpinnerState: Current spinner state
  • is_spinning::Bool: Whether the spinner should animate
  • on_state_change::Function: Callback when spinner state changes
source
Fugl.TableMethod
Table(headers, data; kwargs...)

Create a table component with column headers and row data.

Arguments

  • headers::Vector{String}: Column header names
  • data::Vector{Vector{String}}: Table data as rows of strings
  • style::TableStyle=TableStyle(): Table styling options
  • state::TableState=TableState(): Table state for column widths and sizing
  • on_cell_click::Function=(row, col) -> nothing: Callback for cell clicks
  • on_state_change::Function=(new_state) -> nothing: Callback for state changes

Example

headers = ["Name", "Age", "City"]
data = [
    ["Alice", "25", "New York"],
    ["Bob", "30", "London"],
    ["Carol", "28", "Tokyo"]
]
table = Table(headers, data)
source
Fugl.TextMethod
Text(text::String; style=TextStyle(), horizontal_align=:center, vertical_align=:middle, wrap_text=true)

Create a Text component with the specified properties.

source
Fugl.TextFieldFunction
TextField(
    state::EditorState=EditorState();
    max_length::Union{Int, Nothing}=nothing,
    style::TextEditorStyle=TextBoxStyle(border_width=1.0f0),
    on_state_change::Function=(new_state::EditorState) -> nothing,
    on_change::Function=(new_text) -> nothing,
    on_focus::Function=() -> nothing,
    on_blur::Function=() -> nothing
)

Single-line form field for entering text. Supports optional length limiting.

Arguments

  • state::EditorState: Initial state of the text box.
  • max_length::Union{Int, Nothing}: Maximum number of characters allowed (default is nothing for unlimited).
  • style::TextEditorStyle: Style for the text field.
  • on_state_change::Function: Callback for when the state changes. Must update a state ref or similar.
  • on_change::Function: Optional callback for when the text changes. Passes the new text string.
  • on_focus::Function: Optional callback for when the component gains focus.
  • on_blur::Function: Optional callback for when the component loses focus.
source
Fugl.VerticalScrollAreaMethod

Create a VerticalScrollArea component

Arguments

  • content::AbstractView: The content to be scrolled
  • scroll_state::VerticalScrollState: Current scroll state
  • style::ScrollAreaStyle: Styling for the scroll area
  • show_scrollbar::Bool: Show visual scrollbar
  • on_scroll_change::Function: Callback when scroll state changes
  • on_click::Function: Callback for click events
source
Fugl.VerticalSplitContainerMethod
VerticalSplitContainer(top, bottom; kwargs...)

Create a vertical split container with top and bottom child components.

Arguments

  • top::AbstractView: Top child component
  • bottom::AbstractView: Bottom child component
  • style::SplitContainerStyle=SplitContainerStyle(): Style configuration
  • state::SplitContainerState=SplitContainerState(): State including split position and interactions
  • on_state_change::Function=() -> nothing: Callback for state changes (including split position)
source
Fugl.add_overlay_functionMethod
add_overlay_function(func::Function)

Add a function to be rendered as an overlay after all main content is rendered. The function should take no arguments and handle its own rendering.

source
Fugl.adjust_manual_scaling!Method
adjust_manual_scaling!(dpi_scaling_ref::Ref{DPIScaling}, delta::Float32)

Adjust the manual scaling by a delta amount. Positive values increase scale, negative decrease. Clamped to reasonable bounds (0.25x to 4x with fractional values supported).

source
Fugl.apply_layoutMethod
apply_layout(component::AbstractView)

Apply layout to a GUI component and its children. This function calculates and applies the layout to components. The interpret_view function then uses the positions and sizes calculated by this function.

source
Fugl.apply_move_cursorMethod

Apply cursor movement action. Returns a new EditorState with the cursor moved and selection updated if needed.

source
Fugl.apply_step_snappingMethod

Apply discrete step snapping to a value. Returns the value snapped to the nearest step if steps are defined. For discrete steps (Int), automatically rounds to the appropriate output type.

source
Fugl.blurMethod
blur(::AbstractView)

Blurs (de-focuses) the component.

source
Fugl.calculate_and_update_column_widths!Method
calculate_and_update_column_widths!(view::TableView, available_width::Float32)

Calculate new column widths and update the table state via callback. This function can be called by the user when they want to recalculate column sizing.

source
Fugl.calculate_column_widthsMethod
calculate_column_widths(view::TableView, available_width::Float32)::Vector{Float32}

Calculate optimal column widths based on content and available space. Uses a simple algorithm that:

  1. Calculates minimum width needed for each column based on content
  2. If total minimum width < available width, distributes extra space proportionally
  3. If total minimum width > available width, scales all columns down proportionally
source
Fugl.calculate_visible_textMethod

Calculate which portion of a text line is visible given horizontal scroll and viewport width. Returns (visibletext, startx_offset) where:

  • visible_text is the substring that should be drawn
  • startxoffset is how much to shift the drawing position
source
Fugl.cartesian_to_polarFunction

Convert Cartesian coordinates (x, y) to polar coordinates (r, θ).

Returns angle normalized to [0, 2π) range.

Arguments

  • x::Float32: X coordinate
  • y::Float32: Y coordinate
  • theta_start::Float32: Angle offset where θ=0 points
  • theta_direction::Symbol: :counterclockwise or :clockwise rotation direction
  • center_x::Float32: Center X coordinate
  • center_y::Float32: Center Y coordinate

Returns

  • Tuple{Float32,Float32}: Polar coordinates (r, θ) where θ is in [0, 2π)
source
Fugl.char_callbackMethod

New character callback for proper text input This function handles character input from the keyboard, converting Unicode codepoints to characters.

source
Fugl.clear_overlaysMethod
clear_overlays()

Clear all pending overlay functions without rendering them. Useful for cleanup or when aborting rendering.

source
Fugl.clear_render_caches!Method

Clear all render caches and free associated OpenGL resources. Call this when the OpenGL context is being destroyed or recreated.

source
Fugl.clip_text_with_ellipsisMethod
clip_text_with_ellipsis(text, font, size_points, available_width)

Clip text at character level to fit within available width, adding "..." if clipped.

source
Fugl.create_dpi_scaling_refMethod
create_dpi_scaling_ref()::Ref{DPIScaling}

Create a new DPI scaling reference with default 1x scaling. This must be passed to Fugl.run() for proper scaling support.

Example

dpi_ref = create_dpi_scaling_ref()
Fugl.run(MyApp, dpi_scaling=dpi_ref)
source
Fugl.create_glyph_atlasFunction
create_glyph_atlas(width=4096, height=4096) -> GlyphAtlas

Create a new glyph atlas texture with larger size for better performance. Inspired by Makie.jl's approach with larger atlases to reduce cache misses.

source
Fugl.cull_line_dataMethod

Cull line data and clip line segments to viewport bounds using proper interpolation. This function clips line segments at the exact viewport boundaries to prevent lines from extending outside the visible area. Returns culled x and y data arrays with clipped segments.

source
Fugl.cull_point_dataMethod

Cull point data to only include points within the specified bounds. Returns culled x and y data arrays.

source
Fugl.detect_clickMethod

Detect click events and handle focus, cursor positioning, drag selection, and double-clicks.

source
Fugl.detect_clickMethod

Detect clicks on the Column and its children. The method returns the click result with the highest z-height.

source
Fugl.detect_clickMethod

Detect clicks on the IntrinsicColumn and its children. The method returns the click result with the highest z-height.

source
Fugl.detect_clickMethod

Detect clicks on the IntrinsicRow and its children. The method returns the click result with the highest z-height.

source
Fugl.detect_clickMethod

Detect clicks on the Row and its children. The method returns the click result with the highest z-height.

source
Fugl.detect_clickMethod

Detect click events and handle focus, cursor positioning, drag selection, and double-clicks for TextBox.

source
Fugl.draw_axes_with_labelsMethod

Draw axes with labels and tick marks using both lines and Text components Axis lines, tick marks, and labels are positioned at plot edges (left/bottom), not at zero lines

source
Fugl.draw_closed_linesMethod
draw_closed_lines(vertices::Vector{Point2f}, color_rgba::Vec4{<:Float32})

Draw closed lines using the provided vertices and color.

source
Fugl.draw_configurable_rectangleMethod
draw_configurable_rectangle(
    vertices, width, height, fill_color, border_color, border_width,
    corner_radii, projection_matrix, anti_aliasing_width
)

Draw a rectangle with configurable per-corner radii.

Arguments

  • vertices: Vector of corner positions
  • width, height: Rectangle dimensions
  • fill_color: Fill color as Vec4
  • border_color: Border color as Vec4
  • border_width: Border thickness in pixels
  • corner_radii: Vec4 of corner radii (top-left, top-right, bottom-right, bottom-left)
  • projection_matrix: Projection matrix
  • anti_aliasing_width: Anti-aliasing width in pixels
source
Fugl.draw_glyph_atlas_debugMethod
draw_glyph_atlas_debug(atlas, x, y, scale, projection_matrix)

Draw the entire glyph atlas texture to the screen for debugging purposes. This helps visualize what glyphs are actually stored in the atlas.

source
Fugl.draw_glyph_from_atlasMethod
draw_glyph_from_atlas(texture, x, y, width, height, u_min, v_min, u_max, v_max, projection_matrix, color)

Draw a single glyph from the atlas texture with specified UV coordinates.

source
Fugl.draw_lineMethod
draw_line(points::Vector{Point2f}, color::Vec4{Float32}, width::Float32, line_style::LinePattern, projection_matrix::Mat4{Float32}; anti_aliasing_width::Float32=1.5f0)

Draw a single line with the specified properties.

source
Fugl.draw_linesMethod
draw_lines(lines::Vector{SimpleLine}, projection_matrix::Mat4{Float32}; anti_aliasing_width::Float32=1.5f0)

Draw multiple lines efficiently in a single batch.

source
Fugl.draw_matrix_with_colormapMethod

Generalized texture-based rendering function for colormapped data. Can be used by heatmaps, colorbars, and other texture-based visualizations.

source
Fugl.draw_multiline_text_batchedFunction

Multi-line batched text rendering that collects all lines into a single batch. This provides maximum performance for rendering multiple lines of text.

source
Fugl.draw_rectangleMethod
draw_rectangle(vertices::Vector{Point2f}, color_rgba::Vec4{<:Float32}, projection_matrix::Mat4{Float32})

Draw a rectangle using the provided vertices and color.

source
Fugl.draw_rounded_rectangleMethod
draw_rounded_rectangle(
    vertices::Vector{Point2f},
    width::Float32, height::Float32,
    fill_color_rgba::Vec4{<:Float32}, border_color_rgba::Vec4{<:Float32},
    border_width::Float32, radius::Float32,
    projection_matrix::Mat4{Float32},
    anti_aliasing_width::Float32
)

Draw a rounded rectangle with border using the custom shader.

source
Fugl.draw_simple_lineMethod
draw_simple_line(start_point::Point2f, end_point::Point2f, color::Vec4{Float32}, width::Float32, projection_matrix::Mat4{Float32}; line_style::LinePattern=SOLID, anti_aliasing_width::Float32=1.5f0)

Convenience function to draw a simple line between two points.

source
Fugl.draw_text_batchedFunction

Optimized batched text rendering function that collects all glyphs first, then renders them in a single draw call. Much faster for large amounts of text.

source
Fugl.ensure_cursor_visibleMethod

Ensure the cursor is visible by adjusting scroll offsets if needed.

Arguments:

  • state: Current editor state
  • font: Font used for rendering text
  • size_points: Font size in pixels
  • visible_width: Width of the visible area in pixels (excluding padding)
  • visible_height: Height of the visible area in pixels (excluding padding)
  • padding: Padding around the text

Returns a new EditorState with adjusted scroll offsets if the cursor was out of view.

source
Fugl.enum_display_namesMethod

Generic function to get display names for enum values. Uses a display name mapping if provided, otherwise converts enum names to strings.

source
Fugl.fugl_to_pixelsMethod
fugl_to_pixels(dpi_scaling_ref::Ref{DPIScaling}, fugl_coord::Float32)::Float32

Convert a Fugl logical coordinate to screen pixels using manual scaling. 1 point = manual_scale pixels.

source
Fugl.fugl_to_pixels_yMethod
fugl_to_pixels_y(dpi_scaling_ref::Ref{DPIScaling}, fugl_y::Float32)::Float32

Convert a Fugl logical Y coordinate to screen pixels using manual scaling.

source
Fugl.generate_line_geometryMethod
generate_line_geometry(points::Vector{Point2f}, color::Vec4{Float32}, width::Float32, line_style::LinePattern)

Generate geometry for a single line using triangles. Returns arrays for positions, directions, widths, colors, vertextypes, linestyles, and line_progresses.

source
Fugl.generate_rectangle_verticesMethod
generate_rectangle_vertices(x, y, width, height)

Function to generate a rectangle with specified position and size in pixel coordinates.

This function creates a rectangle defined by its top-left corner (x, y), width, and height.

source
Fugl.get_current_dpi_scalingMethod
get_current_dpi_scaling()::Ref{DPIScaling}

Get the current DPI scaling ref for this rendering context. Throws an error if no DPI scaling is set (which shouldn't happen during normal rendering).

source
Fugl.get_default_fontMethod
get_default_font()::FreeTypeAbstraction.FTFont

Get the default font from cache. If not already loaded, calls load_default_font!() automatically.

source
Fugl.get_dpi_scaleMethod
get_dpi_scale(dpi_scaling_ref::Ref{DPIScaling})::Tuple{Float32, Float32}

Get the current manual scaling factor as both X and Y scaling (they're the same).

source
Fugl.get_dpi_scaleMethod
get_dpi_scale()::Tuple{Float32, Float32}

Get the current DPI scaling factors using the current DPI scaling context.

source
Fugl.get_effective_boundsMethod

Get effective bounds for plotting (considering zoom state) Priority: currentbounds -> initialbounds (with partial bounds support) -> auto-calculated from elements

source
Fugl.get_effective_column_widthsMethod
get_effective_column_widths(view::TableView, available_width::Float32)::Vector{Float32}

Get effective column widths for rendering. Priority: state.column_widths -> auto-calculated widths

source
Fugl.get_effective_scaleMethod
get_effective_scale(dpi_scaling_ref::Ref{DPIScaling})::Float32

Get the effective scaling factor being applied to the UI. This is just the manual scaling factor (1.0 = 1 point = 1 pixel).

source
Fugl.get_fontMethod
get_font(cache_key::Symbol)::FreeTypeAbstraction.FTFont

Retrieve a font from the cache by its cache key. Automatically loads the default font if the cache key matches DEFAULTFONTCACHE_KEY. Throws an error if the font is not found in the cache.

source
Fugl.get_fontMethod
get_font(style::TextStyle)::FreeTypeAbstraction.FTFont

Retrieve the font associated with a TextStyle from the font cache.

source
Fugl.get_font_by_nameMethod
get_font_by_name(cache_key::Symbol, font_name::String)::FreeTypeAbstraction.FTFont

Find and load a system font by name, caching it with the specified key. If already cached with this key, returns the cached font.

Example

# Load a system font
get_font_by_name(:my_system_font, "Arial")
style = TextStyle(font_cache_key=:my_system_font, size_points=16)
source
Fugl.get_font_by_pathMethod
get_font_by_path(cache_key::Symbol, font_path::String)::FreeTypeAbstraction.FTFont

Load a font from a file path and cache it with the specified key. If already cached with this key, returns the cached font.

Example

# Load a custom font with an explicit cache key
get_font_by_path(:my_title_font, "/path/to/font.ttf")
style = TextStyle(font_cache_key=:my_title_font, size_points=32)
source
Fugl.get_font_hashMethod
get_font_hash(font::FreeTypeAbstraction.FTFont) -> UInt64

Get a unique hash for a font face.

source
Fugl.get_line_lengthMethod

Get the character length of a specific line (1-indexed). Returns 0 if the line number is out of bounds.

source
Fugl.get_linesMethod

Split text into lines for easier manipulation. Returns a vector of strings, where each string is a line of text.

source
Fugl.get_linesMethod

Split text into lines for easier manipulation. Returns a vector of strings, where each string is a line of text.

source
Fugl.get_logical_sizeMethod
get_logical_size(dpi_scaling_ref::Ref{DPIScaling})::Tuple{Float32, Float32}

Get the current window size in logical coordinates (width, height). This is what components should use for layout calculations.

source
Fugl.get_manual_scalingMethod
get_manual_scaling(dpi_scaling_ref::Ref{DPIScaling})::Float32

Get the current manual scaling factor (1.0 = normal, 2.0 = twice as large, etc.)

source
Fugl.get_manual_scalingMethod
get_manual_scaling()::Float32

Get the current manual scaling factor using the current DPI scaling context.

source
Fugl.get_or_insert_glyph!Method
get_or_insert_glyph!(atlas::GlyphAtlas, font, char, pixelsize) -> GlyphUV

Get glyph UV coordinates from atlas, inserting the glyph if not present.

source
Fugl.get_orthographic_matrixMethod
get_orthographic_matrix(left::T, right::T, bottom::T, top::T, near::T, far::T)::Matrix{T} where {T<:Real}

Create an orthographic projection matrix.

source
Fugl.get_pixel_perfect_scaleMethod
get_pixel_perfect_scale(dpi_scaling_ref::Ref{DPIScaling})::Float32

Get the scaling factor that achieves 1 point = 1 actual pixel when manual_scale=1. This compensates for the system DPI ratio.

source
Fugl.get_pixel_sizeMethod
get_pixel_size(dpi_scaling_ref::Ref{DPIScaling})::Tuple{Float32, Float32}

Get the current framebuffer size in actual pixels (width, height). This is used internally for OpenGL rendering.

source
Fugl.get_selection_rangeMethod

Get the selection range in a normalized form (start <= end). Returns (startpos, endpos) or (nothing, nothing) if no selection.

source
Fugl.get_system_dpi_ratioMethod
get_system_dpi_ratio(dpi_scaling_ref::Ref{DPIScaling})::Float32

Get the system's DPI ratio (pixels per point). On Retina displays this is typically 2.0.

source
Fugl.hash_text_contentMethod

Generate a content hash for text components (TextBox/CodeEditor) that captures all rendering-relevant state

source
Fugl.interpret_viewMethod
interpret_view(component::AbstractView, x::Float32, y::Float32, width::Float32, height::Float32, projection_matrix::Mat4{Float32}, mouse_x::Float32, mouse_y::Float32)

Interpret the view of a GUI component. This function is responsible for interpreting the view of a GUI component based on its layout and properties.

source
Fugl.key_callbackMethod

Alternative signature in case GLFW passes Char directly This function adds a character directly to the key buffer.

source
Fugl.load_default_font!Method
load_default_font!()

Load the font at DEFAULT_FONT_PATH into the font cache as the default font. This should be called before creating any text components. Users can override DEFAULT_FONT_PATH before calling this function to use a custom default font.

Example

# Use default font
Fugl.load_default_font!()

# Or use custom font
Fugl.DEFAULT_FONT_PATH[] = "/path/to/my/font.ttf"
Fugl.load_default_font!()
source
Fugl.measureMethod

Measure the horizontal scroll area - measures content width, takes all available space in height

source
Fugl.measureMethod
measure(view::TextView)::Tuple{Float32,Float32}

Assumes text is rendered in a single line.

source
Fugl.measureMethod

Measure function - tooltip takes the size of the wrapped component.

source
Fugl.measureMethod

Measure the vertical scroll area - takes all available space in width, measures content height

source
Fugl.measure_word_widthMethod
measure_word_width(font::FreeTypeAbstraction.FTFont, word::AbstractString, size_points::Int)::Float32

Measure the width of a word using FreeType for accurate rendering metrics. This is more accurate but slower than estimatewordwidth.

source
Fugl.measure_word_widthMethod
measure_word_width(style::TextStyle, word::AbstractString)::Float32

Measure the width of a word using a TextStyle. Convenience function that extracts the font and size from the style.

source
Fugl.measure_word_width_cachedMethod
measure_word_width_cached(font::FreeTypeAbstraction.FTFont, word::AbstractString, size_points::Int)::Float32

Measure the width of a word using cached glyph advance widths from the glyph atlas. This is faster than measurewordwidth since it avoids re-rendering glyphs that are already cached.

source
Fugl.measure_word_width_cachedMethod
measure_word_width_cached(style::TextStyle, word::AbstractString)::Float32

Measure the width of a word using a TextStyle. Convenience function that extracts the font and size from the style.

source
Fugl.mouse_to_cursor_positionMethod

Convert mouse coordinates to cursor position within a text editor component. This is a generic function that works for both CodeEditor and TextBox.

source
Fugl.pixels_to_fuglMethod
pixels_to_fugl(dpi_scaling_ref::Ref{DPIScaling}, pixel_coord::Float32)::Float32

Convert screen pixels to Fugl logical coordinates using manual scaling.

source
Fugl.pixels_to_fugl_xMethod
pixels_to_fugl_x(dpi_scaling_ref::Ref{DPIScaling}, pixel_x::Float32)::Float32

Convert screen pixels to Fugl logical X coordinate using manual scaling.

source
Fugl.pixels_to_fugl_yMethod
pixels_to_fugl_y(dpi_scaling_ref::Ref{DPIScaling}, pixel_y::Float32)::Float32

Convert screen pixels to Fugl logical Y coordinate using manual scaling.

source
Fugl.polar_to_cartesianFunction

Convert polar coordinates (r, θ) to Cartesian coordinates (x, y).

Automatically handles negative angles - no conversion needed! Just pass your angles as-is (e.g., -π to π works directly).

Arguments

  • r::Float32: Radius
  • theta::Float32: Angle in radians (can be negative, e.g., -π to π)
  • theta_start::Float32: Angle offset where θ=0 points (0 = right/east, π/2 = up/north, π = left/west, 3π/2 = down/south)
  • theta_direction::Symbol: :counterclockwise or :clockwise rotation direction
  • center_x::Float32: Center X coordinate in Cartesian space
  • center_y::Float32: Center Y coordinate in Cartesian space

Returns

  • Tuple{Float32,Float32}: Cartesian coordinates (x, y)
source
Fugl.register_shader_initializer!Method
register_shader_initializer!(init_function::Function)

Register an external shader initialization function to be called during Fugl's shader initialization. This allows external packages (like FuglDrawing.jl) to register their shaders.

Arguments

  • init_function::Function: A function that will be called during shader initialization

Example

# In FuglDrawing.jl
function initialize_drawing_shaders()
    # Initialize drawing-specific shaders
    drawing_prog[] = Program(drawing_vertex_shader, drawing_fragment_shader)
end

# Register with Fugl
Fugl.register_shader_initializer!(initialize_drawing_shaders)
source
Fugl.render_fps_overlayMethod
render_fps_overlay(frame_count, fps, screen_width, screen_height, projection_matrix)

Render debug overlay showing frame count and FPS in the upper right corner.

source
Fugl.render_glyph_batch!Method

Render all glyphs in the batch with a single draw call. This is dramatically faster than individual glyph rendering.

source
Fugl.render_no_overlayMethod
render_no_overlay(frame_count, fps, screen_width, screen_height, projection_matrix)

No-op function for when FPS overlay is disabled. This gets optimized away by the compiler.

source
Fugl.render_overlaysMethod
render_overlays()

Render all overlay functions and clear the overlay list. This should be called after all main content is rendered.

source
Fugl.reset_plot_view_boundsMethod
reset_plot_view_bounds(state::PlotState)

Returns a copy of the PlotState with currentbounds reset to nothing, falling back to initialbounds.

source
Fugl.runMethod
run(ui_function::Function; title::String="Fugl", window_width_points::Integer=1920, window_height_points::Integer=1080, fps_overlay::Bool=false, periodic_callbacks::Vector{PeriodicCallback}=PeriodicCallback[])

Run the main loop for the GUI application. This function handles the rendering and event processing for the GUI.

Arguments

  • ui_function::Function: Function that returns an AbstractView for the UI
  • title::String="Fugl": Window title
  • window_width_points::Integer=1920: Initial window width in logical points
  • window_height_points::Integer=1080: Initial window height in logical points
  • fps_overlay::Bool=false: Show frame count and FPS in upper right corner
  • periodic_callbacks::Vector{PeriodicCallback}=PeriodicCallback[]: [Experimental] Periodic callbacks to execute at specified frame intervals

Examples

# Create a callback that runs every 60 frames (approximately once per second at 60fps)
file_check_callback = PeriodicCallback(() -> check_files(), 60)

# Create a callback that runs every 300 frames (every 5 seconds at 60fps)
data_update_callback = PeriodicCallback(() -> update_data(), 300)

run(MyApp, periodic_callbacks=[file_check_callback, data_update_callback])
source
Fugl.safe_substringMethod

Safely get a substring using character-based indexing instead of byte indexing. This handles Unicode characters correctly.

source
Fugl.set_current_dpi_scaling!Method
set_current_dpi_scaling!(dpi_scaling_ref::Ref{DPIScaling})

Set the current DPI scaling ref for this rendering context. This is used internally by the rendering system.

source
Fugl.set_manual_scaling!Method
set_manual_scaling!(scale_factor::Float32)

Set the UI scaling factor (1x = 1 point = 1 pixel, 2x = 1 point = 2 pixels). System DPI scaling is ignored for consistent 1:1 pixel mapping. Supports fractional values for smooth scaling.

Arguments

  • scale_factor: UI scale multiplier (0.25 = quarter size, 0.5 = half size, 1.0 = normal size, 2.0 = twice as large, etc.)

Example

# Half size: 1 point = 0.5 pixels
Fugl.set_manual_scaling!(0.5f0)

# Normal size: 1 point = 1 pixel
Fugl.set_manual_scaling!(1.0f0)

# Large UI: 1 point = 2 pixels  
Fugl.set_manual_scaling!(2.0f0)
source
Fugl.should_invalidate_cacheMethod

Check if a cache needs to be invalidated based on content hash and bounds. Each component should provide its own contenthashfunc that captures all the state that affects rendering.

source
Fugl.split_line_at_nanMethod

Split line data at NaN values into separate continuous segments. Returns a vector of (xsegment, ysegment) tuples.

source
Fugl.tokenize_julia_lineMethod

Tokenize a Julia line and return tokens with color data. Returns (tokens, tokendata) where tokendata is [(position, text, color), ...]

source
Fugl.tokenize_line_with_colorsMethod

Tokenize a line of code and return tokens with color data. Returns (tokens, tokendata) where tokendata is [(position, text, color), ...]

source
Fugl.update_dpi_scaling!Method
update_dpi_scaling!(dpi_scaling_ref::Ref{DPIScaling}, window_width::Integer, window_height::Integer, fb_width::Integer, fb_height::Integer)

Update the DPI scaling with current window and framebuffer sizes. No automatic DPI detection - only tracks window dimensions.

source
Fugl.update_fps_stats!Method
update_fps_stats!(debug_frame_count, debug_last_time, frame_start_time, debug_fps_update_interval, current_fps)

Update FPS statistics when overlay is enabled. Returns current FPS value.

source
Fugl.update_no_fps_statsMethod
update_no_fps_stats(debug_frame_count, debug_last_time, frame_start_time, debug_fps_update_interval, current_fps)

No-op function for when FPS overlay is disabled. Returns unchanged debug_fps value.

source
Fugl.wrap_cell_textMethod
wrap_cell_text(text, font, size_points, available_width, max_rows)

Wrap text for a table cell, respecting maxrows limit and clipping if necessary. Returns a vector of strings representing the lines to display. maxrows = 0 means no wrapping (single line with character-level clipping and ellipsis).

source