MCPcopy Create free account
hub / github.com/bluescan/tacentview / DoSelectable

Method DoSelectable

Src/FileDialog.cpp:1043–1095  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1041
1042
1043void FileDialog::DoSelectable(ContentItem* item)
1044{
1045 tString label = item->Name;
1046 if (ImGui::Selectable(label.Chr(), &item->Selected, ImGuiSelectableFlags_SpanAllColumns))
1047 {
1048 // This block enforces single selection.
1049 if (item->Selected)
1050 {
1051 // Only allowed one selected max. Clear the others.
1052 for (ContentItem* i = SelectedNode->Contents.First(); i; i = i->Next())
1053 {
1054 if (i == item)
1055 continue;
1056 i->Selected = false;
1057 }
1058
1059 // If item just selected and we're in SaveFile mode we need to update the Edit widget.
1060 // This widget uses the SaveFileResult string, so we update that.
1061 if (Mode == DialogMode::SaveFile)
1062 SaveFileResult = tGetFileBaseName(label).Chr();
1063 }
1064
1065 // Do not allow deselection of the single item.
1066 item->Selected = true;
1067
1068 // If a directory is selected in the right panel, we support updating the current selected TreeNode.
1069 if (item->IsDir)
1070 {
1071 SelectedNode->NextOpen = true;
1072 TreeNode* node = SelectedNode->Find(item->Name);
1073 if (!node)
1074 {
1075 // Need to create a new one and connect it up.
1076 node = new TreeNode(item->Name, false, this, SelectedNode);
1077 SelectedNode->AppendChild(node);
1078 tAssert(node->ChildrenPopulated == false);
1079
1080 tString newdir = NodeToDir(node);
1081 node->Hidden = tIsHidden(newdir);
1082 }
1083 SelectedNode = node;
1084 SelectedNode->SortingDirty = true;
1085
1086 // SelectedNode Updated. Need to update global config path.
1087 if (Mode == DialogMode::OpenFile)
1088 NodeToPath(ConfigOpenFilePath, SelectedNode);
1089 else if (Mode == DialogMode::OpenDir)
1090 NodeToPath(ConfigOpenDirPath, SelectedNode);
1091 if (Mode == DialogMode::SaveFile)
1092 NodeToPath(ConfigSaveFilePath, SelectedNode);
1093 }
1094 }
1095}
1096
1097
1098void FileDialog::DoSelect(const tString& filename)

Callers

nothing calls this directly

Calls 2

FindMethod · 0.80
AppendChildMethod · 0.80

Tested by

no test coverage detected