35 const auto &items =
m_owner->GetFlatList();
36 if (n >= items.size())
39 const auto &entry = items[n];
43 dc.SetBrush(wxBrush(wxColour(38, 40, 45)));
44 dc.SetPen(*wxTRANSPARENT_PEN);
45 dc.DrawRectangle(rect);
49 bool isSelected = IsSelected(n);
50 bool isCurrent = (entry.id ==
m_owner->GetCurrentTreeId());
53 dc.SetBrush(wxBrush(wxColour(55, 75, 100)));
54 }
else if (isCurrent) {
55 dc.SetBrush(wxBrush(wxColour(50, 60, 75)));
56 }
else if (n % 2 == 1) {
57 dc.SetBrush(wxBrush(wxColour(48, 48, 53)));
59 dc.SetBrush(wxBrush(wxColour(45, 45, 50)));
61 dc.SetPen(*wxTRANSPARENT_PEN);
62 dc.DrawRectangle(rect);
65 dc.SetBrush(wxBrush(wxColour(80, 160, 220)));
66 dc.SetPen(*wxTRANSPARENT_PEN);
67 dc.DrawRectangle(rect.x, rect.y + 4, 3, rect.height - 8);
72 const auto &items =
m_owner->GetFlatList();
73 if (n >= items.size())
76 const auto &entry = items[n];
83 int toggleX = leftPad;
84 int toggleY = rect.y + (rect.height / 2) - (
TOGGLE_SIZE / 2);
86 dc.SetPen(wxPen(wxColour(180, 185, 195), 1));
87 dc.SetBrush(wxBrush(wxColour(180, 185, 195)));
89 if (entry.isCollapsed) {
90 wxPoint tri[3] = {wxPoint(toggleX, toggleY), wxPoint(toggleX, toggleY +
TOGGLE_SIZE),
92 dc.DrawPolygon(3, tri);
94 wxPoint tri[3] = {wxPoint(toggleX, toggleY + 1), wxPoint(toggleX +
TOGGLE_SIZE, toggleY + 1),
96 dc.DrawPolygon(3, tri);
101 wxFont headerFont = GetFont();
102 headerFont.SetPointSize(11);
103 headerFont.SetWeight(wxFONTWEIGHT_BOLD);
104 dc.SetFont(headerFont);
105 dc.SetTextForeground(wxColour(200, 205, 215));
107 wxString headerText = wxString::FromUTF8(entry.displayName);
108 int textY = rect.y + (rect.height - dc.GetTextExtent(headerText).GetHeight()) / 2;
109 dc.DrawText(headerText, rect.x + leftPad, textY);
112 wxFont countFont = GetFont();
113 countFont.SetPointSize(9);
114 dc.SetFont(countFont);
115 dc.SetTextForeground(wxColour(130, 135, 145));
117 wxString countText = wxString::Format(
"(%d)", entry.sectionCount);
118 int countW = dc.GetTextExtent(countText).GetWidth();
119 int countX = rect.x + rect.width - countW - 10;
120 dc.DrawText(countText, countX, textY + 1);
123 dc.SetPen(wxPen(wxColour(60, 65, 75), 1));
124 dc.DrawLine(rect.x + 4, rect.y + rect.height - 1, rect.x + rect.width - 4, rect.y + rect.height - 1);
129 bool isCurrent = (entry.id ==
m_owner->GetCurrentTreeId());
130 int depth = entry.depth;
132 int leftPad = basePad + depth * INDENT_PX;
135 wxPen connPen(wxColour(80, 85, 95), 1);
138 for (
int d = 1; d < depth; ++d) {
139 if (d - 1 <
static_cast<int>(entry.parentHasMore.size()) && entry.parentHasMore[d - 1]) {
141 dc.DrawLine(lineX, rect.y, lineX, rect.y + rect.height);
146 int midY = rect.y + rect.height / 2;
147 dc.DrawLine(connX, rect.y, connX, entry.isLastChild ? midY : rect.y + rect.height);
148 dc.DrawLine(connX, midY, connX + 8, midY);
151 if (entry.hasChildren) {
152 int toggleX = leftPad;
153 int toggleY = rect.y + (rect.height / 2) - (
TOGGLE_SIZE / 2);
155 dc.SetPen(wxPen(wxColour(150, 155, 165), 1));
157 if (entry.isCollapsed) {
158 wxPoint tri[3] = {wxPoint(toggleX, toggleY), wxPoint(toggleX, toggleY +
TOGGLE_SIZE),
160 dc.SetBrush(wxBrush(wxColour(150, 155, 165)));
161 dc.DrawPolygon(3, tri);
163 wxPoint tri[3] = {wxPoint(toggleX, toggleY + 1), wxPoint(toggleX +
TOGGLE_SIZE, toggleY + 1),
165 dc.SetBrush(wxBrush(wxColour(150, 155, 165)));
166 dc.DrawPolygon(3, tri);
173 wxFont nameFont = GetFont();
174 nameFont.SetPointSize(10);
176 nameFont.SetWeight(wxFONTWEIGHT_BOLD);
177 dc.SetFont(nameFont);
179 wxColour nameColour = isCurrent ? wxColour(230, 240, 255) : wxColour(210, 210, 215);
180 if (!entry.isImplemented)
181 nameColour = wxColour(140, 140, 155);
182 dc.SetTextForeground(nameColour);
184 wxString name = wxString::FromUTF8(entry.displayName);
185 int nameY = rect.y + 7;
186 dc.DrawText(name, rect.x + leftPad, nameY);
188 wxFont subFont = GetFont();
189 subFont.SetPointSize(8);
191 dc.SetTextForeground(wxColour(110, 115, 125));
194 if (entry.nodeCount > 0) {
195 info = wxString::Format(
"%d node%s", entry.nodeCount, entry.nodeCount == 1 ?
"" :
"s");
197 if (!entry.isImplemented) {
200 info +=
"unimplemented";
207 if (entry.hasChildren && entry.isCollapsed) {
213 if (!info.IsEmpty()) {
214 int infoY = nameY + dc.GetCharHeight() + 1;
215 dc.DrawText(info, rect.x + leftPad, infoY);
307 wxBoxSizer *mainSizer =
new wxBoxSizer(wxVERTICAL);
310 new wxSearchCtrl(
this,
ID_SEARCH_CTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER);
319 wxBoxSizer *toolbarSizer =
new wxBoxSizer(wxHORIZONTAL);
321 new wxButton(
this,
ID_COLLAPSE_ALL_BTN,
"Collapse All", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
323 new wxButton(
this,
ID_EXPAND_ALL_BTN,
"Expand All", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
326 toolbarSizer->AddStretchSpacer();
327 mainSizer->Add(toolbarSizer, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 4);
330 mainSizer->Add(
m_listBox, 1, wxEXPAND | wxLEFT | wxRIGHT, 2);
332 m_statusLabel =
new wxStaticText(
this, wxID_ANY,
"No project loaded");
335 statusFont.SetPointSize(8);
404 std::set<std::string> referencedAsChild;
406 for (
const auto &ref : pair.second.subtreeRefs) {
407 referencedAsChild.insert(ref);
411 std::vector<std::string> rootTrees;
412 std::vector<std::string> subtrees;
414 if (referencedAsChild.find(pair.first) == referencedAsChild.end()) {
415 rootTrees.push_back(pair.first);
417 subtrees.push_back(pair.first);
420 std::sort(rootTrees.begin(), rootTrees.end());
421 std::sort(subtrees.begin(), subtrees.end());
425 std::vector<std::string> all;
427 wxString lower = wxString::FromUTF8(pair.first).Lower();
429 all.push_back(pair.first);
432 std::sort(all.begin(), all.end());
433 for (
const auto &
id : all) {
453 if (!rootTrees.empty()) {
455 header.
id =
"__section_root__";
465 header.
sectionCount =
static_cast<int>(rootTrees.size());
469 for (
size_t i = 0; i < rootTrees.size(); ++i) {
470 std::set<std::string> visited;
471 bool isLast = (i == rootTrees.size() - 1);
478 if (!subtrees.empty()) {
480 header.
id =
"__section_subtrees__";
490 header.
sectionCount =
static_cast<int>(subtrees.size());
494 for (
size_t i = 0; i < subtrees.size(); ++i) {
495 const auto &
id = subtrees[i];
528 bool isLastChild, std::vector<bool> parentHasMore) {
536 bool isCircular = visited.find(treeId) != visited.end();
537 visited.insert(treeId);
540 bool hasKids = !isCircular && !info.
subtreeRefs.empty();
559 if (hasKids && !collapsed) {
561 std::sort(sortedRefs.begin(), sortedRefs.end());
563 std::vector<bool> childParentHasMore = parentHasMore;
564 childParentHasMore.push_back(!isLastChild);
566 for (
size_t i = 0; i < sortedRefs.size(); ++i) {
567 bool childIsLast = (i == sortedRefs.size() - 1);
568 FlattenTree(sortedRefs[i], depth + 1, visited, childIsLast, childParentHasMore);
572 visited.erase(treeId);
MainFrame::OnExit MainFrame::OnNewProject MainFrame::OnCloseProject MainFrame::OnToggleMaximize MainFrame::OnPreviousScene MainFrame::OnPreferences MainFrame::OnEditorTool EVT_BUTTON(ID_MonitorTool, MainFrame::OnMonitorTool) EVT_PAINT(MainFrame
MainFrame::OnExit EVT_MENU(wxID_ABOUT, MainFrame::OnAbout) EVT_MENU(ID_NewProject
Main application window for EmberForge.