Beispiel #1
0
        public ThemedButton()
        {
            var presenter = new ButtonPresenter();

            Nodes.Clear();
            MinMaxSize    = Theme.Metrics.DefaultButtonSize;
            Size          = MinSize;
            Padding       = Theme.Metrics.ControlsPadding;
            Presenter     = presenter;
            PostPresenter = new Theme.KeyboardFocusBorderPresenter(2.0f);
            DefaultAnimation.AnimationEngine = new AnimationEngineDelegate {
                OnRunAnimation = (animation, markerId, animationTimeCorrection) => {
                    presenter.SetState(markerId);
                    return(true);
                }
            };
            var caption = new SimpleText {
                Id           = "TextPresenter",
                TextColor    = Theme.Colors.BlackText,
                FontHeight   = Theme.Metrics.TextHeight,
                HAlignment   = HAlignment.Center,
                VAlignment   = VAlignment.Center,
                OverflowMode = TextOverflowMode.Ellipsis
            };

            AddNode(caption);
            TabTravesable = new TabTraversable();
            caption.ExpandToContainerWithAnchors();
        }
Beispiel #2
0
        public ThemedTab()
        {
            Padding = Theme.Metrics.ControlsPadding;
            MinSize = Theme.Metrics.MinTabSize;
            MaxSize = Theme.Metrics.MaxTabSize;
            Size    = MinSize;
            Layout  = new HBoxLayout();
            var caption = new SimpleText {
                Id             = "TextPresenter",
                ForceUncutText = false,
                FontHeight     = Theme.Metrics.TextHeight,
                HAlignment     = HAlignment.Center,
                VAlignment     = VAlignment.Center,
                OverflowMode   = TextOverflowMode.Ellipsis,
                LayoutCell     = new LayoutCell(Alignment.Center)
            };
            var presenter = new TabPresenter(caption);

            Presenter = presenter;
            DefaultAnimation.AnimationEngine = new AnimationEngineDelegate {
                OnRunAnimation = (animation, markerId, animationTimeCorrection) => {
                    presenter.SetState(markerId);
                    return(true);
                }
            };
            var closeButton = new ThemedTabCloseButton {
                Id = "CloseButton"
            };

            AddNode(caption);
            AddNode(closeButton);
            LateTasks.Add(Theme.MouseHoverInvalidationTask(this));
        }
Beispiel #3
0
 public CommonEditBox()
 {
     ScrollWidget         = new Frame();
     ScrollView           = new ScrollView(ScrollWidget, ScrollDirection.Horizontal);
     ScrollView.CanScroll = false;
     TextWidget           = new SimpleText();
     TextWidget.Height    = Height;
     ScrollView.Content.AddNode(TextWidget);
     Layout = new StackLayout();
     AddNode(ScrollWidget);
 }
Beispiel #4
0
 internal static void Decorate(SimpleText text)
 {
     text.ForceUncutText  = true;
     text.Localizable     = true;
     text.TextColor       = Color4.White;
     text.Color           = Theme.Colors.BlackText;
     text.Font            = new SerializableFont();
     text.FontHeight      = Theme.Metrics.TextHeight;
     text.HAlignment      = HAlignment.Left;
     text.VAlignment      = VAlignment.Top;
     text.OverflowMode    = TextOverflowMode.Ellipsis;
     text.TrimWhitespaces = true;
     text.Size            = text.MinSize;
 }
Beispiel #5
0
        public void Append(string text)
        {
            var        lastLine            = lines.Count > 0 ? lines[lines.Count - 1] : null;
            SimpleText lastNonSentinelLine = null;

            if (SquashDuplicateLines)
            {
                lastNonSentinelLine = lines.Count > 1 ? lines[lines.Count - 2] : null;
            }
            var newLines = text.Split('\n');

            for (int i = 0; i < newLines.Length; i++)
            {
                var l = newLines[i];
                if (SquashDuplicateLines)
                {
                    if (lastNonSentinelLine != null && lastNonSentinelLine.Text == l)
                    {
                        lastNonSentinelLine.Components.Get <ThemedTextView.TextLineMultiplicity>().Multiplicity++;
                        lastNonSentinelLine.Invalidate();
                        //TODO: invalidate window only if it isn't docked
                        (GetRoot() as WindowWidget)?.Window.Invalidate();
                        continue;
                    }
                }
                if (lastLine != null)
                {
                    lastLine.Text += l;
                    if (SquashDuplicateLines)
                    {
                        lastNonSentinelLine = lastLine;
                    }
                    lastLine = null;
                }
                else
                {
                    var line = new ThemedSimpleText(l)
                    {
                        TrimWhitespaces = TrimWhitespaces
                    };
                    line.TextProcessor += ProcessTextLine;
                    line.Components.Add(new TextLineMultiplicity());
                    lines.Add(line);
                    Behaviour.Content.AddNode(line);
                }
            }
        }
Beispiel #6
0
 public TabPresenter(SimpleText label)
 {
     this.label = label;
 }