Skip to content

Commit

Permalink
[GoldenLayout] Add jsdoc comments
Browse files Browse the repository at this point in the history
  • Loading branch information
hyazinthh committed Feb 21, 2024
1 parent 3f7a77e commit 3157e84
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ if (!aardvark.golden) {
instances: new Map()
};

/**
* @param {{element: HTMLElement}} container
* @param {HTMLElement} element
* @param {number} width
* @param {number} height
*/
const onVirtualRecting = function (container, element, width, height) {
const containerBoundingClientRect = container.element.getBoundingClientRect();
const left = containerBoundingClientRect.left;
Expand All @@ -21,6 +27,10 @@ if (!aardvark.golden) {
element.style.height = `${height}px`;
}

/**
* @param {HTMLElement} element
* @param {boolean} visible
*/
const onVisibilityChange = function (element, visible) {
if (visible) {
element.style.display = '';
Expand All @@ -29,12 +39,25 @@ if (!aardvark.golden) {
}
}

/**
* @param {HTMLElement} element
* @param {string} logicalZIndex
* @param {string} defaultZIndex
*/
const onVirtualZIndexChange = function (element, logicalZIndex, defaultZIndex) {
element.style.zIndex = defaultZIndex;
}

/**
* @param {HTMLElement} layoutElement
* @param {boolean} isPopout
* @param {boolean} setPopoutTitle
*/
const createInstance = function (layoutElement, isPopout, setPopoutTitle) {
const components = new Map(); // Currently bound components
/** @type {Map<any, {rootHtmlElement: HTMLElement}>} */
const components = new Map(); // Currently bound

/** @type {Map<string, HTMLElement>} */
const elements = new Map(); // Elements to keep alive and hide if their component is unbound

const onBindComponent = function (container, itemConfig) {
Expand Down Expand Up @@ -163,12 +186,20 @@ if (!aardvark.golden) {
return instance;
}

/**
* @param {HTMLElement} layoutElement
* @param {*} config
*/
aardvark.golden.setLayout = function (layoutElement, config) {
const instance = aardvark.golden.instances.get(layoutElement.id);
instance.layout.closeAllOpenPopouts(true);
instance.layout.loadLayout(config);
}

/**
* @param {HTMLElement} layoutElement
* @param {string | undefined} key
*/
aardvark.golden.saveLayout = function (layoutElement, key) {
const instance = aardvark.golden.instances.get(layoutElement.id);

Expand All @@ -182,6 +213,10 @@ if (!aardvark.golden) {
}
}

/**
* @param {HTMLElement} layoutElement
* @param {string | undefined} key
*/
aardvark.golden.loadLayout = function (layoutElement, key) {
const instance = aardvark.golden.instances.get(layoutElement.id);

Expand All @@ -201,6 +236,10 @@ if (!aardvark.golden) {
}
}

/**
* @param {HTMLElement} layoutElement
* @param {*} config
*/
aardvark.golden.createLayout = function (layoutElement, config) {
var instance = aardvark.golden.instances.get(layoutElement.id);
const isPopout = (config === undefined);
Expand All @@ -218,6 +257,9 @@ if (!aardvark.golden) {
}
}

/**
* @param {HTMLElement} layoutElement
*/
aardvark.golden.destroyLayout = function (layoutElement) {
const instance = aardvark.golden.instances.get(layoutElement.id);

Expand Down
5 changes: 3 additions & 2 deletions src/Scratch/25 - GoldenLayout/App.fs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
module Inc.App
module Golden.App

open Aardvark.UI
open Aardvark.UI.Primitives
open Aardvark.UI.Primitives.Golden

open Aardvark.Base
open FSharp.Data.Adaptive
open Aardvark.Rendering
open Inc.Model
open Golden.Model

let initialTitle = "Golden Layout Example"

Expand Down
2 changes: 1 addition & 1 deletion src/Scratch/25 - GoldenLayout/Model.fs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Inc.Model
namespace Golden.Model

open Aardvark.UI.Primitives
open Adaptify
Expand Down
6 changes: 5 additions & 1 deletion src/Scratch/25 - GoldenLayout/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ open Aardvark.Application.Slim
open Aardvark.UI
open Aardvark.UI.Primitives.Golden
open Aardium
open Inc
open Golden

[<EntryPoint; STAThread>]
let main argv =
Expand All @@ -15,6 +15,8 @@ let main argv =
use app = new OpenGlApplication()
let instance = App.app |> App.start

Config.defaultDocumentTitle <- App.initialTitle

// use can use whatever suave server to start you mutable app.
// startServerLocalhost is one of the convinience functions which sets up
// a server without much boilerplate.
Expand All @@ -34,6 +36,8 @@ let main argv =
url "http://localhost:4321/"
width 1024
height 768
title App.initialTitle
dynamicTitle true
debug true
log (fun msg -> Report.Line(2, $"[Aardium] %s{msg}"))
}
Expand Down

0 comments on commit 3157e84

Please sign in to comment.