예제 #1
0
        public override void CreateUIEntry(PGridPanel parent, ref int row)
        {
            if (getTitle != null)
            {
                Title = getTitle.Invoke();
            }
            else
            {
                // Only displayed in error cases, should not be localized
                Title = "<No Title>";
            }
            var label = new PLabel("Label")
            {
                Text = LookInStrings(Title), TextStyle = PUITuning.Fonts.TextLightStyle
            };

            label.OnRealize += OnRealizeLabel;
            parent.AddChild(label, new GridComponentSpec(row, 0)
            {
                Margin = LABEL_MARGIN, Alignment = TextAnchor.MiddleLeft
            });
            parent.AddChild(this, new GridComponentSpec(row, 1)
            {
                Alignment = TextAnchor.MiddleRight, Margin = CONTROL_MARGIN
            });
        }
예제 #2
0
 /// <summary>
 /// Adds the line item entry for this options entry.
 /// </summary>
 /// <param name="parent">The location to add this entry.</param>
 /// <param name="row">The layout row index to use.</param>
 internal void CreateUIEntry(PGridPanel parent, int row)
 {
     parent.AddChild(new PLabel("Label")
     {
         Text      = LookInStrings(Title), ToolTip = LookInStrings(ToolTip),
         TextStyle = PUITuning.Fonts.TextLightStyle
     }, new GridComponentSpec(row, 0)
     {
         Margin = LABEL_MARGIN, Alignment = TextAnchor.MiddleLeft
     });
     parent.AddChild(GetUIComponent(), new GridComponentSpec(row, 1)
     {
         Alignment = TextAnchor.MiddleRight, Margin = CONTROL_MARGIN
     });
 }
예제 #3
0
 /// <summary>
 /// Creates a default UI entry. This entry will have the title and tool tip in the
 /// first column, and the provided UI component in the second column. Only one row is
 /// added by this method.
 /// </summary>
 /// <param name="entry">The options entry to be presented.</param>
 /// <param name="parent">The parent where the components will be added.</param>
 /// <param name="row">The row index where the components will be added.</param>
 /// <param name="presenter">The presenter that can display this option's value.</param>
 public static void CreateDefaultUIEntry(IOptionsEntry entry, PGridPanel parent,
                                         int row, IUIComponent presenter)
 {
     parent.AddChild(new PLabel("Label")
     {
         Text      = LookInStrings(entry.Title), ToolTip = LookInStrings(entry.Tooltip),
         TextStyle = PUITuning.Fonts.TextLightStyle
     }, new GridComponentSpec(row, 0)
     {
         Margin = LABEL_MARGIN, Alignment = TextAnchor.MiddleLeft
     });
     parent.AddChild(presenter, new GridComponentSpec(row, 1)
     {
         Alignment = TextAnchor.MiddleRight, Margin = CONTROL_MARGIN
     });
 }
예제 #4
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));
     }
 }
예제 #5
0
 public override void CreateUIEntry(PGridPanel parent, ref int row)
 {
     parent.AddChild(new PLabel(Field)
     {
         Text      = LookInStrings(Title), ToolTip = LookInStrings(ToolTip),
         TextStyle = WRAP_TEXT_STYLE
     }, new GridComponentSpec(row, 0)
     {
         Margin = CONTROL_MARGIN, Alignment = TextAnchor.MiddleCenter, ColumnSpan = 2
     });
 }
예제 #6
0
 public override void CreateUIEntry(PGridPanel parent, ref int row)
 {
     parent.AddChild(new PButton(Field)
     {
         Text    = LookInStrings(Title), ToolTip = LookInStrings(Tooltip),
         OnClick = OnButtonClicked
     }.SetKleiPinkStyle(), new GridComponentSpec(row, 0)
     {
         Margin = CONTROL_MARGIN, Alignment = TextAnchor.MiddleCenter, ColumnSpan = 2
     });
 }
예제 #7
0
        public override void CreateUIEntry(PGridPanel parent, ref int row)
        {
            double minLimit, maxLimit;

            base.CreateUIEntry(parent, ref row);
            if (limits != null && (minLimit = limits.Minimum) > float.MinValue && (maxLimit =
                                                                                       limits.Maximum) < float.MaxValue && maxLimit > minLimit)
            {
                // NaN will be false on either comparison
                var slider = GetSlider();
                // Min and max labels
                var minLabel = new PLabel("MinValue")
                {
                    TextStyle = PUITuning.Fonts.TextLightStyle, Text = minLimit.
                                                                       ToString("G4"), TextAlignment = TextAnchor.MiddleRight
                };
                var maxLabel = new PLabel("MaxValue")
                {
                    TextStyle = PUITuning.Fonts.TextLightStyle, Text = maxLimit.
                                                                       ToString("G4"), TextAlignment = TextAnchor.MiddleLeft
                };
                // Lay out left to right
                var panel = new PRelativePanel("Slider Grid")
                {
                    FlexSize = Vector2.right, DynamicSize = false
                }.AddChild(slider).AddChild(minLabel).AddChild(maxLabel).AnchorYAxis(slider).
                AnchorYAxis(minLabel, 0.5f).AnchorYAxis(maxLabel, 0.5f).SetLeftEdge(
                    minLabel, fraction: 0.0f).SetRightEdge(maxLabel, fraction: 1.0f).
                SetLeftEdge(slider, toRight: minLabel).SetRightEdge(slider, toLeft:
                                                                    maxLabel).SetMargin(slider, SLIDER_MARGIN);
                slider.OnRealize += OnRealizeSlider;
                // Add another row for the slider
                parent.AddRow(new GridRowSpec());
                parent.AddChild(panel, new GridComponentSpec(++row, 0)
                {
                    ColumnSpan = 2, Margin = ENTRY_MARGIN
                });
            }
        }