Ejemplo n.º 1
0
 /// <summary>
 /// Fired when the header is clicked.
 /// </summary>
 private void OnHeaderClicked()
 {
     if (toggle != null)
     {
         bool state = PToggle.GetToggleState(toggle);
         PToggle.SetToggleState(toggle, !state);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Adds a category header to the dialog.
 /// </summary>
 /// <param name="container">The parent of the header.</param>
 /// <param name="category">The header title.</param>
 /// <param name="contents">The panel containing the options in this category.</param>
 private void AddCategoryHeader(PGridPanel container, string category,
                                PGridPanel contents)
 {
     contents.AddColumn(new GridColumnSpec(flex: 1.0f)).AddColumn(new GridColumnSpec());
     if (!string.IsNullOrEmpty(category))
     {
         bool state   = !(infoAttr?.ForceCollapseCategories ?? false);
         var  handler = new CategoryExpandHandler(state);
         container.AddColumn(new GridColumnSpec()).AddColumn(new GridColumnSpec(
                                                                 flex: 1.0f)).AddRow(new GridRowSpec()).AddRow(new GridRowSpec(flex: 1.0f));
         // Toggle is upper left, header is upper right
         var header = new PLabel("CategoryHeader")
         {
             Text = OptionsEntry.LookInStrings(category), TextStyle =
                 CATEGORY_TITLE_STYLE, TextAlignment = TextAnchor.LowerCenter
         };
         var toggle = new PToggle("CategoryToggle")
         {
             Color          = PUITuning.Colors.ComponentDarkStyle, InitialState = state,
             ToolTip        = PUIStrings.TOOLTIP_TOGGLE, Size = TOGGLE_SIZE,
             OnStateChanged = handler.OnExpandContract
         };
         header.OnRealize += handler.OnRealizeHeader;
         toggle.OnRealize += handler.OnRealizeToggle;
         container.AddChild(header, new GridComponentSpec(0, 1)
         {
             Margin = new RectOffset(OUTER_MARGIN, OUTER_MARGIN, 0, 0)
         }).AddChild(toggle, new GridComponentSpec(0, 0));
         if (contents != null)
         {
             contents.OnRealize += handler.OnRealizePanel;
         }
         container.AddChild(contents, new GridComponentSpec(1, 0)
         {
             ColumnSpan = 2
         });
     }
     else
     {
         // Default of unconstrained fills the whole panel
         container.AddColumn(new GridColumnSpec(flex: 1.0f)).AddRow(new GridRowSpec(
                                                                        flex: 1.0f)).AddChild(contents, new GridComponentSpec(0, 0));
     }
 }
Ejemplo n.º 3
0
            internal TypeSelectCategory(TypeSelectControl parent, Tag categoryTag,
                                        string overrideName = null)
            {
                Control     = parent ?? throw new ArgumentNullException("parent");
                CategoryTag = categoryTag;
                string title = string.IsNullOrEmpty(overrideName) ? CategoryTag.ProperName() :
                               overrideName;
                var selectBox = new PCheckBox("SelectCategory")
                {
                    Text = title, OnChecked = OnCheck, CheckSize = ROW_SIZE, InitialState =
                        PCheckBox.STATE_CHECKED, TextStyle = PUITuning.Fonts.TextDarkStyle
                };

                selectBox.OnRealize += (obj) => { CheckBox = obj; };
                var showHide = new PToggle("ShowHide")
                {
                    OnStateChanged = OnToggle, Size = new Vector2(ROW_SIZE.x * 0.5f,
                                                                  ROW_SIZE.y * 0.5f), Color = PUITuning.Colors.ComponentLightStyle
                };

                Header = new PRelativePanel("TypeSelectCategory")
                {
                    DynamicSize = false
                }.
                AddChild(showHide).AddChild(selectBox).SetLeftEdge(showHide,
                                                                   fraction: 0.0f).SetRightEdge(selectBox, fraction: 1.0f).SetLeftEdge(
                    selectBox, toRight: showHide).SetMargin(selectBox, HEADER_MARGIN).
                AnchorYAxis(showHide, anchor: 0.5f).Build();
                children = new SortedList <Tag, TypeSelectElement>(16, TagAlphabetComparer.
                                                                   INSTANCE);
                ChildPanel = new PPanel("Children")
                {
                    Direction = PanelDirection.Vertical, Alignment = TextAnchor.UpperLeft,
                    Spacing   = ROW_SPACING, Margin = new RectOffset(INDENT, 0, 0, 0)
                }.Build();
                ChildPanel.transform.localScale = Vector3.zero;
            }