M1: style — Style/StyleRefinement, generated Styled API, font, card example (#2)
This commit was merged in pull request #2.
This commit is contained in:
1 parent
8c0685fe01
commit
ae3fd7da55
26 files changed
+45666
-30
No files matched your search
@@ -0,0 +1,572 @@
|
||||
// GENERATED by tools/gen_style.py. DO NOT EDIT.
|
||||
// Port of GPUI's derive(Refineable) / gpui_macros style helpers.
|
||||
|
||||
///|
|
||||
/// The fully resolved style of an element (GPUI: `Style`).
|
||||
/// Immutable; build one by refining `Style::default()`.
|
||||
#derive(Eq, Debug)
|
||||
pub(all) struct Style {
|
||||
/// How the element is laid out (block, flex, grid, none).
|
||||
display : Display
|
||||
/// Whether the element is painted.
|
||||
visibility : Visibility
|
||||
/// Overflow behavior per axis.
|
||||
overflow : @geometry.Point[Overflow]
|
||||
/// Space reserved for scrollbars.
|
||||
scrollbar_width : @geometry.AbsoluteLength
|
||||
/// Whether both axes may scroll at once.
|
||||
allow_concurrent_scroll : Bool
|
||||
/// Whether scrolling is restricted to the dominant axis.
|
||||
restrict_scroll_to_axis : Bool
|
||||
/// Relative or absolute positioning.
|
||||
position : Position
|
||||
/// Offsets for positioned elements.
|
||||
inset : @geometry.Edges[@geometry.Length]
|
||||
/// Preferred size.
|
||||
size : @geometry.Size[@geometry.Length]
|
||||
/// Minimum size.
|
||||
min_size : @geometry.Size[@geometry.Length]
|
||||
/// Maximum size.
|
||||
max_size : @geometry.Size[@geometry.Length]
|
||||
/// Preferred width / height ratio.
|
||||
aspect_ratio : Double?
|
||||
/// Outer spacing.
|
||||
margin : @geometry.Edges[@geometry.Length]
|
||||
/// Inner spacing.
|
||||
padding : @geometry.Edges[@geometry.DefiniteLength]
|
||||
/// Border width per side.
|
||||
border_widths : @geometry.Edges[@geometry.AbsoluteLength]
|
||||
/// Cross-axis alignment of children.
|
||||
align_items : AlignItems?
|
||||
/// Cross-axis alignment of this element (GPUI: AlignSelf).
|
||||
align_self : AlignItems?
|
||||
/// Distribution of lines in a multi-line container.
|
||||
align_content : AlignContent?
|
||||
/// Main-axis distribution of children (GPUI: JustifyContent).
|
||||
justify_content : AlignContent?
|
||||
/// Gap between children (width: column gap, height: row gap).
|
||||
gap : @geometry.Size[@geometry.DefiniteLength]
|
||||
/// Main axis direction.
|
||||
flex_direction : FlexDirection
|
||||
/// Whether children wrap onto new lines.
|
||||
flex_wrap : FlexWrap
|
||||
/// Initial main size before growing or shrinking.
|
||||
flex_basis : @geometry.Length
|
||||
/// Share of free space to take.
|
||||
flex_grow : Double
|
||||
/// Share of negative space to give up.
|
||||
flex_shrink : Double
|
||||
/// Background fill.
|
||||
background : Fill?
|
||||
/// Border color.
|
||||
border_color : @color.Hsla?
|
||||
/// Solid or dashed border.
|
||||
border_style : @scene.BorderStyle
|
||||
/// Corner radii.
|
||||
corner_radii : @geometry.Corners[@geometry.AbsoluteLength]
|
||||
/// Box shadows, painted in order. Treat as immutable.
|
||||
box_shadow : Array[BoxShadow]
|
||||
/// Text style inherited by descendants.
|
||||
text : TextStyleRefinement
|
||||
/// Cursor shown while hovering.
|
||||
mouse_cursor : CursorStyle?
|
||||
/// Opacity multiplier for the element and its children.
|
||||
opacity : Double?
|
||||
/// Grid column template.
|
||||
grid_cols : GridTemplate?
|
||||
/// Grid row template.
|
||||
grid_rows : GridTemplate?
|
||||
/// Placement within a grid parent.
|
||||
grid_location : @geometry.GridLocation?
|
||||
/// Paint a debug outline around the element.
|
||||
debug : Bool
|
||||
/// Paint debug outlines around all descendants.
|
||||
debug_below : Bool
|
||||
}
|
||||
|
||||
///|
|
||||
/// A partial `Style`: every field optional (GPUI: `StyleRefinement`).
|
||||
/// Mutable, because it is the builder that `Styled` methods write to.
|
||||
#derive(Eq, Debug)
|
||||
pub(all) struct StyleRefinement {
|
||||
mut display : Display?
|
||||
mut visibility : Visibility?
|
||||
mut overflow : @geometry.PointRefinement[Overflow]
|
||||
mut scrollbar_width : @geometry.AbsoluteLength?
|
||||
mut allow_concurrent_scroll : Bool?
|
||||
mut restrict_scroll_to_axis : Bool?
|
||||
mut position : Position?
|
||||
mut inset : @geometry.EdgesRefinement[@geometry.Length]
|
||||
mut size : @geometry.SizeRefinement[@geometry.Length]
|
||||
mut min_size : @geometry.SizeRefinement[@geometry.Length]
|
||||
mut max_size : @geometry.SizeRefinement[@geometry.Length]
|
||||
mut aspect_ratio : Double?
|
||||
mut margin : @geometry.EdgesRefinement[@geometry.Length]
|
||||
mut padding : @geometry.EdgesRefinement[@geometry.DefiniteLength]
|
||||
mut border_widths : @geometry.EdgesRefinement[@geometry.AbsoluteLength]
|
||||
mut align_items : AlignItems?
|
||||
mut align_self : AlignItems?
|
||||
mut align_content : AlignContent?
|
||||
mut justify_content : AlignContent?
|
||||
mut gap : @geometry.SizeRefinement[@geometry.DefiniteLength]
|
||||
mut flex_direction : FlexDirection?
|
||||
mut flex_wrap : FlexWrap?
|
||||
mut flex_basis : @geometry.Length?
|
||||
mut flex_grow : Double?
|
||||
mut flex_shrink : Double?
|
||||
mut background : Fill?
|
||||
mut border_color : @color.Hsla?
|
||||
mut border_style : @scene.BorderStyle?
|
||||
mut corner_radii : @geometry.CornersRefinement[@geometry.AbsoluteLength]
|
||||
mut box_shadow : Array[BoxShadow]?
|
||||
mut text : TextStyleRefinement
|
||||
mut mouse_cursor : CursorStyle?
|
||||
mut opacity : Double?
|
||||
mut grid_cols : GridTemplate?
|
||||
mut grid_rows : GridTemplate?
|
||||
mut grid_location : @geometry.GridLocation?
|
||||
mut debug : Bool?
|
||||
mut debug_below : Bool?
|
||||
}
|
||||
|
||||
///|
|
||||
/// An empty refinement (no field set).
|
||||
pub fn StyleRefinement::new() -> StyleRefinement {
|
||||
{
|
||||
display: None,
|
||||
visibility: None,
|
||||
overflow: Default::default(),
|
||||
scrollbar_width: None,
|
||||
allow_concurrent_scroll: None,
|
||||
restrict_scroll_to_axis: None,
|
||||
position: None,
|
||||
inset: Default::default(),
|
||||
size: Default::default(),
|
||||
min_size: Default::default(),
|
||||
max_size: Default::default(),
|
||||
aspect_ratio: None,
|
||||
margin: Default::default(),
|
||||
padding: Default::default(),
|
||||
border_widths: Default::default(),
|
||||
align_items: None,
|
||||
align_self: None,
|
||||
align_content: None,
|
||||
justify_content: None,
|
||||
gap: Default::default(),
|
||||
flex_direction: None,
|
||||
flex_wrap: None,
|
||||
flex_basis: None,
|
||||
flex_grow: None,
|
||||
flex_shrink: None,
|
||||
background: None,
|
||||
border_color: None,
|
||||
border_style: None,
|
||||
corner_radii: Default::default(),
|
||||
box_shadow: None,
|
||||
text: Default::default(),
|
||||
mouse_cursor: None,
|
||||
opacity: None,
|
||||
grid_cols: None,
|
||||
grid_rows: None,
|
||||
grid_location: None,
|
||||
debug: None,
|
||||
debug_below: None,
|
||||
}
|
||||
}
|
||||
|
||||
///|
|
||||
pub impl Default for StyleRefinement with fn default() {
|
||||
StyleRefinement::new()
|
||||
}
|
||||
|
||||
///|
|
||||
/// A copy that can be mutated independently.
|
||||
pub fn StyleRefinement::copy(self : StyleRefinement) -> StyleRefinement {
|
||||
{
|
||||
display: self.display,
|
||||
visibility: self.visibility,
|
||||
overflow: self.overflow,
|
||||
scrollbar_width: self.scrollbar_width,
|
||||
allow_concurrent_scroll: self.allow_concurrent_scroll,
|
||||
restrict_scroll_to_axis: self.restrict_scroll_to_axis,
|
||||
position: self.position,
|
||||
inset: self.inset,
|
||||
size: self.size,
|
||||
min_size: self.min_size,
|
||||
max_size: self.max_size,
|
||||
aspect_ratio: self.aspect_ratio,
|
||||
margin: self.margin,
|
||||
padding: self.padding,
|
||||
border_widths: self.border_widths,
|
||||
align_items: self.align_items,
|
||||
align_self: self.align_self,
|
||||
align_content: self.align_content,
|
||||
justify_content: self.justify_content,
|
||||
gap: self.gap,
|
||||
flex_direction: self.flex_direction,
|
||||
flex_wrap: self.flex_wrap,
|
||||
flex_basis: self.flex_basis,
|
||||
flex_grow: self.flex_grow,
|
||||
flex_shrink: self.flex_shrink,
|
||||
background: self.background,
|
||||
border_color: self.border_color,
|
||||
border_style: self.border_style,
|
||||
corner_radii: self.corner_radii,
|
||||
box_shadow: self.box_shadow,
|
||||
text: self.text,
|
||||
mouse_cursor: self.mouse_cursor,
|
||||
opacity: self.opacity,
|
||||
grid_cols: self.grid_cols,
|
||||
grid_rows: self.grid_rows,
|
||||
grid_location: self.grid_location,
|
||||
debug: self.debug,
|
||||
debug_below: self.debug_below,
|
||||
}
|
||||
}
|
||||
|
||||
///|
|
||||
/// Applies `other` on top of `self`, in place: fields set in `other` win.
|
||||
pub fn StyleRefinement::refine(
|
||||
self : StyleRefinement,
|
||||
other : StyleRefinement,
|
||||
) -> Unit {
|
||||
if other.display is Some(_) {
|
||||
self.display = other.display
|
||||
}
|
||||
if other.visibility is Some(_) {
|
||||
self.visibility = other.visibility
|
||||
}
|
||||
self.overflow = self.overflow.refined(other.overflow)
|
||||
if other.scrollbar_width is Some(_) {
|
||||
self.scrollbar_width = other.scrollbar_width
|
||||
}
|
||||
if other.allow_concurrent_scroll is Some(_) {
|
||||
self.allow_concurrent_scroll = other.allow_concurrent_scroll
|
||||
}
|
||||
if other.restrict_scroll_to_axis is Some(_) {
|
||||
self.restrict_scroll_to_axis = other.restrict_scroll_to_axis
|
||||
}
|
||||
if other.position is Some(_) {
|
||||
self.position = other.position
|
||||
}
|
||||
self.inset = self.inset.refined(other.inset)
|
||||
self.size = self.size.refined(other.size)
|
||||
self.min_size = self.min_size.refined(other.min_size)
|
||||
self.max_size = self.max_size.refined(other.max_size)
|
||||
if other.aspect_ratio is Some(_) {
|
||||
self.aspect_ratio = other.aspect_ratio
|
||||
}
|
||||
self.margin = self.margin.refined(other.margin)
|
||||
self.padding = self.padding.refined(other.padding)
|
||||
self.border_widths = self.border_widths.refined(other.border_widths)
|
||||
if other.align_items is Some(_) {
|
||||
self.align_items = other.align_items
|
||||
}
|
||||
if other.align_self is Some(_) {
|
||||
self.align_self = other.align_self
|
||||
}
|
||||
if other.align_content is Some(_) {
|
||||
self.align_content = other.align_content
|
||||
}
|
||||
if other.justify_content is Some(_) {
|
||||
self.justify_content = other.justify_content
|
||||
}
|
||||
self.gap = self.gap.refined(other.gap)
|
||||
if other.flex_direction is Some(_) {
|
||||
self.flex_direction = other.flex_direction
|
||||
}
|
||||
if other.flex_wrap is Some(_) {
|
||||
self.flex_wrap = other.flex_wrap
|
||||
}
|
||||
if other.flex_basis is Some(_) {
|
||||
self.flex_basis = other.flex_basis
|
||||
}
|
||||
if other.flex_grow is Some(_) {
|
||||
self.flex_grow = other.flex_grow
|
||||
}
|
||||
if other.flex_shrink is Some(_) {
|
||||
self.flex_shrink = other.flex_shrink
|
||||
}
|
||||
if other.background is Some(_) {
|
||||
self.background = other.background
|
||||
}
|
||||
if other.border_color is Some(_) {
|
||||
self.border_color = other.border_color
|
||||
}
|
||||
if other.border_style is Some(_) {
|
||||
self.border_style = other.border_style
|
||||
}
|
||||
self.corner_radii = self.corner_radii.refined(other.corner_radii)
|
||||
if other.box_shadow is Some(_) {
|
||||
self.box_shadow = other.box_shadow
|
||||
}
|
||||
self.text = self.text.refined(other.text)
|
||||
if other.mouse_cursor is Some(_) {
|
||||
self.mouse_cursor = other.mouse_cursor
|
||||
}
|
||||
if other.opacity is Some(_) {
|
||||
self.opacity = other.opacity
|
||||
}
|
||||
if other.grid_cols is Some(_) {
|
||||
self.grid_cols = other.grid_cols
|
||||
}
|
||||
if other.grid_rows is Some(_) {
|
||||
self.grid_rows = other.grid_rows
|
||||
}
|
||||
if other.grid_location is Some(_) {
|
||||
self.grid_location = other.grid_location
|
||||
}
|
||||
if other.debug is Some(_) {
|
||||
self.debug = other.debug
|
||||
}
|
||||
if other.debug_below is Some(_) {
|
||||
self.debug_below = other.debug_below
|
||||
}
|
||||
}
|
||||
|
||||
///|
|
||||
/// A new refinement: `self` with `other` applied on top.
|
||||
pub fn StyleRefinement::refined(
|
||||
self : StyleRefinement,
|
||||
other : StyleRefinement,
|
||||
) -> StyleRefinement {
|
||||
let result = self.copy()
|
||||
result.refine(other)
|
||||
result
|
||||
}
|
||||
|
||||
///|
|
||||
/// Whether any field is set.
|
||||
pub fn StyleRefinement::is_some(self : StyleRefinement) -> Bool {
|
||||
self.display is Some(_) ||
|
||||
self.visibility is Some(_) ||
|
||||
self.overflow.is_some() ||
|
||||
self.scrollbar_width is Some(_) ||
|
||||
self.allow_concurrent_scroll is Some(_) ||
|
||||
self.restrict_scroll_to_axis is Some(_) ||
|
||||
self.position is Some(_) ||
|
||||
self.inset.is_some() ||
|
||||
self.size.is_some() ||
|
||||
self.min_size.is_some() ||
|
||||
self.max_size.is_some() ||
|
||||
self.aspect_ratio is Some(_) ||
|
||||
self.margin.is_some() ||
|
||||
self.padding.is_some() ||
|
||||
self.border_widths.is_some() ||
|
||||
self.align_items is Some(_) ||
|
||||
self.align_self is Some(_) ||
|
||||
self.align_content is Some(_) ||
|
||||
self.justify_content is Some(_) ||
|
||||
self.gap.is_some() ||
|
||||
self.flex_direction is Some(_) ||
|
||||
self.flex_wrap is Some(_) ||
|
||||
self.flex_basis is Some(_) ||
|
||||
self.flex_grow is Some(_) ||
|
||||
self.flex_shrink is Some(_) ||
|
||||
self.background is Some(_) ||
|
||||
self.border_color is Some(_) ||
|
||||
self.border_style is Some(_) ||
|
||||
self.corner_radii.is_some() ||
|
||||
self.box_shadow is Some(_) ||
|
||||
self.text.is_some() ||
|
||||
self.mouse_cursor is Some(_) ||
|
||||
self.opacity is Some(_) ||
|
||||
self.grid_cols is Some(_) ||
|
||||
self.grid_rows is Some(_) ||
|
||||
self.grid_location is Some(_) ||
|
||||
self.debug is Some(_) ||
|
||||
self.debug_below is Some(_)
|
||||
}
|
||||
|
||||
///|
|
||||
/// `self` with every field set in `refinement` overwritten.
|
||||
pub fn Style::refined(self : Style, refinement : StyleRefinement) -> Style {
|
||||
{
|
||||
display: refine_value(refinement.display, self.display),
|
||||
visibility: refine_value(refinement.visibility, self.visibility),
|
||||
overflow: self.overflow.refined(refinement.overflow),
|
||||
scrollbar_width: refine_value(
|
||||
refinement.scrollbar_width,
|
||||
self.scrollbar_width,
|
||||
),
|
||||
allow_concurrent_scroll: refine_value(
|
||||
refinement.allow_concurrent_scroll,
|
||||
self.allow_concurrent_scroll,
|
||||
),
|
||||
restrict_scroll_to_axis: refine_value(
|
||||
refinement.restrict_scroll_to_axis,
|
||||
self.restrict_scroll_to_axis,
|
||||
),
|
||||
position: refine_value(refinement.position, self.position),
|
||||
inset: self.inset.refined(refinement.inset),
|
||||
size: self.size.refined(refinement.size),
|
||||
min_size: self.min_size.refined(refinement.min_size),
|
||||
max_size: self.max_size.refined(refinement.max_size),
|
||||
aspect_ratio: refine_option(refinement.aspect_ratio, self.aspect_ratio),
|
||||
margin: self.margin.refined(refinement.margin),
|
||||
padding: self.padding.refined(refinement.padding),
|
||||
border_widths: self.border_widths.refined(refinement.border_widths),
|
||||
align_items: refine_option(refinement.align_items, self.align_items),
|
||||
align_self: refine_option(refinement.align_self, self.align_self),
|
||||
align_content: refine_option(refinement.align_content, self.align_content),
|
||||
justify_content: refine_option(
|
||||
refinement.justify_content,
|
||||
self.justify_content,
|
||||
),
|
||||
gap: self.gap.refined(refinement.gap),
|
||||
flex_direction: refine_value(refinement.flex_direction, self.flex_direction),
|
||||
flex_wrap: refine_value(refinement.flex_wrap, self.flex_wrap),
|
||||
flex_basis: refine_value(refinement.flex_basis, self.flex_basis),
|
||||
flex_grow: refine_value(refinement.flex_grow, self.flex_grow),
|
||||
flex_shrink: refine_value(refinement.flex_shrink, self.flex_shrink),
|
||||
background: refine_option(refinement.background, self.background),
|
||||
border_color: refine_option(refinement.border_color, self.border_color),
|
||||
border_style: refine_value(refinement.border_style, self.border_style),
|
||||
corner_radii: self.corner_radii.refined(refinement.corner_radii),
|
||||
box_shadow: refine_value(refinement.box_shadow, self.box_shadow),
|
||||
text: self.text.refined(refinement.text),
|
||||
mouse_cursor: refine_option(refinement.mouse_cursor, self.mouse_cursor),
|
||||
opacity: refine_option(refinement.opacity, self.opacity),
|
||||
grid_cols: refine_option(refinement.grid_cols, self.grid_cols),
|
||||
grid_rows: refine_option(refinement.grid_rows, self.grid_rows),
|
||||
grid_location: refine_option(refinement.grid_location, self.grid_location),
|
||||
debug: refine_value(refinement.debug, self.debug),
|
||||
debug_below: refine_value(refinement.debug_below, self.debug_below),
|
||||
}
|
||||
}
|
||||
|
||||
///|
|
||||
/// The resolved style of a run of text (GPUI: `TextStyle`).
|
||||
#derive(Eq, Debug)
|
||||
pub(all) struct TextStyle {
|
||||
/// Text color.
|
||||
color : @color.Hsla
|
||||
/// Font family name.
|
||||
font_family : String
|
||||
/// OpenType features.
|
||||
font_features : @font.FontFeatures
|
||||
/// Fallback families.
|
||||
font_fallbacks : @font.FontFallbacks?
|
||||
/// Font size.
|
||||
font_size : @geometry.AbsoluteLength
|
||||
/// Line height; fractions are relative to the font size.
|
||||
line_height : @geometry.DefiniteLength
|
||||
/// Font weight.
|
||||
font_weight : @font.FontWeight
|
||||
/// Upright, italic or oblique.
|
||||
font_style : @font.FontStyle
|
||||
/// Background behind the glyphs.
|
||||
background_color : @color.Hsla?
|
||||
/// Underline decoration.
|
||||
underline : UnderlineStyle?
|
||||
/// Strikethrough decoration.
|
||||
strikethrough : StrikethroughStyle?
|
||||
/// Whether text wraps.
|
||||
white_space : WhiteSpace
|
||||
/// How overflowing text is truncated.
|
||||
text_overflow : TextOverflow?
|
||||
/// Horizontal alignment.
|
||||
text_align : TextAlign
|
||||
/// Maximum number of lines.
|
||||
line_clamp : Int32?
|
||||
}
|
||||
|
||||
///|
|
||||
/// A partial `TextStyle` (GPUI: `TextStyleRefinement`). Immutable.
|
||||
#derive(Eq, Default, Debug)
|
||||
pub(all) struct TextStyleRefinement {
|
||||
color : @color.Hsla?
|
||||
font_family : String?
|
||||
font_features : @font.FontFeatures?
|
||||
font_fallbacks : @font.FontFallbacks?
|
||||
font_size : @geometry.AbsoluteLength?
|
||||
line_height : @geometry.DefiniteLength?
|
||||
font_weight : @font.FontWeight?
|
||||
font_style : @font.FontStyle?
|
||||
background_color : @color.Hsla?
|
||||
underline : UnderlineStyle?
|
||||
strikethrough : StrikethroughStyle?
|
||||
white_space : WhiteSpace?
|
||||
text_overflow : TextOverflow?
|
||||
text_align : TextAlign?
|
||||
line_clamp : Int32?
|
||||
}
|
||||
|
||||
///|
|
||||
/// Combines two refinements; fields set in `other` win.
|
||||
pub fn TextStyleRefinement::refined(
|
||||
self : TextStyleRefinement,
|
||||
other : TextStyleRefinement,
|
||||
) -> TextStyleRefinement {
|
||||
{
|
||||
color: refine_option(other.color, self.color),
|
||||
font_family: refine_option(other.font_family, self.font_family),
|
||||
font_features: refine_option(other.font_features, self.font_features),
|
||||
font_fallbacks: refine_option(other.font_fallbacks, self.font_fallbacks),
|
||||
font_size: refine_option(other.font_size, self.font_size),
|
||||
line_height: refine_option(other.line_height, self.line_height),
|
||||
font_weight: refine_option(other.font_weight, self.font_weight),
|
||||
font_style: refine_option(other.font_style, self.font_style),
|
||||
background_color: refine_option(
|
||||
other.background_color,
|
||||
self.background_color,
|
||||
),
|
||||
underline: refine_option(other.underline, self.underline),
|
||||
strikethrough: refine_option(other.strikethrough, self.strikethrough),
|
||||
white_space: refine_option(other.white_space, self.white_space),
|
||||
text_overflow: refine_option(other.text_overflow, self.text_overflow),
|
||||
text_align: refine_option(other.text_align, self.text_align),
|
||||
line_clamp: refine_option(other.line_clamp, self.line_clamp),
|
||||
}
|
||||
}
|
||||
|
||||
///|
|
||||
/// Whether any field is set.
|
||||
pub fn TextStyleRefinement::is_some(self : TextStyleRefinement) -> Bool {
|
||||
self.color is Some(_) ||
|
||||
self.font_family is Some(_) ||
|
||||
self.font_features is Some(_) ||
|
||||
self.font_fallbacks is Some(_) ||
|
||||
self.font_size is Some(_) ||
|
||||
self.line_height is Some(_) ||
|
||||
self.font_weight is Some(_) ||
|
||||
self.font_style is Some(_) ||
|
||||
self.background_color is Some(_) ||
|
||||
self.underline is Some(_) ||
|
||||
self.strikethrough is Some(_) ||
|
||||
self.white_space is Some(_) ||
|
||||
self.text_overflow is Some(_) ||
|
||||
self.text_align is Some(_) ||
|
||||
self.line_clamp is Some(_)
|
||||
}
|
||||
|
||||
///|
|
||||
/// `self` with every field set in `refinement` overwritten.
|
||||
pub fn TextStyle::refined(
|
||||
self : TextStyle,
|
||||
refinement : TextStyleRefinement,
|
||||
) -> TextStyle {
|
||||
{
|
||||
color: refine_value(refinement.color, self.color),
|
||||
font_family: refine_value(refinement.font_family, self.font_family),
|
||||
font_features: refine_value(refinement.font_features, self.font_features),
|
||||
font_fallbacks: refine_option(
|
||||
refinement.font_fallbacks,
|
||||
self.font_fallbacks,
|
||||
),
|
||||
font_size: refine_value(refinement.font_size, self.font_size),
|
||||
line_height: refine_value(refinement.line_height, self.line_height),
|
||||
font_weight: refine_value(refinement.font_weight, self.font_weight),
|
||||
font_style: refine_value(refinement.font_style, self.font_style),
|
||||
background_color: refine_option(
|
||||
refinement.background_color,
|
||||
self.background_color,
|
||||
),
|
||||
underline: refine_option(refinement.underline, self.underline),
|
||||
strikethrough: refine_option(refinement.strikethrough, self.strikethrough),
|
||||
white_space: refine_value(refinement.white_space, self.white_space),
|
||||
text_overflow: refine_option(refinement.text_overflow, self.text_overflow),
|
||||
text_align: refine_value(refinement.text_align, self.text_align),
|
||||
line_clamp: refine_option(refinement.line_clamp, self.line_clamp),
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user