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

            dict[nameState] = value;
        }
Ejemplo n.º 3
0
        public void Set <T>(StylePropertyName 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;
            }
        }
Ejemplo n.º 4
0
        public StyleRule <T> GetRule <T>(StylePropertyName 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);
        }
Ejemplo n.º 5
0
        public T Get <T>(StylePropertyName styleName, GUIState state)
        {
            if (GetFromStack <T>(styleName, state, out var value))
            {
                return(value);
            }

            var rule = this.GetRule <T>(styleName, state);

            if (rule == null)
            {
                rule = this.GetRule <T>(styleName, GUIState.Normal);
            }

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

            return(rule.Value);
        }
Ejemplo n.º 6
0
        public T Get <T>(StylePropertyName 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);
            }

            //try to get the style value of Normal state
            var normalNameState = new NameState {
                Name = styleName, State = GUIState.Normal
            };

            if (dict.TryGetValue(normalNameState, 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);
            }

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

            throw new InvalidOperationException($"Cannot find the style<{styleName},{state}>");
        }
Ejemplo n.º 7
0
 public T Get <T>(StylePropertyName styleName)
 {
     return(Get <T>(styleName, this.currentState));
 }
Ejemplo n.º 8
0
 public static void PushStyle <T>(StylePropertyName name, T value, GUIState state)
 {
     styleRuleStack.Add(new StyleRule <T>(name, value, state));
 }
Ejemplo n.º 9
0
 public StyleRule(StylePropertyName name, T value, GUIState state)
 {
     this.Name  = name;
     this.Value = value;
     this.State = state;
 }
Ejemplo n.º 10
0
 public StyleRule(StylePropertyName name, T value)
 {
     this.Name  = name;
     this.Value = value;
     this.State = GUIState.Normal;
 }