protected LayoutFloatingWindowControl(ILayoutElement model)
 {
     Loaded += OnLoaded;
     Unloaded += OnUnloaded;
     _model = model;
     UpdateThemeResources();
 }
Example #2
0
        private static void SizeLayoutElement(ILayoutElement layoutElement,
                                              float height,
                                              VerticalAlign verticalAlign,
                                              float restrictedHeight,
                                              float? width,
                                              bool variableColumnWidth,
                                              float columnWidth)
        {
            float? newHeight = null;

            // if verticalAlign is "justify" or "contentJustify", 
            // restrict the height to restrictedHeight.  Otherwise, 
            // size it normally
            if (verticalAlign == VerticalAlign.Justify ||
                verticalAlign == VerticalAlign.ContentJustify)
            {
                newHeight = restrictedHeight;
            }
            else
            {
                if (null != layoutElement.PercentHeight)
                    newHeight = CalculatePercentHeight(layoutElement, height);
            }

            if (variableColumnWidth)
                layoutElement.SetLayoutBoundsSize(width, newHeight);
            else
                layoutElement.SetLayoutBoundsSize(columnWidth, newHeight);
        }
Example #3
0
 private static float CalculatePercentWidth(ILayoutElement layoutElement, float width)
 {
     float percentWidth = Mathf.Clamp(Mathf.Round((float) (layoutElement.PercentWidth * 0.01f * width)),
                                      LayoutUtil.GetMinBoundsWidth((InvalidationManagerClient)layoutElement),
                                      LayoutUtil.GetMaxBoundsWidth((InvalidationManagerClient) layoutElement));
     return percentWidth < width ? percentWidth : width;
 }
Example #4
0
        private static void SizeLayoutElement(ILayoutElement layoutElement,
                                              float width,
                                              HorizontalAlign horizontalAlign,
                                              float restrictedWidth,
                                              float? height,
                                              bool variableRowHeight,
                                              float rowHeight)
        {
            float? newWidth = null;

            // if horizontalAlign is "justify" or "contentJustify", 
            // restrict the width to restrictedWidth.  Otherwise, 
            // size it normally
            if (horizontalAlign == HorizontalAlign.Justify ||
                horizontalAlign == HorizontalAlign.ContentJustify)
            {
                newWidth = restrictedWidth;
            }
            else
            {
                if (null != layoutElement.PercentWidth)
                    newWidth = CalculatePercentWidth(layoutElement, width);
            }

            if (variableRowHeight)
                layoutElement.SetLayoutBoundsSize(newWidth, height);
            else
                layoutElement.SetLayoutBoundsSize(newWidth, rowHeight);
        }
Example #5
0
 private static float CalculatePercentHeight(ILayoutElement layoutElement, float height)
 {
     float percentHeight = Mathf.Clamp(Mathf.Round((float)(layoutElement.PercentHeight * 0.01f * height)),
                                      LayoutUtil.GetMinBoundsHeight((InvalidationManagerClient)layoutElement),
                                      LayoutUtil.GetMaxBoundsHeight((InvalidationManagerClient)layoutElement));
     return percentHeight < height ? percentHeight : height;
 }
 protected LayoutFloatingWindowControl(ILayoutElement model)
 {
     this.Loaded += new RoutedEventHandler(OnLoaded);
     this.Unloaded += new RoutedEventHandler(OnUnloaded);
     _model = model;
     UpdateThemeResources();
 }
        /// <summary>
        /// Get the input element that was focused before user left the layout element
        /// </summary>
        /// <param name="model">Element to look for</param>
        /// <returns>Input element </returns>
        internal static IInputElement GetLastFocusedElement(ILayoutElement model)
        {
            IInputElement objectWithFocus;
            if (_modelFocusedElement.GetValue(model, out objectWithFocus))
                return objectWithFocus;

            return null;
        }
 private void ShowProp(ref Rect labelRect, ref Rect valueRect, ref Rect sourceRect, string label, string value, ILayoutElement source)
 {
   GUI.Label(labelRect, label, this.m_Styles.labelStyle);
   GUI.Label(valueRect, value, this.m_Styles.labelStyle);
   GUI.Label(sourceRect, source != null ? source.GetType().Name : "none", this.m_Styles.labelStyle);
   labelRect.y += EditorGUIUtility.singleLineHeight;
   valueRect.y += EditorGUIUtility.singleLineHeight;
   sourceRect.y += EditorGUIUtility.singleLineHeight;
 }
