UNPKG

dockview-core

Version:

Zero dependency layout manager supporting tabs, groups, grids and splitviews for vanilla TypeScript

96 lines (95 loc) 4.27 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.FloatingTitleBar = void 0; var events_1 = require("../../../events"); var lifecycle_1 = require("../../../lifecycle"); var dom_1 = require("../../../dom"); var groupDragSource_1 = require("./groupDragSource"); /** * A dedicated, blank drag handle rendered above a floating group's tab bar. * * It plays the same dual role the tab-bar void container plays today: a plain * pointer-drag moves the floating window (wired by the overlay via * `setupDrag`), while a shift+drag (mouse) or long-press (touch) detaches the * group to redock it into the grid. The redock half is provided by the shared * {@link GroupDragSource}; the move half is owned by the overlay. * * The bar is intentionally contentless — styling is driven entirely through * the `--dv-floating-titlebar-*` theme variables. */ var FloatingTitleBar = /** @class */ (function (_super) { __extends(FloatingTitleBar, _super); function FloatingTitleBar(accessor, group) { var _this = _super.call(this) || this; _this.accessor = accessor; _this._onDragStart = new events_1.Emitter(); _this.onDragStart = _this._onDragStart.event; _this._group = group; _this._element = document.createElement('div'); _this._element.className = 'dv-floating-titlebar'; _this.addDisposables(_this._onDragStart, (0, events_1.addDisposableListener)(_this._element, 'pointerdown', function () { _this.accessor.doSetGroupActive(_this._group); }), // Shift+pointerdown marks the event so the overlay's // move-the-float drag doesn't fire alongside the HTML5 redock // drag. See VoidContainer for the same disambiguation. (0, events_1.addDisposableListener)(_this._element, 'pointerdown', function (e) { if (e.shiftKey) { (0, dom_1.quasiPreventDefault)(e); } }, true)); _this.dragSource = new groupDragSource_1.GroupDragSource({ element: _this._element, accessor: _this.accessor, // resolve lazily so the drag source follows anchor reassignment group: function () { return _this._group; }, }); _this.addDisposables(_this.dragSource, _this.dragSource.onDragStart(function (event) { _this._onDragStart.fire(event); })); return _this; } Object.defineProperty(FloatingTitleBar.prototype, "element", { get: function () { return this._element; }, enumerable: false, configurable: true }); Object.defineProperty(FloatingTitleBar.prototype, "group", { /** The window's current anchor group — the one this bar drags/activates. */ get: function () { return this._group; }, enumerable: false, configurable: true }); /** * Retarget the bar at a new anchor group. Called when the original anchor * leaves a multi-group floating window and another member is promoted, so * the bar keeps activating/redocking a group that actually lives here. */ FloatingTitleBar.prototype.setGroup = function (group) { this._group = group; }; FloatingTitleBar.prototype.updateDragAndDropState = function () { this.dragSource.updateDragAndDropState(); }; return FloatingTitleBar; }(lifecycle_1.CompositeDisposable)); exports.FloatingTitleBar = FloatingTitleBar;