Beispiel #1
0
        public ChildViewBase()
        {
            SetValue(DocumentsPropertyKey, new FreezableCollection<BaseLayoutItem>());

              // Если понадобится зависимый Ribbon для DocumentPanel, то он будет объединяться.
              MDIMergeStyle = MDIMergeStyle.Always;

              LayoutGroup layoutGroup = new LayoutGroup();
              layoutGroup.Orientation = Orientation.Horizontal;
              LayoutRoot = layoutGroup;

              documentGroup = DockController.AddDocumentGroup(DockType.None);
              DockController.Dock(documentGroup, layoutGroup, DockType.Fill);
              documentGroup.ItemWidth = new GridLength(70, GridUnitType.Star);
              // При изменении активного элемента, изменим зависимое свойство.
              documentGroup.SelectedItemChanged += (s, e) =>
              {
            SelectedDocumentIndex = documentGroup.Items.IndexOf(documentGroup.SelectedItem);
              };

              propLayoutPanel = DockController.AddPanel(DockType.None);
              DockController.Dock(propLayoutPanel, layoutGroup, DockType.Right);
              propLayoutPanel.Caption = "Свойства";
              propLayoutPanel.AllowDrag = false;
              propLayoutPanel.AllowClose = false;
              propLayoutPanel.ItemWidth = new GridLength(30, GridUnitType.Star);

              AutoHideGroup autoHideGroup = new AutoHideGroup();
              autoHideGroup.DockType = Dock.Bottom;
              AutoHideGroups.Add(autoHideGroup);

              LayoutPanel outLayoutPanel = new LayoutPanel();
              outLayoutPanel.Caption = "Вывод";
              outLayoutPanel.AllowDrag = false;
              outLayoutPanel.AllowClose = false;
              autoHideGroup.Add(outLayoutPanel);

              // Элемент для вывода информации о построении.
              txtMessages = new RichTextBox();
              txtMessages.IsReadOnly = true;
              txtMessages.VerticalScrollBarVisibility = ScrollBarVisibility.Visible;
              // Уберем отступы между параграфами.
              Style noSpaceStyle = new Style(typeof(Paragraph));
              noSpaceStyle.Setters.Add(new Setter(Paragraph.MarginProperty, new Thickness(0)));
              txtMessages.Resources.Add(typeof(Paragraph), noSpaceStyle);
              // При изменении содержимого активируем панель и будем прокручивать текст вниз.
              txtMessages.TextChanged += (s, e) =>
              {
            Activate(outLayoutPanel);
            (s as RichTextBox).ScrollToEnd();
              };
              outLayoutPanel.Content = txtMessages;

              synchronizationContext = SynchronizationContext.Current;
              managedThreadId = Thread.CurrentThread.ManagedThreadId;
        }
        public override void HelpInstantiate(params InstantiationOptions[] options)
        {
            if (!options.Contains(InstantiationOptions.HasLayoutHorizontal) && !options.Contains(InstantiationOptions.HasLayoutVertical))
            {
                DestroyImmediate(m_TopLayoutGroup);
                m_BottomRectTransform.anchorMin = Vector2.zero;
                m_BottomRectTransform.anchorMax = Vector2.one;
                m_BottomRectTransform.sizeDelta = Vector2.zero;
                m_BottomRectTransform.anchoredPosition = Vector2.zero;
            }
            else
            {
                if (options.Contains(InstantiationOptions.HasLayoutHorizontal))
                {
                    GameObject go = m_TopLayoutGroup.gameObject;
                    DestroyImmediate(m_TopLayoutGroup);
                    m_TopLayoutGroup = go.AddComponent<HorizontalLayoutGroup>();
                    m_TopLayoutGroup.childAlignment = TextAnchor.MiddleCenter;

                    m_BottomLayoutGroup = m_BottomRectTransform.gameObject.AddComponent<HorizontalLayoutGroup>();
                    m_BottomLayoutGroup.childAlignment = TextAnchor.MiddleCenter;
                    ((HorizontalLayoutGroup)m_BottomLayoutGroup).childForceExpandWidth = false;
                    ((HorizontalLayoutGroup)m_BottomLayoutGroup).childForceExpandHeight = false;
                }
                else
                {
                    m_BottomLayoutGroup = m_BottomRectTransform.gameObject.AddComponent<VerticalLayoutGroup>();
                    m_BottomLayoutGroup.childAlignment = TextAnchor.MiddleCenter;
                    ((VerticalLayoutGroup)m_BottomLayoutGroup).childForceExpandWidth = false;
                    ((VerticalLayoutGroup)m_BottomLayoutGroup).childForceExpandHeight = false;
                }
            }

            if (!options.Contains(InstantiationOptions.Fitted))
            {
                DestroyImmediate(m_SizeFitter);
                m_RectTransform.sizeDelta = new Vector2(300f, 300f);
                m_RectTransform.anchoredPosition = Vector2.zero;
            }

            if (options.Contains(InstantiationOptions.HasContent))
            {
                m_RectTransform.anchorMin = new Vector2(0f, 0f);
                m_RectTransform.anchorMax = new Vector2(1f, 1f);
                m_RectTransform.sizeDelta = new Vector2(-48f, -48f);
                m_RectTransform.anchoredPosition = Vector2.zero;
            }

#if UNITY_EDITOR
            Selection.activeGameObject = m_BottomRectTransform.gameObject;
#endif

            base.HelpInstantiate(options);
        }
