Home /Modules/gui/gui-effects-demo.sleela

gui-effects-demo.sleela

lib/gui/version-thual/gui-effects-demo.sleela · 131 line(s) · sleela

<< lib/gui/version-thual/gui-effects-demo.sleela
   A runnable walkthrough of the thual (3.0) visual-effects surface: clean,
   professional UI components with lighting/glow, 3D shine, drop shadow, a metal
   look-and-feel, fixed and scheduled ("schene") rotation, fade in/out,
   activation audio, and logo branding. SLeeLa names every effect; the host
   renders the pixels and plays the cues. >>
#sleela 2.5
material;
class GuiEffectsDemo {
  < ---- 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 = 11118;
  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-16";
  < 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() {
    < Version identity: this is the 3.0 line. >
    SLPackage pkg = new SLPackage(); pkg.configure("gui");
    print("gui package " + pkg.version() + " (featureLevel " + pkg.featureLevel() +
          ", 3.0=" + pkg.isThreePointZero() + ")");

    < ---- Branding: a logo + accent painted into the app chrome ---- >
    SLGuiBranding brand = new SLGuiBranding();
    brand.configure("brand/logo.svg");
    brand.setPlacement(brand.PLACE_HEADER);
    brand.setWordmark("SLeeLa");
    brand.setColors("#2E8BFF", "#0B1E3A");
    brand.setTagline("built to inspire");
    print("branding: " + brand.report() + " valid=" + brand.valid());

    < ---- Activation audio: the cue registry ---- >
    SLGuiAudioCues audio = new SLGuiAudioCues();
    audio.configure();
    audio.register("whoosh", "audio/ui/whoosh.wav");
    audio.setMasterGainPct(90);
    print("audio cues=" + audio.cues() + " enabled=" + audio.isEnabled() +
          " master=" + audio.getMasterGainPct() + "%");

    < ---- A button with the full clean/professional effect stack ---- >
    SLGuiEffects fx = new SLGuiEffects();
    fx.configure();
    < lighting + glow >
    fx.enableGlow(16, 70, "#2E8BFF");
    < 3D specular shine >
    fx.enableShine(60, 55);
    < soft drop shadow >
    fx.enableShadow(0, 6, 18, 40);
    < brushed-metal surface >
    fx.enableMetal(65);
    < audio on activation >
    fx.setActivationCue("whoosh", 85);
    print("button fx -> " + fx.toStyle());
    print("  effects honored=" + fx.honored());

    < Play the activation cue through the registry (host gets the effective gain). >
    int gain = audio.play(fx.getActivationCue(), fx.getActivationGainPct());
    print("  activation '" + fx.getActivationCue() + "' -> effective gain " + gain + "%");

    < ---- Fade in, then fade out ---- >
    fx.setFadeMillis(250);
    fx.fadeOut(); print("  faded out: opacity=" + fx.opacity() + "% (faded=" + fx.faded() + ")");
    fx.fadeIn();  print("  faded in:  opacity=" + fx.opacity() + "%");

    < ---- Fixed rotation ---- >
    fx.rotateTo(90); print("  rotateTo(90) -> " + fx.rotation() + " deg");
    fx.rotateBy(300); print("  rotateBy(300) -> " + fx.rotation() + " deg (wrapped)");

    < ---- Scheduled "schene" rotation bound to an internal memorandum ---- >
    < The visible component rotates 45 deg every 1000 ms; each step also rotates >
    < the bound memorandum's internal key by one epoch (visible rotation is the >
    < honest external signal of an internal key rotation). >
    SLGuiRotationSchedule schene = new SLGuiRotationSchedule();
    schene.configure(1000, 45);
    < cap at 8 epochs >
    schene.bindMemorandum("quarterly-keys", 8);
    schene.start();
    fx.setSchedule(schene);
    print("schene: every " + schene.getIntervalMillis() + "ms step " +
          schene.getStepDeg() + " deg, memo='" + schene.memorandum() + "'");

    < Drive 3 seconds of ticks at 250 ms; a step (and key epoch) lands each 1000 ms. >
    int t = 0;
    while (t < 3000) {
      boolean moved = fx.tickRotation(250);
      t = t + 250;
      if (moved) {
        print("  t=" + t + "ms: rotated to " + fx.rotation() +
              " deg, memo key epoch=" + schene.epochNow() + " (turn " + schene.totalTurns() + ")");
      }
    }
    print("final: angle=" + fx.rotation() + " deg, key epoch=" + schene.epochNow() +
          ", schedule honored=" + schene.honored());
  }
}