docs: 更新 containers 和 threading 模块文档

- containers: 更新 string 类的多个方法文档
- threading: 更新 mutex 和 task-group 方法文档
This commit is contained in:
2026-03-26 01:59:14 +08:00
parent 8df04c120f
commit 5c3566774b
42 changed files with 714 additions and 96 deletions

View File

@@ -1,6 +1,8 @@
#include "MenuBar.h"
#include "Core/IEditorContext.h"
#include "Core/ISceneManager.h"
#include "Core/IUndoManager.h"
#include "Core/ISelectionManager.h"
#include "Utils/SceneEditorUtils.h"
#include <filesystem>
#include <imgui.h>
@@ -29,6 +31,8 @@ void MenuBar::NewScene() {
}
m_context->GetSceneManager().NewScene();
m_context->GetSelectionManager().ClearSelection();
m_context->GetUndoManager().ClearHistory();
}
void MenuBar::OpenScene() {
@@ -40,7 +44,10 @@ void MenuBar::OpenScene() {
m_context->GetProjectPath(),
m_context->GetSceneManager().GetCurrentScenePath());
if (!filePath.empty()) {
m_context->GetSceneManager().LoadScene(filePath);
if (m_context->GetSceneManager().LoadScene(filePath)) {
m_context->GetSelectionManager().ClearSelection();
m_context->GetUndoManager().ClearHistory();
}
}
}
@@ -78,7 +85,7 @@ void MenuBar::HandleShortcuts() {
return;
}
auto& sceneManager = m_context->GetSceneManager();
auto& undoManager = m_context->GetUndoManager();
if (ImGui::IsKeyPressed(ImGuiKey_N, false)) {
NewScene();
}
@@ -92,6 +99,20 @@ void MenuBar::HandleShortcuts() {
SaveScene();
}
}
if (!io.WantTextInput) {
if (ImGui::IsKeyPressed(ImGuiKey_Z, false)) {
if (io.KeyShift) {
if (undoManager.CanRedo()) {
undoManager.Redo();
}
} else if (undoManager.CanUndo()) {
undoManager.Undo();
}
}
if (ImGui::IsKeyPressed(ImGuiKey_Y, false) && undoManager.CanRedo()) {
undoManager.Redo();
}
}
}
void MenuBar::ShowFileMenu() {
@@ -116,8 +137,15 @@ void MenuBar::ShowFileMenu() {
void MenuBar::ShowEditMenu() {
if (ImGui::BeginMenu("Edit")) {
if (ImGui::MenuItem("Undo", "Ctrl+Z")) {}
if (ImGui::MenuItem("Redo", "Ctrl+Y")) {}
auto& undoManager = m_context->GetUndoManager();
const std::string undoLabel = undoManager.CanUndo() ? "Undo " + undoManager.GetUndoLabel() : "Undo";
const std::string redoLabel = undoManager.CanRedo() ? "Redo " + undoManager.GetRedoLabel() : "Redo";
if (ImGui::MenuItem(undoLabel.c_str(), "Ctrl+Z", false, undoManager.CanUndo())) {
undoManager.Undo();
}
if (ImGui::MenuItem(redoLabel.c_str(), "Ctrl+Y", false, undoManager.CanRedo())) {
undoManager.Redo();
}
ImGui::Separator();
if (ImGui::MenuItem("Cut", "Ctrl+X")) {}
if (ImGui::MenuItem("Copy", "Ctrl+C")) {}