Beispiel #3
0
 private void AddItem()
 {
     switch (AppMode)
     {
         case AppModes.LayoutGroups:
             SelectedLayoutGroup = new LayoutGroup();
             AppMode = AppModes.AddLayoutGroup;
             break;
         case AppModes.ViewLayoutGroup:
             SelectedLayout = new Layout();
             AppMode = AppModes.AddLayout;
             break;
     }
 }
        public override void HelpInstantiate(params InstantiationOptions[] options)
        {
            if (!options.Contains(InstantiationOptions.Raised))
            {
                DestroyImmediate(m_Shadow);
                DestroyImmediate(m_BackgroundImage);
            }

            if (!options.Contains(InstantiationOptions.Label))
            {
                DestroyImmediate(m_Label);
            }

            if (!options.Contains(InstantiationOptions.HasLayoutHorizontal) && !options.Contains(InstantiationOptions.HasLayoutVertical))
            {
                this.transform.SetParent(m_LayoutGroup.transform.parent, true);
                GameObject.DestroyImmediate(m_LayoutGroup.gameObject);
                m_ProgressIndicator.baseObjectOverride = null;
            }
            else
            {
                if (options.Contains(InstantiationOptions.HasLayoutHorizontal))
                {
                    GameObject go = m_LayoutGroup.gameObject;
                    DestroyImmediate(m_LayoutGroup);
                    m_LayoutGroup = go.AddComponent<HorizontalLayoutGroup>();
                    m_LayoutGroup.childAlignment = TextAnchor.MiddleCenter;
                    ((HorizontalLayoutGroup)m_LayoutGroup).childForceExpandWidth = false;
                    ((HorizontalLayoutGroup)m_LayoutGroup).childForceExpandHeight = false;
                }

                if (options.Contains(InstantiationOptions.Raised))
                {
                    if (options.Contains(InstantiationOptions.HasLayoutHorizontal))
                    {
                        ((HorizontalLayoutGroup)m_LayoutGroup).spacing = 16f;
                    }
                    else if (options.Contains(InstantiationOptions.HasLayoutVertical))
                    {
                        ((VerticalLayoutGroup)m_LayoutGroup).spacing = 16f;
                    }
                }
            }

            base.HelpInstantiate(options);
        }
Beispiel #5
0
    private static int set_childAlignment(IntPtr L)
    {
        object obj = null;
        int    result;

        try
        {
            obj = ToLua.ToObject(L, 1);
            LayoutGroup layoutGroup    = (LayoutGroup)obj;
            TextAnchor  childAlignment = (TextAnchor)((int)ToLua.CheckObject(L, 2, typeof(TextAnchor)));
            layoutGroup.childAlignment = childAlignment;
            result = 0;
        }
        catch (Exception ex)
        {
            result = LuaDLL.toluaL_exception(L, ex, (obj != null) ? ex.Message : "attempt to index childAlignment on a nil value");
        }
        return(result);
    }
Beispiel #6
0
    private static int set_padding(IntPtr L)
    {
        object obj = null;
        int    result;

        try
        {
            obj = ToLua.ToObject(L, 1);
            LayoutGroup layoutGroup = (LayoutGroup)obj;
            RectOffset  padding     = (RectOffset)ToLua.CheckObject(L, 2, typeof(RectOffset));
            layoutGroup.padding = padding;
            result = 0;
        }
        catch (Exception ex)
        {
            result = LuaDLL.toluaL_exception(L, ex, (obj != null) ? ex.Message : "attempt to index padding on a nil value");
        }
        return(result);
    }
