SLMeasure.sleela
lib/user-interface/SLMeasure.sleela · 104 line(s) · sleela
<< lib/user-interface/SLMeasure.sleela
SLeeLa Standard Library Definition.
Definition: Defines SLMeasure — a standardized unit of measurement for the
SleelaUI layout system, spanning US customary (inch, foot, point, pica),
Eurasian metric (mm, cm, m), device pixels (px), and relative units
(percent, flexible fraction fr, em). A measure is a (value, unit) pair that
resolves to device pixels at a DPI — one vocabulary across US and Eurasian
countries, with px available of course. It is a pure value helper mirroring
SLUIMeasure in the SleelaUI Layout C ABI (sleela_ui_layout.h).
Family: user-interface. >>
#sleela 2.5
material;
class SLMeasure {
< ---- Descriptive metadata (version 1.11 nested-friendly accessors) ---- >
<< Eleven catalogued attributes with getter/setter pairs, so a GUI, loader,
or catalog can read and (where appropriate) override this record.
Values are faithful to the subject's real origin where publicly known. >>
String metaVersion = "1.0.0";
int metaId = 10381;
String metaAuthor = "Kiro Agent";
String metaDate = "2026-10-16";
String metaCopyright = "SLeeLa project";
String metaTrademark = "none";
String metaCorporation = "none";
< metaOrigin: National | <nation> | International | Galactic >
String metaOrigin = "International";
String metaBirthDate = "2026-10-07";
< metaScienceRating: maturity/robustness on a 1..10 scale >
int metaScienceRating = 9;
< metaNationalSchedule: a real, citable instrument or "none" >
String metaNationalSchedule = "none";
String getMetaVersion() { return metaVersion; }
void setMetaVersion(String v) { metaVersion = v; }
int getMetaId() { return metaId; }
void setMetaId(int v) { metaId = v; }
String getAuthor() { return metaAuthor; }
void setAuthor(String v) { metaAuthor = v; }
String getDate() { return metaDate; }
void setDate(String v) { metaDate = v; }
String getCopyright() { return metaCopyright; }
void setCopyright(String v) { metaCopyright = v; }
String getTrademark() { return metaTrademark; }
void setTrademark(String v) { metaTrademark = v; }
String getCorporation() { return metaCorporation; }
void setCorporation(String v) { metaCorporation = v; }
String getOrigin() { return metaOrigin; }
void setOrigin(String v) { metaOrigin = v; }
String getBirthDate() { return metaBirthDate; }
void setBirthDate(String v) { metaBirthDate = v; }
int getScienceRating() { return metaScienceRating; }
void setScienceRating(int v) { metaScienceRating = v; }
String getNationalSchedule() { return metaNationalSchedule; }
void setNationalSchedule(String v) { metaNationalSchedule = v; }
< Unit ordinals (mirror SLUIUnitKind). >
< device pixels >
static final int PX = 0;
< millimetre (metric) >
static final int MM = 1;
< centimetre (metric) >
static final int CM = 2;
< metre (metric) >
static final int M = 3;
< inch (US) >
static final int IN = 4;
< foot (US) >
static final int FT = 5;
< typographic point (US, 1/72in) >
static final int PT = 6;
< pica (US, 12pt) >
static final int PICA = 7;
< percent of the reference extent >
static final int PCT = 8;
< flexible fraction / weight share >
static final int FR = 9;
< multiples of the base font size >
static final int EM = 10;
double value;
int unit;
void of(double v, int u) { value = v; unit = u; }
< US customary + metric + device + relative builders. >
void px(double v) { of(v, PX); }
void mm(double v) { of(v, MM); }
void cm(double v) { of(v, CM); }
void meters(double v){ of(v, M); }
void inch(double v) { of(v, IN); }
void feet(double v) { of(v, FT); }
void points(double v){ of(v, PT); }
void pica(double v) { of(v, PICA); }
void percent(double v){ of(v, PCT); }
void fraction(double v){ of(v, FR); }
void em(double v) { of(v, EM); }
< Resolve to device pixels at `dpi`, with a reference extent (for percent) >
< and em size (for em). >
double toPixels(double dpi, double referencePx, double emPx) {
return measureToPx(value, unit, dpi, referencePx, emPx);
}
boolean isFlexible() { return unit == FR; }
}