Example #9
0
 BaseInfo ConvertLayoutElement(ILayoutElement e)
 {
     if (e is LayoutPanel)
     {
         var panel = e as LayoutPanel;
         var sp = new LayoutPanelInfo
         {
             Width = new GridLengthInfo {Unit = panel.DockWidth.GridUnitType, Value = panel.DockWidth.Value},
             Height = new GridLengthInfo {Unit = panel.DockHeight.GridUnitType, Value = panel.DockHeight.Value}
         };
         foreach (var x in panel.Children)
         {
             sp.Children.Add(ConvertLayoutElement(x));
         }
         return sp;
     }
     else if (e is LayoutRoot)
     {
         var root = e as LayoutRoot;
         var sp = new LayoutRootInfo {Center = (LayoutPanelInfo) ConvertLayoutElement(root.RootPanel)};
         return sp;
     }
     else if (e is LayoutDocumentPane)
     {
         var doc = e as LayoutDocumentPane;
         var sp = new DocumentPaneInfo
         {
             Width = new GridLengthInfo {Unit = doc.DockWidth.GridUnitType, Value = doc.DockWidth.Value},
             Height = new GridLengthInfo {Unit = doc.DockHeight.GridUnitType, Value = doc.DockHeight.Value}
         };
         sp.Content.AddRange(ConvertViews(doc.Children));
         return sp;
     }
     else if (e is LayoutDocumentPaneGroup)
     {
         var doc = e as LayoutDocumentPaneGroup;
         var sp = new LayoutDocumentPaneGroupInfo
         {
             Width = new GridLengthInfo {Unit = doc.DockWidth.GridUnitType, Value = doc.DockWidth.Value},
             Height = new GridLengthInfo {Unit = doc.DockHeight.GridUnitType, Value = doc.DockHeight.Value},
             Orientation = doc.Orientation
         };
         foreach (var x in doc.Children)
         {
             sp.Children.Add(ConvertLayoutElement(x));
         }
         return sp;
     }
     else
         throw new NotSupportedException();
 }
Example #10
0
        public static float GetLayoutProperty(RectTransform rect, System.Func<ILayoutElement, float> property, float defaultValue, out ILayoutElement source)
        {
            source = null;
            if (rect == null)
                return 0;
            float min = defaultValue;
            int maxPriority = System.Int32.MinValue;
            var components = ComponentListPool.Get();
            rect.GetComponents(typeof(ILayoutElement), components);

            for (int i = 0; i < components.Count; i++)
            {
                var layoutComp = components[i] as ILayoutElement;
                if (layoutComp is Behaviour && !(layoutComp as Behaviour).enabled)
                    continue;

                int priority = layoutComp.layoutPriority;
                // If this layout components has lower priority than a previously used, ignore it.
                if (priority < maxPriority)
                    continue;
                float prop = property(layoutComp);
                // If this layout property is set to a negative value, it means it should be ignored.
                if (prop < 0)
                    continue;

                // If this layout component has higher priority than all previous ones,
                // overwrite with this one's value.
                if (priority > maxPriority)
                {
                    min = prop;
                    maxPriority = priority;
                    source = layoutComp;
                }
                // If the layout component has the same priority as a previously used,
                // use the largest of the values with the same priority.
                else if (prop > min)
                {
                    min = prop;
                    source = layoutComp;
                }
            }

            ComponentListPool.Release(components);
            return min;
        }
Example #11
0
 /**
  *  
  * 
  *  Used only for virtual layout.
  */
 private float? CalculateElementWidth(ILayoutElement elt, float targetWidth, float containerWidth)
 {
    // If percentWidth is specified then the element's width is the percentage
    // of targetWidth clipped to min/maxWidth and to (upper limit) targetWidth.
    float? percentWidth = elt.PercentWidth;
    if (null != percentWidth)
    {
       float width = (float) (percentWidth * 0.01f * targetWidth);
       return Mathf.Min(targetWidth, Mathf.Min(
           LayoutUtil.GetMaxBoundsWidth((InvalidationManagerClient) elt), 
           Mathf.Max(LayoutUtil.GetMinBoundsWidth((InvalidationManagerClient)elt), 
           width
         )));
    }
    switch(_horizontalAlign)
    {
        case HorizontalAlign.Justify: 
            return targetWidth;
        case HorizontalAlign.ContentJustify:
            return Mathf.Max(LayoutUtil.GetPreferredBoundsWidth((InvalidationManagerClient) elt), containerWidth);
    }
    return null;  // not constrained
 }
        public static void AssertRightOfGreaterThanOrEqual(this ILayoutElement element, ILayoutElement secondElement, double expected)
        {
            var actualDistance = CalculateRightOfDistance(element, secondElement);

            BA.Assert.IsTrue <LayoutAssertFailedException>(actualDistance >= expected, $"{element.ElementName} should be >= {expected} px right from {secondElement.ElementName} but was {actualDistance} px.");
            AssertedRightOfGreaterOrEqualThanEvent?.Invoke(element, new LayoutTwoElementsActionEventArgs(element, secondElement, expected));
        }
