This commit is contained in:
T0b1
2023-06-29 02:13:07 +02:00
parent 83fb234d5c
commit 6f0b3b9e99
4 changed files with 65 additions and 17 deletions

View File

@@ -1283,9 +1283,10 @@ void WatchWindow::draw_value(Frontend &frontend,
if (!is_editing)
{
tree_open =
ImGui::TreeNodeEx(tree_id_buf, ImGuiTreeNodeFlags_SpanFullWidth, "%.*s",
static_cast<int>(name_end - name_begin), name_begin);
tree_open = ImGui::TreeNodeEx(
tree_id_buf,
ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_SpanAvailWidth,
"%.*s", static_cast<int>(name_end - name_begin), name_begin);
if (name.index() == 1
&& ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)
&& ImGui::IsItemHovered())
@@ -1542,20 +1543,33 @@ void WatchWindow::draw_value(Frontend &frontend,
{
// TODO: make this func be able to not print the "outer" line
// and just accept a bool to only draw the containing value
std::string path{"*"};
std::string path{};
if (type_id.sub_type != Type::i8)
{
// TODO: better check if this is really a string
path = "*";
}
// why cant i just path name_begin, name_end to string_view? :[
construct_expr_path(
path, expr_path,
std::string_view{name_begin,
static_cast<size_t>(name_end - name_begin)});
auto src_id =
frontend.target->find_or_create_expr_path(std::move(path));
auto src_id = frontend.target->find_or_create_expr_path(
std::move(path), type_id.sub_type == Type::i8);
auto res_idx = frontend.target->data_idx_for_src_id(src_id);
if (res_idx)
{
const auto &node = *frontend.target->data_res_nodes[*res_idx];
if (node.success && node.children.size() == 1)
if (type_id.sub_type == Type::i8 && node.success)
{
// TODO: make span whole row (see https://github.com/ocornut/imgui/issues/3565)
assert(node.type_id.type == Type::custom);
assert(node.vec_data().back() == '\0');
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(1);
ImGui::TextWrapped("\"%s\"", node.vec_data().data());
} else if (node.success && node.children.size() == 1)
{
auto data_idx = node.children[0];
const auto &data_node =