2026-03-24 20:02:38 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
2026-03-26 16:43:06 +08:00
|
|
|
#include "StyleTokens.h"
|
|
|
|
|
|
2026-03-24 20:02:38 +08:00
|
|
|
#include <imgui.h>
|
|
|
|
|
|
|
|
|
|
namespace XCEngine {
|
|
|
|
|
namespace Editor {
|
|
|
|
|
namespace UI {
|
|
|
|
|
|
2026-03-26 16:43:06 +08:00
|
|
|
inline float DefaultControlLabelWidth() {
|
|
|
|
|
return 104.0f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline ImVec2 DefaultControlCellPadding() {
|
|
|
|
|
return ImVec2(0.0f, 2.0f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline ImVec2 DefaultControlFramePadding() {
|
|
|
|
|
return ImVec2(6.0f, 3.0f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline void PushControlRowStyles() {
|
|
|
|
|
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, DefaultControlCellPadding());
|
|
|
|
|
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, DefaultControlFramePadding());
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-24 20:02:38 +08:00
|
|
|
inline void StyleVarPush(ImGuiStyleVar idx, float val) {
|
|
|
|
|
ImGui::PushStyleVar(idx, val);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline void StyleVarPush(ImGuiStyleVar idx, ImVec2 val) {
|
|
|
|
|
ImGui::PushStyleVar(idx, val);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline void StyleColorPush(ImGuiCol idx, ImU32 col) {
|
|
|
|
|
ImGui::PushStyleColor(idx, col);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline void StyleColorPush(ImGuiCol idx, ImVec4 col) {
|
|
|
|
|
ImGui::PushStyleColor(idx, col);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline void PopStyleVar(int count = 1) {
|
|
|
|
|
ImGui::PopStyleVar(count);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline void PopStyleColor(int count = 1) {
|
|
|
|
|
ImGui::PopStyleColor(count);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline bool BeginPopup(const char* str_id, ImGuiWindowFlags flags = 0) {
|
|
|
|
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(12.0f, 10.0f));
|
|
|
|
|
bool is_open = ImGui::BeginPopup(str_id, flags);
|
|
|
|
|
if (!is_open) {
|
|
|
|
|
ImGui::PopStyleVar();
|
|
|
|
|
}
|
|
|
|
|
return is_open;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline void EndPopup() {
|
|
|
|
|
ImGui::EndPopup();
|
|
|
|
|
ImGui::PopStyleVar();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline void BeginDisabled(bool disabled = true) {
|
|
|
|
|
if (disabled) {
|
|
|
|
|
ImGui::BeginDisabled();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline void EndDisabled(bool disabled = true) {
|
|
|
|
|
if (disabled) {
|
|
|
|
|
ImGui::EndDisabled();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-26 16:43:06 +08:00
|
|
|
inline void DrawCurrentWindowBottomBorder(ImU32 color = PanelDividerColor()) {
|
|
|
|
|
ImDrawList* drawList = ImGui::GetWindowDrawList();
|
|
|
|
|
const ImVec2 min = ImGui::GetWindowPos();
|
|
|
|
|
const ImVec2 max = ImVec2(min.x + ImGui::GetWindowSize().x, min.y + ImGui::GetWindowSize().y);
|
|
|
|
|
drawList->AddLine(ImVec2(min.x, max.y - 1.0f), ImVec2(max.x, max.y - 1.0f), color);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline bool ToolbarButton(const char* label, bool active = false, ImVec2 size = ImVec2(0.0f, 0.0f)) {
|
|
|
|
|
const ImVec4 buttonColor = ToolbarButtonColor(active);
|
|
|
|
|
const ImVec4 hoverColor = ToolbarButtonHoveredColor(active);
|
|
|
|
|
const ImVec4 activeColor = ToolbarButtonActiveColor();
|
|
|
|
|
|
|
|
|
|
ImGui::PushStyleColor(ImGuiCol_Button, buttonColor);
|
|
|
|
|
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, hoverColor);
|
|
|
|
|
ImGui::PushStyleColor(ImGuiCol_ButtonActive, activeColor);
|
|
|
|
|
const bool pressed = ImGui::Button(label, size);
|
|
|
|
|
ImGui::PopStyleColor(3);
|
|
|
|
|
return pressed;
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-24 20:02:38 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|