Beispiel #1
0
        private void MeasureLayout(PopupWindow sender)
        {
            // We can obtain the size of keyboard by comparing the layout of two popup windows
            // where one (AdjustResize) resizes to keyboard and one(AdjustNothing) that doesn't:
            // [size] realMetrics			: screen
            // [rect] adjustNothingFrame	: screen - (top: status_bar) - (bottom: nav_bar)
            // [rect] adjustResizeFrame		: screen - (top: status_bar) - (bottom: keyboard + nav_bar)
            var realMetrics        = Get <DisplayMetrics>(_activity.WindowManager.DefaultDisplay.GetRealMetrics);
            var adjustNothingFrame = Get <Rect>(_adjustNothingLayoutProvider.ContentView.GetWindowVisibleDisplayFrame);
            var adjustResizeFrame  = Get <Rect>(_adjustResizeLayoutProvider.ContentView.GetWindowVisibleDisplayFrame);

            StatusBarRect     = new Rect(0, 0, realMetrics.WidthPixels, adjustNothingFrame.Top);
            KeyboardRect      = new Rect(0, adjustResizeFrame.Bottom, realMetrics.WidthPixels, adjustNothingFrame.Bottom);
            NavigationBarRect = new Rect(0, adjustNothingFrame.Bottom, realMetrics.WidthPixels, realMetrics.HeightPixels);

            LayoutChanged?.Invoke(StatusBarRect, KeyboardRect, NavigationBarRect);

            T Get <T>(Action <T> getter) where T : new()
            {
                var result = new T();

                getter(result);

                return(result);
            }
        }
        private void Current_InputLanguageChanged(object sender, InputLanguageEventArgs e)
        {
            var layout = layouts.First(l => l.CultureInfo.Equals(e.NewLanguage));

            logger.Info($"Detected keyboard layout change from {ToString(e.PreviousLanguage)} to {ToString(e.NewLanguage)}.");
            LayoutChanged?.Invoke(layout);
        }
Beispiel #3
0
        protected void UpdateChildrenLayout()
        {
            if (!ShouldLayoutChildren())
            {
                return;
            }

            var startingLayout = new List <Rectangle>(LogicalChildren.Count);

            foreach (VisualElement c in LogicalChildren)
            {
                startingLayout.Add(c.Bounds);
            }

            double x = Padding.Left;
            double y = Padding.Top;
            double w = Math.Max(0, Width - Padding.HorizontalThickness);
            double h = Math.Max(0, Height - Padding.VerticalThickness);

            LayoutChildren(x, y, w, h);

            for (var i = 0; i < LogicalChildren.Count; i++)
            {
                var c = (VisualElement)LogicalChildren[i];

                if (c.Bounds != startingLayout[i])
                {
                    LayoutChanged?.Invoke(this, EventArgs.Empty);
                    return;
                }
            }
        }
 public override void layout()
 {
     if (LayoutChanged != null)
     {
         LayoutChanged.Invoke(this);
     }
     base.layout();
 }
Beispiel #5
0
 public override void layout()
 {
     widget.setCoord(Location.x, Location.y, WorkingSize.Width, WorkingSize.Height);
     if (LayoutChanged != null)
     {
         LayoutChanged.Invoke();
     }
 }
 internal void fireLayoutChanged()
 {
     if (changedProperties)
     {
         if (LayoutChanged != null)
         {
             LayoutChanged.Invoke(this);
         }
         changedProperties = false;
     }
 }
        public virtual void layout()
        {
            int height = flowLayout.DesiredSize.Height;
            int width  = widget.Width;

            flowLayout.WorkingSize = new IntSize2(width - rightPadding, height);
            flowLayout.layout();
            if (LayoutChanged != null)
            {
                LayoutChanged.Invoke(this);
            }
        }
