This commit is contained in:
T0b1
2023-06-20 12:45:50 +02:00
parent 6fb5d69e47
commit 279e9e68ec
6 changed files with 174 additions and 29 deletions

View File

@@ -1015,42 +1015,106 @@ bool WatchWindow::draw(Frontend &frontend)
}
// ImGuiTableFlags_SizingFixedFit
if (ImGui::BeginTable("##Variables", 2, ImGuiTableFlags_RowBg))
if (ImGui::BeginTable("##Variables", 2,
ImGuiTableFlags_RowBg | ImGuiTableFlags_Resizable))
{
ImGui::TableSetupColumn("Name");
ImGui::TableSetupColumn("Value");
ImGui::TableHeadersRow();
auto locals_idx = frontend.target->data_idx_for_src_id(this->locals_src_id);
if (locals_idx)
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
ImGui::PushID("TTTTTT");
if (ImGui::TreeNodeEx("Locals", ImGuiTreeNodeFlags_SpanFullWidth))
{
const auto &local_node = *frontend.target->data_res_nodes[*locals_idx];
const auto &locals_data = local_node.vec_data();
size_t cur_off = 0;
size_t cur_idx = 0;
while (cur_off < locals_data.size())
auto locals_idx =
frontend.target->data_idx_for_src_id(this->locals_src_id);
if (locals_idx)
{
if (cur_off + 2 > locals_data.size())
const auto &local_node = *frontend.target->data_res_nodes[*locals_idx];
const auto &locals_data = local_node.vec_data();
size_t cur_off = 0;
size_t cur_idx = 0;
while (cur_off < locals_data.size())
{
break;
if (cur_off + 2 > locals_data.size())
{
break;
}
auto str_len =
*reinterpret_cast<const uint16_t *>(locals_data.data() + cur_off);
if (cur_off + 2 + str_len > locals_data.size())
{
break;
}
auto name = std::string_view{
reinterpret_cast<const char *>(locals_data.data() + cur_off + 2),
str_len};
auto node_idx = local_node.children[cur_idx];
this->draw_value(frontend,
frontend.target->data_res_nodes[node_idx]->type_id,
name, node_idx, 0);
cur_idx += 1;
cur_off += 2 + str_len;
}
auto str_len =
*reinterpret_cast<const uint16_t *>(locals_data.data() + cur_off);
if (cur_off + 2 + str_len > locals_data.size())
}
ImGui::TreePop();
}
ImGui::PopID();
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
if (ImGui::InputText("##EXTRASLOT", this->extra_slot_path_buf,
sizeof(this->extra_slot_path_buf),
ImGuiInputTextFlags_AutoSelectAll
| ImGuiInputTextFlags_EnterReturnsTrue)
&& ImGui::IsItemDeactivatedAfterEdit())
{
if (this->extra_slot_bak != this->extra_slot_path_buf)
{
if (this->extra_slot_id)
{
break;
frontend.target->backend->remove_data_node(*this->extra_slot_id);
this->extra_slot_id = {};
}
this->extra_slot_bak = this->extra_slot_path_buf;
if (this->extra_slot_bak != "")
{
auto id = frontend.target->data_node_id++;
this->extra_slot_id = id;
auto name = std::string_view{
reinterpret_cast<const char *>(locals_data.data() + cur_off + 2),
str_len};
auto node_idx = local_node.children[cur_idx];
this->draw_value(frontend,
frontend.target->data_res_nodes[node_idx]->type_id,
name, node_idx, 0);
cur_idx += 1;
cur_off += 2 + str_len;
using namespace data::source;
frontend.target->backend->add_data_node(
Node{.id = id,
.type = Node::Type::source,
.data = Source{.type = Source::Type::variable,
.data = Source::Variable{
.expr_path = this->extra_slot_bak}}});
}
}
}
if (this->extra_slot_id)
{
auto res_idx = frontend.target->data_idx_for_src_id(*this->extra_slot_id);
if (res_idx)
{
const auto &node = *frontend.target->data_res_nodes[*res_idx];
if (!node.success || node.children.size() != 1)
{
ImGui::TableNextColumn();
ImGui::TextDisabled("<not available>");
} else
{
//printf("Extratypeid: %u", node.type_id.type);
const auto &child_node =
*frontend.target->data_res_nodes[node.children[0]];
//printf("Child: %u\n", child_node.type_id.type);
this->draw_value(frontend, child_node.type_id, this->extra_slot_bak,
node.children[0], 0);
}
}
}