Example #13
0
 /// <summary>
 /// Creates a new instance of the layout element.
 /// </summary>
 /// <param name="Document">Document containing the new element.</param>
 /// <param name="Parent">Parent element.</param>
 /// <returns>New instance.</returns>
 public override ILayoutElement Create(Layout2DDocument Document, ILayoutElement Parent)
 {
     return(new TurnRight(Document, Parent));
 }
Example #14
0
 /// <summary>
 /// Creates a new instance of the layout element.
 /// </summary>
 /// <param name="Document">Document containing the new element.</param>
 /// <param name="Parent">Parent element.</param>
 /// <returns>New instance.</returns>
 public override ILayoutElement Create(Layout2DDocument Document, ILayoutElement Parent)
 {
     return(new TurnTowardsRel(Document, Parent));
 }
Example #15
0
 /// <summary>
 /// Creates a new instance of the layout element.
 /// </summary>
 /// <param name="Document">Document containing the new element.</param>
 /// <param name="Parent">Parent element.</param>
 /// <returns>New instance.</returns>
 public override ILayoutElement Create(Layout2DDocument Document, ILayoutElement Parent)
 {
     return(new Polygon(Document, Parent));
 }
 public static float GetLayoutProperty(RectTransform rect, Func<ILayoutElement, float> property, float defaultValue, out ILayoutElement source)
 {
   source = (ILayoutElement) null;
   if ((UnityEngine.Object) rect == (UnityEngine.Object) null)
     return 0.0f;
   float num1 = defaultValue;
   int num2 = int.MinValue;
   List<Component> componentList = ListPool<Component>.Get();
   rect.GetComponents(typeof (ILayoutElement), componentList);
   for (int index = 0; index < componentList.Count; ++index)
   {
     ILayoutElement layoutElement = componentList[index] as ILayoutElement;
     if (!(layoutElement is Behaviour) || ((Behaviour) layoutElement).isActiveAndEnabled)
     {
       int layoutPriority = layoutElement.layoutPriority;
       if (layoutPriority >= num2)
       {
         float num3 = property(layoutElement);
         if ((double) num3 >= 0.0)
         {
           if (layoutPriority > num2)
           {
             num1 = num3;
             num2 = layoutPriority;
             source = layoutElement;
           }
           else if ((double) num3 > (double) num1)
           {
             num1 = num3;
             source = layoutElement;
           }
         }
       }
     }
   }
   ListPool<Component>.Release(componentList);
   return num1;
 }
		public override void ReplaceChild(ILayoutElement oldElement, ILayoutElement newElement)
		{
			Debug.Assert(oldElement == RootPanel && oldElement != null);
			RootPanel = newElement as LayoutAnchorablePaneGroup;
		}
Example #18
0
 public abstract void RemoveChild(ILayoutElement element);
 public override void ReplaceChild(ILayoutElement oldElement, ILayoutElement newElement)
 {
     Debug.Assert(oldElement == RootDocument && oldElement != null);
     RootDocument = newElement as LayoutDocument;
 }
Example #20
0
 public override void ReplaceChild(ILayoutElement oldElement, ILayoutElement newElement)
 {
     Debug.Assert(oldElement == RootDocument && oldElement != null);
     RootDocument = newElement as LayoutDocument;
 }
Example #21
0
 private static bool ConstraintsDetermineHeight(ILayoutElement layoutElement)
 {
     return null != layoutElement.PercentHeight ||
            null != layoutElement.GetConstraintValue("top") &&
            null != layoutElement.GetConstraintValue("bottom");
 }
Example #22
0
 public override void RemoveChild(ILayoutElement element)
 {
     Debug.Assert(element == RootDocument && element != null);
     RootDocument = null;
 }
Example #23
0
 /// <summary>
 /// Represents a segment of italic text in flowing text.
 /// </summary>
 /// <param name="Document">Layout document containing the element.</param>
 /// <param name="Parent">Parent element.</param>
 public Italic(Layout2DDocument Document, ILayoutElement Parent)
     : base(Document, Parent)
 {
 }
Example #24
0
 /// <summary>
 /// Abstract base class of dynamic layout elements (i.e. elements that can
 /// generate child elements dynamically).
 /// </summary>
 /// <param name="Document">Layout document containing the element.</param>
 /// <param name="Parent">Parent element.</param>
 public DynamicElement(Layout2DDocument Document, ILayoutElement Parent)
     : base(Document, Parent)
 {
 }