Beispiel #8
0
        private void MeasureLayout(PopupWindow sender)
        {
#pragma warning disable 618
            // We can obtain the size of keyboard by comparing the layout of two popup windows
            // where one (AdjustResize) resizes to keyboard and one(AdjustNothing) that doesn't:
            // [size] realMetrics			: screen
            // [size] metrics				: screen - dead zones
            // [rect] displayRect			: screen - (bottom: nav_bar)
            // [rect] adjustNothingFrame	: screen - (top: status_bar) - (bottom: nav_bar)
            // [rect] adjustResizeFrame		: screen - (top: status_bar) - (bottom: keyboard + nav_bar)
            var realMetrics        = Get <DisplayMetrics>(_activity.WindowManager.DefaultDisplay.GetRealMetrics);
            var metrics            = Get <DisplayMetrics>(_activity.WindowManager.DefaultDisplay.GetMetrics);
            var displayRect        = Get <Rect>(_activity.WindowManager.DefaultDisplay.GetRectSize);
            var adjustNothingFrame = Get <Rect>(_adjustNothingLayoutProvider.ContentView.GetWindowVisibleDisplayFrame);
            var adjustResizeFrame  = Get <Rect>(_adjustResizeLayoutProvider.ContentView.GetWindowVisibleDisplayFrame);
#pragma warning restore 618

            var orientation = DisplayInformation.GetForCurrentView().CurrentOrientation;

            StatusBarRect = new Rect(0, 0, realMetrics.WidthPixels, adjustNothingFrame.Top);
            KeyboardRect  = new Rect(0, adjustResizeFrame.Bottom, realMetrics.WidthPixels, adjustNothingFrame.Bottom);

            switch (orientation)
            {
            case DisplayOrientations.Landscape:
                NavigationBarRect = new Rect(0, 0, metrics.WidthPixels - displayRect.Width(), metrics.HeightPixels);
                break;

            case DisplayOrientations.LandscapeFlipped:
                NavigationBarRect = new Rect(adjustNothingFrame.Width(), 0, metrics.WidthPixels - displayRect.Width(), metrics.HeightPixels);
                break;

            // Miss portrait flipped
            case DisplayOrientations.Portrait:
            default:
                NavigationBarRect = new Rect(0, adjustNothingFrame.Bottom, realMetrics.WidthPixels, realMetrics.HeightPixels);
                break;
            }

            LayoutChanged?.Invoke(StatusBarRect, KeyboardRect, NavigationBarRect);

            T Get <T>(Action <T> getter) where T : new()
            {
                var result = new T();

                getter(result);

                return(result);
            }
        }
Beispiel #9
0
        public PuzzleLayout()
        {
            _puzzleNodes   = new PuzzleNodes();
            _puzzleObjects = new PuzzleObjects();

            NodeRemoved       += node => RemoveObject(node.Position);
            ConnectionAdded   += _ => LayoutChanged.CallEvent();
            ConnectionRemoved += _ => LayoutChanged.CallEvent();

            ObjectAdded   += (_, __) => LayoutChanged.CallEvent();
            ObjectRemoved += _ => LayoutChanged.CallEvent();
            PropertySet   += (_, __, ___) => LayoutChanged.CallEvent();
            _puzzleObjects.PropertyRemoved += (_, __) => LayoutChanged.CallEvent();
        }
Beispiel #10
0
        protected void UpdateChildrenLayout()
        {
            if (!ShouldLayoutChildren())
            {
                return;
            }

            double x = Padding.Left;
            double y = Padding.Top;

            for (var i = 0; i < LogicalChildren.Count; i++)
            {
                LayoutChanged?.Invoke(this, EventArgs.Empty);
            }
        }
Beispiel #11
0
        private void Layout_LayoutChanged(object sender, LayoutChangedEventArgs e)
        {
            HasChanged = true;

            if (!IsUndoing)
            {
                if (CurrentActionIndex < ModificationList.Count - 1)
                {
                    ModificationList.RemoveRange(CurrentActionIndex + 1, ModificationList.Count - CurrentActionIndex - 1);
                }
                CurrentActionIndex++;
                ModificationList.Add(e.Change);
            }

            LayoutChanged?.Invoke(this, EventArgs.Empty);
        }
