diff options
author | rtk0c <[email protected]> | 2021-06-14 22:28:34 -0700 |
---|---|---|
committer | rtk0c <[email protected]> | 2021-06-14 22:28:34 -0700 |
commit | eec8dfd8a21b8bb37f6acac1da84cde8fbf7ace7 (patch) | |
tree | d6368d4157a1d850f135f441dfa381ad26f8eac3 /core/src/UI | |
parent | d3a9d7565b18404b2042c9dc025cc690250cb50c (diff) |
Table cell text rendering and inspector
Diffstat (limited to 'core/src/UI')
-rw-r--r-- | core/src/UI/UI_Templates.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/core/src/UI/UI_Templates.cpp b/core/src/UI/UI_Templates.cpp index 48393dc..ab9c317 100644 --- a/core/src/UI/UI_Templates.cpp +++ b/core/src/UI/UI_Templates.cpp @@ -154,6 +154,30 @@ private: } ImGui::EndCombo(); } + + switch (cell.Type) { + case TableCell::ConstantCell: + ImGui::InputText(I18N_TEXT("Content", L10N_TABLE_CELL_CONTENT), &cell.Content); + break; + + case TableCell::SingularParametricCell: + if (ImGui::InputText(I18N_TEXT("Variable name", L10N_TABLE_CELL_VAR_NAME), &cell.Content)) { + // TODO validate if name is repeat + } + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip(I18N_TEXT("Name of the parameter link to this cell.", L10N_TABLE_CELL_VAR_TOOLTIP)); + } + break; + + case TableCell::ArrayParametricCell: + if (ImGui::InputText(I18N_TEXT("Variable name", L10N_TABLE_CELL_VAR_NAME), &cell.Content)) { + // TODO validate if name is repeat + } + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip(I18N_TEXT("Name of the parameter lnk to this cell; local within the array group.", L10N_TABLE_CELL_ARRAY_VAR_TOOLTIP)); + } + break; + } } void DisplayRangeProperties(Vec2i tl, Vec2i br) @@ -198,6 +222,9 @@ private: window->DC.CursorPos + ImGui::CalcItemSize(size, 0.0f, 0.0f), }; + // TODO draw indicator for parameter cells + /* Draw cell body */ + if (uiCell.Selected) { window->DrawList->AddRectFilled( rect.Min - ImVec2(2, 1), @@ -215,6 +242,27 @@ private: window->DrawList->AddRectFilled(rect.Min, rect.Max, color); } + /* Draw cell content */ + + auto content = cell.Content.c_str(); + auto contentEnd = content + cell.Content.size(); + auto textSize = ImGui::CalcTextSize(content, contentEnd); + + ImVec2 textRenderPos; + switch (cell.HorizontalAlignment) { + case TableCell::AlignAxisMin: textRenderPos.x = rect.Min.x; break; + case TableCell::AlignCenter: textRenderPos.x = rect.Min.x + colWidth / 2 - textSize.x / 2; break; + case TableCell::AlignAxisMax: textRenderPos.x = rect.Max.x - textSize.x; break; + } + switch (cell.VerticalAlignment) { + case TableCell::AlignAxisMin: textRenderPos.y = rect.Min.y; break; + case TableCell::AlignCenter: textRenderPos.y = rect.Min.y + rowHeight / 2 - textSize.y / 2; break; + case TableCell::AlignAxisMax: textRenderPos.y = rect.Max.y - textSize.y; break; + } + window->DrawList->AddText(textRenderPos, IM_COL32(0, 0, 0, 255), content, contentEnd); + + /* Update ImGui cursor */ + ImGui::ItemSize(size); if (!ImGui::ItemAdd(rect, id)) { continue; |