Example #25
0
        /**
         *  
         *  This method is called by updateDisplayList() after initial values for 
         *  visibleStartIndex, visibleEndIndex have been calculated.  We 
         *  re-calculateDisplayParameters() to account for the possibility that
         *  larger cells may have been exposed.  Since tileWdth,Height can only
         *  increase, the new visibleStart,EndIndex values will be greater than or
         *  equal to the old ones. 
         */
         /*private void updateVirtualLayout(int unscaledWidth, int unscaledHeight)
         {
            int oldVisibleStartIndex = _visibleStartIndex;
            int oldVisibleEndIndex = _visibleEndIndex;
            calculateDisplayParameters(unscaledWidth, unscaledHeight);  // compute new visibleStart,EndIndex values
            
            // We're responsible for laying out *all* of the elements requested
            // with getVirtualElementAt(), even if they don't fall within the final
            // visible range.  Hide any extra ones.  On the next layout pass, they'll
            // be added to DataGroup::freeRenderers
            
            GroupBase layoutTarget = Target;
            for (int i = oldVisibleStartIndex; i <= oldVisibleEndIndex; i++)
            {
                if ((i >= _visibleStartIndex) && (i <= _visibleEndIndex)) // skip past the visible range
                {
                    i = _visibleEndIndex;
                    continue;
                } 
                //ILayoutElement el = layoutTarget.getVirtualElementAt(i);
                //if (null == el)
                //    continue;
                //el.setLayoutBoundsSize(0, 0);
                //if (el is IVisualElement)
                //    IVisualElement(el).visible = false; 
            }
        } */

        /**
         *  Sets the size and the position of the specified layout element and cell bounds.
         *  Param: element - the element to resize and position.
         *  Param: cellX - the x coordinate of the cell.
         *  Param: cellY - the y coordinate of the cell.
         *  Param: cellWidth - the width of the cell.
         *  Param: cellHeight - the height of the cell.
         */
        private void sizeAndPositionElement(ILayoutElement element,
                                                  int cellX,
                                                  int cellY,
                                                  int cellWidth,
                                                  int cellHeight)
        {
            float childWidth;
            float childHeight;

            // Determine size of the element
            if (_horizontalAlign == HorizontalAlign.Justify)
                childWidth = cellWidth;
            else if (null != element.PercentWidth)
                childWidth = Mathf.Round((float) (cellWidth * element.PercentWidth * 0.01f));
            else
                childWidth = LayoutUtil.GetPreferredBoundsWidth((InvalidationManagerClient) element);

            if (_verticalAlign == global::eDriven.Gui.Layout.VerticalAlign.Justify)
                childHeight = cellHeight;
            else if (null != element.PercentHeight)
                childHeight = Mathf.Round((float) (cellHeight * element.PercentHeight * 0.01f));
            else
                childHeight = LayoutUtil.GetPreferredBoundsHeight((InvalidationManagerClient) element);

            // Enforce min and max limits
            float maxChildWidth = Math.Min(LayoutUtil.GetMaxBoundsWidth((InvalidationManagerClient) element), cellWidth);
            float maxChildHeight = Math.Min(LayoutUtil.GetMaxBoundsHeight((InvalidationManagerClient) element), cellHeight);
            // Make sure we enforce element's minimum last, since it has the highest priority
            childWidth = Math.Max(LayoutUtil.GetMinBoundsWidth((InvalidationManagerClient) element), Math.Min(maxChildWidth, childWidth));
            childHeight = Math.Max(LayoutUtil.GetMinBoundsHeight((InvalidationManagerClient) element), Math.Min(maxChildHeight, childHeight));

            // Size the element
            element.SetLayoutBoundsSize(childWidth, childHeight);

            float x = cellX;
            switch (_horizontalAlign)
            {
                case HorizontalAlign.Right:
                    x += cellWidth - LayoutUtil.GetLayoutBoundsWidth((InvalidationManagerClient) element);
                break;
                case HorizontalAlign.Center:
                    // Make sure division result is integer - Math.floor() the result.
                    x = cellX + Mathf.Floor((cellWidth - LayoutUtil.GetLayoutBoundsWidth((InvalidationManagerClient) element)) / 2);
                break;
            }

            float y = cellY;
            switch (_verticalAlign)
            {
                case VerticalAlign.Bottom:
                    y += cellHeight - LayoutUtil.GetLayoutBoundsHeight((InvalidationManagerClient)element);
                break;
                case VerticalAlign.Middle:
                    // Make sure division result is integer - Math.floor() the result.
                y += Mathf.Floor((cellHeight - LayoutUtil.GetLayoutBoundsHeight((InvalidationManagerClient) element)) / 2);
                break;
            }

            // Position the element
            element.SetLayoutBoundsPosition(x, y);
        }
Example #26
0
 public abstract void ReplaceChild(ILayoutElement oldElement, ILayoutElement newElement);
