Beispiel #1
0
            public OverflowMenuButton(OverflowBar overflowBar, ImageBuffer icon, ThemeConfig theme)
                : base(icon, theme)
            {
                this.DynamicPopupContent = () =>
                {
                    var popupMenu = new PopupMenu(ApplicationController.Instance.MenuTheme);

                    // Perform overflow
                    bool hasOverflowItems = false;
                    foreach (var widget in overflowBar.ActionArea.Children.Where(c => !c.Visible && !ignoredInMenuTypes.Contains(c.GetType())))
                    {
                        if (widget is ToolbarSeparator)
                        {
                            popupMenu.CreateSeparator();
                            continue;
                        }

                        hasOverflowItems = true;

                        PopupMenu.MenuItem menuItem;

                        var iconButton = widget as IconButton;

                        var iconImage = iconButton?.IconImage;

                        // Invert the menu icon if the application theme is dark
                        if (iconImage != null &&
                            theme.InvertIcons)
                        {
                            iconImage = iconImage.InvertLightness();
                        }

                        menuItem = popupMenu.CreateMenuItem(
                            widget.ToolTipText ?? widget.Text,
                            iconImage);

                        menuItem.Enabled = widget.Enabled;

                        menuItem.Click += (s, e) =>
                        {
                            widget.OnClick(e);
                        };
                    }

                    if (hasOverflowItems)
                    {
                        popupMenu.CreateSeparator();
                    }

                    // Extend menu with non-overflow/standard items
                    overflowBar.OnExtendPopupMenu(popupMenu);

                    return(popupMenu);
                };
            }
Beispiel #2
0
        public SimpleTabs(ThemeConfig theme, GuiWidget rightAnchorItem = null)
            : base(FlowDirection.TopToBottom)
        {
            this.TabContainer = this;

            if (rightAnchorItem == null)
            {
                TabBar = new OverflowBar(theme)
                {
                    HAnchor = HAnchor.Stretch,
                    VAnchor = VAnchor.Fit
                };
            }
            else
            {
                TabBar = new Toolbar(theme, rightAnchorItem)
                {
                    HAnchor = HAnchor.Stretch,
                    VAnchor = VAnchor.Fit
                };
            }

            this.AddChild(this.TabBar);
        }
        public static void SlideToNewState(this RadioIconButton widget, RadioIconButton newActiveButton, OverflowBar parent, Action animationComplete, ThemeConfig theme)
        {
            double displayTime = 600;
            double elapsedMs   = 0;

            var box = new GuiWidget()
            {
                HAnchor                = HAnchor.Absolute,
                VAnchor                = VAnchor.Absolute,
                Position               = widget.Position + new VectorMath.Vector2(widget.Margin.Width, widget.Margin.Height),
                Size                   = widget.Size,
                BackgroundColor        = theme.AccentMimimalOverlay,
                BackgroundRadius       = theme.ButtonRadius,
                BackgroundOutlineWidth = 1,
                BorderColor            = theme.PrimaryAccentColor
            };

            parent.AddChildDirect(box);

            var startX    = box.Position.X;
            var startY    = box.Position.Y;
            var xdistance = (newActiveButton.Position.X + newActiveButton.Margin.Width) - startX;
            var direction = xdistance > 0 ? 1 : -1;
            var startedMS = UiThread.CurrentTimerMs;

            var animation = new Animation()
            {
                DrawTarget      = widget,
                FramesPerSecond = 20,
            };

            animation.Update += (s1, updateEvent) =>
            {
                elapsedMs = UiThread.CurrentTimerMs - startedMS;
                if (elapsedMs < (displayTime + 300))
                {
                    var    ratio = Math.Min(1, elapsedMs / displayTime);
                    double blend = Easing.Cubic.In(ratio);
                    box.Position = new VectorMath.Vector2(startX + (xdistance * blend), startY);

                    // Console.WriteLine("Ms: {0}, Ratio: {1}, Easing: {2}, Position: {3}", elapsedMs, ratio, blend, box.Position);
                    box.Invalidate();
                }
                else
                {
                    animation.Stop();

                    animationComplete?.Invoke();

                    UiThread.RunOnIdle(box.Close, .3);
                }
            };

            animation.Start();
        }
Beispiel #4
0
 public OverflowMenuButton(OverflowBar overflowBar, ThemeConfig theme)
     : this(overflowBar, CreateOverflowIcon(theme), theme)
 {
 }