public T Get <T>(string customStyleName) { var propertyName = CustomStylePropertyName.Get(customStyleName); if (propertyName == null) { Log.Warning($"Custom style property \"{customStyleName}\" is undefined. Default value returned."); return(default);
public static StylePropertyName GetOrAdd(string name) { if (s_customStylePropertyNameMap.TryGetValue(name, out var value)) { return(value); } var o = new CustomStylePropertyName(name); s_customStylePropertyNameMap.Add(name, o); return(o); }
private static GUIStyle CreateDefaultStyle() { var style = new GUIStyle(true); style.numberStyles = new Dictionary <NameState, double> { [new NameState { Name = StylePropertyName.MinWidth, State = GUIState.Normal }] = 1, [new NameState { Name = StylePropertyName.MaxWidth, State = GUIState.Normal }] = 9999, [new NameState { Name = StylePropertyName.MinHeight, State = GUIState.Normal }] = 1, [new NameState { Name = StylePropertyName.MaxHeight, State = GUIState.Normal }] = 9999, [new NameState { Name = StylePropertyName.BorderTop, State = GUIState.Normal }] = 0, [new NameState { Name = StylePropertyName.BorderTop, State = GUIState.Hover }] = 0, [new NameState { Name = StylePropertyName.BorderTop, State = GUIState.Active }] = 0, [new NameState { Name = StylePropertyName.BorderRight, State = GUIState.Normal }] = 0, [new NameState { Name = StylePropertyName.BorderRight, State = GUIState.Hover }] = 0, [new NameState { Name = StylePropertyName.BorderRight, State = GUIState.Active }] = 0, [new NameState { Name = StylePropertyName.BorderBottom, State = GUIState.Normal }] = 0, [new NameState { Name = StylePropertyName.BorderBottom, State = GUIState.Hover }] = 0, [new NameState { Name = StylePropertyName.BorderBottom, State = GUIState.Active }] = 0, [new NameState { Name = StylePropertyName.BorderLeft, State = GUIState.Normal }] = 0, [new NameState { Name = StylePropertyName.BorderLeft, State = GUIState.Hover }] = 0, [new NameState { Name = StylePropertyName.BorderLeft, State = GUIState.Active }] = 0, [new NameState { Name = StylePropertyName.BorderImageSliceTop, State = GUIState.Normal }] = 0, [new NameState { Name = StylePropertyName.BorderImageSliceTop, State = GUIState.Hover }] = 0, [new NameState { Name = StylePropertyName.BorderImageSliceTop, State = GUIState.Active }] = 0, [new NameState { Name = StylePropertyName.BorderImageSliceRight, State = GUIState.Normal }] = 0, [new NameState { Name = StylePropertyName.BorderImageSliceRight, State = GUIState.Hover }] = 0, [new NameState { Name = StylePropertyName.BorderImageSliceRight, State = GUIState.Active }] = 0, [new NameState { Name = StylePropertyName.BorderImageSliceBottom, State = GUIState.Normal }] = 0, [new NameState { Name = StylePropertyName.BorderImageSliceBottom, State = GUIState.Hover }] = 0, [new NameState { Name = StylePropertyName.BorderImageSliceBottom, State = GUIState.Active }] = 0, [new NameState { Name = StylePropertyName.BorderImageSliceLeft, State = GUIState.Normal }] = 0, [new NameState { Name = StylePropertyName.BorderImageSliceLeft, State = GUIState.Hover }] = 0, [new NameState { Name = StylePropertyName.BorderImageSliceLeft, State = GUIState.Active }] = 0, [new NameState { Name = StylePropertyName.BorderTopLeftRadius, State = GUIState.Normal }] = 0, [new NameState { Name = StylePropertyName.BorderTopLeftRadius, State = GUIState.Hover }] = 0, [new NameState { Name = StylePropertyName.BorderTopLeftRadius, State = GUIState.Active }] = 0, [new NameState { Name = StylePropertyName.BorderTopRightRadius, State = GUIState.Normal }] = 0, [new NameState { Name = StylePropertyName.BorderTopRightRadius, State = GUIState.Hover }] = 0, [new NameState { Name = StylePropertyName.BorderTopRightRadius, State = GUIState.Active }] = 0, [new NameState { Name = StylePropertyName.BorderBottomRightRadius, State = GUIState.Normal }] = 0, [new NameState { Name = StylePropertyName.BorderBottomRightRadius, State = GUIState.Hover }] = 0, [new NameState { Name = StylePropertyName.BorderBottomRightRadius, State = GUIState.Active }] = 0, [new NameState { Name = StylePropertyName.BorderBottomLeftRadius, State = GUIState.Normal }] = 0, [new NameState { Name = StylePropertyName.BorderBottomLeftRadius, State = GUIState.Hover }] = 0, [new NameState { Name = StylePropertyName.BorderBottomLeftRadius, State = GUIState.Active }] = 0, [new NameState { Name = StylePropertyName.PaddingTop, State = GUIState.Normal }] = 0, [new NameState { Name = StylePropertyName.PaddingTop, State = GUIState.Hover }] = 0, [new NameState { Name = StylePropertyName.PaddingTop, State = GUIState.Active }] = 0, [new NameState { Name = StylePropertyName.PaddingRight, State = GUIState.Normal }] = 0, [new NameState { Name = StylePropertyName.PaddingRight, State = GUIState.Hover }] = 0, [new NameState { Name = StylePropertyName.PaddingRight, State = GUIState.Active }] = 0, [new NameState { Name = StylePropertyName.PaddingBottom, State = GUIState.Normal }] = 0, [new NameState { Name = StylePropertyName.PaddingBottom, State = GUIState.Hover }] = 0, [new NameState { Name = StylePropertyName.PaddingBottom, State = GUIState.Active }] = 0, [new NameState { Name = StylePropertyName.PaddingLeft, State = GUIState.Normal }] = 0, [new NameState { Name = StylePropertyName.PaddingLeft, State = GUIState.Hover }] = 0, [new NameState { Name = StylePropertyName.PaddingLeft, State = GUIState.Active }] = 0, [new NameState { Name = StylePropertyName.CellSpacingHorizontal, State = GUIState.Normal }] = 0, [new NameState { Name = StylePropertyName.CellSpacingHorizontal, State = GUIState.Hover }] = 0, [new NameState { Name = StylePropertyName.CellSpacingHorizontal, State = GUIState.Active }] = 0, [new NameState { Name = StylePropertyName.CellSpacingVertical, State = GUIState.Normal }] = 0, [new NameState { Name = StylePropertyName.CellSpacingVertical, State = GUIState.Hover }] = 0, [new NameState { Name = StylePropertyName.CellSpacingVertical, State = GUIState.Active }] = 0, [new NameState { Name = StylePropertyName.OutlineWidth, State = GUIState.Normal }] = 0, [new NameState { Name = StylePropertyName.OutlineWidth, State = GUIState.Hover }] = 0, [new NameState { Name = StylePropertyName.OutlineWidth, State = GUIState.Active }] = 0, [new NameState { Name = StylePropertyName.FontSize, State = GUIState.Normal }] = DefaultFontSize, [new NameState { Name = StylePropertyName.FontSize, State = GUIState.Hover }] = DefaultFontSize, [new NameState { Name = StylePropertyName.FontSize, State = GUIState.Active }] = DefaultFontSize, [new NameState { Name = StylePropertyName.MinTextureCoordinateU, State = GUIState.Normal }] = 0, [new NameState { Name = StylePropertyName.MinTextureCoordinateU, State = GUIState.Hover }] = 0, [new NameState { Name = StylePropertyName.MinTextureCoordinateU, State = GUIState.Active }] = 0, [new NameState { Name = StylePropertyName.MinTextureCoordinateV, State = GUIState.Normal }] = 0, [new NameState { Name = StylePropertyName.MinTextureCoordinateV, State = GUIState.Hover }] = 0, [new NameState { Name = StylePropertyName.MinTextureCoordinateV, State = GUIState.Active }] = 0, [new NameState { Name = StylePropertyName.MaxTextureCoordinateU, State = GUIState.Normal }] = 1, [new NameState { Name = StylePropertyName.MaxTextureCoordinateU, State = GUIState.Hover }] = 1, [new NameState { Name = StylePropertyName.MaxTextureCoordinateU, State = GUIState.Active }] = 1, [new NameState { Name = StylePropertyName.MaxTextureCoordinateV, State = GUIState.Normal }] = 1, [new NameState { Name = StylePropertyName.MaxTextureCoordinateV, State = GUIState.Hover }] = 1, [new NameState { Name = StylePropertyName.MaxTextureCoordinateV, State = GUIState.Active }] = 1, [new NameState { Name = StylePropertyName.StrokeWidth, State = GUIState.Normal }] = 1, [new NameState { Name = StylePropertyName.StrokeWidth, State = GUIState.Hover }] = 1, [new NameState { Name = StylePropertyName.StrokeWidth, State = GUIState.Active }] = 1, [new NameState { Name = StylePropertyName.ScrollBarWidth, State = GUIState.Normal }] = 20, [new NameState { Name = StylePropertyName.ScrollBarWidth, State = GUIState.Hover }] = 20, [new NameState { Name = StylePropertyName.ScrollBarWidth, State = GUIState.Active }] = 20, //TODO Following custom styles should be moved into GUISkin [new NameState { Name = CustomStylePropertyName.GetOrAdd("ControlLabelSpacing"), State = GUIState.Normal }] = 5, [new NameState { Name = CustomStylePropertyName.GetOrAdd("ControlLabelSpacing"), State = GUIState.Hover }] = 5, [new NameState { Name = CustomStylePropertyName.GetOrAdd("ControlLabelSpacing"), State = GUIState.Active }] = 5, [new NameState { Name = CustomStylePropertyName.GetOrAdd("FieldWidth"), State = GUIState.Normal }] = 200, [new NameState { Name = CustomStylePropertyName.GetOrAdd("FieldWidth"), State = GUIState.Hover }] = 200, [new NameState { Name = CustomStylePropertyName.GetOrAdd("FieldWidth"), State = GUIState.Active }] = 200, [new NameState { Name = CustomStylePropertyName.GetOrAdd("LabelWidth"), State = GUIState.Normal }] = 80, [new NameState { Name = CustomStylePropertyName.GetOrAdd("LabelWidth"), State = GUIState.Hover }] = 80, [new NameState { Name = CustomStylePropertyName.GetOrAdd("LabelWidth"), State = GUIState.Active }] = 80, [new NameState { Name = CustomStylePropertyName.GetOrAdd("LabelHeight"), State = GUIState.Normal }] = 70, [new NameState { Name = CustomStylePropertyName.GetOrAdd("LabelHeight"), State = GUIState.Hover }] = 70, [new NameState { Name = CustomStylePropertyName.GetOrAdd("LabelHeight"), State = GUIState.Active }] = 70, }; style.colorStyles = new Dictionary <NameState, Color> { [new NameState { Name = StylePropertyName.BorderTopColor, State = GUIState.Normal }] = Color.Black, [new NameState { Name = StylePropertyName.BorderTopColor, State = GUIState.Hover }] = Color.Black, [new NameState { Name = StylePropertyName.BorderTopColor, State = GUIState.Active }] = Color.Black, [new NameState { Name = StylePropertyName.BorderRightColor, State = GUIState.Normal }] = Color.Black, [new NameState { Name = StylePropertyName.BorderRightColor, State = GUIState.Hover }] = Color.Black, [new NameState { Name = StylePropertyName.BorderRightColor, State = GUIState.Active }] = Color.Black, [new NameState { Name = StylePropertyName.BorderBottomColor, State = GUIState.Normal }] = Color.Black, [new NameState { Name = StylePropertyName.BorderBottomColor, State = GUIState.Hover }] = Color.Black, [new NameState { Name = StylePropertyName.BorderBottomColor, State = GUIState.Active }] = Color.Black, [new NameState { Name = StylePropertyName.BorderLeftColor, State = GUIState.Normal }] = Color.Black, [new NameState { Name = StylePropertyName.BorderLeftColor, State = GUIState.Hover }] = Color.Black, [new NameState { Name = StylePropertyName.BorderLeftColor, State = GUIState.Active }] = Color.Black, [new NameState { Name = StylePropertyName.BackgroundColor, State = GUIState.Normal }] = Color.Clear, [new NameState { Name = StylePropertyName.BackgroundColor, State = GUIState.Hover }] = Color.Clear, [new NameState { Name = StylePropertyName.BackgroundColor, State = GUIState.Active }] = Color.Clear, [new NameState { Name = StylePropertyName.OutlineColor, State = GUIState.Normal }] = Color.Clear, [new NameState { Name = StylePropertyName.OutlineColor, State = GUIState.Hover }] = Color.Clear, [new NameState { Name = StylePropertyName.OutlineColor, State = GUIState.Active }] = Color.Clear, [new NameState { Name = StylePropertyName.FontColor, State = GUIState.Normal }] = Color.Black, [new NameState { Name = StylePropertyName.FontColor, State = GUIState.Hover }] = Color.Black, [new NameState { Name = StylePropertyName.FontColor, State = GUIState.Active }] = Color.Black, [new NameState { Name = StylePropertyName.GradientLeftColor, State = GUIState.Normal }] = Color.Rgb(247, 247, 247), [new NameState { Name = StylePropertyName.GradientLeftColor, State = GUIState.Hover }] = Color.Rgb(247, 247, 247), [new NameState { Name = StylePropertyName.GradientLeftColor, State = GUIState.Active }] = Color.Rgb(247, 247, 247), [new NameState { Name = StylePropertyName.GradientTopColor, State = GUIState.Normal }] = Color.Rgb(247, 247, 247), [new NameState { Name = StylePropertyName.GradientTopColor, State = GUIState.Hover }] = Color.Rgb(247, 247, 247), [new NameState { Name = StylePropertyName.GradientTopColor, State = GUIState.Active }] = Color.Rgb(247, 247, 247), [new NameState { Name = StylePropertyName.GradientRightColor, State = GUIState.Normal }] = Color.Rgb(221, 221, 221), [new NameState { Name = StylePropertyName.GradientRightColor, State = GUIState.Hover }] = Color.Rgb(221, 221, 221), [new NameState { Name = StylePropertyName.GradientRightColor, State = GUIState.Active }] = Color.Rgb(221, 221, 221), [new NameState { Name = StylePropertyName.GradientBottomColor, State = GUIState.Normal }] = Color.Rgb(221, 221, 221), [new NameState { Name = StylePropertyName.GradientBottomColor, State = GUIState.Hover }] = Color.Rgb(221, 221, 221), [new NameState { Name = StylePropertyName.GradientBottomColor, State = GUIState.Active }] = Color.Rgb(221, 221, 221), [new NameState { Name = StylePropertyName.StrokeColor, State = GUIState.Normal }] = Color.Black, [new NameState { Name = StylePropertyName.StrokeColor, State = GUIState.Hover }] = Color.Black, [new NameState { Name = StylePropertyName.StrokeColor, State = GUIState.Active }] = Color.Black, [new NameState { Name = StylePropertyName.FillColor, State = GUIState.Normal }] = Color.White, [new NameState { Name = StylePropertyName.FillColor, State = GUIState.Hover }] = Color.White, [new NameState { Name = StylePropertyName.FillColor, State = GUIState.Active }] = Color.White, [new NameState { Name = StylePropertyName.ScrollBarBackgroundColor, State = GUIState.Normal }] = Color.Rgb(232), [new NameState { Name = StylePropertyName.ScrollBarBackgroundColor, State = GUIState.Hover }] = Color.Rgb(232), [new NameState { Name = StylePropertyName.ScrollBarBackgroundColor, State = GUIState.Active }] = Color.Rgb(232), [new NameState { Name = StylePropertyName.ScrollBarButtonColor, State = GUIState.Normal }] = Color.Rgb(194, 195, 201), [new NameState { Name = StylePropertyName.ScrollBarButtonColor, State = GUIState.Hover }] = Color.Rgb(104), [new NameState { Name = StylePropertyName.ScrollBarButtonColor, State = GUIState.Active }] = Color.Rgb(91), }; style.imageStyles = new Dictionary <NameState, ITexture> { [new NameState { Name = StylePropertyName.BackgroundImage, State = GUIState.Normal }] = null, [new NameState { Name = StylePropertyName.BackgroundImage, State = GUIState.Hover }] = null, [new NameState { Name = StylePropertyName.BackgroundImage, State = GUIState.Active }] = null, }; style.intStyles = new Dictionary <NameState, int> { [new NameState { Name = StylePropertyName.HorizontalStretchFactor, State = GUIState.Normal }] = 0, [new NameState { Name = StylePropertyName.VerticalStretchFactor, State = GUIState.Normal }] = 0, [new NameState { Name = StylePropertyName.TextAlignment, State = GUIState.Normal }] = (int)TextAlignment.Leading, [new NameState { Name = StylePropertyName.TextAlignment, State = GUIState.Hover }] = (int)TextAlignment.Leading, [new NameState { Name = StylePropertyName.TextAlignment, State = GUIState.Active }] = (int)TextAlignment.Leading, [new NameState { Name = StylePropertyName.FontStyle, State = GUIState.Normal }] = (int)FontStyle.Normal, [new NameState { Name = StylePropertyName.FontStyle, State = GUIState.Hover }] = (int)FontStyle.Normal, [new NameState { Name = StylePropertyName.FontStyle, State = GUIState.Active }] = (int)FontStyle.Normal, [new NameState { Name = StylePropertyName.FontWeight, State = GUIState.Normal }] = (int)FontWeight.Normal, [new NameState { Name = StylePropertyName.FontWeight, State = GUIState.Hover }] = (int)FontWeight.Normal, [new NameState { Name = StylePropertyName.FontWeight, State = GUIState.Active }] = (int)FontWeight.Normal, [new NameState { Name = StylePropertyName.FontStretch, State = GUIState.Normal }] = (int)FontStretch.Normal, [new NameState { Name = StylePropertyName.FontStretch, State = GUIState.Hover }] = (int)FontStretch.Normal, [new NameState { Name = StylePropertyName.FontStretch, State = GUIState.Active }] = (int)FontStretch.Normal, [new NameState { Name = StylePropertyName.AlignmentHorizontal, State = GUIState.Normal }] = (int)Alignment.Start, [new NameState { Name = StylePropertyName.AlignmentHorizontal, State = GUIState.Hover }] = (int)Alignment.Start, [new NameState { Name = StylePropertyName.AlignmentHorizontal, State = GUIState.Active }] = (int)Alignment.Start, [new NameState { Name = StylePropertyName.AlignmentVertical, State = GUIState.Normal }] = (int)Alignment.Start, [new NameState { Name = StylePropertyName.AlignmentVertical, State = GUIState.Hover }] = (int)Alignment.Start, [new NameState { Name = StylePropertyName.AlignmentVertical, State = GUIState.Active }] = (int)Alignment.Start, [new NameState { Name = StylePropertyName.BackgroundGradient, State = GUIState.Normal }] = (int)Gradient.None, [new NameState { Name = StylePropertyName.BackgroundGradient, State = GUIState.Hover }] = (int)Gradient.None, [new NameState { Name = StylePropertyName.BackgroundGradient, State = GUIState.Active }] = (int)Gradient.None, [new NameState { Name = StylePropertyName.OverflowX, State = GUIState.Normal }] = (int)OverflowPolicy.Hidden, [new NameState { Name = StylePropertyName.OverflowX, State = GUIState.Hover }] = (int)OverflowPolicy.Hidden, [new NameState { Name = StylePropertyName.OverflowX, State = GUIState.Active }] = (int)OverflowPolicy.Hidden, [new NameState { Name = StylePropertyName.OverflowY, State = GUIState.Normal }] = (int)OverflowPolicy.Hidden, [new NameState { Name = StylePropertyName.OverflowY, State = GUIState.Hover }] = (int)OverflowPolicy.Hidden, [new NameState { Name = StylePropertyName.OverflowY, State = GUIState.Active }] = (int)OverflowPolicy.Hidden, }; style.strStyles = new Dictionary <NameState, string> { [new NameState { Name = StylePropertyName.FontFamily, State = GUIState.Normal }] = DefaultFontFamily, [new NameState { Name = StylePropertyName.FontFamily, State = GUIState.Hover }] = DefaultFontFamily, [new NameState { Name = StylePropertyName.FontFamily, State = GUIState.Active }] = DefaultFontFamily, [new NameState { Name = StylePropertyName.BorderImageSource, State = GUIState.Normal }] = null, [new NameState { Name = StylePropertyName.BorderImageSource, State = GUIState.Hover }] = null, [new NameState { Name = StylePropertyName.BorderImageSource, State = GUIState.Active }] = null, }; return(style); }
public static void PushCustomStyle <T>(string name, T value, GUIState state) { var propertyName = CustomStylePropertyName.GetOrAdd(name); styleRuleStack.Add(new StyleRule <T>(propertyName, value, state)); }