Exemple #1
0
        public static Rect GetContentBox(Rect rect, StyleRuleSet style)
        {
            //Widths of border
            var bt = style.Get <double>(GUIStyleName.BorderTop);
            var br = style.Get <double>(GUIStyleName.BorderRight);
            var bb = style.Get <double>(GUIStyleName.BorderBottom);
            var bl = style.Get <double>(GUIStyleName.BorderLeft);

            //Widths of padding
            var pt = style.Get <double>(GUIStyleName.PaddingTop);
            var pr = style.Get <double>(GUIStyleName.PaddingRight);
            var pb = style.Get <double>(GUIStyleName.PaddingBottom);
            var pl = style.Get <double>(GUIStyleName.PaddingLeft);

            //4 corner of the border-box
            var btl = new Point(rect.Left, rect.Top);
            var btr = new Point(rect.Right, rect.Top);
            var bbr = new Point(rect.Right, rect.Bottom);
            var bbl = new Point(rect.Left, rect.Bottom);

            //4 corner of the padding-box
            var ptl = new Point(btl.X + bl, btl.Y + bt);
            var ptr = new Point(btr.X - br, btr.Y + bt);
            var pbr = new Point(bbr.X - br, bbr.Y - bb);
            var pbl = new Point(bbl.X + bl, bbl.Y - bb);

            Debug.Assert(ptl.X < ptr.X);//TODO what if (ptl.X > ptr.X) happens?

            //4 corner of the content-box
            var ctl = new Point(ptl.X + pl, ptl.Y + pt);
            var ctr = new Point(ptr.X - pr, ptr.Y + pr);
            var cbr = new Point(pbr.X - pr, pbr.Y - pb);
            var cbl = new Point(pbl.X + pl, pbl.Y - pb);

            if (ctl.X >= ctr.X)
            {
                Log.Warning("Content box is zero-sized.");
                return(new Rect(ctl, Size.Zero));
            }

            return(new Rect(ctl, cbr));
        }
Exemple #2
0
        private static GUISkin CreateDefaultSkin()
        {
            GUISkin skin = new GUISkin();

            // init default rule lists
            StyleRuleSet button = new StyleRuleSet();

            skin.InitButtonStyles(button);
            skin.styles[GUIControlName.Button] = button;

            StyleRuleSet label = new StyleRuleSet();

            skin.InitLabelStyles(label);
            skin.styles[GUIControlName.Label] = label;

            //skin.InitSelectableStyles();
            //skin.InitListBoxStyles();
            //skin.InitTextBoxStyles();

            return(skin);
        }
Exemple #3
0
        internal static ITextContext GetTextContext(string text, Size size, StyleRuleSet style, GUIState state)
        {
            if (text == null)
            {
                throw new ArgumentNullException(nameof(text));
            }
            if (style == null)
            {
                throw new ArgumentNullException(nameof(style));
            }

            int textMeshId = GetTextId(text, state);

            ITextContext textContext;

            if (TextContextCache.TryGetValue(textMeshId, out textContext))
            {
                return(textContext);
            }
            else
            {
                // create a TextContent for the text
                var fontFamily    = style.Get <string>(GUIStyleName.FontFamily, state);
                var fontSize      = style.Get <double>(GUIStyleName.FontSize, state);
                var fontStretch   = (FontStretch)style.Get <int>(GUIStyleName.FontStretch, state);
                var fontStyle     = (FontStyle)style.Get <int>(GUIStyleName.FontStyle, state);
                var fontWeight    = (FontWeight)style.Get <int>(GUIStyleName.FontWeight, state);
                var textAlignment = (TextAlignment)style.Get <int>(GUIStyleName.TextAlignment, state);
                textContext = Application.PlatformContext.CreateTextContext(
                    text,
                    fontFamily, (int)fontSize, fontStretch, fontStyle, fontWeight,
                    (int)Math.Ceiling(size.Width), (int)Math.Ceiling(size.Height),
                    textAlignment);
                textContext.Build(Point.Zero);
                TextContextCache.Add(textMeshId, textContext);
            }
            return(textContext);
        }
Exemple #4
0
 public StyleRuleSetBuilder(StyleRuleSet ruleSet)
 {
     this.s = ruleSet;
 }
Exemple #5
0
 internal void Replace(StyleRuleSet styleRuleSet)
 {
     this.rules.Clear();
     this.rules.AddRange(styleRuleSet.rules);
 }
Exemple #6
0
 private void InitProgressBarStyles(StyleRuleSet ruleSet)
 {
     ruleSet.TextAlignment = TextAlignment.Center;
 }
Exemple #7
0
        private static GUISkin CreateDefaultSkin()
        {
            GUISkin skin = new GUISkin();

            // init default rule lists
            StyleRuleSet button = new StyleRuleSet();

            skin.InitButtonStyles(button);
            skin.styles[GUIControlName.Button] = button;

            StyleRuleSet label = new StyleRuleSet();

            skin.InitLabelStyles(label);
            skin.styles[GUIControlName.Label] = label;

            StyleRuleSet box = new StyleRuleSet();

            skin.InitBoxStyles(box);
            skin.styles[GUIControlName.Box] = box;

            skin.InitCollapsingHeaderStyles(button, out var collapsingHeader);
            skin.styles[GUIControlName.CollapsingHeader] = collapsingHeader;

            StyleRuleSet textBox = new StyleRuleSet();

            skin.InitTextBoxStyles(textBox);
            skin.styles[GUIControlName.TextBox] = textBox;

            StyleRuleSet image = new StyleRuleSet();

            skin.InitImageStyles(image);
            skin.styles[GUIControlName.Image] = image;

            StyleRuleSet toggle = new StyleRuleSet();

            skin.InitToggleStyles(toggle);
            skin.styles[GUIControlName.Toggle] = toggle;

            StyleRuleSet selectable = new StyleRuleSet();

            skin.InitSelectableStyles(selectable);
            skin.styles[GUIControlName.Selectable] = selectable;

            StyleRuleSet separator = new StyleRuleSet();

            skin.InitSeparatorStyle(separator);
            skin.styles[GUIControlName.Separator] = separator;

            StyleRuleSet progressBar = new StyleRuleSet();

            skin.InitProgressBarStyles(progressBar);
            skin.styles[GUIControlName.ProgressBar] = progressBar;

            StyleRuleSet slider = new StyleRuleSet();

            skin.InitSliderStyles(slider);
            skin.styles[GUIControlName.Slider] = slider;

            StyleRuleSet listbox = new StyleRuleSet();

            skin.InitListBoxStyles(listbox);
            skin.styles[GUIControlName.ListBox] = listbox;

            skin.InitTreeNodeStyles(button, out var treeNode);
            skin.styles[GUIControlName.TreeNode] = treeNode;

            StyleRuleSet colorField = new StyleRuleSet();

            skin.InitColorFieldStyles(colorField);
            skin.styles[GUIControlName.ColorField] = colorField;

            return(skin);
        }
Exemple #8
0
 private void InitColorFieldStyles(StyleRuleSet ruleSet)
 {
     //TODO
 }