Skip to main content

Crate gpui_types

Crate gpui_types 

Source
Expand description

Core API primitive types shared between GPUI and its platform backends.

This crate sits at the bottom of GPUI’s dependency graph. It holds the pure value types — geometry (Pixels, Point, Size, Bounds, …) and colors (Rgba, Hsla, Background, …) — that both the gpui crate and the platform implementations depend on.

Keeping these types here means a platform backend can depend on the API primitives without depending on all of gpui. The gpui crate re-exports everything in this crate, so gpui::Pixels and gpui_types::Pixels name the same type and consumers do not need to know this crate exists.

Structs§

Background
A background color, which can be either a solid color or a linear gradient.
Bounds
Represents a rectangular area in a 2D space with an origin point and a size.
BoundsRefinement
A refinable version of [#ident], see that documentation for details.
Capslock
The state of the capslock key at some point in time
ContentMask
Indicates which region of the window is visible. Content falling outside of this mask will not be rendered. Currently, only rectangular content masks are supported, but we give the mask its own type to leave room to support more complex shapes in the future.
Corners
Represents the corners of a box in a 2D space, such as border radius.
CornersRefinement
A refinable version of [#ident], see that documentation for details.
DevicePixels
Represents physical pixels on the display.
Edges
Represents the edges of a box in a 2D space, such as padding or margin.
EdgesRefinement
A refinable version of [#ident], see that documentation for details.
GridLocation
A location in a grid layout.
Hsla
An HSLA color
InvalidKeystrokeError
Error type for Keystroke::parse. This is used instead of anyhow::Error so that Zed can use markdown to display it.
KeyDownEvent
The key down event equivalent for the platform.
KeyUpEvent
The key up event equivalent for the platform.
KeybindingKeystroke
Represents a keystroke that can be used in keybindings and displayed to the user.
Keystroke
A keystroke and associated metadata generated by the platform
LinearColorStop
A color stop in a linear gradient.
Modifiers
The state of the modifier keys at some point in time
MouseDownEvent
A mouse down event from the platform
MouseMoveEvent
A mouse move event from the platform.
Percentage
A type representing a percentage value.
Pixels
Represents a length in pixels, the base unit of measurement in the UI framework.
Point
Describes a location in a 2D cartesian space.
PointRefinement
A refinable version of [#ident], see that documentation for details.
Radians
Represents an angle in Radians
Rems
Represents a length in rems, a unit based on the font-size of the window, which can be assigned with Window::set_rem_size.
Rgba
An RGBA color
ScaledPixels
Represents scaled pixels that take into account the device’s scale factor.
Shadow
Size
A structure representing a two-dimensional size with width and height in a given unit.
SizeRefinement
A refinable version of [#ident], see that documentation for details.
StrikethroughStyle
The properties that can be applied to a strikethrough.
StrikethroughStyleRefinement
A refinable version of [#ident], see that documentation for details.
UnderlineStyle
The properties that can be applied to an underline.
UnderlineStyleRefinement
A refinable version of [#ident], see that documentation for details.

Enums§

AbsoluteLength
Represents an absolute length in pixels or rems.
Anchor
Identifies a reference point on a 2D box, used to anchor positioned elements.
AvailableSpace
The space available for an element to be laid out in
Axis
Axis in a 2D cartesian space.
BackgroundTag
Identifies which kind of Background is being described.
ColorSpace
A color space for color interpolation.
DefiniteLength
A non-auto length that can be defined in pixels, rems, or percent of parent.
GridPlacement
The placement of an item within a grid layout’s column or row.
Length
A length that can be defined in pixels, rems, percent of parent, or auto.
MouseButton
An enum representing the mouse button that was pressed.
NavigationDirection
A navigation direction, such as back or forward.

Constants§

KEYSTROKE_PARSE_EXPECTED_MESSAGE
Sentence explaining what keystroke parser expects, starting with “Expected …”

Traits§

Along
A trait for accessing the given unit along a certain axis.
AsKeystroke
This is a helper trait so that we can simplify the implementation of some functions
Half
Provides a trait for types that can calculate half of their value.
HasRemSize
A source of the current rem size, used to convert Pixels to Rems.
IsZero
A trait for checking if a value is zero.

Functions§

auto
Returns a Length representing an automatic length.
black
Pure black in Hsla
blue
The color blue in Hsla
bounds
Create a bounds with the given origin and size
ceil_to_device_pixel
Rounds a logical coordinate up to a device pixel boundary.
checkerboard
Creates a checkerboard pattern background
floor_to_device_pixel
Rounds a logical coordinate down to a device pixel boundary.
green
The color green in Hsla
hsla
Construct an Hsla object from plain values
linear_color_stop
Creates a new linear color stop.
linear_gradient
Creates a LinearGradient background color.
opaque_grey
Opaque grey in Hsla, values will be clamped to the range [0, 1]
pattern_slash
Creates a hash pattern background
percentage
Generate a Radian from a percentage of a full circle.
phi
Returns the Golden Ratio, i.e. ~(1.0 + sqrt(5.0)) / 2.0.
point
Constructs a new Point<T> with the given x and y coordinates.
px
Constructs a Pixels value representing a length in pixels.
radians
Create a Radian from a raw value
red
The color red in Hsla
relative
Constructs a DefiniteLength representing a relative fraction of a parent size.
rems
Constructs a Rems value representing a length in rems.
rgb
Convert an RGB hex color code number to a color type
rgba
Convert an RGBA hex color code number to Rgba
round_half_toward_zero
Rounds to the nearest integer with 0.5 ties toward zero.
round_half_toward_zero_f64
Rounds to the nearest integer with 0.5 ties toward zero.
round_stroke_to_device_pixel
Snaps a stroke width to at least one device pixel.
round_to_device_pixel
Rounds a logical coordinate to the nearest device pixel.
size
Constructs a new Size<T> with the provided width and height.
solid_background
Creates a solid background color.
swap_rgba_pa_to_bgra
Swap from RGBA with premultiplied alpha to BGRA
transparent_black
Transparent black in Hsla
transparent_white
Transparent white in Hsla
white
Pure white in Hsla
yellow
The color yellow in Hsla

Type Aliases§

DrawOrder
The order in which a primitive is painted within a frame.