private void RefreshPanelChoices() { m_PanelChoices.Clear(); m_PanelToEditorWindow.Clear(); List <GUIView> guiViews = new List <GUIView>(); GUIViewDebuggerHelper.GetViews(guiViews); var it = UIElementsUtility.GetPanelsIterator(); while (it.MoveNext()) { // Skip this window GUIView view = guiViews.FirstOrDefault(v => v.GetInstanceID() == it.Current.Key); HostView hostView = view as HostView; if (hostView != null && hostView.actualView == this) { continue; } var p = it.Current.Value; m_PanelChoices.Add(new PanelChoice(p)); if (hostView != null && hostView.actualView != null) { m_PanelToEditorWindow.Add(p, hostView.actualView); } } var menu = m_PanelSelect.menu; var menuItemsCount = menu.MenuItems().Count; // Clear previous items for (int i = 0; i < menuItemsCount; i++) { menu.RemoveItemAt(0); } foreach (var panelChoice in m_PanelChoices) { menu.AppendAction(panelChoice.ToString(), OnSelectPanel, DropdownMenuAction.AlwaysEnabled, panelChoice); } }
private void RequestNodeCreation(VisualElement target, int index, Vector2 position) { if (nodeCreationRequest == null) { return; } GUIView guiView = elementPanel.ownerObject as GUIView; if (guiView == null) { return; } Vector2 screenPoint = guiView.screenPosition.position + position; nodeCreationRequest(new NodeCreationContext() { screenMousePosition = screenPoint, target = target, index = index }); }
protected virtual void PopulatePanelChoices(List <IPanelChoice> panelChoices) { List <GUIView> guiViews = new List <GUIView>(); GUIViewDebuggerHelper.GetViews(guiViews); var it = UIElementsUtility.GetPanelsIterator(); while (it.MoveNext()) { // Skip this debugger window GUIView view = guiViews.FirstOrDefault(v => v.GetInstanceID() == it.Current.Key); HostView hostView = view as HostView; if (!m_DebuggerWindow.CanDebugView(hostView)) { continue; } var p = it.Current.Value; panelChoices.Add(new PanelChoice(p)); } }
/// <summary> /// Undoes the set-parent command. Instead of doing the opposite of the /// Execute function, we simply restore everything to their original values /// </summary> /// <returns></returns> public override bool Undo() { if (mNewParent == null) { return(false); } for (int i = mControlStates.Count - 1; i >= 0; i--) { GUIControl control = mControlStates[i].mControl; GUIControl origParent = mControlStates[i].mParent; int origIndex = mControlStates[i].mIndex; GUIView view = (origParent is GUIView) ? origParent as GUIView : origParent.ParentView; if (view == control.ParentView) { view.SetNewParent(control, origParent, origIndex); foreach (ChannelState channelState in mControlStates[i].mChannelStates) { for (int j = 0; j < channelState.mChannel.KeyFrames.Count; j++) { channelState.mChannel.KeyFrames[j].Layout = (ControlLayout)channelState.mLayouts[j].Clone(); } } } else { control.ParentView.RemoveControl(control); view.AddControl(origParent, control); } control.Center = mControlStates[i].mCenter; control.Rotation = mControlStates[i].mRotation; control.Location = mControlStates[i].mLocation; } return(true); }
/// <summary> /// Undoes the set-parent command. Instead of doing the opposite of the /// Execute function, we simply restore everything to their original values /// </summary> /// <returns></returns> public override bool Undo() { for (int i = mControls.Count - 1; i >= 0; i--) { GUIControl control = mControls[i]; if (control is GUIView) { GUIView view = control as GUIView; GUIScene scene = view.Scene; scene.Views.Remove(view); scene.Views.Insert(mOriginalIndices[i], view); } else { GUIControl parent = control.Parent; parent.Controls.Remove(control, false); parent.Controls.Insert(mOriginalIndices[i], control); } } return(true); }
// Virtual so clients can override header behavior and rendering entirely public virtual void OnGUI(Rect rect, float xScroll) { Event evt = Event.current; if (m_GUIView == null) { m_GUIView = GUIView.current; } DetectSizeChanges(rect); if (m_ResizeToFit && evt.type == EventType.Repaint) { m_ResizeToFit = false; ResizeColumnsWidthsProportionally(rect.width - GUI.skin.verticalScrollbar.fixedWidth - state.widthOfAllVisibleColumns); } // We create a guiclip to let the header be able to scroll horizontally according to the tree view's horizontal scroll GUIClip.Push(rect, new Vector2(-xScroll, 0f), Vector2.zero, false); { Rect localRect = new Rect(0, 0, rect.width, rect.height); // Background ( We always add the width of the vertical scrollbar to accomodate if this is being shown below e.g by a tree view) float widthOfAllColumns = state.widthOfAllVisibleColumns; float backgroundWidth = (localRect.width > widthOfAllColumns ? localRect.width : widthOfAllColumns) + GUI.skin.verticalScrollbar.fixedWidth; Rect backgroundRect = new Rect(0, 0, backgroundWidth, localRect.height); GUI.Label(backgroundRect, GUIContent.none, DefaultStyles.background); // Context menu if (evt.type == EventType.ContextClick && backgroundRect.Contains(evt.mousePosition)) { evt.Use(); DoContextMenu(); } // Update column rects (cached for clients to have fast access to column rects by using GetCellRect) UpdateColumnHeaderRects(localRect); // Columns for (int v = 0; v < state.visibleColumns.Length; v++) { int columnIndex = state.visibleColumns[v]; MultiColumnHeaderState.Column column = state.columns[columnIndex]; Rect headerRect = m_ColumnRects[v]; const float limitHeightOfDivider = 4f; Rect dividerRect = new Rect(headerRect.xMax - 1, headerRect.y + limitHeightOfDivider, 1f, headerRect.height - 2 * limitHeightOfDivider); // Resize columns logic Rect dragRect = new Rect(dividerRect.x - m_DividerWidth * 0.5f, localRect.y, m_DividerWidth, localRect.height); bool hasControl; column.width = EditorGUI.WidthResizer(dragRect, column.width, column.minWidth, column.maxWidth, out hasControl); if (hasControl && evt.type == EventType.Repaint) { DrawColumnResizing(headerRect, column); } // Draw divider (can be overridden) DrawDivider(dividerRect, column); // Draw header (can be overridden) ColumnHeaderGUI(column, headerRect, columnIndex); } } GUIClip.Pop(); }
/* For tests */ public static bool HasGUIView(this VisualElement ve) { GUIView guiView = ve.elementPanel.ownerObject as GUIView; return(guiView != null); }
public HighlightData(GUIView view, IReadOnlyList <Rect> instructionRects, GUIStyle style) { View = view; InstructionRects = instructionRects; Style = style; }
/// <summary> /// Adds a sceneView node to the scene hierarchy /// </summary> /// <param name="sceneView"></param> /// <returns></returns> private void AddViewNode(GUIView view) { AddViewNode(view, -1); }
extern internal static void PrepareDragAndDropTestingInternal(GUIView guiView);
//first call after ctr, so we do init here public void Awake() { Debug.Log("GA WhichData::Awake"); //initialize sub components. string error = string.Empty; for(int i = Active; i < ModelCount; ++i) { m_shipModels[i] = new ShipModel(); m_guiViews[i] = new GUIView(); error += m_shipModels[i].Initialize(this, i); error += m_guiViews[i].Initialize(this, i); } if (error != string.Empty) { //They can fail, cascading a cleanup & shutdown of the mod. //TODOJEFFGIFFEN i teardowns Debug.Log("Giffen Aerospace WhichData error: " + error); return; } for (int i = Active; i < ModelCount; ++i) { //faultless inits m_selectedLists[i] = new List<DataPage>(); m_selectedDirty[i] = false; //passthrough the Awake events m_shipModels[i].OnAwake(); m_guiViews[i].OnAwake(); } GameEvents.onVesselChange.Add(OnVesselSwitchEvent); //load/launch/quick switch GameEvents.onVesselLoaded.Add(OnVesselLoaded); //when it physically loads (2.5kmish) instance = this; }
public TreeViewController(EditorWindow editorWindow, TreeViewState treeViewState) { this.m_GUIView = ((!editorWindow) ? GUIView.current : editorWindow.m_Parent); this.state = treeViewState; }
public static void ShowPopup(GUIView viewToUpdate) { instance.Show(viewToUpdate, null); }
/// <summary> /// Sets the control's new parent. This function will also fix up any /// other animations that references the control. /// </summary> /// <param name="control"></param> /// <param name="newParent"></param> private static void SetParent(GUIControl control, GUIControl newParent, int index) { GUIView view = (newParent is GUIView) ? newParent as GUIView : newParent.ParentView; Otter.Interface.Matrix invTransform = newParent.FullTransformInv; PointF center = PointF.Empty; float rotation = 0.0f; PointF location = PointF.Empty; Matrix oldTransformInv = control.TransformInv; Matrix newTransform = control.FullTransform * invTransform; Matrix toLocal = oldTransformInv * newTransform; GetComponents(control, ref newTransform, out center, out rotation, out location); if (control.ParentView == view) { GUIAnimation currentAnim = view.CurrentAnimation; uint currentFrame = currentAnim.Frame; foreach (GUIAnimation animation in view.Animations) { uint oldFrame = animation.Frame; GUIAnimationChannel channel = animation.GetAnimationChannel(control); if (channel == null) { continue; } view.CurrentAnimation = animation; foreach (KeyFrame keyFrame in channel.KeyFrames) { // This will update the control view.CurrentAnimation.Frame = keyFrame.Frame; PointF kfCenter = control.Center; float kfRotation = control.Rotation; PointF kfLocation = control.Location; Matrix kfTransform = control.Transform * toLocal; GetComponents(control, ref kfTransform, out kfCenter, out kfRotation, out kfLocation); keyFrame.Layout.Center = kfCenter; keyFrame.Layout.Rotation = kfRotation; keyFrame.Layout.Location = kfLocation; } animation.Frame = oldFrame; } view.CurrentAnimation = currentAnim; view.CurrentAnimation.Frame = currentFrame; view.SetNewParent(control, newParent, index); } else { control.ParentView.RemoveControl(control); view.AddControl(newParent, control); } control.Center = center; control.Rotation = rotation; control.Location = location; }
/// <summary> /// Constructor /// </summary> /// <param name="scene"></param> /// <param name="view"></param> public DeleteViewCommand(GUIScene scene, GUIView view) { mScene = scene; mView = view; mIndex = mScene.Views.IndexOf(mView); }
public GUIViewChunk() { m_inspectedView = default; m_inspectedEditorWindow = default; }
private void drawAnEditor(SoundManagerMainWindow.Editors displayOrNot, GUIView drawWindow, ref Vector2 scroll, ref bool foldout, bool scrollable, bool withBox) { if(SoundManagerMainWindow.getDisplayWindows((int)displayOrNot)){ drawWindow.SetSource(_shownSource); drawWindow.SetWithBox(withBox); if(scrollable){ scroll = EditorGUILayout.BeginScrollView(scroll); drawWindow.Show(); EditorGUILayout.EndScrollView(); } else{ foldout = EditorGUILayout.Foldout(foldout, displayOrNot.ToString()); if(foldout) drawWindow.Show(); } } }
public void SetSourceView() { m_SourceView = GUIView.current; }
internal void Init(IConflictResolver conflictResolver, IEnumerable <KeyCombination> keyCombinationSequence, IEnumerable <ShortcutEntry> entries, GUIView previouslyFocusedView) { m_PreviouslyFocusedView = previouslyFocusedView; m_ConflictResolver = conflictResolver; m_Entries = entries.ToList(); var multiColumnHeader = new MultiColumnHeader(m_MulticolumnHeaderState); multiColumnHeader.ResizeToFit(); m_ConflictListView = new ConflictListView(m_TreeViewState, multiColumnHeader, m_Entries); m_Header = string.Format(L10n.Tr("The binding \"{0}\" conflicts with multiple commands."), KeyCombination.SequenceToString(keyCombinationSequence)); }
private void mSceneTreeView_DragOver(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(typeof(TreeNodeAdv[])) && mSceneTreeView.DropPosition.Node != null) { TreeNodeAdv[] nodes = e.Data.GetData(typeof(TreeNodeAdv[])) as TreeNodeAdv[]; TreeNodeAdv parent = mSceneTreeView.DropPosition.Node; if (mSceneTreeView.DropPosition.Position != NodePosition.Inside) { parent = parent.Parent; } SceneNode parentSceneNode = parent.Tag as SceneNode; bool bParentIsView = parentSceneNode != null && parentSceneNode.Control is GUIView; foreach (TreeNodeAdv node in nodes) { SceneNode sceneNode = node.Tag as SceneNode; // Can't re-parent to one of its children if (!CheckNodeParent(parent, node)) { e.Effect = DragDropEffects.None; return; } // GUIViews can only be direct children of the root (scene) if (sceneNode.Control is GUIView && (parent != mSceneTreeView.Root)) { e.Effect = DragDropEffects.None; return; } if (!(sceneNode.Control is GUIView)) { GUIView parentView = sceneNode.Control.ParentView; GUIView targetParentView = null; if (parentSceneNode != null) { if (bParentIsView) { targetParentView = parentSceneNode.Control as GUIView; } else { targetParentView = parentSceneNode.Control.ParentView; } } // Can't reparent to a different view if (parentView != targetParentView) { e.Effect = DragDropEffects.None; return; } // Can't reparent to a non-GUIGroup if (!(parentSceneNode.Control is GUIGroup) && !(parentSceneNode.Control is GUIView)) { e.Effect = DragDropEffects.None; return; } } } e.Effect = e.AllowedEffect; } }
public void OnGUI(Rect rect, int keyboardControlID) { this.m_KeyboardControlID = keyboardControlID; Event current = Event.current; if (current.type == EventType.Repaint) { this.m_TotalRect = rect; } if (this.m_GUIView == null) { this.m_GUIView = GUIView.current; } if (this.m_GUIView != null && !this.m_GUIView.hasFocus && this.state.renameOverlay.IsRenaming()) { this.EndNameEditing(true); } if (this.m_GrabKeyboardFocus || (current.type == EventType.MouseDown && this.m_TotalRect.Contains(current.mousePosition))) { this.m_GrabKeyboardFocus = false; GUIUtility.keyboardControl = this.m_KeyboardControlID; this.m_AllowRenameOnMouseUp = true; this.Repaint(); } bool flag = this.HasFocus(); if (flag != this.m_HadFocusLastEvent && current.type != EventType.Layout) { this.m_HadFocusLastEvent = flag; if (flag) { if (current.type == EventType.MouseDown) { this.m_AllowRenameOnMouseUp = false; } } } if (this.animatingExpansion) { this.m_ExpansionAnimator.OnBeforeAllRowsGUI(); } this.data.InitIfNeeded(); Vector2 totalSize = this.gui.GetTotalSize(); this.m_ContentRect = new Rect(0f, 0f, totalSize.x, totalSize.y); if (this.m_UseScrollView) { this.state.scrollPos = GUI.BeginScrollView(this.m_TotalRect, this.state.scrollPos, this.m_ContentRect, (this.horizontalScrollbarStyle == null) ? GUI.skin.horizontalScrollbar : this.horizontalScrollbarStyle, (this.verticalScrollbarStyle == null) ? GUI.skin.verticalScrollbar : this.verticalScrollbarStyle); } else { GUI.BeginClip(this.m_TotalRect); } if (current.type == EventType.Repaint) { this.m_VisibleRect = ((!this.m_UseScrollView) ? this.m_TotalRect : GUI.GetTopScrollView().visibleRect); } this.gui.BeginRowGUI(); int num; int num2; this.gui.GetFirstAndLastRowVisible(out num, out num2); if (num2 >= 0) { int numVisibleRows = num2 - num + 1; float rowWidth = Mathf.Max(GUIClip.visibleRect.width, this.m_ContentRect.width); this.IterateVisibleItems(num, numVisibleRows, rowWidth, flag); } if (this.animatingExpansion) { this.m_ExpansionAnimator.OnAfterAllRowsGUI(); } this.gui.EndRowGUI(); if (this.m_UseScrollView) { GUI.EndScrollView(this.showingVerticalScrollBar); } else { GUI.EndClip(); } this.HandleUnusedEvents(); this.KeyboardGUI(); GUIUtility.GetControlID(33243602, FocusType.Passive); }
public ClipPopupCallbackInfo(int controlID) { m_ControlID = controlID; m_SourceView = GUIView.current; }
/// <summary> /// Constructor /// </summary> /// <param name="view"></param> /// <param name="control"></param> public AddControlCommand(GUIView view, GUIControl parent, GUIControl control) { mView = view; mParent = parent; Controls.Add(control); }
public static EditorWindow GetEditorWindow(this GUIView view) => view is HostView hostView ? hostView.actualView : default;
internal GUIViewProxy(GUIView guiView) { GuiView = guiView; }
/// <summary> /// Constructor /// </summary> /// <param name="scene"></param> /// <param name="view"></param> public AddViewCommand(GUIScene scene, GUIView view) { mScene = scene; mView = view; }