74class API_AUI_VIEWS AMetric
89 float convertValueToMyUnit(
const AMetric& anotherMetric) {
90 return fromPxToMetric(anotherMetric.getValuePx(), mUnit);
110 template<
typename T,
typename std::enable_if_t<std::is_
integral_v<T>,
bool> = 0>
115 "please use _px, _dp or _pt literal for AMetric initialisation. only zero allowed to "
116 "initialise AMetric without literal");
119 constexpr AMetric(
float value, Unit unit): mValue(value), mUnit(unit) {
123 AMetric(
const AString& text);
125 [[nodiscard]]
float getRawValue()
const
130 [[nodiscard]] Unit getUnit()
const
135 [[nodiscard]]
float getValuePx()
const;
136 [[nodiscard]]
float getValueDp()
const;
138 static float fromPxToMetric(
float value, Unit unit);
140 operator float()
const {
144 AMetric operator-()
const {
145 return {-mValue, mUnit};
148 AMetric& operator+=(AMetric rhs)
noexcept {
150 mValue += rhs.mValue;
154 AMetric& operator-=(AMetric rhs)
noexcept {
156 mValue -= rhs.mValue;
160 AMetric& operator*=(AMetric rhs)
noexcept {
162 mValue *= rhs.mValue;
166 AMetric& operator/=(AMetric rhs)
noexcept {
168 mValue /= rhs.mValue;
172 AMetric operator+(AMetric rhs)
const noexcept {
179 AMetric operator-(AMetric rhs)
const noexcept {
186 AMetric operator*(AMetric rhs)
const noexcept {
193 AMetric operator/(AMetric rhs)
const noexcept {
200 AMetric& operator*=(
float rhs)
noexcept {
205 AMetric& operator/=(
float rhs)
noexcept {
210 AMetric operator*(
float rhs)
const noexcept {
216 AMetric operator/(
float rhs)
const noexcept {
222 bool operator==(
const AMetric& rhs)
const {
223 return std::tie(mValue, mUnit) == std::tie(rhs.mValue, rhs.mUnit);
226 bool operator!=(
const AMetric& rhs)
const {
227 return !(rhs == *
this);
#define AUI_ASSERTX(condition, what)
Asserts that the passed condition evaluates to true. Adds extra message string.
Definition Assert.h:74