Example #27
0
 /// <summary>
 /// A solid background
 /// </summary>
 /// <param name="Document">Layout document containing the element.</param>
 /// <param name="Parent">Parent element.</param>
 public SolidBackground(Layout2DDocument Document, ILayoutElement Parent)
     : base(Document, Parent)
 {
 }
Example #28
0
 /// <summary>
 /// Abstract base class for figures based on a point.
 /// </summary>
 /// <param name="Document">Layout document containing the element.</param>
 /// <param name="Parent">Parent element.</param>
 public FigurePoint(Layout2DDocument Document, ILayoutElement Parent)
     : base(Document, Parent)
 {
 }
        /// <summary>
        /// Get the last window handle focused before user left the element passed as argument
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        internal static IntPtr GetLastWindowHandle(ILayoutElement model)
        {
            IntPtr handleWithFocus;
            if (_modelFocusedWindowHandle.GetValue(model, out handleWithFocus))
                return handleWithFocus;

            return IntPtr.Zero;
        }
Example #30
0
 private static bool ConstraintsDetermineWidth(ILayoutElement layoutElement)
 {
     return null != layoutElement.PercentWidth ||
            null != layoutElement.GetConstraintValue("left") &&
            null != layoutElement.GetConstraintValue("right");
 }
Example #31
0
        public static void AssertNearBottomOfApproximate(this ILayoutElement element, ILayoutElement secondElement, double expected, double percent)
        {
            var actualDistance          = CalculateBelowOfDistance(element, secondElement);
            var actualPercentDifference = CalculatePercentDifference(expected, actualDistance);

            BA.Assert.IsTrue <LayoutAssertFailedException>(actualPercentDifference <= percent, $"{element.ElementName} should be <= {percent}% of {expected} px below of {secondElement.ElementName} but was {actualDistance} px.");
            AssertedNearBottomOfApproximateEvent?.Invoke(element, new LayoutTwoElementsActionTwoValuesEventArgs(element, secondElement, expected, percent));
        }
Example #32
0
 void Awake()
 {
     m_redirectedLayoutElement = layoutObject.GetComponent <ILayoutElement> ();
 }
Example #33
0
 /**
  *  
  *  Fills in the result with preferred and min sizes of the element.
  */
 private void GetElementWidth(ILayoutElement element, float? fixedColumnWidth, SizesAndLimit result)
 {
     // Calculate preferred height first, as it's being used to calculate min height below
     float elementPreferredWidth = fixedColumnWidth ?? Mathf.Ceil(LayoutUtil.GetPreferredBoundsWidth((InvalidationManagerClient)element));
     // Calculate min height
     bool flexibleWidth = null != element.PercentWidth;
     float elementMinWidth = flexibleWidth ? Mathf.Ceil(LayoutUtil.GetMinBoundsWidth((InvalidationManagerClient)element)) :
                                                    elementPreferredWidth;
     result.PreferredSize = elementPreferredWidth;
     result.MinSize = elementMinWidth;
 }
Example #34
0
 /// <summary>
 /// A translation transform
 /// </summary>
 /// <param name="Document">Layout document containing the element.</param>
 /// <param name="Parent">Parent element.</param>
 public Translate(Layout2DDocument Document, ILayoutElement Parent)
     : base(Document, Parent)
 {
 }
Example #35
0
 /// <summary>
 /// A polygon
 /// </summary>
 /// <param name="Document">Layout document containing the element.</param>
 /// <param name="Parent">Parent element.</param>
 public Polygon(Layout2DDocument Document, ILayoutElement Parent)
     : base(Document, Parent)
 {
 }
Example #36
0
        /// <summary>
        /// Gets a calculated layout property for the layout element with the given RectTransform.
        /// </summary>
        /// <param name="rect">The RectTransform of the layout element to get a property for.</param>
        /// <param name="property">The property to calculate.</param>
        /// <param name="defaultValue">The default value to use if no component on the layout element supplies the given property</param>
        /// <param name="source">Optional out parameter to get the component that supplied the calculated value.</param>
        /// <returns>The calculated value of the layout property.</returns>
        public static float GetLayoutProperty(RectTransform rect, System.Func <ILayoutElement, float> property, float defaultValue, out ILayoutElement source)
        {
            source = null;
            if (rect == null)
            {
                return(0);
            }
            float min         = defaultValue;
            int   maxPriority = System.Int32.MinValue;
            var   components  = ListPool <Component> .Get();

            rect.GetComponents(typeof(ILayoutElement), components);

            var componentsCount = components.Count;

            for (int i = 0; i < componentsCount; i++)
            {
                var layoutComp = components[i] as ILayoutElement;
                if (layoutComp is Behaviour && !((Behaviour)layoutComp).isActiveAndEnabled)
                {
                    continue;
                }

                int priority = layoutComp.layoutPriority;
                // If this layout components has lower priority than a previously used, ignore it.
                if (priority < maxPriority)
                {
                    continue;
                }
                float prop = property(layoutComp);
                // If this layout property is set to a negative value, it means it should be ignored.
                if (prop < 0)
                {
                    continue;
                }

                // If this layout component has higher priority than all previous ones,
                // overwrite with this one's value.
                if (priority > maxPriority)
                {
                    min         = prop;
                    maxPriority = priority;
                    source      = layoutComp;
                }
                // If the layout component has the same priority as a previously used,
                // use the largest of the values with the same priority.
                else if (prop > min)
                {
                    min    = prop;
                    source = layoutComp;
                }
            }

            ListPool <Component> .Release(components);

            return(min);
        }
