psychic-ui 0.0.0
Loading...
Searching...
No Matches
psychic_ui::Length Struct Reference

#include <Length.hpp>

Public Types

enum class  Unit : std::uint8_t { Px , Percent , Auto }

Public Member Functions

constexpr Length (float value, Unit unit)
template<class T>
requires (std::is_arithmetic_v<T> && !std::same_as<T, bool>)
constexpr Length (T px)
constexpr bool isPx () const
constexpr bool isPercent () const
constexpr bool isAuto () const
constexpr float resolve (float relativeTo, float fallback=0.0f) const
constexpr bool operator== (const Length &) const =default

Static Public Member Functions

static constexpr Length px (float value)
static constexpr Length percent (float value)

Public Attributes

float value {0.0f}
Unit unit {Unit::Px}

Detailed Description

A length in pixels, in percent of the parent (0-100, like CSS), or Auto. A plain number is pixels: width(24). Percent and auto read like CSS: width(50_pct), width(Auto).

Constructor & Destructor Documentation

◆ Length()

template<class T>
requires (std::is_arithmetic_v<T> && !std::same_as<T, bool>)
psychic_ui::Length::Length ( T px)
inlineconstexpr

Pixels. Any number but a bool, which is a mistake

Member Function Documentation

◆ resolve()

float psychic_ui::Length::resolve ( float relativeTo,
float fallback = 0.0f ) const
inlinenodiscardconstexpr

The length in pixels, given what a percent is relative to; fallback when auto


The documentation for this struct was generated from the following file: