Expand description
Cursors over the viewport: what the active tool shows under the pointer, resolved each time the situation changes (the tool, the keys held, a drag, a handle under the pointer) and drawn crisp at the window’s scale.
A Cursor is one of:
- a system cursor ([
egui::CursorIcon]); - one of egui-pop’s tool cursors (
ToolCursor: a crosshair, an eyedropper, a hand, zoom in and out…), drawn as a bitmap at the cursor size and the window’s scale, in the theme’s colours, and handed to the system as a real cursor; - a bitmap the application registered by name (
register_image), at several sizes, with a dark variant and frames if it wants; - a brush outline (
BrushOutline) painted over the image, sized in image pixels so it follows the zoom, the system cursor hidden.
The viewport asks default_cursor for a CursorQuery (Alt turns
zoom in into zoom out, a hand closes while dragging), then its
on_cursor hook, which may give
another cursor (egui-pop-imaging runs it as the cursor.resolve
step). shown then decides what reaches the
screen, under the CursorSettings: painted cursors may be turned
off (system cursors only), and the cursor size follows the system’s.
Bitmap cursors go through egui::Context::set_cursor_image, which
eframe’s native integration hands to winit as a custom cursor; where
it cannot (the web, immediate viewports), the system cursor given as
the fallback shows instead.
Structs§
- Bitmap
- A bitmap of a cursor: straight (not premultiplied) RGBA.
- Brush
- A brush tool’s size and hardness.
- Brush
Outline - A brush outline: a ring of the brush’s radius, in image pixels, so it follows the zoom, and an inner ring where its hardness ends (the feather between them).
- Cursor
Image - A cursor of the application’s: bitmaps at several sizes (give one per scale used: 1x, 1.5x, 2x…), a dark theme’s variant, more frames for an animation, and the system cursor shown where bitmaps cannot be.
- Cursor
Query - What a viewport knows when it asks which cursor to show. It asks again only when this changes.
- Cursor
Settings - How cursors are shown in a context (
set_settings).
Enums§
- Brush
Mark - What a brush outline carries beside the pointer.
- Cursor
- A cursor.
- Shown
- What reaches the screen for a cursor.
- Tool
- The tool active over a viewport, which decides its cursor.
- Tool
Cursor - egui-pop’s tool cursors, drawn in the icon set’s line style.
Constants§
- DEFAULT_
SIZE - The cursor size when the system says nothing, in points.
- MIN_
OUTLINE_ RADIUS - Below this radius on screen (points), a brush outline gives way to a crosshair: too small to read, it would hide the point painted.
Functions§
- apply
- Shows a cursor for this frame at
pos: sets the system cursor, hands a bitmap to the integration, or paints an outline withpainter. Returns whether a bitmap was set: the caller clears it (clear_image) once the pointer leaves, as egui keeps it from frame to frame. - clear_
image - Clears a bitmap cursor set by
apply. - default_
cursor - The cursor egui-pop shows for a query, before the application’s hook:
- image
- The cursor image registered under a name.
- paint_
outline - Paints a brush outline: a ring of
radiuspoints, a lighter one atinner(none at 0), a point at the centre and the mark beside it, each a line over a wider one in the outline colour so it reads on any image. - paint_
sample - Paints a tool cursor with
painterin a square (the gallery’s samples, a legend): the bitmap the system would show, as a texture. - parse_
size - A cursor size from the text of
XCURSOR_SIZE: 8 to 256, else the default. - rasterize
- Draws a tool cursor at
sidephysical pixels: its strokes infill, ringed byoutline(about a pixel at 24, more when larger), with anti-aliased edges. Straight RGBA, row by row. - register_
image - Registers a cursor image under a name, for
Cursor::Image. - set_
settings - Sets the cursor settings of a context (an application maps its own settings here).
- settings
- The cursor settings of a context.
- shown
- What a cursor shows in a context at a zoom (physical pixels per image
pixel) and scale: with painted cursors off, the system cursor
standing for it; a brush outline under
MIN_OUTLINE_RADIUS, a crosshair; an image nobody registered, its name’s system arrow. - size
- The cursor size in use in a context, in points.
- system_
size - The system’s cursor size, in points:
XCURSOR_SIZEwhere it is set (X11 and Wayland desktops), elseDEFAULT_SIZE. - tool_
image - A tool cursor’s bitmap at the context’s cursor size and scale, in the theme’s colours; drawn once, then kept.