Example #37
0
 /// <summary>
 /// A rounded rectangle
 /// </summary>
 /// <param name="Document">Layout document containing the element.</param>
 /// <param name="Parent">Parent element.</param>
 public RoundedRectangle(Layout2DDocument Document, ILayoutElement Parent)
     : base(Document, Parent)
 {
 }
Example #38
0
 /// <summary>
 /// A rotation transform
 /// </summary>
 /// <param name="Document">Layout document containing the element.</param>
 /// <param name="Parent">Parent element.</param>
 public Rotate(Layout2DDocument Document, ILayoutElement Parent)
     : base(Document, Parent)
 {
 }
Example #39
0
 /// <summary>
 /// Turns the current direction right.
 /// </summary>
 /// <param name="Document">Layout document containing the element.</param>
 /// <param name="Parent">Parent element.</param>
 public TurnRight(Layout2DDocument Document, ILayoutElement Parent)
     : base(Document, Parent)
 {
 }
Example #40
0
 public int IndexOfChild(ILayoutElement element)
 {
     return(_children.Cast <ILayoutElement>().ToList().IndexOf(element));
 }
Example #41
0
 /// <summary>
 /// Abstract base class for layout elements with an implicit area.
 /// </summary>
 /// <param name="Document">Layout document containing the element.</param>
 /// <param name="Parent">Parent element.</param>
 public LayoutArea(Layout2DDocument Document, ILayoutElement Parent)
     : base(Document, Parent)
 {
 }
Example #42
0
 public void InsertChildAt(int index, ILayoutElement element)
 {
     _children.Insert(index, (T)element);
 }
Example #43
0
 /**
  *  
  *  Update _tileWidth,Height to be the maximum of their current
  *  value and the element's preferred bounds. 
  */
 private void updateVirtualTileSize(ILayoutElement elt)
 {
     if (null == elt || !elt.IncludeInLayout)
         return;
     float w = LayoutUtil.GetPreferredBoundsWidth((InvalidationManagerClient) elt);
     float h = LayoutUtil.GetPreferredBoundsHeight((InvalidationManagerClient) elt);
     _tileWidthCached = null == _tileWidthCached ? w : Mathf.Max(w, (float)_tileWidthCached);
     _tileHeightCached = null == _tileHeightCached ? h : Mathf.Max(h, (float)_tileHeightCached);
 }
Example #44
0
 public void RemoveChild(ILayoutElement element)
 {
     _children.Remove((T)element);
 }
Example #45
0
 /// <summary>
 /// An image provided by the caller, identified by a content id.
 /// </summary>
 /// <param name="Document">Layout document containing the element.</param>
 /// <param name="Parent">Parent element.</param>
 public ImageInternal(Layout2DDocument Document, ILayoutElement Parent)
     : base(Document, Parent)
 {
 }
