Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CMake/Target.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -415,16 +415,16 @@ function(exp_add_mirror_info_source_generation_target)

add_custom_command(
OUTPUT ${output_source}
COMMAND "$<TARGET_FILE:MirrorTool>" ${dynamic_arg} "-i" ${input_header_file} "-o" ${output_source} ${inc_args} ${fwk_dir_args}
DEPENDS MirrorTool ${input_header_file}
COMMAND "$<TARGET_FILE:MirrorSourceGenerator>" ${dynamic_arg} "-i" ${input_header_file} "-o" ${output_source} ${inc_args} ${fwk_dir_args}
DEPENDS MirrorSourceGenerator ${input_header_file}
)
endforeach()
endforeach ()

set(custom_target_name "${arg_NAME}.Generated")
add_custom_target(
${custom_target_name}
DEPENDS MirrorTool ${output_sources}
DEPENDS MirrorSourceGenerator ${output_sources}
)
set_target_properties(${custom_target_name} PROPERTIES FOLDER ${AUX_TARGETS_FOLDER})
set(${arg_OUTPUT_SRC} ${output_sources} PARENT_SCOPE)
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ else ()
endif ()

add_subdirectory(Engine)
add_subdirectory(Tool)
add_subdirectory(Program)
add_subdirectory(Sample)

if (BUILD_EDITOR)
Expand Down
10 changes: 10 additions & 0 deletions Editor/Include/Editor/Widget/IconWidgets.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#pragma once

#include <string>
#include <string_view>

namespace Editor::Widgets {
std::string Label(const char* inIcon, std::string_view inText);
std::string Label(const char* inIcon, std::string_view inText, std::string_view inId);
bool IconButton(const char* inId, const char* inIcon, const char* inTooltip);
}
5,342 changes: 5,342 additions & 0 deletions Editor/Include/Editor/Widget/TablerIcons.h

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions Editor/Resource/Icons/Tabler/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020-2026 Paweł Kuna

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
12 changes: 12 additions & 0 deletions Editor/Resource/Icons/Tabler/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Tabler Icons

