Esempio n. 1
0
 public StyleModifier(GUIStyleName name, StyleType styleType, string value, GUIState state = GUIState.Normal)
 {
     this.name        = name;
     this.styleType   = styleType;
     this.state       = state;
     this.stringValue = value;
 }
Esempio n. 2
0
        public void Set <T>(GUIStyleName styleName, T value, GUIState state = GUIState.Normal)
        {
            var nameState = new NameState {
                Name = styleName, State = state
            };
            var dict = this.GetDict <T>();

            dict[nameState] = value;
        }
Esempio n. 3
0
        public T Get <T>(GUIStyleName styleName)
        {
            var rule = this.GetRule <T>(styleName, this.currentState);

            if (rule == null)
            {
                return(GUIStyle.Default.Get <T>(styleName, this.currentState));
            }

            return(rule.Value);
        }
Esempio n. 4
0
        public void Set <T>(GUIStyleName styleName, T value, GUIState state)
        {
            var rule = this.GetRule <T>(styleName, state);

            if (rule == null)
            {
                rule = new StyleRule <T>(styleName, value, state);
                this.AppendRule(rule);
            }
            else
            {
                rule.Value = value;
            }
        }
Esempio n. 5
0
        public StyleRule <T> GetRule <T>(GUIStyleName name)
        {
            var rule = this.rules.Find(i =>
            {
                var r = i as StyleRule <T>;
                if (r != null && r.Name == name && r.State == this.currentState)
                {
                    return(true);
                }

                return(false);
            }) as StyleRule <T>;

            return(rule);
        }
Esempio n. 6
0
        public T Get <T>(GUIStyleName styleName, GUIState state = GUIState.Normal)
        {
            T   value;
            var nameState = new NameState {
                Name = styleName, State = state
            };
            var dict = GetDict <T>();

            //try get the style value of specified state
            if (dict.TryGetValue(nameState, out value))
            {
                return(value);
            }

            if (state != GUIState.Normal)
            {
                //try to get the style value of Normal state
                if (dict.TryGetValue(new NameState {
                    Name = styleName, State = GUIState.Normal
                }, out value))
                {
                    return(value);
                }
            }

            var defalutDict = Default.GetDict <T>();

            //try to get a default value of  specified state
            if (defalutDict.TryGetValue(nameState, out value))
            {
                return(value);
            }

            if (state != GUIState.Normal)
            {
                // try to get a default value of Normal state
                if (defalutDict.TryGetValue(new NameState {
                    Name = styleName, State = GUIState.Normal
                }, out value))
                {
                    return(value);
                }
            }

            Log.Warning("Cannot find the style<{0},{1}>", styleName.ToString(), state.ToString());
            return(default(T));//still not found, get defalut value of that types //FIXME may we should throw an exception instead?
        }
Esempio n. 7
0
        public T Get <T>(GUIStyleName styleName, GUIState state = GUIState.Normal)
        {
            T   value;
            var nameState = new NameState {
                Name = styleName, State = state
            };
            var dict = this.GetDict <T>();

            //try get the style value of specified state
            if (dict.TryGetValue(nameState, out value))
            {
                return(value);
            }

            if (state != GUIState.Normal)
            {
                //try to get the style value of Normal state
                if (dict.TryGetValue(new NameState {
                    Name = styleName, State = GUIState.Normal
                }, out value))
                {
                    return(value);
                }
            }

            var defalutDict = Default.GetDict <T>();

            //try to get a default value of  specified state
            if (defalutDict.TryGetValue(nameState, out value))
            {
                return(value);
            }

            if (state != GUIState.Normal)
            {
                // try to get a default value of Normal state
                if (defalutDict.TryGetValue(new NameState {
                    Name = styleName, State = GUIState.Normal
                }, out value))
                {
                    return(value);
                }
            }

            throw new InvalidOperationException($"Cannot find the style<{styleName},{state}>");
        }
Esempio n. 8
0
 private void Set <T>(GUIStyleName styleName, T value)
 {
     this.s.Set <T>(styleName, value);
 }
Esempio n. 9
0
 public StyleRule(GUIStyleName name, T value, GUIState state)
 {
     this.Name  = name;
     this.Value = value;
     this.State = state;
 }
Esempio n. 10
0
 public StyleRule(GUIStyleName name, T value)
 {
     this.Name  = name;
     this.Value = value;
     this.State = GUIState.Normal;
 }
Esempio n. 11
0
        /// <summary>
        /// Push 1 style color to stack.
        /// </summary>
        /// <param name="name">style name, <see cref="GUIStyleName"/></param>
        /// <param name="color">color</param>
        /// <param name="state">which state will this style be apply to</param>
        public static void PushStyleColor(GUIStyleName name, Color color, GUIState state = GUIState.Normal)
        {
            var style = GUIStyle.Basic;

            style.Push(new StyleModifier(name, StyleType.Color, color, state));
        }