Example #46
0
        public void RemoveChild(ILayoutElement element)
        {
            if (element == RootPanel)
                RootPanel = null;
            else if (_floatingWindows != null && _floatingWindows.Contains(element))
                _floatingWindows.Remove(element as LayoutFloatingWindow);
            else if (_hiddenAnchorables != null && _hiddenAnchorables.Contains(element))
                _hiddenAnchorables.Remove(element as LayoutAnchorable);
            else if (element == TopSide)
                TopSide = null;
            else if (element == RightSide)
                RightSide = null;
            else if (element == BottomSide)
                BottomSide = null;
            else if (element == LeftSide)
                LeftSide = null;

        }
        /// <summary>
        /// Given a layout element tries to set the focus of the keyword where it was before user moved to another element
        /// </summary>
        /// <param name="model"></param>
        internal static void SetFocusOnLastElement(ILayoutElement model)
        {
            bool focused = false;
            IInputElement objectToFocus;
            if (_modelFocusedElement.GetValue(model, out objectToFocus))
            {
                focused = objectToFocus == Keyboard.Focus(objectToFocus);
            }

            IntPtr handleToFocus;
            if (_modelFocusedWindowHandle.GetValue(model, out handleToFocus))
                focused = IntPtr.Zero != Win32Helper.SetFocus(handleToFocus);

            Debug.WriteLine("SetFocusOnLastElement(focused={0}, model={1}, element={2})", focused, model, handleToFocus == IntPtr.Zero ? (objectToFocus == null ?  "" : objectToFocus.ToString()) : handleToFocus.ToString());
           
            if (focused)
            {
                _lastFocusedElement = new WeakReference(model);
            }

        }
 public abstract void ReplaceChild(ILayoutElement oldElement, ILayoutElement newElement);
        /// <summary>
        /// Given a layout element tries to set the focus of the keyword where it was before user moved to another element
        /// </summary>
        /// <param name="model"></param>
        internal static void SetFocusOnLastElement(ILayoutElement model)
        {
            bool focused = false;
            IInputElement objectToFocus;
            if (_modelFocusedElement.GetValue(model, out objectToFocus))
            {
                focused = objectToFocus == Keyboard.Focus(objectToFocus);
            }

            IntPtr handleToFocus;
            if (_modelFocusedWindowHandle.GetValue(model, out handleToFocus))
                focused = IntPtr.Zero != Win32Helper.SetFocus(handleToFocus);


            if (focused)
            {
                _lastFocusedElement = new WeakReference(model);
            }

        }
Example #50
0
        internal UIElement CreateUIElementForModel(ILayoutElement model)
        {
            if (model is LayoutPanel)
                return new LayoutPanelControl(model as LayoutPanel);
            if (model is LayoutAnchorablePaneGroup)
                return new LayoutAnchorablePaneGroupControl(model as LayoutAnchorablePaneGroup);
            if (model is LayoutDocumentPaneGroup)
                return new LayoutDocumentPaneGroupControl(model as LayoutDocumentPaneGroup);

            if (model is LayoutAnchorSide)
            {
                var templateModelView = new LayoutAnchorSideControl(model as LayoutAnchorSide);
                templateModelView.SetBinding(LayoutAnchorSideControl.TemplateProperty, new Binding("AnchorSideTemplate") { Source = this });
                return templateModelView;
            }
            if (model is LayoutAnchorGroup)
            {
                var templateModelView = new LayoutAnchorGroupControl(model as LayoutAnchorGroup);
                templateModelView.SetBinding(LayoutAnchorGroupControl.TemplateProperty, new Binding("AnchorGroupTemplate") { Source = this });
                return templateModelView;
            }

            if (model is LayoutDocumentPane)
            {
                var templateModelView = new LayoutDocumentPaneControl(model as LayoutDocumentPane);
                templateModelView.SetBinding(LayoutDocumentPaneControl.StyleProperty, new Binding("DocumentPaneControlStyle") { Source = this });
                return templateModelView;
            }
            if (model is LayoutAnchorablePane)
            {
                var templateModelView = new LayoutAnchorablePaneControl(model as LayoutAnchorablePane);
                templateModelView.SetBinding(LayoutAnchorablePaneControl.StyleProperty, new Binding("AnchorablePaneControlStyle") { Source = this });
                return templateModelView;
            }

            if (model is LayoutAnchorableFloatingWindow)
            {
                if (DesignerProperties.GetIsInDesignMode(this))
                    return null;
                var modelFW = model as LayoutAnchorableFloatingWindow;
                var newFW = new LayoutAnchorableFloatingWindowControl(modelFW)
                {
                    //Owner = Window.GetWindow(this)
                };
                newFW.SetParentToMainWindowOf(this);

                var paneForExtentions = modelFW.RootPanel.Children.OfType<LayoutAnchorablePane>().FirstOrDefault();
                if (paneForExtentions != null)
                {
                    //ensure that floating window position is inside current (or nearest) monitor
                    paneForExtentions.KeepInsideNearestMonitor();

                    newFW.Left = paneForExtentions.FloatingLeft;
                    newFW.Top = paneForExtentions.FloatingTop;
                    newFW.Width = paneForExtentions.FloatingWidth;
                    newFW.Height = paneForExtentions.FloatingHeight;
                }

                newFW.ShowInTaskbar = false;
                newFW.Show();
                return newFW;
            }

            if (model is LayoutDocumentFloatingWindow)
            {
                if (DesignerProperties.GetIsInDesignMode(this))
                    return null;
                var modelFW = model as LayoutDocumentFloatingWindow;
                var newFW = new LayoutDocumentFloatingWindowControl(modelFW)
                {
                    //Owner = Window.GetWindow(this)
                };
                newFW.SetParentToMainWindowOf(this);

                var paneForExtentions = modelFW.RootDocument;
                if (paneForExtentions != null)
                {
                    //ensure that floating window position is inside current (or nearest) monitor
                    paneForExtentions.KeepInsideNearestMonitor();

                    newFW.Left = paneForExtentions.FloatingLeft;
                    newFW.Top = paneForExtentions.FloatingTop;
                    newFW.Width = paneForExtentions.FloatingWidth;
                    newFW.Height = paneForExtentions.FloatingHeight;
                }

                newFW.ShowInTaskbar = false;
                newFW.Show();
                return newFW;
            }

            if (model is LayoutDocument)
            {
                var templateModelView = new LayoutDocumentControl() { Model = model as LayoutDocument };
                return templateModelView;
            }

            return null;
        }
 public abstract void RemoveChild(ILayoutElement element);
