Skip to content

Commit

Permalink
xrSdkControls: add TreeView control
Browse files Browse the repository at this point in the history
  • Loading branch information
Xottab-DUTY committed Mar 17, 2018
1 parent 7cefcdf commit f2a6a3d
Show file tree
Hide file tree
Showing 22 changed files with 1,599 additions and 36 deletions.
29 changes: 20 additions & 9 deletions src/editors/xrECore/Props/ItemList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,24 @@ namespace ECore
{
namespace Props
{
void ItemList::AssignItems(ListItemsVec& new_items, bool full_expand, bool full_sort /*= false*/)
void ItemList::AssignItems(ListItemsVec& newItems, bool fullExpand, bool fullSort /*= false*/)
{
/*// begin fill mode
viewItems->BeginUpdate();

viewItems->Nodes->Clear();

for (const auto& item : newItems)
{
viewItems->AddItem(BackSlashToSlash(item->Key()));
}
/*// begin fill mode
// clear values
// if (tvItems->Selected) FHelper.MakeFullName(tvItems->Selected,0,last_selected_item);
//if (!items->empty())
// ClearParams();
// fill values
items = &new_items;
items = &newItems;
for (auto& prop : *items)
{
if (prop->Key.size() && (prop->Key[prop->Key.size() - 1] == '\\'))
Expand Down Expand Up @@ -62,7 +70,7 @@ void ItemList::AssignItems(ListItemsVec& new_items, bool full_expand, bool full_
}
// end fill mode
if (full_expand)
if (fullExpand)
viewItems->ExpandAll();
// folder restore
Expand All @@ -88,7 +96,7 @@ void ItemList::AssignItems(ListItemsVec& new_items, bool full_expand, bool full_
}
// sorting
if (full_sort)
if (fullSort)
{
viewItems->Sort();
}
Expand All @@ -105,15 +113,18 @@ void ItemList::AssignItems(ListItemsVec& new_items, bool full_expand, bool full_
for (RStringVecIt s_it = last_selected_items.begin(); s_it != last_selected_items.end(); s_it++)
FHelper.ExpandItem(tvItems, **s_it);
viewItems->EndUpdate();
for (RStringVecIt s_it = last_selected_items.begin(); s_it != last_selected_items.end(); s_it++)
FHelper.RestoreSelection(tvItems, **s_it, true);
*/

// restore selection
viewItems->SelectedNode = nullptr;

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

toolStripStatusLabel2->Text = items->size().ToString();*/
viewItems->EndUpdate();
}
} // namespace Props
} // namespace ECore
Expand Down
16 changes: 11 additions & 5 deletions src/editors/xrECore/Props/ItemList.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,27 +61,27 @@ public ref class ItemList : public System::Windows::Forms::Form
}

public:
void AssignItems(ListItemsVec& new_items, bool full_expand, bool full_sort);
void AssignItems(ListItemsVec& newItems, bool fullExpand, bool fullSort);

private:
Flags32* flags;
ListItemsVec* items;

private: XRay::SdkControls::TreeView^ viewItems;
private: System::Windows::Forms::StatusStrip^ statusStrip1;
private: System::Windows::Forms::ToolStripStatusLabel^ toolStripStatusLabel1;
private: System::Windows::Forms::ToolStripStatusLabel^ toolStripStatusLabel2;
private: System::Windows::Forms::TreeView^ viewItems;
private: System::ComponentModel::IContainer^ components;

private:
System::ComponentModel::Container^ components;

#pragma region Windows Form Designer generated code
void InitializeComponent(void)
{
this->components = (gcnew System::ComponentModel::Container());
this->statusStrip1 = (gcnew System::Windows::Forms::StatusStrip());
this->toolStripStatusLabel1 = (gcnew System::Windows::Forms::ToolStripStatusLabel());
this->toolStripStatusLabel2 = (gcnew System::Windows::Forms::ToolStripStatusLabel());
this->viewItems = (gcnew System::Windows::Forms::TreeView());
this->viewItems = (gcnew XRay::SdkControls::TreeView());
this->statusStrip1->SuspendLayout();
this->SuspendLayout();
this->statusStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(2) {
Expand All @@ -98,10 +98,16 @@ private: System::Windows::Forms::TreeView^ viewItems;
this->toolStripStatusLabel1->Text = L"Items count:";
this->toolStripStatusLabel2->Name = L"toolStripStatusLabel2";
this->toolStripStatusLabel2->Size = System::Drawing::Size(0, 17);
this->viewItems->AutoExpandOnFilter = false;
this->viewItems->Dock = System::Windows::Forms::DockStyle::Fill;
this->viewItems->FilterVisible = false;
this->viewItems->Location = System::Drawing::Point(0, 0);
this->viewItems->MultiSelect = true;
this->viewItems->SelectableGroups = false;
this->viewItems->Name = L"viewItems";
this->viewItems->PathSeparator = L"/";
this->viewItems->Size = System::Drawing::Size(284, 242);
this->viewItems->Source = nullptr;
this->viewItems->TabIndex = 1;
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
Expand Down
7 changes: 7 additions & 0 deletions src/editors/xrECore/pch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,12 @@
#include "xrCore/xrCore.h"

#include "xrServerEntities/xrEProps.h"
#include "xrEProps.h"

#include <msclr/marshal.h>

inline System::String^ BackSlashToSlash(pcstr originalString)
{
System::String^ newString = gcnew System::String(originalString);
return newString->Replace('\\', '/');
}
5 changes: 1 addition & 4 deletions src/editors/xrECore/xrECore.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,13 @@
<Reference Include="Flobbster.Windows.Forms.PropertyGrid">
<HintPath>Flobbster.Windows.Forms.PropertyGrid</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xaml" />
<Reference Include="System.Xml" />
<Reference Include="UIAutomationProvider" />
<Reference Include="WindowsBase" />
<Reference Include="WindowsFormsIntegration" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp">
Expand Down Expand Up @@ -130,6 +126,7 @@
<ItemGroup>
<EmbeddedResource Include="Props\ItemList.resx">
<DependentUpon>Props\ItemList.h</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Props\PropertiesList.resx">
<DependentUpon>Props\PropertiesList.h</DependentUpon>
Expand Down
10 changes: 2 additions & 8 deletions src/editors/xrECore/xrEProps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
#include "Props/TextEdit.h"
#include "xrEngine/WaveForm.h"

namespace XRay
{
namespace ECore
{
namespace Props
namespace XRay::ECore::Props
{
bool NumericVectorRun(pcstr title, Fvector* data, int decimal, Fvector* reset_value, Fvector* min, Fvector* max, int* X, int* Y)
{
Expand Down Expand Up @@ -38,6 +34,4 @@ bool TextEditRun(xr_string& text, pcstr caption /*= "Text"*/, bool read_only /*=
auto form = gcnew TextEdit();
return form->Run(text, caption, read_only, lim, apply_name, on_apply, on_close, on_insight);
}
} // namespace Props
} // namespace ECore
} // namespace XRay
} // XRay::ECore::Props
10 changes: 2 additions & 8 deletions src/editors/xrECore/xrEProps.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,12 @@ using TOnApplyClick = fastdelegate::FastDelegate1<pcstr, bool>;
using TOnCloseClick = fastdelegate::FastDelegate0<bool>;
using TOnCodeInsight = fastdelegate::FastDelegate3<const xr_string&, xr_string&, bool&>;

namespace XRay
{
namespace ECore
{
namespace Props
namespace XRay::ECore::Props
{
XRECORE_API bool NumericVectorRun(pcstr title, Fvector* data, int decimal, Fvector* reset_value, Fvector* min, Fvector* max, int* X, int* Y);
XRECORE_API bool ShaderFunctionRun(WaveForm* func);
XRECORE_API bool GameTypeRun(pcstr title, GameTypeChooser* data);
XRECORE_API bool TextEditRun(xr_string& text, pcstr caption = "Text", bool read_only = false, int lim = 0,
pcstr apply_name = "Apply", TOnApplyClick on_apply = 0, TOnCloseClick on_close = 0,
TOnCodeInsight on_insight = 0);
} // namespace Props
} // namespace ECore
} // namespace XRay
} // namespace XRay::ECore::Props
13 changes: 13 additions & 0 deletions src/editors/xrSdkControls/Controls/Interfaces/ITreeViewSource.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace XRay.SdkControls
{
public interface ITreeViewSource
{
TreeView Parent
{
get;
set;
}

void Refresh();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace XRay.SdkControls
{
public sealed partial class NumericSpinner : UserControl
public partial class NumericSpinner : UserControl
{
private bool ignoreOnChanged;

Expand Down
81 changes: 81 additions & 0 deletions src/editors/xrSdkControls/Controls/TreeNode/TreeNode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
namespace XRay.SdkControls
{
public enum TreeNodeType
{
SingleItem,
GroupItem
}

public class TreeNode : System.Windows.Forms.TreeNode
{
public TreeNode() {}

public TreeNode(string name) : base(name) => Name = name;

public TreeNode(string name, int imageIndex, int selectedImageIndex)
: base(name, imageIndex, selectedImageIndex) => Name = name;

public TreeNode(string name, int imageIndex, int selectedImageIndex, System.Windows.Forms.TreeNode[] children)
: base(name, imageIndex, selectedImageIndex, children) => Name = name;

public TreeNode(string name, System.Windows.Forms.TreeNode[] children)
: base(name, children) => Name = name;

public TreeNodeType NodeType;

public new bool IsSelected;
public int ImageIndexExpanded;
public int ImageIndexCollapsed;

public new TreeNode Parent => base.Parent as TreeNode;

public TreeNode AddNodeSingle(string name, int imageIndex = -1)
{
TreeNode node = new TreeNode(name)
{
NodeType = TreeNodeType.SingleItem,
ContextMenuStrip = ContextMenuStrip
};

if (imageIndex == -1)
{
node.ImageIndex = 2;
node.SelectedImageIndex = 2;
}
else
{
node.ImageIndex = imageIndex;
node.SelectedImageIndex = imageIndex;
}

Nodes.Add(node);
return node;
}

public TreeNode AddNodeGroup(string name, int imageIndexExpanded = -1, int imageIndexCollapsed = -1)
{
TreeNode node = new TreeNode(name)
{
ImageIndexCollapsed = imageIndexCollapsed,
ImageIndexExpanded = imageIndexExpanded,
Name = name,
NodeType = TreeNodeType.SingleItem,
ContextMenuStrip = ContextMenuStrip
};

if (imageIndexCollapsed == -1)
{
node.ImageIndex = 0;
node.SelectedImageIndex = 0;
}
else
{
node.ImageIndex = imageIndexCollapsed;
node.SelectedImageIndex = imageIndexCollapsed;
}

Nodes.Add(node);
return node;
}
}
}
90 changes: 90 additions & 0 deletions src/editors/xrSdkControls/Controls/TreeView/TreeView.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f2a6a3d

Please sign in to comment.