gui-transitions-demo.sleela
lib/gui/version-dual/gui-transitions-demo.sleela · 121 line(s) · sleela
<< lib/gui/version-dual/gui-transitions-demo.sleela
A runnable walkthrough of the four fade/transition surfaces that ship in
every /lib/gui version line:
- SLGuiTransition — the FADING ACTION: an enter/exit tween (opacity over
time) with an easing curve (linear / ease-in /
ease-out / ease-in-out / dissolve).
- SLGuiToast — a TOAST / SNACKBAR: fades in at a corner, dwells a few
seconds, fades out.
- SLGuiModal — a MODAL / OVERLAY: a dialog that fades in over a
darkened backdrop (scrim).
- SLGuiSkeleton — a SKELETON SCREEN / PLACEHOLDER: shimmers while loading,
then dissolves to reveal content.
SLeeLa owns the curve + timing + lifecycle; the host paints each surface at
the opacity these models report. We drive them here with explicit elapsed-
time ticks so the walkthrough is deterministic and headless. Ordinals
(easing / severity / position / shape) are passed as small ints — the house
style for callers, documented inline and in each class. >>
#sleela 2.5
material;
import gui.version-dual;
class GuiTransitionsDemo {
< ---- 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 = 11364;
String metaAuthor = "Kiro Agent";
String metaDate = "2026-10-19";
String metaCopyright = "SLeeLa project";
String metaTrademark = "none";
String metaCorporation = "none";
< metaOrigin: National | <nation> | International | Galactic >
String metaOrigin = "International";
String metaBirthDate = "2026-10-19";
< 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; }
void main() {
SLPackage pkg = new SLPackage(); pkg.configure("gui");
print("gui package " + pkg.version() + " (featureLevel " + pkg.featureLevel() + ")");
< ---- 1. The fading action: an enter transition (tween + easing) -------- >
< easing: 0=linear 1=ease-in 2=ease-out 3=ease-in-out 4=dissolve >
SLGuiTransition fade = new SLGuiTransition(); fade.configure();
< 0 -> 100% over 400ms, ease-out >
fade.fadeIn(400, 2);
print("TRANSITION -> " + fade.report());
print(" opacity at 0ms=" + fade.opacityAt(0) + "%");
print(" opacity at 100ms=" + fade.opacityAt(100) + "%");
print(" opacity at 200ms=" + fade.opacityAt(200) + "% (ease-out: past half already)");
print(" opacity at 400ms=" + fade.opacityAt(400) + "%");
print(" css -> " + fade.toStyle());
< ---- 2. Toast / snackbar lifecycle ------------------------------------- >
< severity: 0=info 1=success 2=warning 3=danger ; position: 4=bottom-right >
SLGuiToast toast = new SLGuiToast(); toast.configure("Saved your changes.");
toast.setSeverity(1);
toast.setPosition(4);
toast.setFadeInMillis(200); toast.setDwell(1000); toast.setFadeOutMillis(200);
toast.show();
print("TOAST -> " + toast.report());
toast.tick(200); print(" after fade-in : " + toast.stateName() + " " + toast.opacityPct() + "%");
toast.tick(1000); print(" after dwell : " + toast.stateName() + " " + toast.opacityPct() + "%");
toast.tick(200); print(" after fade-out : " + toast.stateName() + " " + toast.opacityPct() + "%");
< ---- 3. Modal / overlay over a darkened backdrop ----------------------- >
SLGuiModal modal = new SLGuiModal(); modal.configure("Confirm deletion");
modal.setScrimDim(60); modal.setFadeMillis(200);
modal.open();
print("MODAL -> " + modal.report());
modal.tick(200); print(" opened : dialog=" + modal.dialogOpacityPct() + "% scrim=" + modal.scrimOpacityPct() + "%");
< user clicks the dim backdrop >
boolean dismissed = modal.onBackdropClick();
print(" backdrop click dismissed=" + dismissed + " -> " + modal.stateName());
modal.tick(200); print(" closed : dialog=" + modal.dialogOpacityPct() + "% scrim=" + modal.scrimOpacityPct() + "%");
< ---- 4. Skeleton screen -> content dissolve ---------------------------- >
< shape: 0=text 1=card 2=avatar 3=list >
SLGuiSkeleton sk = new SLGuiSkeleton();
sk.configure(1, 4);
sk.setShimmerPeriod(600); sk.setRevealMillis(260);
sk.beginLoading();
print("SKELETON -> " + sk.report());
sk.tick(300); print(" loading : placeholder=" + sk.placeholderOpacityPct() + "% shimmer=" + sk.shimmerPhasePct() + "%");
< content arrived >
sk.complete();
sk.tick(130); print(" reveal 1/2: placeholder=" + sk.placeholderOpacityPct() + "% content=" + sk.contentOpacityPct() + "%");
sk.tick(130); print(" reveal 2/2: placeholder=" + sk.placeholderOpacityPct() + "% content=" + sk.contentOpacityPct() + "% revealed=" + sk.revealed());
print("done: fade transitions, toast/snackbar, modal/overlay, skeleton — dual line.");
}
}