Skip to content

Commit f2a6a3d

Browse files
committed
xrSdkControls: add TreeView control
1 parent 7cefcdf commit f2a6a3d

22 files changed

+1599
-36
lines changed

src/editors/xrECore/Props/ItemList.cpp

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,24 @@ namespace ECore
1111
{
1212
namespace Props
1313
{
14-
void ItemList::AssignItems(ListItemsVec& new_items, bool full_expand, bool full_sort /*= false*/)
14+
void ItemList::AssignItems(ListItemsVec& newItems, bool fullExpand, bool fullSort /*= false*/)
1515
{
16-
/*// begin fill mode
1716
viewItems->BeginUpdate();
17+
18+
viewItems->Nodes->Clear();
19+
20+
for (const auto& item : newItems)
21+
{
22+
viewItems->AddItem(BackSlashToSlash(item->Key()));
23+
}
24+
/*// begin fill mode
25+
1826
// clear values
1927
// if (tvItems->Selected) FHelper.MakeFullName(tvItems->Selected,0,last_selected_item);
2028
//if (!items->empty())
2129
// ClearParams();
2230
// fill values
23-
items = &new_items;
31+
items = &newItems;
2432
for (auto& prop : *items)
2533
{
2634
if (prop->Key.size() && (prop->Key[prop->Key.size() - 1] == '\\'))
@@ -62,7 +70,7 @@ void ItemList::AssignItems(ListItemsVec& new_items, bool full_expand, bool full_
6270
}
6371
6472
// end fill mode
65-
if (full_expand)
73+
if (fullExpand)
6674
viewItems->ExpandAll();
6775
6876
// folder restore
@@ -88,7 +96,7 @@ void ItemList::AssignItems(ListItemsVec& new_items, bool full_expand, bool full_
8896
}
8997
9098
// sorting
91-
if (full_sort)
99+
if (fullSort)
92100
{
93101
viewItems->Sort();
94102
}
@@ -105,15 +113,18 @@ void ItemList::AssignItems(ListItemsVec& new_items, bool full_expand, bool full_
105113
for (RStringVecIt s_it = last_selected_items.begin(); s_it != last_selected_items.end(); s_it++)
106114
FHelper.ExpandItem(tvItems, **s_it);
107115
108-
viewItems->EndUpdate();
116+
109117
118+
for (RStringVecIt s_it = last_selected_items.begin(); s_it != last_selected_items.end(); s_it++)
119+
FHelper.RestoreSelection(tvItems, **s_it, true);
120+
*/
121+
110122
// restore selection
111123
viewItems->SelectedNode = nullptr;
112124

113-
for (RStringVecIt s_it = last_selected_items.begin(); s_it != last_selected_items.end(); s_it++)
114-
FHelper.RestoreSelection(tvItems, **s_it, true);
125+
toolStripStatusLabel2->Text = newItems.size().ToString();
115126

116-
toolStripStatusLabel2->Text = items->size().ToString();*/
127+
viewItems->EndUpdate();
117128
}
118129
} // namespace Props
119130
} // namespace ECore

src/editors/xrECore/Props/ItemList.h

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,27 +61,27 @@ public ref class ItemList : public System::Windows::Forms::Form
6161
}
6262

6363
public:
64-
void AssignItems(ListItemsVec& new_items, bool full_expand, bool full_sort);
64+
void AssignItems(ListItemsVec& newItems, bool fullExpand, bool fullSort);
6565

6666
private:
6767
Flags32* flags;
6868
ListItemsVec* items;
6969

70+
private: XRay::SdkControls::TreeView^ viewItems;
7071
private: System::Windows::Forms::StatusStrip^ statusStrip1;
7172
private: System::Windows::Forms::ToolStripStatusLabel^ toolStripStatusLabel1;
7273
private: System::Windows::Forms::ToolStripStatusLabel^ toolStripStatusLabel2;
73-
private: System::Windows::Forms::TreeView^ viewItems;
74+
private: System::ComponentModel::IContainer^ components;
7475

7576
private:
76-
System::ComponentModel::Container^ components;
77-
7877
#pragma region Windows Form Designer generated code
7978
void InitializeComponent(void)
8079
{
80+
this->components = (gcnew System::ComponentModel::Container());
8181
this->statusStrip1 = (gcnew System::Windows::Forms::StatusStrip());
8282
this->toolStripStatusLabel1 = (gcnew System::Windows::Forms::ToolStripStatusLabel());
8383
this->toolStripStatusLabel2 = (gcnew System::Windows::Forms::ToolStripStatusLabel());
84-
this->viewItems = (gcnew System::Windows::Forms::TreeView());
84+
this->viewItems = (gcnew XRay::SdkControls::TreeView());
8585
this->statusStrip1->SuspendLayout();
8686
this->SuspendLayout();
8787
this->statusStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(2) {
@@ -98,10 +98,16 @@ private: System::Windows::Forms::TreeView^ viewItems;
9898
this->toolStripStatusLabel1->Text = L"Items count:";
9999
this->toolStripStatusLabel2->Name = L"toolStripStatusLabel2";
100100
this->toolStripStatusLabel2->Size = System::Drawing::Size(0, 17);
101+
this->viewItems->AutoExpandOnFilter = false;
101102
this->viewItems->Dock = System::Windows::Forms::DockStyle::Fill;
103+
this->viewItems->FilterVisible = false;
102104
this->viewItems->Location = System::Drawing::Point(0, 0);
105+
this->viewItems->MultiSelect = true;
106+
this->viewItems->SelectableGroups = false;
103107
this->viewItems->Name = L"viewItems";
108+
this->viewItems->PathSeparator = L"/";
104109
this->viewItems->Size = System::Drawing::Size(284, 242);
110+
this->viewItems->Source = nullptr;
105111
this->viewItems->TabIndex = 1;
106112
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
107113
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;

src/editors/xrECore/pch.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,12 @@
55
#include "xrCore/xrCore.h"
66

77
#include "xrServerEntities/xrEProps.h"
8+
#include "xrEProps.h"
89

910
#include <msclr/marshal.h>
11+
12+
inline System::String^ BackSlashToSlash(pcstr originalString)
13+
{
14+
System::String^ newString = gcnew System::String(originalString);
15+
return newString->Replace('\\', '/');
16+
}

src/editors/xrECore/xrECore.vcxproj

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,13 @@
6666
<Reference Include="Flobbster.Windows.Forms.PropertyGrid">
6767
<HintPath>Flobbster.Windows.Forms.PropertyGrid</HintPath>
6868
</Reference>
69-
<Reference Include="PresentationCore" />
70-
<Reference Include="PresentationFramework" />
7169
<Reference Include="System" />
7270
<Reference Include="System.Data" />
7371
<Reference Include="System.Drawing" />
7472
<Reference Include="System.Windows.Forms" />
75-
<Reference Include="System.Xaml" />
7673
<Reference Include="System.Xml" />
7774
<Reference Include="UIAutomationProvider" />
7875
<Reference Include="WindowsBase" />
79-
<Reference Include="WindowsFormsIntegration" />
8076
</ItemGroup>
8177
<ItemGroup>
8278
<ClCompile Include="pch.cpp">
@@ -130,6 +126,7 @@
130126
<ItemGroup>
131127
<EmbeddedResource Include="Props\ItemList.resx">
132128
<DependentUpon>Props\ItemList.h</DependentUpon>
129+
<SubType>Designer</SubType>
133130
</EmbeddedResource>
134131
<EmbeddedResource Include="Props\PropertiesList.resx">
135132
<DependentUpon>Props\PropertiesList.h</DependentUpon>

src/editors/xrECore/xrEProps.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@
66
#include "Props/TextEdit.h"
77
#include "xrEngine/WaveForm.h"
88

9-
namespace XRay
10-
{
11-
namespace ECore
12-
{
13-
namespace Props
9+
namespace XRay::ECore::Props
1410
{
1511
bool NumericVectorRun(pcstr title, Fvector* data, int decimal, Fvector* reset_value, Fvector* min, Fvector* max, int* X, int* Y)
1612
{
@@ -38,6 +34,4 @@ bool TextEditRun(xr_string& text, pcstr caption /*= "Text"*/, bool read_only /*=
3834
auto form = gcnew TextEdit();
3935
return form->Run(text, caption, read_only, lim, apply_name, on_apply, on_close, on_insight);
4036
}
41-
} // namespace Props
42-
} // namespace ECore
43-
} // namespace XRay
37+
} // XRay::ECore::Props

src/editors/xrECore/xrEProps.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,12 @@ using TOnApplyClick = fastdelegate::FastDelegate1<pcstr, bool>;
1010
using TOnCloseClick = fastdelegate::FastDelegate0<bool>;
1111
using TOnCodeInsight = fastdelegate::FastDelegate3<const xr_string&, xr_string&, bool&>;
1212

13-
namespace XRay
14-
{
15-
namespace ECore
16-
{
17-
namespace Props
13+
namespace XRay::ECore::Props
1814
{
1915
XRECORE_API bool NumericVectorRun(pcstr title, Fvector* data, int decimal, Fvector* reset_value, Fvector* min, Fvector* max, int* X, int* Y);
2016
XRECORE_API bool ShaderFunctionRun(WaveForm* func);
2117
XRECORE_API bool GameTypeRun(pcstr title, GameTypeChooser* data);
2218
XRECORE_API bool TextEditRun(xr_string& text, pcstr caption = "Text", bool read_only = false, int lim = 0,
2319
pcstr apply_name = "Apply", TOnApplyClick on_apply = 0, TOnCloseClick on_close = 0,
2420
TOnCodeInsight on_insight = 0);
25-
} // namespace Props
26-
} // namespace ECore
27-
} // namespace XRay
21+
} // namespace XRay::ECore::Props
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
namespace XRay.SdkControls
2+
{
3+
public interface ITreeViewSource
4+
{
5+
TreeView Parent
6+
{
7+
get;
8+
set;
9+
}
10+
11+
void Refresh();
12+
}
13+
}

src/editors/xrSdkControls/Controls/NumericSpinner/NumericSpinner.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
namespace XRay.SdkControls
1111
{
12-
public sealed partial class NumericSpinner : UserControl
12+
public partial class NumericSpinner : UserControl
1313
{
1414
private bool ignoreOnChanged;
1515

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
namespace XRay.SdkControls
2+
{
3+
public enum TreeNodeType
4+
{
5+
SingleItem,
6+
GroupItem
7+
}
8+
9+
public class TreeNode : System.Windows.Forms.TreeNode
10+
{
11+
public TreeNode() {}
12+
13+
public TreeNode(string name) : base(name) => Name = name;
14+
15+
public TreeNode(string name, int imageIndex, int selectedImageIndex)
16+
: base(name, imageIndex, selectedImageIndex) => Name = name;
17+
18+
public TreeNode(string name, int imageIndex, int selectedImageIndex, System.Windows.Forms.TreeNode[] children)
19+
: base(name, imageIndex, selectedImageIndex, children) => Name = name;
20+
21+
public TreeNode(string name, System.Windows.Forms.TreeNode[] children)
22+
: base(name, children) => Name = name;
23+
24+
public TreeNodeType NodeType;
25+
26+
public new bool IsSelected;
27+
public int ImageIndexExpanded;
28+
public int ImageIndexCollapsed;
29+
30+
public new TreeNode Parent => base.Parent as TreeNode;
31+
32+
public TreeNode AddNodeSingle(string name, int imageIndex = -1)
33+
{
34+
TreeNode node = new TreeNode(name)
35+
{
36+
NodeType = TreeNodeType.SingleItem,
37+
ContextMenuStrip = ContextMenuStrip
38+
};
39+
40+
if (imageIndex == -1)
41+
{
42+
node.ImageIndex = 2;
43+
node.SelectedImageIndex = 2;
44+
}
45+
else
46+
{
47+
node.ImageIndex = imageIndex;
48+
node.SelectedImageIndex = imageIndex;
49+
}
50+
51+
Nodes.Add(node);
52+
return node;
53+
}
54+
55+
public TreeNode AddNodeGroup(string name, int imageIndexExpanded = -1, int imageIndexCollapsed = -1)
56+
{
57+
TreeNode node = new TreeNode(name)
58+
{
59+
ImageIndexCollapsed = imageIndexCollapsed,
60+
ImageIndexExpanded = imageIndexExpanded,
61+
Name = name,
62+
NodeType = TreeNodeType.SingleItem,
63+
ContextMenuStrip = ContextMenuStrip
64+
};
65+
66+
if (imageIndexCollapsed == -1)
67+
{
68+
node.ImageIndex = 0;
69+
node.SelectedImageIndex = 0;
70+
}
71+
else
72+
{
73+
node.ImageIndex = imageIndexCollapsed;
74+
node.SelectedImageIndex = imageIndexCollapsed;
75+
}
76+
77+
Nodes.Add(node);
78+
return node;
79+
}
80+
}
81+
}

src/editors/xrSdkControls/Controls/TreeView/TreeView.Designer.cs

Lines changed: 90 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)