aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/TabDocView.tsx
diff options
context:
space:
mode:
authormehekj <mehek.jethani@gmail.com>2023-01-13 18:11:34 -0500
committermehekj <mehek.jethani@gmail.com>2023-01-13 18:11:34 -0500
commit82de335e0643f907e44cb193c9b2c6da1b3cbaf1 (patch)
treee72a74f8b18bfd1e9d6f7262a0fb5203d82b6921 /src/client/views/collections/TabDocView.tsx
parent73d3c63658c4bdf3268ea81a02eb96566869b855 (diff)
parent6d32fe60ce32d650a2ba0d5eb8e36dccb591521f (diff)
Merge branch 'master' into schema-mehek
Diffstat (limited to 'src/client/views/collections/TabDocView.tsx')
-rw-r--r--src/client/views/collections/TabDocView.tsx99
1 files changed, 46 insertions, 53 deletions
diff --git a/src/client/views/collections/TabDocView.tsx b/src/client/views/collections/TabDocView.tsx
index 31ed5a83b..cd58319cb 100644
--- a/src/client/views/collections/TabDocView.tsx
+++ b/src/client/views/collections/TabDocView.tsx
@@ -11,7 +11,7 @@ import { List } from '../../../fields/List';
import { FieldId } from '../../../fields/RefField';
import { listSpec } from '../../../fields/Schema';
import { ScriptField } from '../../../fields/ScriptField';
-import { BoolCast, Cast, NumCast, StrCast } from '../../../fields/Types';
+import { BoolCast, Cast, DocCast, NumCast, StrCast } from '../../../fields/Types';
import { emptyFunction, lightOrDark, returnEmptyDoclist, returnFalse, returnTrue, setupMoveUpEvents, simulateMouseClick, Utils } from '../../../Utils';
import { DocServer } from '../../DocServer';
import { DocUtils } from '../../documents/Documents';
@@ -26,7 +26,7 @@ import { DashboardView } from '../DashboardView';
import { Colors, Shadows } from '../global/globalEnums';
import { LightboxView } from '../LightboxView';
import { MainView } from '../MainView';
-import { DocFocusOptions, DocumentView, DocumentViewProps } from '../nodes/DocumentView';
+import { DocFocusOptions, DocumentView, DocumentViewProps, OpenWhere, OpenWhereMod } from '../nodes/DocumentView';
import { DashFieldView } from '../nodes/formattedText/DashFieldView';
import { PinProps, PresBox, PresMovement } from '../nodes/trails';
import { DefaultStyleProvider, StyleProp } from '../StyleProvider';
@@ -55,6 +55,11 @@ export class TabDocView extends React.Component<TabDocViewProps> {
@computed get layoutDoc() {
return this._document && Doc.Layout(this._document);
}
+ @computed get tabBorderColor() {
+ const highlight = DefaultStyleProvider(this._document, undefined, StyleProp.Highlighting);
+ if (highlight?.highlightIndex >= Doc.DocBrushStatus.highlighted) return highlight.highlightColor;
+ return 'transparent';
+ }
@computed get tabColor() {
let tabColor = StrCast(this._document?._backgroundColor, StrCast(this._document?.backgroundColor, DefaultStyleProvider(this._document, undefined, StyleProp.BackgroundColor)));
if (tabColor === 'transparent') return 'black';
@@ -147,17 +152,15 @@ export class TabDocView extends React.Component<TabDocViewProps> {
ReactDOM.createRoot(closeWrap).render(closeIcon);
tab.reactComponents = [iconWrap, closeWrap];
tab.element[0].prepend(iconWrap);
- tab._disposers.layerDisposer = reaction(
- () => ({ layer: tab.DashDoc.activeLayer, color: this.tabColor }),
- ({ layer, color }) => {
- // console.log("TabDocView: " + this.tabColor);
- // console.log("lightOrDark: " + lightOrDark(this.tabColor));
+ tab._disposers.color = reaction(
+ () => ({ color: this.tabColor, borderColor: this.tabBorderColor }),
+ coloring => {
const textColor = lightOrDark(this.tabColor); //not working with StyleProp.Color
titleEle.style.color = textColor;
- titleEle.style.backgroundColor = 'transparent';
+ titleEle.style.backgroundColor = coloring.borderColor;
iconWrap.style.color = textColor;
closeWrap.style.color = textColor;
- tab.element[0].style.background = !layer ? color : 'dimgrey';
+ tab.element[0].style.background = coloring.color;
},
{ fireImmediately: true }
);
@@ -193,11 +196,12 @@ export class TabDocView extends React.Component<TabDocViewProps> {
() => SelectionManager.Views().some(v => v.topMost && v.props.Document === doc),
action(selected => {
if (selected) this._activated = true;
- const toggle = tab.element[0].children[1].children[0] as HTMLInputElement;
+ const toggle = tab.element[0].children[2].children[0] as HTMLInputElement;
selected && tab.contentItem !== tab.header.parent.getActiveContentItem() && UndoManager.RunInBatch(() => tab.header.parent.setActiveContentItem(tab.contentItem), 'tab switch');
- // toggle.style.fontWeight = selected ? "bold" : "";
+ toggle.style.fontWeight = selected ? 'bold' : '';
// toggle.style.textTransform = selected ? "uppercase" : "";
- })
+ }),
+ { fireImmediately: true }
);
// highlight the tab when the tab document is brushed in any part of the UI
@@ -226,7 +230,7 @@ export class TabDocView extends React.Component<TabDocViewProps> {
* Adds a document to the presentation view
**/
@action
- public static PinDoc(docs: Doc | Doc[], pinProps?: PinProps) {
+ public static PinDoc(docs: Doc | Doc[], pinProps: PinProps) {
const docList = docs instanceof Doc ? [docs] : docs;
const batch = UndoManager.StartBatch('pinning doc');
@@ -243,8 +247,9 @@ export class TabDocView extends React.Component<TabDocViewProps> {
alert('Cannot pin presentation document to itself');
return;
}
- const pinDoc = Doc.MakeAlias(doc);
- pinDoc.presentationTargetDoc = doc;
+ const anchorDoc = DocumentManager.Instance.getDocumentView(doc)?.ComponentView?.getAnchor?.();
+ const pinDoc = Doc.MakeAlias(anchorDoc ?? doc);
+ pinDoc.presentationTargetDoc = anchorDoc ?? doc;
pinDoc.title = doc.title + ' - Slide';
pinDoc.data = new List<Doc>(); // the children of the alias' layout are the presentation slide children. the alias' data field might be children of a collection, PDF data, etc -- in any case we don't want the tree view to "see" this data
pinDoc.presMovement = doc.type === DocumentType.SCRIPTING || pinProps?.pinDocLayout ? PresMovement.None : PresMovement.Zoom;
@@ -268,7 +273,7 @@ export class TabDocView extends React.Component<TabDocViewProps> {
pinDoc.presStartTime = NumCast(doc.clipStart);
pinDoc.presEndTime = NumCast(doc.clipEnd, duration);
}
- PresBox.pinDocView(pinDoc, pinProps, doc);
+ PresBox.pinDocView(pinDoc, pinProps.pinDocContent ? { ...pinProps, pinData: PresBox.pinDataTypes(doc) } : pinProps, doc);
pinDoc.onClick = ScriptField.MakeFunction('navigateToDoc(self.presentationTargetDoc, self)');
Doc.AddDocToList(curPres, 'data', pinDoc, presSelected);
//save position
@@ -277,6 +282,11 @@ export class TabDocView extends React.Component<TabDocViewProps> {
pinDoc.title = doc.title + ' (move)';
pinDoc.presMovement = PresMovement.Pan;
}
+ if (pinProps?.currentFrame !== undefined) {
+ pinDoc.presCurrentFrame = pinProps?.currentFrame;
+ pinDoc.title = doc.title + ' (move)';
+ pinDoc.presMovement = PresMovement.Pan;
+ }
if (pinDoc.isInkMask) {
pinDoc.presHideAfter = true;
pinDoc.presHideBefore = true;
@@ -293,8 +303,8 @@ export class TabDocView extends React.Component<TabDocViewProps> {
) {
const docs = Cast(Doc.MyOverlayDocs.data, listSpec(Doc), []);
if (docs.includes(curPres)) docs.splice(docs.indexOf(curPres), 1);
- CollectionDockingView.AddSplit(curPres, 'right');
- setTimeout(() => DocumentManager.Instance.jumpToDocument(docList.lastElement(), false, undefined, []), 100); // keeps the pinned doc in view since the sidebar shifts things
+ CollectionDockingView.AddSplit(curPres, OpenWhereMod.right);
+ setTimeout(() => DocumentManager.Instance.jumpToDocument(docList.lastElement(), { willPan: true }, undefined, []), 100); // keeps the pinned doc in view since the sidebar shifts things
}
setTimeout(batch.end, 500); // need to wait until dockingview (goldenlayout) updates all its structurs
}
@@ -340,31 +350,21 @@ export class TabDocView extends React.Component<TabDocViewProps> {
// "replace:right" - will replace the stack on the right named "right" if it exists, or create a stack on the right with that name,
// "replace:monkeys" - will replace any tab that has the label 'monkeys', or a tab with that label will be created by default on the right
// inPlace - will add the document to any collection along the path from the document to the docking view that has a field isInPlaceContainer. if none is found, inPlace adds a tab to current stack
- addDocTab = (doc: Doc, location: string) => {
+ addDocTab = (doc: Doc, location: OpenWhere) => {
SelectionManager.DeselectAll();
- const locationFields = doc._viewType === CollectionViewType.Docking ? ['dashboard'] : location.split(':');
- const locationParams = locationFields.length > 1 ? locationFields[1] : '';
- switch (locationFields[0]) {
- case 'dashboard':
- return DashboardView.openDashboard(doc);
- case 'close':
- return CollectionDockingView.CloseSplit(doc, locationParams);
- case 'fullScreen':
- return CollectionDockingView.OpenFullScreen(doc);
- case 'replace':
- return CollectionDockingView.ReplaceTab(doc, locationParams, this.stack);
- // case "lightbox": {
- // // TabDocView.PinDoc(doc, { hidePresBox: true });
- // return LightboxView.AddDocTab(doc, location, undefined, this.addDocTab);
- // }
- case 'lightbox':
- return LightboxView.AddDocTab(doc, location, undefined, this.addDocTab);
- case 'toggle':
- return CollectionDockingView.ToggleSplit(doc, locationParams, this.stack);
- case 'inPlace':
- case 'add':
- default:
- return CollectionDockingView.AddSplit(doc, locationParams, this.stack);
+ const whereFields = doc._viewType === CollectionViewType.Docking ? [OpenWhere.dashboard] : location.split(':');
+ const whereMods: OpenWhereMod = whereFields.length > 1 ? (whereFields[1] as OpenWhereMod) : OpenWhereMod.none;
+ if (doc.dockingConfig) return DashboardView.openDashboard(doc);
+ // prettier-ignore
+ switch (whereFields[0]) {
+ case OpenWhere.inPlace: // fall through to lightbox
+ case OpenWhere.lightbox: return LightboxView.AddDocTab(doc, location, undefined, this.addDocTab);
+ case OpenWhere.dashboard: return DashboardView.openDashboard(doc);
+ case OpenWhere.fullScreen: return CollectionDockingView.OpenFullScreen(doc);
+ case OpenWhere.close: return CollectionDockingView.CloseSplit(doc, whereMods);
+ case OpenWhere.replace: return CollectionDockingView.ReplaceTab(doc, whereMods, this.stack);
+ case OpenWhere.toggle: return CollectionDockingView.ToggleSplit(doc, whereMods, this.stack);
+ case OpenWhere.add:default:return CollectionDockingView.AddSplit(doc, whereMods, this.stack);
}
};
remDocTab = (doc: Doc | Doc[]) => {
@@ -382,17 +382,10 @@ export class TabDocView extends React.Component<TabDocViewProps> {
@action
focusFunc = (doc: Doc, options: DocFocusOptions) => {
const shrinkwrap = options?.originalTarget === this._document && this.view?.ComponentView?.shrinkWrap;
- if (options?.willZoom !== false && shrinkwrap && this._document) {
- const focusSpeed = NumCast(this._document.focusSpeed, 500);
+ if (options?.willPanZoom !== false && shrinkwrap && this._document) {
+ const focusSpeed = options.zoomTime ?? 500;
shrinkwrap();
- this._document._viewTransition = `transform ${focusSpeed}ms`;
- setTimeout(
- action(() => {
- this._document!._viewTransition = undefined;
- options?.afterFocus?.(false);
- }),
- focusSpeed
- );
+ this._view?.setViewTransition('transform', focusSpeed, () => options?.afterFocus?.(false));
} else {
options?.afterFocus?.(false);
}
@@ -501,7 +494,7 @@ interface TabMinimapViewProps {
document: Doc;
hideMinimap: () => boolean;
tabView: () => DocumentView | undefined;
- addDocTab: (doc: Doc, where: string) => boolean;
+ addDocTab: (doc: Doc, where: OpenWhere) => boolean;
PanelWidth: () => number;
PanelHeight: () => number;
background: () => string;