public static IComboBox GetCombobox(string id, IGameFactory factory, IObject parent, float?customWidth = null) { var dropDownButton = getDropDownButton(id, factory); var combobox = factory.UI.GetComboBox(id, dropDownButton, null, null, parent, defaultWidth: 100f, defaultHeight: 25f, dropDownPanelOffset: 10f); combobox.TextBox.CaretXOffset = -15; var layout = combobox.DropDownPanel.ContentsPanel.GetComponent <IStackLayoutComponent>(); layout.StopLayout(); layout.RelativeSpacing = 0f; layout.AbsoluteSpacing = -25f; layout.StartLayout(); var config = customWidth == null ? GameViewColors.ComboboxTextConfig : modifyConfig(GameViewColors.ComboboxTextConfig, customWidth.Value); var hoverConfig = customWidth == null ? GameViewColors.ComboboxHoverTextConfig : modifyConfig(GameViewColors.ComboboxHoverTextConfig, customWidth.Value); GameViewColors.AddHoverEffect(combobox.TextBox, GameViewColors.ComboboxTextBorder, GameViewColors.HoveredComboboxTextBorder, config, hoverConfig); combobox.DropDownPanel.ScrollingPanel.Tint = GameViewColors.TextEditor.WithAlpha(240); combobox.DropDownPanel.ScrollingPanel.Border = GameViewColors.DropDownBorder; return(combobox); }
public void AddEditorUI(string id, ITreeNodeView view, IProperty property) { _property = property; var label = view.TreeItem; var config = _enabled ? GameViewColors.TextboxTextConfig : GameViewColors.ReadonlyTextConfig; if (!_enabled) { var layout = view.HorizontalPanel.GetComponent <ITreeTableRowLayoutComponent>(); if (layout != null) { layout.RestrictionList.RestrictionList.Add(id); } } var textbox = _factory.UI.GetTextBox(id, label.X, label.Y, label.TreeNode.Parent, "", config, width: 100f, height: 20f); textbox.Text = property.ValueString; textbox.TextBackgroundVisible = true; textbox.Enabled = _enabled; if (_enabled) { GameViewColors.AddHoverEffect(textbox); } else { textbox.TextBackgroundVisible = false; } _textbox = textbox; textbox.RenderLayer = label.RenderLayer; textbox.Z = label.Z; textbox.OnPressingKey.Subscribe(args => { if (args.PressedKey != Key.Enter) { return; } args.ShouldCancel = true; textbox.IsFocused = false; setString(); }); textbox.LostFocus.Subscribe(args => { textbox.IsFocused = false; setString(); }); }