MCPcopy Create free account
hub / github.com/antopilo/Nuake / DrawFile

Method DrawFile

Editor/Source/Editor/Windows/FileSystemUI.cpp:230–633  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

228 }
229
230 void FileSystemUI::DrawFile(Ref<File> file, uint32_t drawId)
231 {
232 ImGui::PushFont(EditorInterface::bigIconFont);
233 ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 4.0f);
234 ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, {0.f, 0.f});
235 std::string fileExtension = file->GetExtension();
236
237 ImVec2 prevCursor = ImGui::GetCursorPos();
238 ImVec2 prevScreenPos = ImGui::GetCursorScreenPos();
239 std::string id = std::string("##") + file->GetAbsolutePath();
240 const bool selected = ImGui::Selectable(id.c_str(), Editor->Selection.File == file, ImGuiSelectableFlags_AllowOverlap | ImGuiSelectableFlags_AllowDoubleClick, ImVec2(100, 150));
241
242 const std::string hoverMenuId = std::string("item_hover_menu") + std::to_string(drawId);
243 if (ImGui::IsItemHovered() && ImGui::IsMouseReleased(1))
244 {
245 ImGui::OpenPopup(hoverMenuId.c_str());
246 m_HasClickedOnFile = true;
247 }
248
249 bool shouldOpenScene = false;
250 if (selected)
251 {
252 if (ImGui::IsMouseDoubleClicked(0))
253 {
254 switch (file->GetFileType())
255 {
256 case FileType::Map:
257 OS::OpenTrenchbroomMap(file->GetAbsolutePath());
258 break;
259 case FileType::NetScript:
260 case FileType::UI:
261 case FileType::CSS:
262 OS::OpenIn(file->GetAbsolutePath());
263 break;
264 case FileType::Scene:
265 //shouldOpenScene = true;
266 this->Editor->OpenSceneWindow(file->GetRelativePath());
267 break;
268 case FileType::Solution:
269 OS::OpenIn(file->GetAbsolutePath());
270 break;
271 case FileType::Prefab:
272 this->Editor->OpenPrefabWindow(file->GetRelativePath());
273 break;
274 }
275 }
276
277 Editor->Selection = EditorSelection(file);
278 }
279
280 if (ImGui::IsItemHovered())
281 ImGui::SetTooltip(file->GetName().c_str());
282
283 if (ImGui::BeginDragDropSource())
284 {
285 char pathBuffer[256];
286 std::strncpy(pathBuffer, file->GetAbsolutePath().c_str(), sizeof(pathBuffer));
287 std::string dragType;

Callers

nothing calls this directly

Calls 15

PushStyleVarFunction · 0.85
GetCursorPosFunction · 0.85
EditorSelectionClass · 0.85
EndDragDropSourceFunction · 0.85
ImageClass · 0.85
PopStyleVarFunction · 0.85
PushStyleColorFunction · 0.85
PopStyleColorFunction · 0.85
ExtractWadFunction · 0.85
parseFunction · 0.85
LogFunction · 0.85
c_strMethod · 0.80

Tested by

no test coverage detected