Skip to main content

ThemeStyled

Trait ThemeStyled 

Source
pub trait ThemeStyled: Styled + Sized {
    // Required methods
    fn focus_ring_style(self, window: &Window, cx: &App) -> Self
       where Self: ParentElement;
    fn popover_style(self, cx: &App) -> Self;

    // Provided method
    fn rounded_full_style(self, cx: &App) -> Self { ... }
}
Expand description

Finished styles that read the theme.

Separate from StyledExt, which holds neutral helpers that make no visual decisions. Everything here does: it reaches into the theme and produces a specific look, which is why it belongs above the base layer.

Required Methods§

Source

fn focus_ring_style(self, window: &Window, cx: &App) -> Self
where Self: ParentElement,

Give this element the focus appearance the framework’s own controls use: its border tinted with the focus colour, and the ring outside it.

The ring is dropped when crate::Theme::focus_ring is off, leaving the tinted border — an application whose layout clips its containers can turn it off rather than finding room for the ring in each of them.

Calling this turns the ring on; gate it with when for the conditions that decide whether the control shows one at all — its focus state, FocusableExt::focus_ring, appearance, and so on.

The ring sits outside the element’s border, so an ancestor that clips its content will cut it off — leave it a few pixels of room, or don’t clip.

Source

fn popover_style(self, cx: &App) -> Self

Give this element the surface, edge, shadow and radius of a popover.

This is the one surface every popup shares — Popover, PopupMenu, Select, Combobox, DatePicker and the editor’s hover popovers — so they cannot drift apart. See [popover_shadow] for what the shadow is modelled on.

Provided Methods§

Source

fn rounded_full_style(self, cx: &App) -> Self

Round this element as far as its size allows — a circle if it is square, a pill if it is not — unless the theme squares its corners.

Use this instead of gpui::Styled::rounded_full on anything the theme owns. A hardcoded rounded_full survives crate::Theme::radius being set to zero, which leaves avatars, badge dots and slider thumbs round in a UI that is square everywhere else. See crate::Theme::radius_full.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§