Skip to main content

set_icon_resolver

Function set_icon_resolver 

Source
pub fn set_icon_resolver(
    cx: &mut App,
    resolver: impl Fn(&str, &App) -> Option<SharedString> + 'static,
)
Expand description

Set the hook every Icon drawn from an asset path asks for the path to draw, including the icons components draw inside their own controls.

The resolver receives the icon’s path (for example icons/check.svg) and returns the path to draw in its place, or None to keep it. GPUI caches a rendered SVG by its path, so returning a new path is how an application switches icon styles at runtime; the application’s gpui::AssetSource must load the returned path. Icons created with Icon::data are not resolved.

The resolver runs every time an icon is drawn and should be cheap. Call App::refresh_windows after changing what it returns.