Beispiel #12
0
		/// <summary> trigger dependant sizing component update </summary>
		public virtual void OnLayoutChanges(LayoutingType  layoutType)
		{
			#if DEBUG_LAYOUTING
			CurrentInterface.currentLQI.Slot = LastSlots;
			CurrentInterface.currentLQI.NewSlot = Slot;
			Debug.WriteLine ("\t\t{0} => {1}",LastSlots,Slot);
			#endif

			switch (layoutType) {
			case LayoutingType.Width:
				RegisterForLayouting (LayoutingType.X);
				break;
			case LayoutingType.Height:
				RegisterForLayouting (LayoutingType.Y);
				break;
			}
			LayoutChanged.Raise (this, new LayoutingEventArgs (layoutType));
		}
Beispiel #13
0
 public void layout()
 {
     if (allowLayout)
     {
         if (parent != null)
         {
             parent.layout();
         }
         else
         {
             doLayout(0);
             if (LayoutChanged != null)
             {
                 LayoutChanged.Invoke(this);
             }
         }
     }
 }
Beispiel #14
0
 public void Update([CanBeNull] IReadonlyContext context, [CanBeNull] IParadigm paradigm)
 {
     context = context ?? EmptyContext.Instance;
     if (UpdateSummaryVisibility(context, false))
     {
         LayoutChanged?.Invoke(this, LayoutChangedEventArgs.NonInitialization);
     }
     foreach (var holder in _summaryViewModels.Where(sh => sh.IsVisible))
     {
         try
         {
             holder.ContentPresenter.Content = holder.Summary.GetValue(context, paradigm);
         }
         catch (Exception e)
         {
             Logger.Warn("Update - summary", e, "summary", holder.Summary.Name);
             holder.ContentPresenter.Content = new TextBlock {
                 Text = "Err", Foreground = Brushes.Red
             };
         }
     }
 }
Beispiel #15
0
        private void InitializeConfigurationPanel()
        {
            Children.Clear();
            _summaryViewModels.Clear();

            if (Summaries?.Any() ?? false)
            {
                if (GroupHeader != null)
                {
                    Children.Add(ViewHelper.CreateGroupHeader(GroupHeader, null));
                }
                foreach (var summary in Summaries)
                {
                    var summaryViewModel = this.AddSummaryRow(summary);
                    summaryViewModel.AnimationCompleted += (sender, e) => LayoutChanged?.Invoke(this, LayoutChangedEventArgs.NonInitialization);
                    _summaryViewModels.Add(summaryViewModel);
                }
            }

            UpdateSummaryVisibility(EmptyContext.Instance, true);
            LayoutChanged?.Invoke(this, LayoutChangedEventArgs.Initialization);
        }
        private void DrawSceneAssetLine(int i)
        {
            using (new EditorGUILayout.HorizontalScope())
            {
                var moveButtonStyle = new GUIStyle(EditorStyles.miniButton)
                {
                    fontSize = 8
                };
                using (new EditorGUI.DisabledScope(_sceneAssets.Count < 2 || i == 0))
                    if (GUILayout.Button(new GUIContent("\u25B2", "Move Up"), moveButtonStyle, GUILayout.Width(20)))
                    {
                        var thisAsset = _sceneAssets[i];
                        _sceneAssets[i]     = _sceneAssets[i - 1];
                        _sceneAssets[i - 1] = thisAsset;
                    }

                using (new EditorGUI.DisabledScope(_sceneAssets.Count < 2 || i == _sceneAssets.Count - 1))
                    if (GUILayout.Button(new GUIContent("\u25BC", "Move Down"), moveButtonStyle, GUILayout.Width(20)))
                    {
                        var thisAsset = _sceneAssets[i];
                        _sceneAssets[i]     = _sceneAssets[i + 1];
                        _sceneAssets[i + 1] = thisAsset;
                    }

                var sceneAsset = _sceneAssets[i];
                _sceneAssets[i] = EditorGUILayout.ObjectField(
                    GUIContent.none,
                    sceneAsset,
                    typeof(SceneAsset),
                    false) as SceneAsset;

                if (GUILayout.Button(new GUIContent("\u00D7", "Remove asset from list"), EditorStyles.miniButton, GUILayout.Width(20)))
                {
                    _sceneAssets.RemoveAt(i);
                    LayoutChanged?.Invoke();
                }
            }
        }
