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.
- Bounds
Refinement - A refinable version of [
#ident], see that documentation for details. - Capslock
- The state of the capslock key at some point in time
- Content
Mask - 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.
- Corners
Refinement - A refinable version of [
#ident], see that documentation for details. - Device
Pixels - Represents physical pixels on the display.
- Edges
- Represents the edges of a box in a 2D space, such as padding or margin.
- Edges
Refinement - A refinable version of [
#ident], see that documentation for details. - Grid
Location - A location in a grid layout.
- Hsla
- An HSLA color
- Invalid
Keystroke Error - Error type for
Keystroke::parse. This is used instead ofanyhow::Errorso that Zed can use markdown to display it. - KeyDown
Event - The key down event equivalent for the platform.
- KeyUp
Event - The key up event equivalent for the platform.
- Keybinding
Keystroke - Represents a keystroke that can be used in keybindings and displayed to the user.
- Keystroke
- A keystroke and associated metadata generated by the platform
- Linear
Color Stop - A color stop in a linear gradient.
- Modifiers
- The state of the modifier keys at some point in time
- Mouse
Down Event - A mouse down event from the platform
- Mouse
Move Event - 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.
- Point
Refinement - 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
- Scaled
Pixels - 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.
- Size
Refinement - A refinable version of [
#ident], see that documentation for details. - Strikethrough
Style - The properties that can be applied to a strikethrough.
- Strikethrough
Style Refinement - A refinable version of [
#ident], see that documentation for details. - Underline
Style - The properties that can be applied to an underline.
- Underline
Style Refinement - A refinable version of [
#ident], see that documentation for details.
Enums§
- Absolute
Length - Represents an absolute length in pixels or rems.
- Anchor
- Identifies a reference point on a 2D box, used to anchor positioned elements.
- Available
Space - The space available for an element to be laid out in
- Axis
- Axis in a 2D cartesian space.
- Background
Tag - Identifies which kind of
Backgroundis being described. - Color
Space - A color space for color interpolation.
- Definite
Length - A non-auto length that can be defined in pixels, rems, or percent of parent.
- Grid
Placement - 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.
- Mouse
Button - An enum representing the mouse button that was pressed.
- Navigation
Direction - 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.
- HasRem
Size - A source of the current rem size, used to convert
PixelstoRems. - IsZero
- A trait for checking if a value is zero.
Functions§
- auto
- Returns a
Lengthrepresenting 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
Hslaobject 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
Radianfrom 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
Pixelsvalue representing a length in pixels. - radians
- Create a
Radianfrom a raw value - red
- The color red in
Hsla - relative
- Constructs a
DefiniteLengthrepresenting a relative fraction of a parent size. - rems
- Constructs a
Remsvalue 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§
- Draw
Order - The order in which a primitive is painted within a frame.