diff --git a/Content/UniversalEditor.Content.PlatformIndependent/Panels/PropertyList/PropertyListPanel.glade b/Content/UniversalEditor.Content.PlatformIndependent/Panels/PropertyList/PropertyListPanel.glade new file mode 100644 index 00000000..7f46d2a2 --- /dev/null +++ b/Content/UniversalEditor.Content.PlatformIndependent/Panels/PropertyList/PropertyListPanel.glade @@ -0,0 +1,222 @@ + + + + + + + + + + + + + + + + + + + + False + + + + + + True + False + vertical + + + True + False + tmObject + + + + 0 + + + + + False + True + 0 + + + + + True + True + vertical + 250 + True + True + + + True + False + vertical + + + True + True + in + + + True + True + tmProperties + 0 + both + + + + + + True + Name + True + True + 0 + + + + 0 + + + + + + + True + Value + True + True + 1 + + + + 1 + + + + + + + + + True + True + 0 + + + + + True + True + + + + + True + False + vertical + + + True + True + vertical + 120 + True + True + + + True + False + 8 + 8 + 8 + vertical + + + True + False + 8 + 8 + 8 + 8 + Property Title + 0 + + + + + + False + True + 0 + + + + + True + True + in + + + True + True + + + + + True + True + 1 + + + + + False + True + + + + + True + False + vertical + + + + + + True + True + + + + + True + True + 0 + + + + + False + True + + + + + True + True + 1 + + + + + + diff --git a/Content/UniversalEditor.Content.PlatformIndependent/UniversalEditor.Content.PlatformIndependent.csproj b/Content/UniversalEditor.Content.PlatformIndependent/UniversalEditor.Content.PlatformIndependent.csproj index 4cd9ccba..e7a59c79 100644 --- a/Content/UniversalEditor.Content.PlatformIndependent/UniversalEditor.Content.PlatformIndependent.csproj +++ b/Content/UniversalEditor.Content.PlatformIndependent/UniversalEditor.Content.PlatformIndependent.csproj @@ -316,6 +316,7 @@ + @@ -349,6 +350,7 @@ + diff --git a/Libraries/UniversalEditor.UserInterface/Panels/PropertyListPanel.Designer.cs b/Libraries/UniversalEditor.UserInterface/Panels/PropertyListPanel.Designer.cs deleted file mode 100644 index 44f28383..00000000 --- a/Libraries/UniversalEditor.UserInterface/Panels/PropertyListPanel.Designer.cs +++ /dev/null @@ -1,108 +0,0 @@ -// -// PropertyListPanel.Designer.cs -// -// Author: -// Mike Becker -// -// Copyright (c) 2019 Mike Becker -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -using System; -using MBS.Framework.UserInterface; -using MBS.Framework.UserInterface.Controls; -using MBS.Framework.UserInterface.Controls.ListView; -using MBS.Framework.UserInterface.Layouts; - -namespace UniversalEditor.UserInterface.Panels -{ - public partial class PropertyListPanel : Panel - { - private ComboBox cboObject = null; - private SplitContainer scPropertiesDescription = null; - private ListViewControl lvPropertyGrid = null; - private TextBox txtCommands = null; - private TextBox txtDescription = null; - private DefaultTreeModel tmPropertyGrid = null; - private DefaultTreeModel tmObject = null; - private SplitContainer scCommandsDescription = null; - - private void InitializeComponent() - { - Text = "Property List"; - Layout = new BoxLayout(Orientation.Vertical); - - cboObject = new ComboBox(); - tmObject = new DefaultTreeModel(new Type[] { typeof(string), typeof(string) }); - cboObject.Model = tmObject; - // i'd hate to limit it like this.. we should be able to type in an object name, hit "enter", and have it work - // cboObject.ReadOnly = true; - cboObject.KeyDown += CboObject_KeyDown; - cboObject.Changed += cboObject_Changed; - - Controls.Add(cboObject); - - scPropertiesDescription = new SplitContainer(Orientation.Horizontal); - scPropertiesDescription.Panel1.Layout = new BoxLayout(Orientation.Vertical); - - tmPropertyGrid = new DefaultTreeModel(new Type[] { typeof(string), typeof(string) }); - - lvPropertyGrid = new ListViewControl(); - lvPropertyGrid.SelectionChanged += lvPropertyGrid_SelectionChanged; ; - lvPropertyGrid.Model = tmPropertyGrid; - lvPropertyGrid.Columns.Add(new ListViewColumnText(tmPropertyGrid.Columns[0], "Name")); - lvPropertyGrid.Columns.Add(new ListViewColumnText(tmPropertyGrid.Columns[1], "Value")); - - scPropertiesDescription.Panel1.Controls.Add(lvPropertyGrid, new BoxLayout.Constraints(true, true)); - scPropertiesDescription.Panel2.Layout = new BoxLayout(Orientation.Vertical); - - scCommandsDescription = new SplitContainer(Orientation.Horizontal); - txtCommands = new TextBox(); - txtCommands.Editable = false; - txtCommands.Multiline = true; - txtCommands.Text = "Command 1 Command 2"; - scCommandsDescription.SplitterPosition = 100; - scCommandsDescription.Panel1.Layout = new BoxLayout(Orientation.Vertical); - // scCommandsDescription.Panel1.Controls.Add(txtCommands, new BoxLayout.Constraints(true, true)); - // not sure how to do this yet - - txtDescription = new TextBox(); - txtDescription.Editable = false; - txtDescription.Multiline = true; - scCommandsDescription.Panel2.Layout = new BoxLayout(Orientation.Vertical); - scCommandsDescription.Panel2.Controls.Add(txtDescription, new BoxLayout.Constraints(true, true)); - - scPropertiesDescription.SplitterPosition = 100; - scPropertiesDescription.Panel2.Controls.Add(scCommandsDescription, new BoxLayout.Constraints(true, true)); - - Controls.Add(scPropertiesDescription, new BoxLayout.Constraints(true, true)); - } - - void CboObject_KeyDown(object sender, MBS.Framework.UserInterface.Input.Keyboard.KeyEventArgs e) - { - // this don't work, Gtk blocks keyboard input (probably cause it's technically a text box) - if (e.Key == MBS.Framework.UserInterface.Input.Keyboard.KeyboardKey.Enter) - { - if (cboObject.Model != null) - { - TreeModelRow row = cboObject.Model.Find(cboObject.Text); - if (row != null) - { - cboObject.SelectedItem = row; - } - } - } - } - - } -} diff --git a/Libraries/UniversalEditor.UserInterface/Panels/PropertyListPanel.cs b/Libraries/UniversalEditor.UserInterface/Panels/PropertyListPanel.cs index 646916e3..3e81521f 100644 --- a/Libraries/UniversalEditor.UserInterface/Panels/PropertyListPanel.cs +++ b/Libraries/UniversalEditor.UserInterface/Panels/PropertyListPanel.cs @@ -21,6 +21,8 @@ using System; using System.Collections.Generic; using MBS.Framework.UserInterface; +using MBS.Framework.UserInterface.Controls; +using MBS.Framework.UserInterface.Controls.ListView; namespace UniversalEditor.UserInterface.Panels { @@ -114,42 +116,62 @@ namespace UniversalEditor.UserInterface.Panels } } + [ContainerLayout("~/Panels/PropertyList/PropertyListPanel.glade")] partial class PropertyListPanel : Panel { + private ComboBox cboObject; + private SplitContainer scDescriptionCommands; + private ListViewControl lvPropertyGrid; + public PropertyPanelObject.PropertyPanelObjectCollection Objects { get; private set; } = null; public PropertyListPanel() { - InitializeComponent(); - Objects = new PropertyPanelObject.PropertyPanelObjectCollection(this); } + [EventHandler(nameof(cboObject), nameof(ComboBox.KeyDown))] + void cboObject_KeyDown(object sender, MBS.Framework.UserInterface.Input.Keyboard.KeyEventArgs e) + { + // this don't work, Gtk blocks keyboard input (probably cause it's technically a text box) + if (e.Key == MBS.Framework.UserInterface.Input.Keyboard.KeyboardKey.Enter) + { + if (cboObject.Model != null) + { + TreeModelRow row = cboObject.Model.Find(cboObject.Text); + if (row != null) + { + cboObject.SelectedItem = row; + } + } + } + } + internal void ClearPropertyPanelObjects() { - tmObject.Rows.Clear(); + (cboObject.Model as DefaultTreeModel).Rows.Clear(); } internal void AddPropertyPanelObject(PropertyPanelObject item) { TreeModelRow row = new TreeModelRow(new TreeModelRowColumn[] { - new TreeModelRowColumn(tmObject.Columns[0], item.Name), - new TreeModelRowColumn(tmObject.Columns[1], item.ObjectClass?.Name) + new TreeModelRowColumn((cboObject.Model as DefaultTreeModel).Columns[0], item.Name), + new TreeModelRowColumn((cboObject.Model as DefaultTreeModel).Columns[1], item.ObjectClass?.Name) }); row.SetExtraData("obj", item); _rowsByObject[item] = row; - tmObject.Rows.Add(row); + (cboObject.Model as DefaultTreeModel).Rows.Add(row); } private Dictionary _rowsByObject = new Dictionary(); internal void RemovePropertyPanelObject(PropertyPanelObject item) { if (!_rowsByObject.ContainsKey(item)) return; - tmObject.Rows.Remove(_rowsByObject[item]); + (cboObject.Model as DefaultTreeModel).Rows.Remove(_rowsByObject[item]); } internal void RefreshList() { - tmObject.Rows.Clear(); + (cboObject.Model as DefaultTreeModel).Rows.Clear(); for (int i = 0; i < Objects.Count; i++) { AddPropertyPanelObject(Objects[i]); @@ -164,7 +186,7 @@ namespace UniversalEditor.UserInterface.Panels { _SelectedObject = value; - tmPropertyGrid.Rows.Clear(); + lvPropertyGrid.Model.Rows.Clear(); if (_SelectedObject != null) { if (SelectedObject.ObjectClass != null) @@ -186,8 +208,8 @@ namespace UniversalEditor.UserInterface.Panels { TreeModelRow row = new TreeModelRow(new TreeModelRowColumn[] { - new TreeModelRowColumn(tmPropertyGrid.Columns[0], property.Name), - new TreeModelRowColumn(tmPropertyGrid.Columns[1], property.Value == null ? String.Empty : property.Value.ToString()) + new TreeModelRowColumn(lvPropertyGrid.Model.Columns[0], property.Name), + new TreeModelRowColumn(lvPropertyGrid.Model.Columns[1], property.Value == null ? String.Empty : property.Value.ToString()) }); for (int i = 0; i < property.Properties.Count; i++) @@ -201,15 +223,17 @@ namespace UniversalEditor.UserInterface.Panels } else { - tmPropertyGrid.Rows.Add(row); + lvPropertyGrid.Model.Rows.Add(row); } } + [EventHandler(nameof(cboObject), nameof(ComboBox.Changed))] void cboObject_Changed(object sender, EventArgs e) { SelectedObject = cboObject.SelectedItem?.GetExtraData("obj"); } + [EventHandler(nameof(lvPropertyGrid), nameof(ListViewControl.SelectionChanged))] private void lvPropertyGrid_SelectionChanged(object sender, EventArgs e) { diff --git a/Libraries/UniversalEditor.UserInterface/UniversalEditor.UserInterface.csproj b/Libraries/UniversalEditor.UserInterface/UniversalEditor.UserInterface.csproj index c871881c..f1644e30 100644 --- a/Libraries/UniversalEditor.UserInterface/UniversalEditor.UserInterface.csproj +++ b/Libraries/UniversalEditor.UserInterface/UniversalEditor.UserInterface.csproj @@ -115,7 +115,6 @@ -