This directory contains the official Tabler Icons v3.45.0 outline webfont from
[`@tabler/icons-webfont`](https://www.npmjs.com/package/@tabler/icons-webfont).

`tabler-icons.ttf` is copied without modification from `dist/fonts/tabler-icons.ttf` in the upstream package. The editor loads
the complete icon set into the ImGui font atlas.

`TablerIcons.h` is generated from the matching upstream CSS by
[`tabler.py`](../../../../Tool/Scripts/IconFontGenerator/tabler.py).

Tabler Icons is distributed under the [MIT License](LICENSE).
Binary file added Editor/Resource/Icons/Tabler/tabler-icons.ttf
Binary file not shown.
21 changes: 21 additions & 0 deletions Editor/Src/EditorApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
#include <imgui.h>
#include <imgui_internal.h>

#include <Common/Debug.h>
#include <Common/Time.h>
#include <Core/Paths.h>
#include <Editor/EditorApplication.h>
#include <Editor/Panel/EditorPanelNames.h>
#include <Editor/Utils/ImGuiCompatibility.h>
#include <Editor/Widget/TablerIcons.h>
#include <Runtime/Engine.h>

namespace Editor::Internal {
Expand Down Expand Up @@ -82,6 +84,24 @@ namespace Editor::Internal {
style.TabRounding = 2.0f;
}

static void LoadIconFonts(ImFontAtlas& inFontAtlas, float inSizePixels)
{
static ImVector<ImWchar> glyphRanges;
if (glyphRanges.empty()) {
ImFontGlyphRangesBuilder builder;
builder.AddText(Icons::Tabler::allGlyphs);
builder.BuildRanges(&glyphRanges);
}

const std::string fontPath = (Core::Paths::EngineResDir() / "Editor" / "Icons" / "Tabler" / "tabler-icons.ttf").String();
ImFontConfig config;
config.MergeMode = true;
config.PixelSnapH = true;
config.GlyphMinAdvanceX = inSizePixels;
config.GlyphMaxAdvanceX = inSizePixels;
Assert(inFontAtlas.AddFontFromFileTTF(fontPath.c_str(), inSizePixels, &config, glyphRanges.Data) != nullptr);
}

static float CalculatePanelRatio(float inAvailableSize, float inDefaultRatio, float inMinSize, float inMaxSize)
{
if (inAvailableSize <= 0.0f) {
Expand Down Expand Up @@ -223,6 +243,7 @@ namespace Editor {
ImFontConfig defaultFontConfig;
defaultFontConfig.SizePixels = Internal::defaultFontSize;
io.FontDefault = io.Fonts->AddFontDefaultVector(&defaultFontConfig);
Internal::LoadIconFonts(*io.Fonts, Internal::defaultFontSize);
Internal::SetDarkStyle();
}

Expand Down
75 changes: 51 additions & 24 deletions Editor/Src/Frame/EditorFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
#include <Editor/Frame/EditorFrame.h>
#include <Editor/Panel/EditorPanelNames.h>
#include <Editor/System/Camera.h>
#include <Editor/Widget/IconWidgets.h>
#include <Editor/Widget/InputWidgets.h>
#include <Editor/Widget/TablerIcons.h>
#include <Mirror/Mirror.h>
#include <Runtime/Component/Name.h>
#include <Runtime/Component/Transform.h>
Expand Down Expand Up @@ -101,32 +103,41 @@ namespace Editor {
if (!ImGui::BeginMainMenuBar()) {
return;
}
if (ImGui::BeginMenu("File")) {
if (ImGui::MenuItem("Save Level", "Ctrl+S")) {
const std::string fileMenuLabel = Widgets::Label(Icons::Tabler::file, "File");
if (ImGui::BeginMenu(fileMenuLabel.c_str())) {
const std::string saveLevelLabel = Widgets::Label(Icons::Tabler::deviceFloppy, "Save Level");
if (ImGui::MenuItem(saveLevelLabel.c_str(), "Ctrl+S")) {
inContext.GetSceneClient().SaveLevel();
}
ImGui::Separator();
if (ImGui::MenuItem("Exit")) {
const std::string exitLabel = Widgets::Label(Icons::Tabler::doorExit, "Exit");
if (ImGui::MenuItem(exitLabel.c_str())) {
outRequestQuit = true;
}
ImGui::EndMenu();
}
if (ImGui::BeginMenu("View")) {
ImGui::MenuItem(PanelNames::scene, nullptr, &tabVisibility.scene);
ImGui::MenuItem(PanelNames::outliner, nullptr, &tabVisibility.outliner);
ImGui::MenuItem(PanelNames::inspector, nullptr, &tabVisibility.inspector);
const std::string viewMenuLabel = Widgets::Label(Icons::Tabler::layoutDashboard, "View");
if (ImGui::BeginMenu(viewMenuLabel.c_str())) {
const std::string sceneLabel = Widgets::Label(Icons::Tabler::viewportWide, PanelNames::scene);
ImGui::MenuItem(sceneLabel.c_str(), nullptr, &tabVisibility.scene);
const std::string outlinerLabel = Widgets::Label(Icons::Tabler::hierarchy2, PanelNames::outliner);
ImGui::MenuItem(outlinerLabel.c_str(), nullptr, &tabVisibility.outliner);
const std::string inspectorLabel = Widgets::Label(Icons::Tabler::adjustmentsHorizontal, PanelNames::inspector);
ImGui::MenuItem(inspectorLabel.c_str(), nullptr, &tabVisibility.inspector);
panels.RenderViewMenuItems();
ImGui::MenuItem(PanelNames::log, nullptr, &tabVisibility.log);
const std::string logLabel = Widgets::Label(Icons::Tabler::terminal2, PanelNames::log);
ImGui::MenuItem(logLabel.c_str(), nullptr, &tabVisibility.log);
ImGui::EndMenu();
}
ImGui::EndMainMenuBar();
}

void EditorFrame::RenderSceneTab(EditorContext& inContext, Runtime::Canvas& inSceneRenderCanvas, bool& inOutOpen)
{
static const std::string label = Widgets::Label(Icons::Tabler::viewportWide, PanelNames::scene, PanelNames::scene);
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
auto& sceneClient = inContext.GetSceneClient();
if (ImGui::Begin(PanelNames::scene, &inOutOpen, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse)) {
if (ImGui::Begin(label.c_str(), &inOutOpen, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse)) {
ImVec2 sceneSize = ImGui::GetContentRegionAvail();
sceneSize.x = std::max(sceneSize.x, 1.0f);
sceneSize.y = std::max(sceneSize.y, 1.0f);
Expand All @@ -148,18 +159,21 @@ namespace Editor {

void EditorFrame::RenderOutlinerTab(EditorContext& inContext, Runtime::ECRegistry& inRegistry, bool& inOutOpen)
{
if (!ImGui::Begin(PanelNames::outliner, &inOutOpen)) {
static const std::string label = Widgets::Label(Icons::Tabler::hierarchy2, PanelNames::outliner, PanelNames::outliner);
if (!ImGui::Begin(label.c_str(), &inOutOpen)) {
ImGui::End();
return;
}
if (ImGui::Button("New Entity")) {
const std::string newEntityLabel = Widgets::Label(Icons::Tabler::plus, "New Entity");
if (ImGui::Button(newEntityLabel.c_str())) {
ImGui::OpenPopup("NewEntityMenu");
}
ImGui::SetNextWindowSize(ImVec2(260.0f, 0.0f), ImGuiCond_Appearing);
if (ImGui::BeginPopup("NewEntityMenu")) {
ImGui::SetNextItemWidth(-1.0f);
ImGui::InputText("##EntityName", &createEntityName);
if (ImGui::Button("Create", ImVec2(ImGui::GetContentRegionAvail().x, 0.0f))) {
const std::string createLabel = Widgets::Label(Icons::Tabler::check, "Create");
if (ImGui::Button(createLabel.c_str(), ImVec2(ImGui::GetContentRegionAvail().x, 0.0f))) {
const auto entity = inContext.CreateEntity(inRegistry, createEntityName);
inContext.SetSelectedEntity(entity);
ImGui::CloseCurrentPopup();
Expand All @@ -173,15 +187,16 @@ namespace Editor {
if (inRegistry.Has<EditorCameraController>(entity)) {
return;
}
const std::string label = Internal::EntityDisplayName(inRegistry, entity);
const std::string label = Widgets::Label(Icons::Tabler::box, Internal::EntityDisplayName(inRegistry, entity));
const bool selected = inContext.GetSelectedEntity() == entity;
ImGui::PushID(static_cast<int>(entity));
if (ImGui::Selectable(label.c_str(), selected)) {
inContext.SetSelectedEntity(entity);
}
if (ImGui::BeginPopupContextItem("EntityMenu")) {
inContext.SetSelectedEntity(entity);
if (ImGui::MenuItem("Delete")) {
const std::string deleteLabel = Widgets::Label(Icons::Tabler::trash, "Delete");
if (ImGui::MenuItem(deleteLabel.c_str())) {
entityToDelete = entity;
}
ImGui::EndPopup();
Expand All @@ -196,7 +211,8 @@ namespace Editor {

void EditorFrame::RenderInspectorTab(EditorContext& inContext, Runtime::ECRegistry& inRegistry, bool& inOutOpen)
{
if (!ImGui::Begin(PanelNames::inspector, &inOutOpen)) {
static const std::string label = Widgets::Label(Icons::Tabler::adjustmentsHorizontal, PanelNames::inspector, PanelNames::inspector);
if (!ImGui::Begin(label.c_str(), &inOutOpen)) {
ImGui::End();
return;
}
Expand All @@ -216,15 +232,17 @@ namespace Editor {
}

ImGui::BeginDisabled(addableComponents.empty());
if (ImGui::Button("Add Component")) {
const std::string addComponentLabel = Widgets::Label(Icons::Tabler::plus, "Add Component");
if (ImGui::Button(addComponentLabel.c_str())) {
ImGui::OpenPopup("AddComponentMenu");
}
ImGui::EndDisabled();
if (ImGui::BeginPopup("AddComponentMenu")) {
for (const auto* clazz : addableComponents) {
const std::string componentName = Internal::ComponentDisplayName(*clazz);
ImGui::PushID(clazz->GetName().c_str());
if (ImGui::MenuItem(componentName.c_str())) {
const std::string componentLabel = Widgets::Label(Icons::Tabler::boxMultiple, componentName);
if (ImGui::MenuItem(componentLabel.c_str())) {
inContext.AddComponent(inRegistry, selectedEntity, clazz);
}
ImGui::PopID();
Expand All @@ -237,9 +255,11 @@ namespace Editor {
inRegistry.CompEach(selectedEntity, [&](Runtime::CompClass compClass) -> void {
ImGui::PushID(compClass->GetName().c_str());
const std::string componentName = Internal::ComponentDisplayName(*compClass);
const bool open = ImGui::CollapsingHeader(componentName.c_str(), ImGuiTreeNodeFlags_DefaultOpen);
const std::string componentLabel = Widgets::Label(Icons::Tabler::boxMultiple, componentName);
const bool open = ImGui::CollapsingHeader(componentLabel.c_str(), ImGuiTreeNodeFlags_DefaultOpen);
if (inContext.CanRemoveComponent(inRegistry, selectedEntity, compClass) && ImGui::BeginPopupContextItem("ComponentMenu")) {
if (ImGui::MenuItem("Remove")) {
const std::string removeLabel = Widgets::Label(Icons::Tabler::trash, "Remove");
if (ImGui::MenuItem(removeLabel.c_str())) {
componentToRemove = compClass;
}
ImGui::EndPopup();
Expand All @@ -259,9 +279,11 @@ namespace Editor {
inRegistry.TagEach(selectedEntity, [&](Runtime::TagClass tagClass) -> void {
ImGui::PushID(tagClass->GetName().c_str());
const std::string tagName = Internal::ComponentDisplayName(*tagClass);
ImGui::TextUnformatted(tagName.c_str());
const std::string tagLabel = Widgets::Label(Icons::Tabler::box, tagName);
ImGui::TextUnformatted(tagLabel.c_str());
if (inContext.CanRemoveComponent(inRegistry, selectedEntity, tagClass) && ImGui::BeginPopupContextItem("ComponentMenu")) {
if (ImGui::MenuItem("Remove")) {
const std::string removeLabel = Widgets::Label(Icons::Tabler::trash, "Remove");
if (ImGui::MenuItem(removeLabel.c_str())) {
componentToRemove = tagClass;
}
ImGui::EndPopup();
Expand All @@ -277,12 +299,14 @@ namespace Editor {

void EditorFrame::RenderLogTab(bool& inOutOpen)
{
if (!ImGui::Begin(PanelNames::log, &inOutOpen)) {
static const std::string label = Widgets::Label(Icons::Tabler::terminal2, PanelNames::log, PanelNames::log);
if (!ImGui::Begin(label.c_str(), &inOutOpen)) {
ImGui::End();
return;
}
const auto entries = EditorLogStream::Get().Snapshot();
if (ImGui::Button("Copy")) {
const std::string copyLabel = Widgets::Label(Icons::Tabler::copy, "Copy");
if (ImGui::Button(copyLabel.c_str())) {
std::string text;
for (const auto& entry : entries) {
text += std::format("[{}][{}][{}] {}\n", entry.time, Internal::LevelString(entry.level), entry.tag, entry.content);
Expand All @@ -293,13 +317,16 @@ namespace Editor {
ImGui::BeginChild("LogEntries", ImVec2(0.0f, 0.0f), false, ImGuiWindowFlags_HorizontalScrollbar);
for (const auto& entry : entries) {
ImVec4 color = ImGui::GetStyleColorVec4(ImGuiCol_Text);
const char* levelIcon = Icons::Tabler::infoCircle;
if (entry.level == Core::LogLevel::warning) {
color = ImVec4(1.0f, 0.78f, 0.25f, 1.0f);
levelIcon = Icons::Tabler::alertTriangle;
} else if (entry.level == Core::LogLevel::error) {
color = ImVec4(1.0f, 0.35f, 0.32f, 1.0f);
levelIcon = Icons::Tabler::circleX;
}
ImGui::PushStyleColor(ImGuiCol_Text, color);
ImGui::TextUnformatted(std::format("[{}][{}][{}] {}", entry.time, Internal::LevelString(entry.level), entry.tag, entry.content).c_str());
ImGui::TextUnformatted(std::format("{} [{}][{}][{}] {}", levelIcon, entry.time, Internal::LevelString(entry.level), entry.tag, entry.content).c_str());
ImGui::PopStyleColor();
}
if (ImGui::GetScrollY() >= ImGui::GetScrollMaxY()) {
Expand Down
Loading
Loading