public BuilderViewportDragger( BuilderPaneWindow paneWindow, VisualElement root, BuilderSelection selection, BuilderViewport viewport = null, BuilderParentTracker parentTracker = null) : base(paneWindow, root, selection, viewport, parentTracker) { }
public BuilderDragger( BuilderPaneWindow paneWindow, VisualElement root, BuilderSelection selection, BuilderViewport viewport = null, BuilderParentTracker parentTracker = null) { m_PaneWindow = paneWindow; m_Root = root; this.viewport = viewport; m_Canvas = viewport?.documentRootElement; m_Selection = selection; m_ParentTracker = parentTracker; m_PlacementIndicator = viewport?.placementIndicator; if (m_PlacementIndicator != null) { m_PlacementIndicator.documentRootElement = m_Canvas; } activators = new List <ManipulatorActivationFilter>(); activators.Add(new ManipulatorActivationFilter { button = MouseButton.LeftMouse }); m_Active = false; m_WeStartedTheDrag = false; m_DraggedElement = CreateDraggedElement(); m_DraggedElement.AddToClassList(s_DraggerPreviewClassName); m_Root.Add(m_DraggedElement); }
public BuilderLibraryDragger( BuilderPaneWindow paneWindow, VisualElement root, BuilderSelection selection, BuilderViewport viewport, BuilderParentTracker parentTracker, VisualElement explorerContainer, BuilderTooltipPreview tooltipPreview) : base(paneWindow, root, selection, viewport, parentTracker) { builderHierarchyRoot = explorerContainer; m_TooltipPreview = tooltipPreview; }
public BuilderViewport(BuilderPaneWindow paneWindow, BuilderSelection selection, BuilderElementContextMenu contextMenuManipulator) { m_PaneWindow = paneWindow; m_Selection = selection; m_ContextMenuManipulator = contextMenuManipulator; AddToClassList("unity-builder-viewport"); var template = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>(BuilderConstants.UIBuilderPackagePath + "/BuilderViewport.uxml"); template.CloneTree(this); m_Toolbar = this.Q("toolbar"); m_ViewportWrapper = this.Q("viewport-wrapper"); m_Viewport = this.Q("viewport"); m_Surface = this.Q("viewport-surface"); m_Surface.pickingMode = PickingMode.Ignore; m_Canvas = this.Q <BuilderCanvas>("canvas"); m_Canvas.document = paneWindow.document; m_SharedStylesAndDocumentElement = this.Q("shared-styles-and-document"); m_StyleSelectorElementContainer = this.Q(BuilderConstants.StyleSelectorElementContainerName); m_DocumentElement = this.Q("document"); m_Canvas.documentElement = m_DocumentElement; m_PickOverlay = this.Q("pick-overlay"); m_HighlightOverlay = this.Q("highlight-overlay"); m_BuilderParentTracker = this.Q <BuilderParentTracker>("parent-tracker"); m_BuilderResizer = this.Q <BuilderResizer>("resizer"); m_BuilderMover = this.Q <BuilderMover>("mover"); m_BuilderAnchorer = this.Q <BuilderAnchorer>("anchorer"); m_BuilderZoomer = new BuilderZoomer(this); m_BuilderPanner = new BuilderPanner(this); m_BuilderMover.parentTracker = m_BuilderParentTracker; m_PickOverlay.RegisterCallback <MouseDownEvent>(OnPick); m_PickOverlay.RegisterCallback <MouseMoveEvent>(OnHover); m_PickOverlay.RegisterCallback <MouseLeaveEvent>(OnMouseLeave); m_Viewport.RegisterCallback <MouseDownEvent>(OnMissPick); m_Viewport.RegisterCallback <GeometryChangedEvent>(OnGeometryChanged); m_ContextMenuManipulator?.RegisterCallbacksOnTarget(m_Viewport); // Make sure this gets focus when the pane gets focused. primaryFocusable = this; focusable = true; // Restore the zoom scale zoomScale = paneWindow.document.viewportZoomScale; contentOffset = paneWindow.document.viewportContentOffset; }
public BuilderViewport(BuilderPaneWindow paneWindow, BuilderSelection selection) { m_PaneWindow = paneWindow; m_Selection = selection; AddToClassList("unity-builder-viewport"); var template = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>(BuilderConstants.UIBuilderPackagePath + "/BuilderViewport.uxml"); template.CloneTree(this); m_Toolbar = this.Q("toolbar"); m_ViewportWrapper = this.Q("viewport-wrapper"); m_Viewport = this.Q("viewport"); m_Canvas = this.Q <BuilderCanvas>("canvas"); m_Canvas.document = paneWindow.document; m_SharedStylesAndDocumentElement = this.Q("shared-styles-and-document"); m_StyleSelectorElementContainer = this.Q(BuilderConstants.StyleSelectorElementContainerName); m_DocumentElement = this.Q("document"); m_PickOverlay = this.Q("pick-overlay"); m_HighlightOverlay = this.Q("highlight-overlay"); m_BuilderParentTracker = this.Q <BuilderParentTracker>("parent-tracker"); m_BuilderResizer = this.Q <BuilderResizer>("resizer"); m_BuilderMover = this.Q <BuilderMover>("mover"); m_BuilderAnchorer = this.Q <BuilderAnchorer>("anchorer"); m_FitCanvasButton = this.Q <Button>("fit-canvas-button"); m_FitCanvasButton.clickable.clicked += FitCanvas; m_Canvas.RegisterCallback <GeometryChangedEvent>(VerifyCanvasStillFitsViewport); m_Viewport.RegisterCallback <GeometryChangedEvent>(VerifyCanvasStillFitsViewport); m_BuilderMover.parentTracker = m_BuilderParentTracker; m_PickOverlay.RegisterCallback <MouseDownEvent>(OnPick); m_PickOverlay.RegisterCallback <MouseMoveEvent>(OnHover); m_PickOverlay.RegisterCallback <MouseLeaveEvent>(OnMouseLeave); m_Viewport.RegisterCallback <MouseDownEvent>(OnMissPick); // Make sure this gets focus when the pane gets focused. primaryFocusable = this; this.focusable = true; }
public BuilderViewport(BuilderPaneWindow paneWindow, BuilderSelection selection, BuilderElementContextMenu contextMenuManipulator) { m_PaneWindow = paneWindow; m_Selection = selection; m_ContextMenuManipulator = contextMenuManipulator; AddToClassList("unity-builder-viewport"); var template = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>(BuilderConstants.UIBuilderPackagePath + "/BuilderViewport.uxml"); template.CloneTree(this); m_Toolbar = this.Q("toolbar"); m_ViewportWrapper = this.Q("viewport-wrapper"); m_Viewport = this.Q("viewport"); m_Surface = this.Q("viewport-surface"); m_Surface.pickingMode = PickingMode.Ignore; m_Canvas = this.Q <BuilderCanvas>("canvas"); m_Canvas.document = paneWindow.document; m_SharedStylesAndDocumentElement = this.Q("shared-styles-and-document"); m_SharedStylesAndDocumentElement.pseudoStates |= PseudoStates.Root; // To apply variables of the active theme that are defined in the :root selector m_StyleSelectorElementContainer = this.Q(BuilderConstants.StyleSelectorElementContainerName); m_DocumentElement = this.Q("document"); m_Canvas.documentElement = m_DocumentElement; m_EditorLayer = this.Q("__unity-editor-layer"); m_EditorLayer.AddToClassList(BuilderConstants.HiddenStyleClassName); m_TextEditor = this.Q <TextField>("__unity-text-editor"); m_Canvas.editorLayer = m_EditorLayer; m_PickOverlay = this.Q("pick-overlay"); m_HighlightOverlay = this.Q("highlight-overlay"); m_BuilderParentTracker = this.Q <BuilderParentTracker>("parent-tracker"); m_BuilderSelectionIndicator = this.Q <BuilderSelectionIndicator>("selection-indicator"); m_BuilderResizer = this.Q <BuilderResizer>("resizer"); m_BuilderMover = this.Q <BuilderMover>("mover"); m_BuilderAnchorer = this.Q <BuilderAnchorer>("anchorer"); m_BuilderZoomer = new BuilderZoomer(this); m_BuilderPanner = new BuilderPanner(this); m_BuilderMover.parentTracker = m_BuilderParentTracker; m_PickOverlay.RegisterCallback <MouseDownEvent>(OnPick); m_PickOverlay.RegisterCallback <MouseMoveEvent>(OnHover); m_PickOverlay.RegisterCallback <MouseLeaveEvent>(OnMouseLeave); m_Viewport.RegisterCallback <MouseDownEvent>(OnMissPick); m_Viewport.RegisterCallback <GeometryChangedEvent>(OnGeometryChanged); m_Canvas.header.AddManipulator(new Clickable(OnCanvasHeaderClick)); m_ContextMenuManipulator?.RegisterCallbacksOnTarget(m_Viewport); // Make sure this gets focus when the pane gets focused. primaryFocusable = this; focusable = true; // Restore the zoom scale zoomScale = paneWindow.document.viewportZoomScale; contentOffset = paneWindow.document.viewportContentOffset; // Repaint bug workaround. m_CheckerboardBackground = this.Q <CheckerboardBackground>(); RegisterCallback <BlurEvent>(e => { m_CheckerboardBackground.MarkDirtyRepaint(); }); RegisterCallback <FocusEvent>(e => { m_CheckerboardBackground.MarkDirtyRepaint(); }); }