public void Init(IStyleSystem s) { MinHeight = s.CreateKey <int>("min-height", false); MaxHeight = s.CreateKey <int>("max-height", false); MaxLinesVisible = s.CreateKey <int>("max-lines-visible", false); UniformItemHeight = s.CreateKey <bool>("uniform-item-height", false); }
public void Init(IStyleSystem s) { TooltipDelay = s.CreateKey <float>("tooltip-delay", true); TooltipDisplayTime = s.CreateKey <float>("tooltip-display-time", true); TooltipPosition = s.CreateKey <TooltipPositionMode>("tooltip-position", true); Visibility = s.CreateKey <Visibility>("visibility", false); FrameTexture = s.CreateKey <IBoxTexture>("frame-texture", false); FrameOverlayTexture = s.CreateKey <IBoxTexture>("frame-overlay-texture", false); FrameOverlayColor = s.CreateKey <Color>("frame-overlay-color", false); HoverOverlayTexture = s.CreateKey <IBoxTexture>("hover-overlay-texture", false); HoverOverlayColor = s.CreateKey <Color>("hover-overlay-color", false); FocusedOverlayTexture = s.CreateKey <IBoxTexture>("focused-overlay-texture", false); FocusedOverlayColor = s.CreateKey <Color>("focused-overlay-color", false); WidgetStateOverlay = s.CreateKey <IBoxTexture>("widget-state-overlay", false); WidgetStateOverlayScale = s.CreateKey <bool>("widget-state-overlay-scale", false); WidgetStateOverlayColor = s.CreateKey <Color>("widget-state-overlay-color", false); Padding = s.CreateKey <Insets>("padding", false); Margin = s.CreateKey <Insets>("margin", false); Color = s.CreateKey <Color>("color", false); }
bool TryGetValue(IStyleKey key, out object value) { var idx = StyleSystem.LinearIndexFor(key); value = cachedValues[idx]; return(value != null); }
public int LinearIndexFor(IStyleKey key) { var sk = key as SecretStyleKey; if (sk == null) { throw new ArgumentException(); } return(sk.LinearIndex); }
public bool IsRegisteredKey(IStyleKey key) { var sk = key as SecretStyleKey; if (sk == null) { return(false); } return(ReferenceEquals(sk.Creator, this)); }
public static T GetValue <T>(this IStyle style, IStyleKey <T> key, T defaultValue = default(T)) { T val; if (style.GetValue(key, out val)) { return(val); } return(defaultValue); }
public void SetResolvedValue(IStyleKey key, object value) { if (ResolvedStyles.SetValue(key, value)) { if (key.Inherit) { inheritableValuesChanged = true; } valueChanged = true; } }
public bool IsExplicitlyInherited(IStyleKey key) { if (!StyleSystem.IsRegisteredKey(key)) { throw new ArgumentException($"StyleKey {key} is not registered here."); } var index = StyleSystem.LinearIndexFor(key); return(InheritMarker.IsInheritMarker(values[index])); }
public void Init(IStyleSystem s) { Font = s.CreateKey <IUIFont>("font", true); TextColor = s.CreateKey <Color>("text-color", true); Alignment = s.CreateKey <Alignment>("text-alignment", true); OutlineColor = s.CreateKey <Color>("outline-color", true); OutlineSize = s.CreateKey <int>("outline-size", true); WrapText = s.CreateKey <WrapText>("wrap-text", true); Underline = s.CreateKey <bool>("underline", true); StrikeThrough = s.CreateKey <bool>("strike-through", true); CaretWidth = s.CreateKey <int>("caret-width", true); CaretBlinkRate = s.CreateKey <float>("caret-blink-rate", true); CaretBlinking = s.CreateKey <bool>("caret-blinking", true); SelectionColor = s.CreateKey <Color>("selection-color", true); }
public bool IsExplicitlyInherited(IStyleKey key) { if (!StyleSystem.IsRegisteredKey(key)) { throw new ArgumentException($"StyleKey {key} is not registered here."); } if (elementStyle.IsExplicitlyInherited(key)) { return(true); } if (ResolvedStyles.IsExplicitlyInherited(key)) { return(true); } return(false); }
public bool SetValue(IStyleKey key, object value) { var idx = StyleSystem.LinearIndexFor(key); cachedValues[idx] = null; if (elementStyle.SetValue(key, value)) { if (key.Inherit || InheritMarker.IsInheritMarker(value)) { // inherited styles are distributed to child elements, so we need to explicitly clear them all. self.InvalidateStyle(false); } self.InvalidateLayout(); return(true); } return(false); }
public bool GetValue <T>(IStyleKey key, out T value) { if (!StyleSystem.IsRegisteredKey(key)) { throw new ArgumentException(); } var index = StyleSystem.LinearIndexFor(key); var o = values[index]; if (o is T) { value = (T)o; return(true); } value = default(T); return(false); }
public bool GetValue <T>(IStyleKey key, out T value) { if (elementStyle.GetValue(key, out value)) { return(true); } if (!elementStyle.IsExplicitlyInherited(key)) { if (ResolvedStyles.GetValue(key, out value)) { return(true); } if (!ResolvedStyles.IsExplicitlyInherited(key) && !key.Inherit) { value = default(T); return(false); } } // inheritance is potentially expensive, as we may traverse multiple // layers to get to the bottom of the tree. Caching is mandatory. object cachedValue; if (TryGetValue(key, out cachedValue)) { value = (T)cachedValue; return(true); } var parentStyle = Self.GetStyleParent()?.Style; if (parentStyle != null) { if (parentStyle.GetValue(key, out value)) { Store(key, value); return(true); } } value = default(T); Store(key, value); return(false); }
private static IStyleKeyPart[] GetKey(ILayoutable control, out int hash) { hash = control.Name.GetHashCode(); List <IStyleKeyPart> key; var parent = control.Parent as ILayoutable; if (parent != null) { int parentHash; IStyleKeyPart[] parentParts; if (parent.StyleKey != null) { IStyleKey parentKey = parent.StyleKey; parentParts = parentKey.Parts; parentHash = parentKey.GetHashCode(); } else { parentParts = GetKey(parent, out parentHash); } key = new List <IStyleKeyPart>(parentParts.Length + 1); key.AddRange(parentParts); hash ^= parentHash; } else { key = new List <IStyleKeyPart>(1); } string cssClass = control.CssClass; if (!string.IsNullOrEmpty(cssClass)) { cssClass = cssClass.ToLower(); hash ^= cssClass.GetHashCode(); } key.Add(!string.IsNullOrEmpty(cssClass) ? new Part(control.Name.ToLower(), cssClass) : new Part(control.Name.ToLower())); return(key.ToArray()); }
public bool SetValue(IStyleKey key, object value) { if (!StyleSystem.IsRegisteredKey(key)) { throw new ArgumentException(); } if (!InheritMarker.IsInheritMarker(value) && value != null && !key.ValueType.IsInstanceOfType(value)) { throw new ArgumentException(); } var index = StyleSystem.LinearIndexFor(key); var changed = !Equals(values[index], value); values[index] = value; if (changed) { ValueChanged?.Invoke(this, new StyleEventArgs(key)); } return(changed); }
public bool SetValue(IStyleKey key, object value) { if (!StyleSystem.IsRegisteredKey(key)) { throw new ArgumentException(); } if (!InheritMarker.IsInheritMarker(value) && value != null && !key.ValueType.IsInstanceOfType(value)) { throw new ArgumentException(); } var index = StyleSystem.LinearIndexFor(key); var changed = !Equals(values[index], value); if (changed) { values[index] = value; } keys[index] = key; valuesTouched[index] = true; return(changed); }
public static IPredefinedStyleBuilder WithBox(this IPredefinedStyleBuilder style, IStyleKey <IBoxTexture> key, string value, Insets insets) { return(WithBox(style, key, value, insets, Insets.Zero)); }
public void Init(IStyleSystem s) { IconTextGap = s.CreateKey <int>("icon-text-gap", false); }
public bool IsRegisteredKey(IStyleKey key) { return(this.parent.IsRegisteredKey(key)); }
public int LinearIndexFor(IStyleKey key) { return(this.parent.LinearIndexFor(key)); }
void Store(IStyleKey key, object value) { var idx = StyleSystem.LinearIndexFor(key); cachedValues[idx] = value; }
public void Init(IStyleSystem s) { DownOverlay = s.CreateKey <IBoxTexture>("down-overlay", false); DownOverlayColor = s.CreateKey <Color>("down-overlay-color", false); }
public StyleEventArgs(IStyleKey key) { Key = key; }
public void Init(IStyleSystem s) { NotebookTabOverlapX = s.CreateKey <int>("notebook-tab-overlap-x", false); NotebookTabOverlapY = s.CreateKey <int>("notebook-tab-overlap-y", false); }
public static IPredefinedStyleBuilder WithValue <T>(this IPredefinedStyleBuilder style, IStyleKey <T> key, T value) { style.SetValue(key, value); return(style); }
public static IPredefinedStyleBuilder WithTexture(this IPredefinedStyleBuilder style, IStyleKey <IUITexture> key, string value) { style.SetValue(key, style.ContentLoader.LoadTexture(value)); return(style); }
public void SetValue <T>(IStyleKey <T> key, T value) { Style.SetValue(key, value); }
internal static void Add(IStyleKey key) { keys.Add(key.Name, key); }
public static bool TryGetByName(string name, [MaybeNullWhen(false)] out IStyleKey styleKey) { return(keys.TryGetValue(name, out styleKey)); }
public static IPredefinedStyleBuilder WithBox(this IPredefinedStyleBuilder style, IStyleKey <IBoxTexture> key, string value, Insets insets, Insets margin) { style.SetValue(key, style.ContentLoader.LoadTexture(value, insets, margin)); return(style); }