diff options
author | rtk0c <[email protected]> | 2021-06-21 18:30:38 -0700 |
---|---|---|
committer | rtk0c <[email protected]> | 2021-06-21 18:30:38 -0700 |
commit | 43cd2bd879d529fcbd0a0f64eccd4ce1eb872ab4 (patch) | |
tree | 12e7bcbd08a30f76d83bd1bc8943133f3d5d51b9 /core/src/UI/UI_Templates.cpp | |
parent | 4378dcd83d2387534f3b10276365d1003832fe81 (diff) |
Implement array group conversion logic
Diffstat (limited to 'core/src/UI/UI_Templates.cpp')
-rw-r--r-- | core/src/UI/UI_Templates.cpp | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/core/src/UI/UI_Templates.cpp b/core/src/UI/UI_Templates.cpp index e77bef3..5255b6a 100644 --- a/core/src/UI/UI_Templates.cpp +++ b/core/src/UI/UI_Templates.cpp @@ -170,23 +170,29 @@ private: ImGui::OpenPopup("ConvertCtxMenu"); } if (ImGui::BeginPopup("ConvertCtxMenu")) { - if (ImGui::MenuItem(I18N_TEXT("Single parameter", L10N_TABLE_CELL_CONV_PARAM))) { + bool constantDisabled = cell.Type == TableCell::ConstantCell; + if (ImGui::MenuItem(I18N_TEXT("Convert to regular cell", L10N_TABLE_CELL_CONV_CONST), nullptr, false, constantDisabled)) { + mTable->SetCellType(pos, TableCell::ConstantCell); + } + + bool singleDisabled = cell.Type == TableCell::SingularParametricCell; + if (ImGui::MenuItem(I18N_TEXT("Convert to parameter cell", L10N_TABLE_CELL_CONV_PARAM), nullptr, false, singleDisabled)) { mTable->SetCellType(pos, TableCell::SingularParametricCell); } - bool createDisabled = cell.Type == TableCell::ArrayParametricCell; - if (ImGui::MenuItemConditional(I18N_TEXT("Create array group", L10N_TABLE_CELL_CONV_CREATE_AG), createDisabled)) { + bool arrayDisabled = cell.Type == TableCell::ArrayParametricCell; + if (ImGui::MenuItem(I18N_TEXT("Add to a new array group", L10N_TABLE_CELL_CONV_CREATE_AG), nullptr, false, arrayDisabled)) { mTable->AddArrayGroup(pos.x, pos.x, pos.y); } - bool leftDisabled = !mSS.HasLeftAG || cell.Type == TableCell::ArrayParametricCell; - if (ImGui::MenuItemConditional(I18N_TEXT("Add to array group to the left", L10N_TABLE_CELL_CONV_ADD_AG_LEFT), leftDisabled)) { + bool leftDisabled = !mSS.HasLeftAG || arrayDisabled; + if (ImGui::MenuItem(I18N_TEXT("Add to the array group to the left", L10N_TABLE_CELL_CONV_ADD_AG_LEFT), nullptr, false, leftDisabled)) { auto& leftCell = mTable->GetCell((Vec2i){ pos.x - 1, pos.y }); mTable->ExtendArrayGroupRight(leftCell.DataId, 1); } - bool rightDisabled = !mSS.HasRightAG || cell.Type == TableCell::ArrayParametricCell; - if (ImGui::MenuItemConditional(I18N_TEXT("Add to array group to the right", L10N_TABLE_CELL_CONV_ADD_AG_RIGHT), rightDisabled)) { + bool rightDisabled = !mSS.HasRightAG || arrayDisabled; + if (ImGui::MenuItem(I18N_TEXT("Add to the array group to the right", L10N_TABLE_CELL_CONV_ADD_AG_RIGHT), nullptr, false, rightDisabled)) { auto& rightCell = mTable->GetCell((Vec2i){ pos.x + 1, pos.y }); mTable->ExtendArrayGroupLeft(rightCell.DataId, 1); } @@ -472,8 +478,8 @@ private: { mSS = {}; mSS.ErrorDuplicateVarName = false; - mSS.HasLeftAG = pos.x >= 1; - mSS.HasRightAG = pos.x < mTable->GetTableWidth(); + mSS.HasLeftAG = pos.x > 1 && mTable->GetCell({ pos.x - 1, pos.y }).Type == TableCell::ArrayParametricCell; + mSS.HasRightAG = pos.x < mTable->GetTableWidth() - 1 && mTable->GetCell({ pos.x + 1, pos.y }).Type == TableCell::ArrayParametricCell; } void SelectCell(Vec2i cell) |