public Widget(WidgetStyleSheet style) : base(null) { m_background = new WindowObjectArray <WindowObject>(); m_backgroundStyle = style.BackgroundStyle; m_backgroundTexture = style.BackgroundTexture; m_backgroundScale = style.BackgroundScale; m_backgroundPivot = style.BackgroundPivot; m_backgroundInited = false; m_backgroundDepth = style.BackgroundDepth; m_backgroundPadding = style.BackgroundPadding; m_colorTint = style.Color; m_alpha = style.Opacity; m_clipContents = style.Clip; m_clipMargin = style.ClipMargin; m_style = style; }
internal WidgetStyleSheet(WidgetStyleSheet parent) { m_clip = parent.Clip; m_size = parent.Size; m_name = parent.Name + "_" + GetHashCode(); m_parameters = new Dictionary <string, string>(); foreach (KeyValuePair <string, string> pair in parent.m_parameters) { m_parameters.Add(pair.Key, pair.Value); } m_color = parent.Color; m_opacity = parent.Opacity; m_clipMargin = parent.ClipMargin; m_font = parent.Font; m_fontSize = parent.FontSize; m_backgroundScale = parent.BackgroundScale; m_backgroundDepth = parent.BackgroundDepth; m_backgroundStyle = parent.BackgroundStyle; m_backgroundTexture = parent.BackgroundTexture; m_backgroundPivot = parent.BackgroundPivot; m_backgroundPadding = parent.m_backgroundPadding; m_padding = parent.Padding; }
internal WidgetStyleSheet(string name, WidgetStyleSheet parent, XmlNode node) : this(parent) { foreach (XmlNode element in node.ChildNodes) { try { string value = element.InnerText; if (string.IsNullOrEmpty(value) && element.Attributes.GetNamedItem("value") != null) { value = element.Attributes.GetNamedItem("value").Value; } if (value == null) { value = string.Empty; } else { value = value.Trim('\r', '\n', '\t', ' '); } switch (element.Name) { case "back_style": m_backgroundStyle = (WidgetBackgroundStyle)Enum.Parse(typeof(WidgetBackgroundStyle), value); break; case "back_depth": m_backgroundDepth = (WidgetBackgroundDepth)Enum.Parse(typeof(WidgetBackgroundDepth), value); break; case "back_image": m_backgroundTexture = value; break; case "back_scale": m_backgroundScale = FloatParse(value); break; case "back_pivot": { string[] values = value.Split(';'); float x = FloatParse(values[0]); float y = FloatParse(values[1]); m_backgroundPivot = new Vector2(x, y); break; } case "font": m_font = WidgetManager.GetFont(value); break; case "font_size": m_fontSize = FloatParse(value); break; case "clip": m_clip = bool.Parse(value); break; case "color": m_color = ColorParse(value); break; case "opacity": m_opacity = FloatParse(value); break; case "size": m_size = Vector2Parse(value); break; case "clip_margin": m_clipMargin = MarginParse(value); break; case "padding": m_padding = MarginParse(value); break; case "back_padding": m_backgroundPadding = MarginParse(value); break; default: m_parameters[element.Name] = value; break; } } catch (Exception ex) { WindowController.Instance.LogError("Error parsing style {0}, element {1}: {2}", name, element.Name, ex); throw; } } }