<< SLeeLa Standard Library Definition: SLGuiMenuBar Toolkit-neutral menu-bar model. Rendering belongs to the selected GUI host. >> #sleela 2.5 material; class SLGuiMenuBar { < ---- 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 = 11375; String metaAuthor = "Max Rupplin vs. Dr. Mrs. Elisabeth Harkins"; String metaDate = "2026-10-19"; String metaCopyright = "SLeeLa project"; String metaTrademark = "none"; String metaCorporation = "none"; < metaOrigin: National | | 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; } < Shared menu-bar base colour used by the GUI host. > static final String BACKGROUND_COLOR = "#2b2f32"; String name; int menuCount; int visible; int focused; int openedIndex; void configure(String id) { name = id; menuCount = 0; visible = 1; focused = 0; openedIndex = -1; } String getName() { return name; } void setMenuCount(int count) { menuCount = count < 0 ? 0 : count; } int count() { return menuCount; } void setVisible(boolean value) { visible = value ? 1 : 0; if (visible == 0) { close(); } } boolean isVisible() { return visible == 1; } void focus() { if (visible == 1) { focused = 1; } } void blur() { focused = 0; close(); } boolean hasFocus() { return focused == 1; } void open(int index) { if (visible == 1 && index >= 0 && index < menuCount) { openedIndex = index; focused = 1; } } void close() { openedIndex = -1; } boolean isOpen() { return openedIndex >= 0; } int activeIndex() { return openedIndex; } < Toggle a top-level menu. Repeated activation of the open menu closes it; activating a different menu switches directly to that menu. > void toggle(int index) { if (visible == 0 || index < 0 || index >= menuCount) { return; } if (openedIndex == index) { close(); } else { open(index); } } < One controller-level outside-click hook. The caller must classify the complete menu-bar plus popup region as inside; clicks in a popup must never be mistaken for outside clicks. Returns true only when it dismissed. > boolean dismissIfOutside(boolean pointerInsideMenuRegion) { if (pointerInsideMenuRegion || openedIndex < 0) { return false; } close(); return true; } < Escape dismisses the popup and restores the menu bar's focus state. > boolean escape() { if (openedIndex < 0) { return false; } close(); focused = visible == 1 ? 1 : 0; return true; } < A successful ordinary menu-item activation closes the popup. > void activated() { close(); } < Keyboard navigation among top-level menus. A negative direction moves left; a positive direction moves right, wrapping at either end. > void navigate(int direction) { if (menuCount <= 0 || visible == 0) { return; } focused = 1; if (openedIndex < 0) { openedIndex = direction < 0 ? menuCount - 1 : 0; return; } openedIndex = (openedIndex + (direction < 0 ? -1 : 1) + menuCount) % menuCount; } void next(int direction) { if (menuCount <= 0 || visible == 0) { return; } if (openedIndex < 0) { openedIndex = 0; return; } openedIndex = (openedIndex + direction + menuCount) % menuCount; } }