添加ui_editor编辑器模块初始代码
This commit is contained in:
31
ui_editor/src/panels/GameViewPanel.cpp
Normal file
31
ui_editor/src/panels/GameViewPanel.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#include "GameViewPanel.h"
|
||||
#include <imgui.h>
|
||||
#include <imgui_internal.h>
|
||||
|
||||
namespace UI {
|
||||
|
||||
GameViewPanel::GameViewPanel() : Panel("Game") {}
|
||||
|
||||
void GameViewPanel::Render() {
|
||||
ImGui::Begin(m_name.c_str(), nullptr, ImGuiWindowFlags_None);
|
||||
|
||||
RenderGameView();
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void GameViewPanel::RenderGameView() {
|
||||
ImVec2 canvasSize = ImGui::GetContentRegionAvail();
|
||||
ImDrawList* drawList = ImGui::GetWindowDrawList();
|
||||
ImVec2 canvasPos = ImGui::GetCursorScreenPos();
|
||||
|
||||
ImU32 bgColor = IM_COL32(20, 20, 25, 255);
|
||||
drawList->AddRectFilled(canvasPos, ImVec2(canvasPos.x + canvasSize.x, canvasPos.y + canvasSize.y), bgColor);
|
||||
|
||||
const char* text = "Game View (Press Play)";
|
||||
ImVec2 textSize = ImGui::CalcTextSize(text);
|
||||
ImVec2 textPos(canvasPos.x + (canvasSize.x - textSize.x) * 0.5f, canvasPos.y + (canvasSize.y - textSize.y) * 0.5f);
|
||||
drawList->AddText(textPos, IM_COL32(128, 128, 128, 255), text);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user