Example #1
0
            public PanelTab()
            {
                MinSize    = new Vector2(TabMinWidth, TabHeight);
                MaxSize    = new Vector2(TabMaxWidth, TabHeight);
                LayoutCell = new LayoutCell(Alignment.LeftTop);
                Size       = MinSize;
                Layout     = new HBoxLayout();
                var caption = new SimpleText {
                    Id             = "TextPresenter",
                    Padding        = Theme.Metrics.ControlsPadding,
                    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);

                CompoundPresenter.Add(presenter);
                DefaultAnimation.AnimationEngine = new AnimationEngineDelegate {
                    OnRunAnimation = (animation, markerId, animationTimeCorrection) => {
                        presenter.SetState(markerId);
                        return(true);
                    }
                };
                AddNode(caption);
                HitTestTarget = true;
                LateTasks.Add(Theme.MouseHoverInvalidationTask(this));
                this.AddChangeWatcher(() => Active,
                                      isActive => Padding = isActive ? new Thickness {
                    Top = -1f, Bottom = 1f
                } : new Thickness());
            }
Example #2
0
        public ThemedNumericEditBox()
        {
            ThemedEditBox.Decorate(this);
            MinWidth           = 0.0f;
            MaxWidth           = 105.0f;
            TextWidget.Padding = new Thickness(left: 5.0f, right: 5.0f, top: 2.0f, bottom: 2.0f);
            Layout             = new HBoxLayout();
            // Lime.EditorParams.MouseSelectionThreshold is 3 by default and this gesture should be recognized first.
            // To achieve that we're setting its drag threshold to 2.0f, add it to Editor.ClickableWidget (same collection
            // editor adds its widgets to) and do it in LateTasks.
            var dragGesture = new DragGesture(exclusive: true, dragThreshold: 2.0f);

            Updated += (delta) => {
                if (Editor.FocusableWidget.IsFocused())
                {
                    dragGesture.Cancel();
                }
                else if (IsMouseOverThisOrDescendant() || isDragging)
                {
                    WidgetContext.Current.MouseCursor = MouseCursor.SizeWE;
                }
            };
            LateTasks.Add(Task.Repeat(() => {
                dragGesture.Recognized += () => Tasks.Add(SpinByDragTask(dragGesture));
                Editor.ClickableWidget.Gestures.Insert(0, dragGesture);
                return(false);
            }));
        }
Example #3
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));
        }
Example #4
0
 public ThemedCheckBox()
 {
     Layout = new StackLayout();
     AddNode(new Button {
         Id            = "Button",
         Presenter     = new CheckBoxPresenter(this),
         LayoutCell    = new LayoutCell(Alignment.Center),
         MinMaxSize    = Theme.Metrics.CheckBoxSize,
         TabTravesable = null
     });
     TabTravesable = new TabTraversable();
     CompoundPostPresenter.Add(new Theme.MouseHoverBorderPresenter());
     LateTasks.Add(Theme.MouseHoverInvalidationTask(this));
 }
Example #5
0
        public ThemedDropDownList()
        {
            MinSize       = Theme.Metrics.DefaultButtonSize;
            MaxHeight     = Theme.Metrics.DefaultButtonSize.Y;
            TabTravesable = new TabTraversable();
            var text = new ThemedSimpleText {
                Id         = "TextWidget",
                VAlignment = VAlignment.Center,
            };

            CompoundPresenter.Add(new DropDownListPresenter(this));
            PostPresenter = new Theme.MouseHoverBorderPresenter();
            LateTasks.Add(Theme.MouseHoverInvalidationTask(this));
            Padding = Theme.Metrics.ControlsPadding;
            AddNode(text);
            text.ExpandToContainerWithAnchors();
            text.X     += 4;
            text.Width -= DropDownListPresenter.IconWidth + 4;
        }
Example #6
0
 protected override void Awake()
 {
     LateTasks.Add(Loop());
 }