public Panel(int instanceID, ContextType contextType, LoadResourceFunction loadResourceDelegate = null, IDataWatchService dataWatch = null, IDispatcher dispatcher = null) { this.instanceID = instanceID; this.contextType = contextType; LoadResourceFunction arg_3B_1 = loadResourceDelegate; if (loadResourceDelegate == null) { if (Panel.< > f__mg$cache0 == null) { Panel.< > f__mg$cache0 = new LoadResourceFunction(Resources.Load); } arg_3B_1 = Panel.< > f__mg$cache0; } this.loadResourceFunc = arg_3B_1; this.dataWatch = dataWatch; this.dispatcher = dispatcher; this.stylePainter = new StylePainter(); this.m_RootContainer = new VisualContainer(); this.m_RootContainer.name = VisualElementUtils.GetUniqueName("PanelContainer"); this.visualTree.ChangePanel(this); this.m_StyleContext = new StyleContext(this.m_RootContainer); this.defaultIMRoot = new IMContainer { name = "DefaultOnGUI", pickingMode = PickingMode.Ignore }; this.defaultIMRoot.StretchToParentSize(); this.visualTree.InsertChild(0, this.defaultIMRoot); this.allowPixelCaching = true; }
public void ApplyCustomProperty <T>(string propertyName, ref Style <T> target) where T : UnityEngine.Object { if (VisualElementStyles.< > f__mg$cache0 == null) { VisualElementStyles.< > f__mg$cache0 = new LoadResourceFunction(Resources.Load); } this.ApplyCustomProperty <T>(propertyName, VisualElementStyles.< > f__mg$cache0, ref target); }
static GUIView() { GUIView.positionChanged = null; GUIView.s_ContextualMenuManager = new EditorContextualMenuManager(); if (GUIView.< > f__mg$cache0 == null) { GUIView.< > f__mg$cache0 = new LoadResourceFunction(StyleSheetResourceUtil.LoadResource); } Panel.loadResourceFunc = GUIView.< > f__mg$cache0; if (GUIView.< > f__mg$cache1 == null) { GUIView.< > f__mg$cache1 = new StyleSheetApplicator.CreateDefaultCursorStyleFunction(UIElementsEditorUtility.CreateDefaultCursorStyle); } StyleSheetApplicator.createDefaultCursorStyleFunc = GUIView.< > f__mg$cache1; Panel.TimeSinceStartup = (() => (long)(EditorApplication.timeSinceStartup * 1000.0)); }
public void ApplyCustomProperty <T>(string propertyName, LoadResourceFunction function, ref Style <T> target) where T : UnityEngine.Object { Style <T> other = new Style <T>((T)((object)null)); CustomProperty customProperty; if (this.m_CustomProperties != null && this.m_CustomProperties.TryGetValue(propertyName, out customProperty)) { if (customProperty.handle.valueType == StyleValueType.ResourcePath) { customProperty.data.Apply(customProperty.handle, customProperty.specificity, function, ref other); } else { Debug.LogWarning(string.Format("Trying to read value as Object while parsed type is {0}", customProperty.handle.valueType)); } } target.Apply(other, StylePropertyApplyMode.CopyIfNotInline); }
internal void ApplyRule(StyleSheet registry, int specificity, StyleRule rule, StylePropertyID[] propertyIDs, LoadResourceFunction loadResourceFunc) { for (int i = 0; i < rule.properties.Length; i++) { StyleProperty styleProperty = rule.properties[i]; StylePropertyID stylePropertyID = propertyIDs[i]; StyleValueHandle handle = styleProperty.values[0]; switch (stylePropertyID) { case StylePropertyID.MarginLeft: registry.Apply(handle, specificity, ref this.marginLeft); break; case StylePropertyID.MarginTop: registry.Apply(handle, specificity, ref this.marginTop); break; case StylePropertyID.MarginRight: registry.Apply(handle, specificity, ref this.marginRight); break; case StylePropertyID.MarginBottom: registry.Apply(handle, specificity, ref this.marginBottom); break; case StylePropertyID.PaddingLeft: registry.Apply(handle, specificity, ref this.paddingLeft); break; case StylePropertyID.PaddingTop: registry.Apply(handle, specificity, ref this.paddingTop); break; case StylePropertyID.PaddingRight: registry.Apply(handle, specificity, ref this.paddingRight); break; case StylePropertyID.PaddingBottom: registry.Apply(handle, specificity, ref this.paddingBottom); break; case StylePropertyID.BorderLeft: registry.Apply(handle, specificity, ref this.borderLeft); break; case StylePropertyID.BorderTop: registry.Apply(handle, specificity, ref this.borderTop); break; case StylePropertyID.BorderRight: registry.Apply(handle, specificity, ref this.borderRight); break; case StylePropertyID.BorderBottom: registry.Apply(handle, specificity, ref this.borderBottom); break; case StylePropertyID.PositionType: registry.Apply(handle, specificity, ref this.positionType); break; case StylePropertyID.PositionLeft: registry.Apply(handle, specificity, ref this.positionLeft); break; case StylePropertyID.PositionTop: registry.Apply(handle, specificity, ref this.positionTop); break; case StylePropertyID.PositionRight: registry.Apply(handle, specificity, ref this.positionRight); break; case StylePropertyID.PositionBottom: registry.Apply(handle, specificity, ref this.positionBottom); break; case StylePropertyID.Width: registry.Apply(handle, specificity, ref this.width); break; case StylePropertyID.Height: registry.Apply(handle, specificity, ref this.height); break; case StylePropertyID.MinWidth: registry.Apply(handle, specificity, ref this.minWidth); break; case StylePropertyID.MinHeight: registry.Apply(handle, specificity, ref this.minHeight); break; case StylePropertyID.MaxWidth: registry.Apply(handle, specificity, ref this.maxWidth); break; case StylePropertyID.MaxHeight: registry.Apply(handle, specificity, ref this.maxHeight); break; case StylePropertyID.Flex: registry.Apply(handle, specificity, ref this.flex); break; case StylePropertyID.BorderWidth: registry.Apply(handle, specificity, ref this.borderWidth); break; case StylePropertyID.BorderRadius: registry.Apply(handle, specificity, ref this.borderRadius); break; case StylePropertyID.FlexDirection: registry.Apply(handle, specificity, ref this.flexDirection); break; case StylePropertyID.FlexWrap: registry.Apply(handle, specificity, ref this.flexWrap); break; case StylePropertyID.JustifyContent: registry.Apply(handle, specificity, ref this.justifyContent); break; case StylePropertyID.AlignContent: registry.Apply(handle, specificity, ref this.alignContent); break; case StylePropertyID.AlignSelf: registry.Apply(handle, specificity, ref this.alignSelf); break; case StylePropertyID.AlignItems: registry.Apply(handle, specificity, ref this.alignItems); break; case StylePropertyID.TextAlignment: registry.Apply(handle, specificity, ref this.textAlignment); break; case StylePropertyID.TextClipping: registry.Apply(handle, specificity, ref this.textClipping); break; case StylePropertyID.Font: registry.Apply(handle, specificity, loadResourceFunc, ref this.font); break; case StylePropertyID.FontSize: registry.Apply(handle, specificity, ref this.fontSize); break; case StylePropertyID.FontStyle: registry.Apply(handle, specificity, ref this.fontStyle); break; case StylePropertyID.BackgroundSize: registry.Apply(handle, specificity, ref this.backgroundSize); break; case StylePropertyID.WordWrap: registry.Apply(handle, specificity, ref this.wordWrap); break; case StylePropertyID.BackgroundImage: registry.Apply(handle, specificity, loadResourceFunc, ref this.backgroundImage); break; case StylePropertyID.TextColor: registry.Apply(handle, specificity, ref this.textColor); break; case StylePropertyID.BackgroundColor: registry.Apply(handle, specificity, ref this.backgroundColor); break; case StylePropertyID.BorderColor: registry.Apply(handle, specificity, ref this.borderColor); break; case StylePropertyID.Overflow: registry.Apply(handle, specificity, ref this.overflow); break; case StylePropertyID.SliceLeft: registry.Apply(handle, specificity, ref this.sliceLeft); break; case StylePropertyID.SliceTop: registry.Apply(handle, specificity, ref this.sliceTop); break; case StylePropertyID.SliceRight: registry.Apply(handle, specificity, ref this.sliceRight); break; case StylePropertyID.SliceBottom: registry.Apply(handle, specificity, ref this.sliceBottom); break; case StylePropertyID.Opacity: registry.Apply(handle, specificity, ref this.opacity); break; case StylePropertyID.Custom: { if (this.m_CustomProperties == null) { this.m_CustomProperties = new Dictionary <string, CustomProperty>(); } CustomProperty value = default(CustomProperty); if (!this.m_CustomProperties.TryGetValue(styleProperty.name, out value) || specificity >= value.specificity) { value.handle = handle; value.data = registry; value.specificity = specificity; this.m_CustomProperties[styleProperty.name] = value; } break; } default: throw new ArgumentException(string.Format("Non exhaustive switch statement (value={0})", stylePropertyID)); } } }
internal static Panel FindOrCreatePanel(int instanceId, ContextType contextType, IDataWatchService dataWatch = null, LoadResourceFunction loadResourceFunction = null) { Panel panel; if (!UIElementsUtility.s_UIElementsCache.TryGetValue(instanceId, out panel)) { panel = new Panel(instanceId, contextType, loadResourceFunction, dataWatch, UIElementsUtility.eventDispatcher); UIElementsUtility.s_UIElementsCache.Add(instanceId, panel); } else { Debug.Assert(contextType == panel.contextType, "Context type mismatch"); } return(panel); }
public static void Apply <T>(this StyleSheet sheet, StyleValueHandle handle, int specificity, LoadResourceFunction loadResourceFunc, ref Style <T> property) where T : UnityEngine.Object { if (handle.valueType == StyleValueType.Keyword && handle.valueIndex == 5) { StyleSheetExtensions.Apply <T>((T)((object)null), specificity, ref property); } else { string text = sheet.ReadResourcePath(handle); if (!string.IsNullOrEmpty(text)) { T t = loadResourceFunc(text, typeof(T)) as T; if (t != null) { StyleSheetExtensions.Apply <T>(t, specificity, ref property); } else { Debug.LogWarning(string.Format("{0} resource not found for path: {1}", typeof(T).Name, text)); } } } }