Beispiel #7
0
    private static int get_layoutPriority(IntPtr L)
    {
        object obj = null;
        int    result;

        try
        {
            obj = ToLua.ToObject(L, 1);
            LayoutGroup layoutGroup    = (LayoutGroup)obj;
            int         layoutPriority = layoutGroup.layoutPriority;
            LuaDLL.lua_pushinteger(L, layoutPriority);
            result = 1;
        }
        catch (Exception ex)
        {
            result = LuaDLL.toluaL_exception(L, ex, (obj != null) ? ex.Message : "attempt to index layoutPriority on a nil value");
        }
        return(result);
    }
    public static int set_childAlignment(IntPtr l)
    {
        int result;

        try
        {
            LayoutGroup layoutGroup = (LayoutGroup)LuaObject.checkSelf(l);
            TextAnchor  childAlignment;
            LuaObject.checkEnum <TextAnchor>(l, 2, out childAlignment);
            layoutGroup.childAlignment = childAlignment;
            LuaObject.pushValue(l, true);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
Beispiel #9
0
    private static int get_preferredWidth(IntPtr L)
    {
        object obj = null;
        int    result;

        try
        {
            obj = ToLua.ToObject(L, 1);
            LayoutGroup layoutGroup    = (LayoutGroup)obj;
            float       preferredWidth = layoutGroup.preferredWidth;
            LuaDLL.lua_pushnumber(L, (double)preferredWidth);
            result = 1;
        }
        catch (Exception ex)
        {
            result = LuaDLL.toluaL_exception(L, ex, (obj != null) ? ex.Message : "attempt to index preferredWidth on a nil value");
        }
        return(result);
    }
Beispiel #10
0
    private static int get_childAlignment(IntPtr L)
    {
        object obj = null;
        int    result;

        try
        {
            obj = ToLua.ToObject(L, 1);
            LayoutGroup layoutGroup    = (LayoutGroup)obj;
            TextAnchor  childAlignment = layoutGroup.childAlignment;
            ToLua.Push(L, childAlignment);
            result = 1;
        }
        catch (Exception ex)
        {
            result = LuaDLL.toluaL_exception(L, ex, (obj != null) ? ex.Message : "attempt to index childAlignment on a nil value");
        }
        return(result);
    }
Beispiel #11
0
    private static int get_padding(IntPtr L)
    {
        object obj = null;
        int    result;

        try
        {
            obj = ToLua.ToObject(L, 1);
            LayoutGroup layoutGroup = (LayoutGroup)obj;
            RectOffset  padding     = layoutGroup.padding;
            ToLua.PushObject(L, padding);
            result = 1;
        }
        catch (Exception ex)
        {
            result = LuaDLL.toluaL_exception(L, ex, (obj != null) ? ex.Message : "attempt to index padding on a nil value");
        }
        return(result);
    }
Beispiel #12
0
        private void AddValueText(LayoutGroup group, UserRequestProperty prop, bool multiline)
        {
            var control = new TextBoxX()
            {
                Text      = prop.Value,
                Tag       = prop,
                Multiline = multiline,
                Size      = new Size(75, multiline ? 75 : 20)
            };

            control.Border.Class = "TextBoxBorder";
            control.TextChanged += (sender, e) =>
            {
                var csender = sender as Control;
                ((UserRequestProperty)csender.Tag).Value = csender.Text.Trim();
            };
            AddHandlerGotFocus(control);
            AddControlToGroup(prop, group, control);
        }
 private void GetComponents()
 {
     if (Canvas == null)
     {
         Canvas = this.GetComponentInParent <Canvas>(true);
     }
     if (ViewPort == null && this.transform.parent != null)
     {
         ViewPort = this.transform.parent as RectTransform;
     }
     if (ScrollRect == null && ViewPort != null && ViewPort.GetComponentInParent <ScrollRect>(true) != null)
     {
         ScrollRect = ViewPort.GetComponentInParent <ScrollRect>(true);
     }
     if (LayoutGroup == null)
     {
         LayoutGroup = this.GetComponent <LayoutGroup>();
     }
 }
Beispiel #14
0
        public EditableText BuildTextField(LayoutGroup uiGroup)
        {
            var textInput = uiGroup.actor.transform.AddActorAsChild("TextInput");

            textInput.transform.LocalDepth = new Depth(-1);
            new BoundingRect(textInput, new Point(32, 28));
            new LayoutElement(textInput).StretchHorizontally();
            new NinepatchRenderer(textInput, this.style.textboxSheet);
            new LayoutGroup(textInput, Orientation.Vertical).SetMarginSize(new Point(3, 3));
            new Hoverable(textInput);
            var clickable = new Clickable(textInput);
            var text      = textInput.transform.AddActorAsChild("TextInput - Text");

            text.transform.LocalDepth = new Depth(-1);
            new BoundingRect(text, new Point(32, 32));
            new LayoutElement(text).StretchHorizontally().StretchVertically();
            new BoundedTextRenderer(text, "", this.style.uiElementFont, Color.Black, overflow: Overflow.Ignore);
            return(new EditableText(text, clickable));
        }
Beispiel #15
0
    private static int get_flexibleHeight(IntPtr L)
    {
        object obj = null;
        int    result;

        try
        {
            obj = ToLua.ToObject(L, 1);
            LayoutGroup layoutGroup    = (LayoutGroup)obj;
            float       flexibleHeight = layoutGroup.flexibleHeight;
            LuaDLL.lua_pushnumber(L, (double)flexibleHeight);
            result = 1;
        }
        catch (Exception ex)
        {
            result = LuaDLL.toluaL_exception(L, ex, (obj != null) ? ex.Message : "attempt to index flexibleHeight on a nil value");
        }
        return(result);
    }
    public static int set_padding(IntPtr l)
    {
        int result;

        try
        {
            LayoutGroup layoutGroup = (LayoutGroup)LuaObject.checkSelf(l);
            RectOffset  padding;
            LuaObject.checkType <RectOffset>(l, 2, out padding);
            layoutGroup.padding = padding;
            LuaObject.pushValue(l, true);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
Beispiel #17
0
        public void Initialize(string[] options, Action <int> onAffirmativeButtonClicked, string affirmativeButtonText, string titleText, ImageData icon, Action onDismissiveButtonClicked, string dismissiveButtonText, int selectedIndexStart)
        {
            m_OptionList     = options;
            m_SelectionItems = new List <DialogRadioOption>();

            for (int i = 0; i < m_OptionList.Length; i++)
            {
                m_SelectionItems.Add(CreateSelectionItem(i));
            }

            if (selectedIndexStart < 0)
            {
                selectedIndexStart = 0;
            }
            if (selectedIndexStart >= m_SelectionItems.Count)
            {
                selectedIndexStart = m_SelectionItems.Count - 1;
            }
            m_SelectionItems[selectedIndexStart].itemRadio.toggle.isOn = true;
            m_SelectedIndex = selectedIndexStart;

            Destroy(m_OptionTemplate);

            m_TitleSection.SetTitle(titleText, icon);
            m_ButtonSection.SetButtons(null, affirmativeButtonText, onDismissiveButtonClicked, dismissiveButtonText);
            m_ButtonSection.SetupButtonLayout(rectTransform);

            m_OnAffirmativeButtonClicked = onAffirmativeButtonClicked;

            float availableHeight = DialogManager.rectTransform.rect.height;

            LayoutGroup textAreaRectTransform = m_TitleSection.text.transform.parent.GetComponent <LayoutGroup>();

            if (textAreaRectTransform.gameObject.activeSelf)
            {
                textAreaRectTransform.CalculateLayoutInputVertical();
                availableHeight -= textAreaRectTransform.preferredHeight;
            }

            m_ListScrollLayoutElement.maxHeight = availableHeight - 98f;

            Initialize();
        }
    //
    // Unity Methods
    //

    private void Awake()
    {
        originalTitleColor = title.color;
        originalValueColor = value.color;

        if (disabled)
        {
            SetDisabledColors();
        }

        var componentManager = ComponentManager.Instance;

        dataLayers  = componentManager.Get <DataLayers>();
        layoutGroup = componentManager.Get <ContoursTool>().InfoPanel.container.GetComponent <LayoutGroup>();

        // Initialize listener
        //translator.OnLanguageChanged += OnLanguageChanged;
        groupToggle.onValueChanged.AddListener(OnGroupToggleChanged);
    }
        /// <summary>
        /// Configures the object.
        /// </summary>
        /// <param name="options">The configuration options.</param>
        public override void HelpInstantiate(params int[] options)
        {
            if (!options.Contains(optionHasLayoutHorizontal) && !options.Contains(optionHasLayoutVertical))
            {
                DestroyImmediate(m_LayoutGroup);
            }
            else
            {
                if (options.Contains(optionHasLayoutHorizontal))
                {
                    GameObject go = m_LayoutGroup.gameObject;
                    DestroyImmediate(m_LayoutGroup);
                    m_LayoutGroup = go.AddComponent <HorizontalLayoutGroup>();
                    m_LayoutGroup.childAlignment = TextAnchor.MiddleCenter;
                    ((HorizontalLayoutGroup)m_LayoutGroup).childForceExpandWidth  = false;
                    ((HorizontalLayoutGroup)m_LayoutGroup).childForceExpandHeight = false;
                }
                else
                {
                    m_LayoutGroup = m_RectTransform.gameObject.GetAddComponent <VerticalLayoutGroup>();
                    m_LayoutGroup.childAlignment = TextAnchor.MiddleCenter;
                    ((VerticalLayoutGroup)m_LayoutGroup).childForceExpandWidth  = false;
                    ((VerticalLayoutGroup)m_LayoutGroup).childForceExpandHeight = false;
                }
            }

            if (!options.Contains(optionFitted))
            {
                DestroyImmediate(m_SizeFitter);
                m_RectTransform.sizeDelta        = new Vector2(100f, 100f);
                m_RectTransform.anchoredPosition = Vector2.zero;
            }

            if (options.Contains(optionStretched))
            {
                m_RectTransform.anchorMin        = new Vector2(0f, 0f);
                m_RectTransform.anchorMax        = new Vector2(1f, 1f);
                m_RectTransform.sizeDelta        = Vector2.zero;
                m_RectTransform.anchoredPosition = Vector2.zero;
            }

            base.HelpInstantiate(options);
        }
Beispiel #20
0
        public void SetLayout(string layoutName)
        {
            switch (layoutName)
            {
            case "grid":
                layout = GameObject.AddComponent <GridLayoutGroup>();
                break;

            case "horizontal":
                layout = GameObject.AddComponent <HorizontalLayoutGroup>();
                SetChildExpand(false);
                break;

            case "vertical":
                layout = GameObject.AddComponent <VerticalLayoutGroup>();
                SetChildExpand(false);
                break;
            }
        }
Beispiel #21
0
        public void ShowAVerticalGroupOf3Items()
        {
            LayoutGroup group = new LayoutGroup(true, Styles.DefaultGroupStyle);
            LayoutEntry item  = new LayoutEntry(Styles.DefaultEntryStyle)
            {
                ContentWidth = 50, ContentHeight = 50
            };

            group.Add(item.Clone());
            group.Add(item.Clone());
            group.Add(item.Clone());

            group.CalcWidth();
            group.CalcHeight();
            group.SetX(0);
            group.SetY(0);

            group.ShowResult();
        }
Beispiel #22
0
        /// <summary>
        /// Raises the view above all other views.
        /// </summary>
        /// <remarks>
        /// Sibling order of views within the parent will be updated automatically.
        /// Once a raise or lower API is used, that view will then have an exclusive sibling order independent of insertion.
        /// </remarks>
        /// <since_tizen> 3 </since_tizen>
        public void RaiseToTop()
        {
            var parentChildren = GetParent()?.Children;

            if (parentChildren != null)
            {
                parentChildren.Remove(this);
                parentChildren.Add(this);

                LayoutGroup layout = Layout as LayoutGroup;
                layout?.ChangeLayoutSiblingOrder(parentChildren.Count - 1);

                Interop.NDalic.RaiseToTop(SwigCPtr);
                if (NDalicPINVOKE.SWIGPendingException.Pending)
                {
                    throw NDalicPINVOKE.SWIGPendingException.Retrieve();
                }
            }
        }
Beispiel #23
0
        /// <summary>
        /// Lowers the view to the bottom of all views.
        /// </summary>
        /// <remarks>
        /// The sibling order of views within the parent will be updated automatically.
        /// Once a raise or lower API is used that view will then have an exclusive sibling order independent of insertion.
        /// </remarks>
        /// <since_tizen> 3 </since_tizen>
        public void LowerToBottom()
        {
            var parentChildren = GetParent()?.Children;

            if (parentChildren != null)
            {
                parentChildren.Remove(this);
                parentChildren.Insert(0, this);

                LayoutGroup layout = Layout as LayoutGroup;
                layout?.ChangeLayoutSiblingOrder(0);

                Interop.NDalic.LowerToBottom(swigCPtr);
                if (NDalicPINVOKE.SWIGPendingException.Pending)
                {
                    throw NDalicPINVOKE.SWIGPendingException.Retrieve();
                }
            }
        }
Beispiel #24
0
        public virtual void Initialize(Menu menu, LayoutGroup layoutGroup)
        {
            Menu   = menu;
            Layout = layoutGroup;

            var promptButtons = Menu.GetComponentsInChildren <ButtonWithHotkeyImageElement>(true).Select(x => x.GetComponent <Button>());

            BaseButtons = promptButtons.Select(x => new ModPromptButton(x, this)).Cast <IModButtonBase>().ToList();

            var ordinaryButtons = Menu.GetComponentsInChildren <Button>(true).Except(promptButtons);

            BaseButtons.AddRange(ordinaryButtons.Select(x => new ModTitleButton(x, this)).Cast <IModButtonBase>().ToList());

            ToggleInputs = Menu.GetComponentsInChildren <TwoButtonToggleElement>(true).Select(x => new ModToggleInput(x, this)).Cast <IModToggleInput>().ToList();
            SliderInputs = Menu.GetComponentsInChildren <SliderElement>(true).Select(x => new ModSliderInput(x, this)).Cast <IModSliderInput>().ToList();
            TextInputs   = new List <IModTextInput>();
            NumberInputs = new List <IModNumberInput>();
            ComboInputs  = new List <IModComboInput>();
        }
Beispiel #25
0
        public void LayoutItemMeasure()
        {
            tlog.Debug(tag, $"LayoutItemMeasure START");

            var testingTarget = new MyLayoutItem();

            Assert.IsNotNull(testingTarget, "null handle");
            Assert.IsInstanceOf <LayoutItem>(testingTarget, "Should be an instance of LayoutGroup type.");

            View view = new View()
            {
                ExcludeLayouting = false,
                Size             = new Size(100, 150)
            };

            testingTarget.AttachToOwner(view);

            LayoutGroup layoutGroup = new LayoutGroup();

            testingTarget.SetParent(layoutGroup);

            testingTarget.RequestLayout(); // Ensures a layout pass is needed.

            MeasureSpecification imposedWidth  = new MeasureSpecification(new LayoutLength(300.0f), MeasureSpecification.ModeType.Exactly);
            MeasureSpecification imposedHeight = new MeasureSpecification(new LayoutLength(300.0f), MeasureSpecification.ModeType.Exactly);

            try
            {
                testingTarget.Measure(imposedWidth, imposedHeight);
            }
            catch (Exception e)
            {
                tlog.Error(tag, "Caught Exception" + e.ToString());
                LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString());
                Assert.Fail("Caught Exception" + e.ToString());
            }

            layoutGroup.Dispose();
            testingTarget.Dispose();
            view.Dispose();
            tlog.Debug(tag, $"LayoutItemMeasure END (OK)");
        }
Beispiel #26
0
        private void AddLayoutGroupComponent(GameObject cellGroup)
        {
            LayoutGroup layoutGroup = null;

            // Update grid-specific Group Layout Parameters
            if (m_ViewType == ViewType.VerticalGrid)
            {
                GridLayoutGroup  gridLayoutGroup = cellGroup.AddComponent <GridLayoutGroup>();
                GridLayoutParams groupParams     = (GridLayoutParams)_contentLayoutGroupParams;
                gridLayoutGroup.cellSize        = groupParams.cellSize;
                gridLayoutGroup.spacing         = groupParams.spacing;
                gridLayoutGroup.startCorner     = groupParams.startCorner;
                gridLayoutGroup.startAxis       = GridLayoutGroup.Axis.Horizontal;
                gridLayoutGroup.constraint      = groupParams.constraint;
                gridLayoutGroup.constraintCount = m_GridLayoutParams.constraintCount;
                gridLayoutGroup.padding         = new RectOffset(0, 0, 0, 0);
                layoutGroup = gridLayoutGroup;
            }
            else if (m_ViewType == ViewType.Vertical)
            {
                VerticalLayoutGroup  verticalLayoutGroup = cellGroup.AddComponent <VerticalLayoutGroup>();
                VerticalLayoutParams groupParams         = (VerticalLayoutParams)_contentLayoutGroupParams;
                verticalLayoutGroup.childForceExpandWidth  = groupParams.forceExpandWidth;
                verticalLayoutGroup.childForceExpandHeight = groupParams.forceExpandHeight;
                verticalLayoutGroup.spacing = groupParams.spacing;
                verticalLayoutGroup.padding = groupParams.padding;
                layoutGroup = verticalLayoutGroup;
            }
            else if (m_ViewType == ViewType.Horizontal)
            {
                HorizontalLayoutGroup  horizontalLayoutGroup = cellGroup.AddComponent <HorizontalLayoutGroup>();
                HorizontalLayoutParams groupParams           = (HorizontalLayoutParams)_contentLayoutGroupParams;
                horizontalLayoutGroup.childForceExpandWidth  = groupParams.forceExpandWidth;
                horizontalLayoutGroup.childForceExpandHeight = groupParams.forceExpandHeight;
                horizontalLayoutGroup.spacing = groupParams.spacing;
                horizontalLayoutGroup.padding = groupParams.padding;
                layoutGroup = horizontalLayoutGroup;
            }

            // Update common group layout parameters
            layoutGroup.childAlignment = _contentLayoutGroupParams.childAlignment;
        }
Beispiel #27
0
    void setLayout(LayoutGroup lg)
    {
        switch (headset)
        {
        case Headset.WMR:
            lg.obj.transform.localPosition    = lg.wmr.position;
            lg.obj.transform.localEulerAngles = lg.wmr.rotation;
            break;

        case Headset.VIVE:
            lg.obj.transform.localPosition    = lg.vive.position;
            lg.obj.transform.localEulerAngles = lg.vive.rotation;
            break;

        case Headset.RIFT:
            lg.obj.transform.localPosition    = lg.rift.position;
            lg.obj.transform.localEulerAngles = lg.rift.rotation;
            break;
        }
    }
Beispiel #28
0
    /// <summary>Sometimes sizeDelta works, sometimes rect works, sometimes neither work and you need to get the layout properties.
    ///	This method provides a simple way to get the size of a RectTransform, no matter what's driving it or what the anchor values are.
    /// </summary>
    /// <param name="rectTransform">The rect transform to check.</param>
    /// <returns>The proper size of the RectTransform.</returns>
    public static Vector2 GetProperSize(this RectTransform rectTransform)     //, bool attemptToRefreshLayout = false)
    {
        Vector2 size = new Vector2(rectTransform.rect.width, rectTransform.rect.height);

        if (size.x == 0 && size.y == 0)
        {
            size.x = LayoutUtility.GetPreferredWidth(rectTransform);
            size.y = LayoutUtility.GetPreferredHeight(rectTransform);
        }
        if (size.x == 0 && size.y == 0)
        {
            LayoutGroup layoutGroup = rectTransform.GetComponent <LayoutGroup>();
            if (layoutGroup != null)
            {
                size.x = layoutGroup.preferredWidth;
                size.y = layoutGroup.preferredHeight;
            }
        }
        return(size);
    }
Beispiel #29
0
        protected void CreateOrReinitCellGroupPrefab()
        {
            if (!_TheOnlyGroupPrefab)
            {
                var go = new GameObject(ScrollViewRT.name + "_CellGroupPrefab", typeof(RectTransform));

                // Additional reminder of the "add recttransform in awake" bug explained in InitIfNeeded()
                if (!(go.transform is RectTransform))
                {
                    Debug.LogException(new OSAException("Don't call OSA.Init() outside MonoBehaviour.Start()!"));
                }

                // TODO also integrate the new SetViewsHolderEnabled functionality here, for grids
                go.SetActive(false);
                go.transform.SetParent(ScrollViewRT, false);
                _TheOnlyGroupPrefab = AddLayoutGroupToCellGroupPrefab(go);
                _TheOnlyGroupPrefabAsHorizontalOrVertical = _TheOnlyGroupPrefab as HorizontalOrVerticalLayoutGroup;
            }
            InitOrReinitCellGroupPrefabLayoutGroup(_TheOnlyGroupPrefab);
        }
Beispiel #30
0
        /// <summary>
        /// 以Float模式向DockManager注册一个DockElement
        /// </summary>
        /// <param name="title">标题栏文字</param>
        /// <param name="content">内容</param>
        /// <param name="imageSource">标题栏图标</param>
        /// <param name="side">停靠方向(默认左侧)</param>
        /// <param name="desiredWidth">期望的宽度</param>
        /// <param name="desiredHeight">期望的高度</param>
        /// <returns></returns>
        public void RegisterFloat(IDockSource content, DockSide side = DockSide.Left, double desiredWidth = Constants.DockDefaultWidthLength, double desiredHeight = Constants.DockDefaultHeightLength)
        {
            DockElement ele = new DockElement()
            {
                ID            = id++,
                Title         = content.Header,
                Content       = content as UIElement,
                ImageSource   = content.Icon,
                Side          = side,
                Mode          = DockMode.Float,
                DesiredWidth  = desiredWidth,
                DesiredHeight = desiredHeight
            };
            var ctrl  = new DockControl(ele);
            var group = new LayoutGroup(side, ele.Mode, this);

            group.Attach(ele);
            AddDockControl(ctrl);
            content.DockControl = ctrl;
        }
Beispiel #31
0
        void Awake()
        {
            _scrollView = GetComponent <ScrollRect>();
            if (_scrollView == null)
            {
                Debug.LogError("ScrollRect is null");
                return;
            }
            _content = _scrollView.content;
            _scrollView.movementType = ScrollRect.MovementType.Unrestricted;
            _layoutGroup             = _content.GetComponent <LayoutGroup>();
            if (_layoutGroup == null)
            {
                Debug.LogError("LayoutGroup component is null");
            }
            _childCount = _content.childCount;

            _scrollViewTrans = _scrollView.GetComponent <RectTransform>();
            _contentTrans    = _content as RectTransform;
        }
        private void Start()
        {
            if (!scoreViewPrefab)
            {
                scoreViewPrefab = Resources.Load("PlayerText") as ScoreView;
            }
            else if (!replayUIPrefab)
            {
                replayUIPrefab = Resources.Load("ReplayUI") as ReplayView;
            }
            currentViewPos = scoreViewPrefab.gameObject.transform.position;

            if (!parentLayoutGroup)
            {
                Debug.Log("Parent not specified, using defaultParent");
                parentLayoutGroup = GameObject.FindObjectOfType <LayoutGroup>();
            }
            GameApplication.Instance.GetService <IReplayService>().SetSceneController(this);
            StartServices();
        }
Beispiel #33
0
        /// <summary>
        /// Gets the height of the item.
        /// </summary>
        /// <returns>The item height.</returns>
        /// <param name="item">Item.</param>
        float CalculateItemHeight(TItem item)
        {
            if (defaultItemLayoutGroup == null)
            {
                defaultItemLayoutGroup = DefaultItemCopy.GetComponent <LayoutGroup>();
            }

            float height = 0f;

            if (!IsCanCalculateHeight || ForceAutoHeightCalculation)
            {
                if (defaultItemLayoutGroup != null)
                {
                    DefaultItemCopy.gameObject.SetActive(true);

                    SetData(DefaultItemCopy, item);

                    Utilites.UpdateLayout(defaultItemLayoutGroup);

                    height = LayoutUtility.GetPreferredHeight(DefaultItemCopyRect);

                    DefaultItemCopy.gameObject.SetActive(false);
                }
            }
            else
            {
                // 是否有默认高度,有默认高度则取默认高度,不去计算,节省性能
                float defautlHeight = (DefaultItemCopy as IListViewItemHeight).DefaultHeight;
                if (defautlHeight > 0f)
                {
                    height = defautlHeight;
                }
                else
                {
                    SetData(DefaultItemCopy, item);
                    height = (DefaultItemCopy as IListViewItemHeight).Height;
                }
            }

            return(height);
        }
        private static SubUIButtonLayoutGroup EditorCreateButtonLayoutGroup <T>(UnityEditor.MenuCommand menuCommand) where T : LayoutGroup
        {
            GameObject             gameObject = new GameObject("ButtonLayoutGroup", typeof(RectTransform), typeof(T), typeof(ContentSizeFitter));
            SubUIButtonLayoutGroup btnLayout  = gameObject.AddComponent <SubUIButtonLayoutGroup>();

            LayoutGroup layoutGroup = gameObject.GetComponent <T>();

            btnLayout.layoutGroup = layoutGroup;

            GameObject itemTemplate = DefaultControls.CreateButton(EditorGetStandardResources());

            itemTemplate.name = "ItemTemplate";
            Text itemTemplateText = itemTemplate.GetComponentInChildren <Text>();

            itemTemplateText.text     = "Template Button";
            itemTemplateText.fontSize = 20;
            //itemTemplate.SetActive(false);
            itemTemplate.transform.SetParent(gameObject.transform, false);
            btnLayout.itemTemplate = itemTemplate;

            ContentSizeFitter fitter = gameObject.GetComponent <ContentSizeFitter>();

            fitter.horizontalFit = ContentSizeFitter.FitMode.PreferredSize;
            fitter.verticalFit   = ContentSizeFitter.FitMode.PreferredSize;

            GameObject parent = menuCommand.context as GameObject;

            if (parent != null)
            {
                gameObject.name = UnityEditor.GameObjectUtility.GetUniqueNameForSibling(parent.transform, gameObject.name);
            }
            UnityEditor.Undo.RegisterCreatedObjectUndo(gameObject, "Create" + gameObject.name);
            if (parent != null)
            {
                UnityEditor.Undo.SetTransformParent(gameObject.transform, parent.transform, "Parent" + gameObject.name);
                UnityEditor.GameObjectUtility.SetParentAndAlign(gameObject, parent);
            }

            UnityEditor.Selection.activeGameObject = gameObject;
            return(btnLayout);
        }
Beispiel #35
0
 void Start()
 {
     rectTransform = GetComponent<RectTransform>();
     layoutGroup = GetComponentInParent<LayoutGroup>();
     layoutElement = GetComponent<LayoutElement>();
     gameMaster.simpleOnGameStateChanges += UpdateInteractivity;
     GetDirectionAsEnum();
     UpdateDisplay();
     startParent = transform.parent;
     UpdateInteractivity();
 }
		void Start()
		{
			layout = GetComponent<LayoutGroup>();
			if (layout!=null)
			{
				Utilites.UpdateLayout(layout);
			}

			Init();
		}
Beispiel #37
0
 public void Remove (LayoutGroup group)
 {
     groups.Remove (group);
 }
Beispiel #38
0
 public void Add (LayoutGroup group)
 {
     groups.Add (group);
 }
Beispiel #39
0
        private void draw()
        {
            Utils.log("draw", "Lookahead({0}), TokenType({1}), Caret({2})", getCurrentToken(), lookahead(), this.currentDrawToken);
            LayoutGroup lg;

            if (getCurrentToken() == this.currentDrawToken)
            {
                DrawCaret();
            }

            switch (lookahead())
            {
                // Basic Terminals
                case TokenType.DIGIT:
                    Utils.log("draw", "Drawing digit");

                    AddTextBox(lexeme(), fontSizes.Peek());
                    accept(TokenType.DIGIT);
                    break;
                case TokenType.OPEN_PAREN:
                    accept(TokenType.OPEN_PAREN);

                    lg = new LayoutGroup(LayoutGroupType.REL_POS_RIGHT);
                    lg.setWrapperParens();
                    layoutGroupCurrent.Push(lg);

                    while (lookahead() != TokenType.CLOSE_PAREN && !atEndOfStream())
                    {
                        draw();
                    }

                    if (getCurrentToken() == this.currentDrawToken)
                    {
                        DrawCaret();
                    }

                    layoutGroupCurrent.Pop();
                    layoutGroupCurrent.Peek().Add(lg);
                    accept(TokenType.CLOSE_PAREN);
                    break;
                case TokenType.OP_SQRT:
                    accept(TokenType.OP_SQRT);
                    accept(TokenType.OPEN_RADICAL);

                    lg = new LayoutGroup(LayoutGroupType.REL_POS_RIGHT);
                    lg.setWrapperRadical();
                    layoutGroupCurrent.Push(lg);

                    while (lookahead() != TokenType.CLOSE_RADICAL && !atEndOfStream())
                    {
                        draw();
                    }

                    if (getCurrentToken() == this.currentDrawToken)
                    {
                        DrawCaret();
                    }

                    //this.centrelineYs.Pop();
                    accept(TokenType.CLOSE_RADICAL);
                    layoutGroupCurrent.Pop();
                    layoutGroupCurrent.Peek().Add(lg);
                    break;
                /*
                 * Drawing fractions by having equidistant 'lines',
                 *  We draw numbers between the lines and the fraction lines ON the lines.
                 *
                 * We do this by 2 principles:
                 *  Fractions on the same level should have their centre lines drawn at the same y-value.
                 *  Fractions which may overlap with above or below lines should create space by pushing them up.
                 *
                 */
                case TokenType.OPEN_FRAC_UP:
                    //Debugger.Log(0, "[draw]", String.Format("OPEN_FRAC_UP"));
                    // Opening a fraction:
                    accept(TokenType.OPEN_FRAC_UP);

                    lg = new LayoutGroup(LayoutGroupType.REL_POS_FRACTION);
                    layoutGroupCurrent.Push(lg);

                    lg = new LayoutGroup(LayoutGroupType.REL_POS_FRACTION_NUMERATOR);
                    layoutGroupCurrent.Push(lg);

                    // Draw Numerator
                    while (lookahead() != TokenType.CLOSE_FRAC_UP && !atEndOfStream())
                    {
                        draw();
                    }

                    if (getCurrentToken() == this.currentDrawToken)
                    {
                        DrawCaret();
                    }

                    accept(TokenType.CLOSE_FRAC_UP);
                    accept(TokenType.OPEN_FRAC_DOWN);

                    lg = new LayoutGroup(LayoutGroupType.REL_POS_FRACTION_DENOMINATOR);
                    layoutGroupCurrent.Push(lg);

                    // Draw Denominator
                    while (lookahead() != TokenType.CLOSE_FRAC_DOWN && !atEndOfStream())
                    {
                        draw();
                    }

                    if (getCurrentToken() == this.currentDrawToken)
                    {
                        DrawCaret();
                    }

                    accept(TokenType.CLOSE_FRAC_DOWN);

                    // Pop Denominator
                    LayoutGroup denom = layoutGroupCurrent.Pop();
                    LayoutGroup num = layoutGroupCurrent.Pop();
                    LayoutGroup frac = layoutGroupCurrent.Pop();
                    frac.Add(num);
                    frac.Add(denom);
                    layoutGroupCurrent.Peek().Add(frac);

                    break;
                case TokenType.OPEN_SUPER:
                    accept(TokenType.OPEN_SUPER);

                    lg = new LayoutGroup(LayoutGroupType.REL_POS_SUPER);
                    layoutGroupCurrent.Push(lg);

                    while (lookahead() != TokenType.CLOSE_SUPER && !atEndOfStream())
                    {
                        draw();
                    }

                    if (getCurrentToken() == this.currentDrawToken)
                    {
                        DrawCaret();
                    }

                    accept(TokenType.CLOSE_SUPER);

                    lg = layoutGroupCurrent.Pop();
                    layoutGroupCurrent.Peek().Add(lg);

                    break;
                case TokenType.PLACEHOLDER:
                    double h = this.fontSizes.Peek();
                    AddRectangle(10, h);
                    accept(TokenType.PLACEHOLDER);
                    break;
                default:
                    AddTextBox(lexRepr(), fontSizes.Peek());
                    accept(lookahead());
                    break;
            }
        }
        /// <summary>
        /// Loads the layout from an XML reader.
        /// </summary>
        /// <param name="reader">The reader.</param>
        public void Load(XmlReader reader)
        {
            // Loop through the file until we find the end XML element.
            while (reader.Read())
            {
                // Ignore everything outside of our namespace.
                if (reader.NamespaceURI != ActionLayoutNamespace)
                {
                    continue;
                }

                // Check for the end of the layout tag.
                if (reader.NodeType == XmlNodeType.EndElement
                    && reader.LocalName == "action-layout")
                {
                    // We are done reading.
                    return;
                }

                // If we have a group, then load that.
                if (reader.LocalName == "layout-group")
                {
                    var group = new LayoutGroup(reader);
                    groups.Add(group);
                }
            }
        }
        void Awake()
        {
            _scrollRect = gameObject.GetComponentInChildren<ScrollRect>();
            _scrollRectTransform = _scrollRect.gameObject.GetComponent<RectTransform>();

            foreach(LayoutGroup layoutGroup in _scrollRect.content.GetComponents<LayoutGroup>())
            {
                layoutGroup.enabled = false;
            }
            if (m_ViewType == ViewType.Vertical)
            {
                _contentLayoutGroup = _scrollRect.content.GetComponent<VerticalLayoutGroup>();
                _contentLayoutGroupParams = m_VerticalLayoutParams;
            } else if (m_ViewType == ViewType.Horizontal)
            {
                _contentLayoutGroup = _scrollRect.content.GetComponent<HorizontalLayoutGroup>();
                _contentLayoutGroupParams = m_HorizontalLayoutParams;
            } else
            {
                _contentLayoutGroup = _scrollRect.content.GetComponent<GridLayoutGroup>();
                _contentLayoutGroupParams = m_GridLayoutParams;
            }
            _contentLayoutGroup.enabled = true;
            _contentTransform = _contentLayoutGroup.GetComponent<RectTransform>();
        }
Beispiel #42
0
		static public void UpdateLayout(LayoutGroup layout)
		{
			layout.CalculateLayoutInputHorizontal();
			layout.SetLayoutHorizontal();
			layout.CalculateLayoutInputVertical();
			layout.SetLayoutVertical();
		}
Beispiel #43
0
	// Use this for initialization
	void Start ()
    {
        layout = GetComponent<LayoutGroup>();
	}