@deephaven/golden-layout
Version:
A multi-screen javascript Layout manager
157 lines • 6.47 kB
TypeScript
import AbstractContentItem from './AbstractContentItem';
import { Splitter } from '../controls';
import type LayoutManager from '../LayoutManager';
import type { ColumnItemConfig, ItemConfig, RowItemConfig } from '../config';
export default class RowOrColumn extends AbstractContentItem {
isRow: boolean;
isColumn: boolean;
childElementContainer: JQuery<HTMLElement>;
parent: AbstractContentItem | null;
private _splitter;
private _splitterSize;
private _splitterGrabSize;
private _isColumn;
private _dimension;
private _splitterPosition;
private _splitterMinPosition;
private _splitterMaxPosition;
constructor(isColumn: true, layoutManager: LayoutManager, config: ColumnItemConfig, parent: AbstractContentItem | null);
constructor(isColumn: false, layoutManager: LayoutManager, config: RowItemConfig, parent: AbstractContentItem | null);
/**
* Add a new contentItem to the Row or Column
*
* @param contentItem
* @param index The position of the new item within the Row or Column.
* If no index is provided the item will be added to the end
* @param _$suspendResize If true the items won't be resized. This will leave the item in
* an inconsistent state and is only intended to be used if multiple
* children need to be added in one go and resize is called afterwards
*/
addChild(contentItem: AbstractContentItem | ItemConfig, index?: number, _$suspendResize?: boolean): void;
/**
* Removes a child of this element
*
* @param contentItem
* @param keepChild If true the child will be removed, but not destroyed
*/
removeChild(contentItem: AbstractContentItem, keepChild: boolean): void;
/**
* Replaces a child of this Row or Column with another contentItem
*
* @param oldChild The old child to replace
* @param newChild The new child to take the old child's place
* @param destroyOldChild If the old child should be destroyed or not
*/
replaceChild(oldChild: AbstractContentItem, newChild: AbstractContentItem, destroyOldChild?: boolean): void;
/**
* Called whenever the dimensions of this item or one of its parents change
*/
setSize(): void;
/**
* Invoked recursively by the layout manager. AbstractContentItem.init appends
* the contentItem's DOM elements to the container, RowOrColumn init adds splitters
* in between them
*/
_$init(): void;
/**
* Turns the relative sizes calculated by _calculateRelativeSizes into
* absolute pixel values and applies them to the children's DOM elements
*
* Assigns additional pixels to counteract Math.floor
*/
_setAbsoluteSizes(): void;
/**
* Calculates the absolute sizes of all of the children of this Item.
* @returns {object} - Set with absolute sizes and additional pixels.
*/
_calculateAbsoluteSizes(): {
itemSizes: number[];
additionalPixel: number;
totalWidth: number;
totalHeight: number;
};
/**
* Calculates the relative sizes of all children of this Item. The logic
* is as follows:
*
* - Add up the total size of all items that have a configured size
*
* - If the total == 100 (check for floating point errors)
* Excellent, job done
*
* - If the total is > 100,
* set the size of items without set dimensions to 1/3 and add this to the total
* set the size off all items so that the total is hundred relative to their original size
*
* - If the total is < 100
* If there are items without set dimensions, distribute the remainder to 100 evenly between them
* If there are no items without set dimensions, increase all items sizes relative to
* their original size so that they add up to 100
*/
_calculateRelativeSizes(): void;
/**
* Adjusts the column widths to respect the dimensions minItemWidth if set.
*/
_respectMinItemWidth(): void;
/**
* Instantiates a new lm.controls.Splitter, binds events to it and adds
* it to the array of splitters at the position specified as the index argument
*
* What it doesn't do though is append the splitter to the DOM
*
* @param index The position of the splitter
* @returns The created splitter
*/
_createSplitter(index: number): Splitter;
/**
* Locates the instance of lm.controls.Splitter in the array of
* registered splitters and returns a map containing the contentItem
* before and after the splitters, both of which are affected if the
* splitter is moved
*
* @param splitter
*
* @returns A map of contentItems that the splitter affects
*/
_getItemsForSplitter(splitter: Splitter): {
before: AbstractContentItem;
after: AbstractContentItem;
};
/**
* Gets the minimum dimensions for the given item configuration array
* @param item
* @private
*/
_getMinimumDimensions(arr: {
minWidth?: number;
minHeight?: number;
}[]): {
horizontal: number;
vertical: number;
};
/**
* Invoked when a splitter's dragListener fires dragStart. Calculates the splitters
* movement area once (so that it doesn't need calculating on every mousemove event)
*
* @param splitter
*/
_onSplitterDragStart(splitter: Splitter): void;
/**
* Invoked when a splitter's DragListener fires drag. Updates the splitters DOM position,
* but not the sizes of the elements the splitter controls in order to minimize resize events
*
* @param splitter
* @param offsetX Relative pixel values to the splitters original position. Can be negative
* @param offsetY Relative pixel values to the splitters original position. Can be negative
*/
_onSplitterDrag(splitter: Splitter, offsetX: number, offsetY: number): void;
/**
* Invoked when a splitter's DragListener fires dragStop. Resets the splitters DOM position,
* and applies the new sizes to the elements before and after the splitter and their children
* on the next animation frame
*
* @param {lm.controls.Splitter} splitter
*/
_onSplitterDragStop(splitter: Splitter): void;
}
//# sourceMappingURL=RowOrColumn.d.ts.map