예제 #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;
 }
예제 #2
0
파일: GUIStyle.cs 프로젝트: zwcloud/ImGui
        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;
        }
예제 #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;
            }
        }
예제 #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);
        }
예제 #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);
        }
예제 #6
0
파일: GUIStyle.cs 프로젝트: zwcloud/ImGui
        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}>");
        }
예제 #7
0
 public T Get <T>(StylePropertyName styleName)
 {
     return(Get <T>(styleName, this.currentState));
 }
예제 #8
0
 public static void PushStyle <T>(StylePropertyName name, T value, GUIState state)
 {
     styleRuleStack.Add(new StyleRule <T>(name, value, state));
 }
예제 #9
0
 public StyleRule(StylePropertyName name, T value, GUIState state)
 {
     this.Name  = name;
     this.Value = value;
     this.State = state;
 }
예제 #10
0
 public StyleRule(StylePropertyName name, T value)
 {
     this.Name  = name;
     this.Value = value;
     this.State = GUIState.Normal;
 }