Beispiel #17
0
        protected void UpdateChildrenLayout()
        {
            if (!ShouldLayoutChildren())
            {
                return;
            }

            var logicalChildren = ((IElementController)this).LogicalChildren;
            var startingLayout  = new List <Rect>(logicalChildren.Count);

            foreach (Element el in logicalChildren)
            {
                if (el is VisualElement c)
                {
                    startingLayout.Add(c.Bounds);
                }
            }

            double x = Padding.Left;
            double y = Padding.Top;
            double w = Math.Max(0, Width - Padding.HorizontalThickness);
            double h = Math.Max(0, Height - Padding.VerticalThickness);

            LayoutChildren(x, y, w, h);

            for (var i = 0; i < logicalChildren.Count; i++)
            {
                var element = logicalChildren[i];
                if (element is VisualElement c)
                {
                    if (startingLayout.Count <= i || c.Bounds != startingLayout[i])
                    {
                        LayoutChanged?.Invoke(this, EventArgs.Empty);
                        return;
                    }
                }
            }
        }
        private void DrawSceneAssetList()
        {
            using (new EditorGUILayout.HorizontalScope())
            {
                EditorGUILayout.LabelField("Quick Switch Scenes");
                if (GUILayout.Button("Refresh", EditorStyles.miniButton, GUILayout.MaxWidth(60)))
                {
                    RefreshClick?.Invoke();
                }
            }

            GUILayout.Space(10);

            if (_sceneAssets.Count == 0)
            {
                EditorGUILayout.LabelField("Press “+” to add Scene Assets...");
            }
            else
            {
                for (int i = 0; i < _sceneAssets.Count; i++)
                {
                    if (i != 0)
                    {
                        GUILayout.Space(2.5f);
                    }
                    DrawSceneAssetLine(i);
                }
            }

            GUILayout.Space(5);

            if (GUILayout.Button(new GUIContent("+", "Add a scene asset"), EditorStyles.miniButton))
            {
                _sceneAssets.Add(null);
                LayoutChanged?.Invoke();
            }
        }
Beispiel #19
0
        void RaiseLayoutChanged(double effectiveViewportWidth, double effectiveViewportHeight, ITextViewLine[] newOrReformattedLines, ITextViewLine[] translatedLines)
        {
            if (IsClosed)
            {
                return;
            }
            Debug.Assert(!raisingLayoutChanged);
            raisingLayoutChanged = true;
            var newViewState = new ViewState(this, effectiveViewportWidth, effectiveViewportHeight);

            LayoutChanged?.Invoke(this, new TextViewLayoutChangedEventArgs(oldViewState, newViewState, newOrReformattedLines, translatedLines));
            oldViewState = newViewState;
            foreach (var p in visiblePhysicalLines)
            {
                foreach (var l in p.Lines)
                {
                    l.SetChange(TextViewLineChange.None);
                    l.SetDeltaY(0);
                }
            }
            Debug.Assert(raisingLayoutChanged);
            raisingLayoutChanged = false;
            mouseHoverHelper.OnLayoutChanged();
        }
        protected internal override Size ArrangeOverride(NonVirtualizingLayoutContext context, Size finalSize)
        {
            var children = context.Children;

            if (children != null)
            {
                var itemCount         = children.Count;
                var minitemsPerColumn = (int)(Math.Floor((float)(itemCount) / m_actualColumnCount));
                var numberOfColumnsWithExtraElements = (int)(itemCount % (int)(m_actualColumnCount));

                var columnSpacing = (float)(ColumnSpacing);
                var rowSpacing    = (float)(RowSpacing);

                var horizontalOffset = 0.0;
                var verticalOffset   = 0.0;
                var index            = 0;
                var column           = 0;
                foreach (var child in children)
                {
                    var desiredSize = child.DesiredSize;
                    child.Arrange(new Rect(horizontalOffset, verticalOffset, desiredSize.Width, desiredSize.Height));
                    if (column < numberOfColumnsWithExtraElements)
                    {
                        if (index % (minitemsPerColumn + 1) == minitemsPerColumn)
                        {
                            horizontalOffset += m_largestChildSize.Width + columnSpacing;
                            verticalOffset    = 0.0;
                            column++;
                        }
                        else
                        {
                            verticalOffset += m_largestChildSize.Height + rowSpacing;
                        }
                    }
                    else
                    {
                        var indexAfterExtraLargeColumns = index - (numberOfColumnsWithExtraElements * (minitemsPerColumn + 1));
                        if (indexAfterExtraLargeColumns % minitemsPerColumn == minitemsPerColumn - 1)
                        {
                            horizontalOffset += m_largestChildSize.Width + columnSpacing;
                            verticalOffset    = 0.0;
                            column++;
                        }
                        else
                        {
                            verticalOffset += m_largestChildSize.Height + rowSpacing;
                        }
                    }
                    index++;
                }

                if (m_testHooksEnabled)
                {
                    //Testhooks setup
                    if (m_largerColumns != numberOfColumnsWithExtraElements ||
                        m_columns != column ||
                        m_rows != minitemsPerColumn)
                    {
                        m_largerColumns = numberOfColumnsWithExtraElements;
                        m_columns       = column;
                        m_rows          = minitemsPerColumn;

                        LayoutChanged?.Invoke(this, null);
                    }
                }
            }
            return(finalSize);
        }