Example #52
0
 /**
  *  
  *  Fills in the result with preferred and min sizes of the element.
  */
 private void GetElementHeight(ILayoutElement element, bool justify, SizesAndLimit result)
 {
     // Calculate preferred width first, as it's being used to calculate min width
     float elementPreferredHeight = Mathf.Ceil(LayoutUtil.GetPreferredBoundsHeight((InvalidationManagerClient)element));
     
     // Calculate min width
     bool flexibleHeight = null != element.PercentHeight || justify;
     float elementMinHeight = flexibleHeight ? Mathf.Ceil(LayoutUtil.GetMinBoundsHeight((InvalidationManagerClient)element)) : 
                                                  elementPreferredHeight;
     result.PreferredSize = elementPreferredHeight;
     result.MinSize = elementMinHeight;
 }
Example #53
0
 /// <summary>
 /// Creates a new instance of the layout element.
 /// </summary>
 /// <param name="Document">Document containing the new element.</param>
 /// <param name="Parent">Parent element.</param>
 /// <returns>New instance.</returns>
 public override ILayoutElement Create(Layout2DDocument Document, ILayoutElement Parent)
 {
     return(new Ellipse(Document, Parent));
 }
Example #54
0
 protected LayoutFloatingWindowControl(ILayoutElement model, bool isContentImmutable)
     : this(model)
 {
     IsContentImmutable = isContentImmutable;
 }
		public override void RemoveChild(ILayoutElement element)
		{
			Debug.Assert(element == RootPanel && element != null);
			RootPanel = null;
		}
Example #56
0
 /// <summary>
 /// Turns the current direction towards a point, relative to the current point.
 /// </summary>
 /// <param name="Document">Layout document containing the element.</param>
 /// <param name="Parent">Parent element.</param>
 public TurnTowardsRel(Layout2DDocument Document, ILayoutElement Parent)
     : base(Document, Parent)
 {
 }
Example #57
0
 public void ReplaceChildAt(int index, ILayoutElement element)
 {
     _children[index] = (T)element;
 }
Example #58
0
 private void MakeViewList(ILayoutElement elem)
 {
     if (elem is LayoutContent)
     {
         viewList[(elem as LayoutContent).ContentId] = elem as LayoutContent;
         return;
     }
     if (elem is ILayoutContainer)
         foreach (var child in (elem as ILayoutContainer).Children)
             MakeViewList(child);
 }
Example #59
0
 public void ReplaceChild(ILayoutElement oldElement, ILayoutElement newElement)
 {
     if (oldElement == RootPanel)
         RootPanel = (LayoutPanel)newElement;
     else if (_floatingWindows != null && _floatingWindows.Contains(oldElement))
     {
         int index = _floatingWindows.IndexOf(oldElement as LayoutFloatingWindow);
         _floatingWindows.Remove(oldElement as LayoutFloatingWindow);
         _floatingWindows.Insert(index, newElement as LayoutFloatingWindow);
     }
     else if (_hiddenAnchorables != null && _hiddenAnchorables.Contains(oldElement))
     {
         int index = _hiddenAnchorables.IndexOf(oldElement as LayoutAnchorable);
         _hiddenAnchorables.Remove(oldElement as LayoutAnchorable);
         _hiddenAnchorables.Insert(index, newElement as LayoutAnchorable);
     }
     else if (oldElement == TopSide)
         TopSide = (LayoutAnchorSide)newElement;
     else if (oldElement == RightSide)
         RightSide = (LayoutAnchorSide)newElement;
     else if (oldElement == BottomSide)
         BottomSide = (LayoutAnchorSide)newElement;
     else if (oldElement == LeftSide)
         LeftSide = (LayoutAnchorSide)newElement;
 }
Example #60
0
 /// <summary>
 /// An ellipse
 /// </summary>
 /// <param name="Document">Layout document containing the element.</param>
 /// <param name="Parent">Parent element.</param>
 public Ellipse(Layout2DDocument Document, ILayoutElement Parent)
     : base(Document, Parent)
 {
 }