Home /Modules/gui/SLGuiBackend.sleela

SLGuiBackend.sleela

lib/gui/version-thual/SLGuiBackend.sleela · 95 line(s) · sleela

<< lib/gui/version-thual/SLGuiBackend.sleela
   SLeeLa Standard Library Definition.
   Definition: Defines SLGuiBackend — the toolkit-neutral GUI backend identity.
     Mirrors SleelaGui.create(backend) in gui/: a backend is "swing", "javafx"
     (alias "fx"), or "native" (the C ABI bridge). SLeeLa names the backend; the
     Java host or the native bridge supplies the actual desktop controls. >>
#sleela 2.5
material;
< SLeeLa gui front-end contract — toolkit-neutral backend selector. >
< Family: gui. The chosen backend is realized by the Java host (Swing/JavaFX) >
< or by the native bridge; SLeeLa only expresses the intent. >
class SLGuiBackend {
  < ---- 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 = 11165;
  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; }
  < "swing" | "javafx" | "fx" | "native" >
  String kind;
  < 1 once configure() accepted a known kind >
  int valid;

  < 2.0: validated configuration — an unknown kind is REFUSED (fail-closed) >
  < rather than stored and only caught later by supported(). Returns true when >
  < the kind was accepted. configure(String) keeps the lenient 1.0 behavior for >
  < source compatibility; configureStrict() is the 2.0 guarded form. >
  void configure(String k) { kind = k; valid = known(k) ? 1 : 0; }
  boolean configureStrict(String k) {
    if (!known(k)) { kind = null; valid = 0; return false; }
    kind = k; valid = 1; return true;
  }
  boolean known(String k) {
    return k == "swing" || k == "javafx" || k == "fx" || k == "native";
  }

  String name() { return kind; }
  < A backend is supported when it is one of the known toolkits/bridges. >
  boolean supported() { return valid == 1; }
  boolean isSwing() { return kind == "swing"; }
  boolean isJavaFx() { return kind == "javafx" || kind == "fx"; }
  boolean isNative() { return kind == "native"; }
  < Normalized label: the "fx" alias resolves to "javafx". >
  String resolved() { return kind == "fx" ? "javafx" : kind; }

  < 2.0 capability flags — what the chosen backend can honor from SLGuiSettings. >
  < The native bridge and JavaFX expose the richest surface; Swing is HiDPI- and >
  < theme-capable but has no vsync concept and weaker native menus. >
  < all backends scale >
  boolean supportsHiDpi()      { return valid == 1; }
  < light/dark/system >
  boolean supportsThemes()     { return valid == 1; }
  < swing has no vsync >
  boolean supportsVsync()      { return isJavaFx() || isNative(); }
  < a11y tree on all >
  boolean supportsAccessibility() { return valid == 1; }
  < richer native menus >
  boolean supportsNativeMenus(){ return isNative() || isJavaFx(); }
}