Beispiel #21
0
        protected override void OnLayout(bool changed, int l, int t, int r, int b)
        {
            base.OnLayout(changed, l, t, r, b);

            LayoutChanged?.Invoke(this, new LayoutChangedEventArgs(l, t, r, b));
        }
Beispiel #22
0
 /// <summary>
 /// 触发布局变化结束事件
 /// </summary>
 internal void OnLayoutChanged()
 {
     _layout?.SaveCurrentLayout();
     LayoutChanged?.Invoke(this, EventArgs.Empty);
 }
Beispiel #23
0
 protected void OnLayoutChanged(LayoutChangedEventArgs args)
 {
     LayoutChanges.Add(args.Change);
     LayoutChanged?.Invoke(this, args);
 }
Beispiel #24
0
 public void OnLayoutChanged(object sender, EventArgs args)
 {
     LayoutChanged?.Invoke(sender, args);
 }
Beispiel #25
0
 private void OnLayoutChanged()
 {
     LayoutChanged?.Invoke(this, new LayoutChangedEventArgs());
 }
Beispiel #26
0
 void LayoutAllocationChanged(object sender, EventArgs e)
 {
     LayoutChanged?.Invoke(this, EventArgs.Empty);
 }
Beispiel #27
0
 protected virtual void OnLayoutChanged(EventArgs e)
 {
     LayoutChanged?.Invoke(this, e);
 }
Beispiel #28
0
 internal void OnLayoutChanged()
 {
     LayoutChanged?.Invoke(this, EventArgs.Empty);
 }
Beispiel #29
0
		internal protected void raiseLayoutChanged(LayoutingEventArgs e){
			LayoutChanged.Raise (this, e);
		}
Beispiel #30
0
 /// <summary>
 /// Raises the <see cref="LayoutChanged"/> event.
 /// </summary>
 /// <param name="eventArgs">
 /// <see cref="EventArgs"/> object that provides the arguments for the event.
 /// </param>
 /// <remarks>
 /// <strong>Notes to Inheritors:</strong><br/> When overriding <see cref="OnLayoutChanged"/>
 /// in a derived class, be sure to call the base class's <see cref="OnLayoutChanged"/>
 /// method so that registered delegates receive the event.
 /// </remarks>
 protected internal virtual void OnLayoutChanged(EventArgs eventArgs)    // Called in EditorDockStrategy.
 {
     LayoutChanged?.Invoke(this, eventArgs);
 }