Ejemplo n.º 1
0
 private static void SetupContext(tkControlEditor control, GUIContent label)
 {
     if (control.Context is tkContextLabelRequest)
     {
         ((tkContextLabelRequest)control.Context).Label = label;
     }
 }
Ejemplo n.º 2
0
 private static void SetupContext(tkControlEditor control, GUIContent label)
 {
     if (control.Context is tkContextLabelRequest) {
         ((tkContextLabelRequest)control.Context).Label = label;
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Draws an editor for the given control at the given rect.
        /// </summary>
        /// <param name="element">The element to edit.</param>
        /// <param name="label">The label for the edited control.</param>
        /// <param name="metadata">The metadata to use when editing.</param>
        /// <param name="control">
        /// The actual control that will be used for the editor.
        /// </param>
        /// <returns>
        /// The height that is needed to fully display this control.
        /// </returns>
        public static float tkControlHeight(GUIContent label, object element, fiGraphMetadata metadata, tkControlEditor control)
        {
            fiLateBindingsBinder.EnsureLoaded();

            SetupContext(control, label);
            var height = control.Control.GetHeight(element, control.Context, metadata.Enter(tkControl_Metadata_Layout, metadata.Context).Metadata);

            if (control.Debug) {
                height += tkControl_MarginBeforeHelp;
                height += tkControl_HelpRectHeight;
                height += fiLateBindings.EditorGUIUtility.standardVerticalSpacing;
                height += tkControl_PropertyEditor.FirstEditor.GetElementHeight(tkControl_DebugControl_Label, control, metadata.Enter(tkControl_Metadata_DebugControl, null));
            }

            return height;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Draws an editor for the given control at the given rect.
        /// </summary>
        /// <param name="rect">The rect to draw the editor within.</param>
        /// <param name="label">The label for the edited control.</param>
        /// <param name="element">The element to edit.</param>
        /// <param name="metadata">The metadata to use when editing.</param>
        /// <param name="control">
        /// The actual control that will be used for the editor.
        /// </param>
        /// <returns>The updated element instance.</returns>
        public static object tkControl(Rect rect, GUIContent label, object element, fiGraphMetadata metadata, tkControlEditor control)
        {
            fiLateBindingsBinder.EnsureLoaded();

            Rect layoutRect = rect;
            Rect helpRect = rect;
            Rect tweakerRect = rect;

            if (control.Debug) {
                float tweakerRectHeight = tkControl_PropertyEditor.FirstEditor.GetElementHeight(tkControl_DebugControl_Label, control, metadata.Enter(tkControl_Metadata_DebugControl, null));

                layoutRect.height -= tkControl_MarginBeforeHelp + tkControl_HelpRectHeight +
                                     fiLateBindings.EditorGUIUtility.standardVerticalSpacing + tweakerRectHeight;

                helpRect = layoutRect;
                helpRect.y += layoutRect.height + tkControl_MarginBeforeHelp;
                helpRect.height = tkControl_HelpRectHeight;

                tweakerRect = helpRect;
                tweakerRect.y += tweakerRect.height + fiLateBindings.EditorGUIUtility.standardVerticalSpacing;
                tweakerRect.height = tweakerRectHeight;
            }

            SetupContext(control, label);
            element = control.Control.Edit(layoutRect, element, control.Context, metadata.Enter(tkControl_Metadata_Layout, metadata.Context).Metadata);

            if (control.Debug) {
                EditorGUI.HelpBox(helpRect, "The layout below should be used for visualizing the runtime layout structure or for tweaking layout values like minimum width. Changes will *not* persist - you need to modify the code itself.", MessageType.Info);
                tkControl_PropertyEditor.FirstEditor.Edit(tweakerRect, tkControl_DebugControl_Label, control, metadata.Enter(tkControl_Metadata_DebugControl, null));
            }

            return element;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Draws an editor for the given control at the given rect.
        /// </summary>
        /// <param name="element">The element to edit.</param>
        /// <param name="label">The label for the edited control.</param>
        /// <param name="metadata">The metadata to use when editing.</param>
        /// <param name="control">
        /// The actual control that will be used for the editor.
        /// </param>
        /// <returns>
        /// The height that is needed to fully display this control.
        /// </returns>
        public static float tkControlHeight(GUIContent label, object element, fiGraphMetadata metadata, tkControlEditor control)
        {
            fiLateBindingsBinder.EnsureLoaded();

            SetupContext(control, label);
            var height = control.Control.GetHeight(element, control.Context, metadata.Enter(tkControl_Metadata_Layout, metadata.Context).Metadata);

            if (control.Debug)
            {
                height += tkControl_MarginBeforeHelp;
                height += tkControl_HelpRectHeight;
                height += fiLateBindings.EditorGUIUtility.standardVerticalSpacing;
                height += tkControl_PropertyEditor.FirstEditor.GetElementHeight(tkControl_DebugControl_Label, control, metadata.Enter(tkControl_Metadata_DebugControl, null));
            }

            return(height);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Draws an editor for the given control at the given rect.
        /// </summary>
        /// <param name="rect">The rect to draw the editor within.</param>
        /// <param name="label">The label for the edited control.</param>
        /// <param name="element">The element to edit.</param>
        /// <param name="metadata">The metadata to use when editing.</param>
        /// <param name="control">
        /// The actual control that will be used for the editor.
        /// </param>
        /// <returns>The updated element instance.</returns>
        public static object tkControl(Rect rect, GUIContent label, object element, fiGraphMetadata metadata, tkControlEditor control)
        {
            fiLateBindingsBinder.EnsureLoaded();

            Rect layoutRect  = rect;
            Rect helpRect    = rect;
            Rect tweakerRect = rect;

            if (control.Debug)
            {
                float tweakerRectHeight = tkControl_PropertyEditor.FirstEditor.GetElementHeight(tkControl_DebugControl_Label, control, metadata.Enter(tkControl_Metadata_DebugControl, null));

                layoutRect.height -= tkControl_MarginBeforeHelp + tkControl_HelpRectHeight +
                                     fiLateBindings.EditorGUIUtility.standardVerticalSpacing + tweakerRectHeight;

                helpRect        = layoutRect;
                helpRect.y     += layoutRect.height + tkControl_MarginBeforeHelp;
                helpRect.height = tkControl_HelpRectHeight;

                tweakerRect        = helpRect;
                tweakerRect.y     += tweakerRect.height + fiLateBindings.EditorGUIUtility.standardVerticalSpacing;
                tweakerRect.height = tweakerRectHeight;
            }

            SetupContext(control, label);
            element = control.Control.Edit(layoutRect, element, control.Context, metadata.Enter(tkControl_Metadata_Layout, metadata.Context).Metadata);

            if (control.Debug)
            {
                EditorGUI.HelpBox(helpRect, "The layout below should be used for visualizing the runtime layout structure or for tweaking layout values like minimum width. Changes will *not* persist - you need to modify the code itself.", MessageType.Info);
                tkControl_PropertyEditor.FirstEditor.Edit(tweakerRect, tkControl_DebugControl_Label, control, metadata.Enter(tkControl_Metadata_DebugControl, null));
            }

            return(element);
        }