Skip to content

Commit

Permalink
feat: Fix content browser spaces & childs
Browse files Browse the repository at this point in the history
  • Loading branch information
diegomrno committed Nov 21, 2024
1 parent 50b0205 commit 624ba82
Show file tree
Hide file tree
Showing 13 changed files with 436 additions and 194 deletions.
4 changes: 4 additions & 0 deletions build/savedatda.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"data": {},
"save": true
}
2 changes: 1 addition & 1 deletion lib/json
Submodule json updated 51 files
+10 −0 .clang-tidy
+1 −1 .github/CONTRIBUTING.md
+3 −3 .github/workflows/check_amalgamation.yml
+1 −1 .github/workflows/cifuzz.yml
+2 −2 .github/workflows/codeql-analysis.yml
+61 −9 .github/workflows/macos.yml
+2 −2 .github/workflows/publish_documentation.yml
+48 −27 .github/workflows/ubuntu.yml
+7 −7 .github/workflows/windows.yml
+0 −1 BUILD.bazel
+6 −1 CMakeLists.txt
+52 −38 README.md
+15 −4 cmake/ci.cmake
+118 −0 docs/mkdocs/docs/api/macros/nlohmann_define_derived_type.md
+22 −0 include/nlohmann/detail/conversions/from_json.hpp
+7 −7 include/nlohmann/detail/conversions/to_chars.hpp
+19 −0 include/nlohmann/detail/conversions/to_json.hpp
+16 −0 include/nlohmann/detail/exceptions.hpp
+9 −0 include/nlohmann/detail/input/input_adapters.hpp
+2 −2 include/nlohmann/detail/input/json_sax.hpp
+1 −1 include/nlohmann/detail/input/lexer.hpp
+2 −2 include/nlohmann/detail/input/parser.hpp
+2 −2 include/nlohmann/detail/iterators/iteration_proxy.hpp
+30 −0 include/nlohmann/detail/macro_scope.hpp
+1 −1 include/nlohmann/detail/meta/cpp_future.hpp
+1 −1 include/nlohmann/detail/meta/std_fs.hpp
+3 −3 include/nlohmann/detail/meta/type_traits.hpp
+1 −1 include/nlohmann/detail/output/binary_writer.hpp
+3 −3 include/nlohmann/detail/output/serializer.hpp
+19 −19 include/nlohmann/json.hpp
+139 −42 single_include/nlohmann/json.hpp
+1 −1 tests/src/unit-32bit.cpp
+2 −2 tests/src/unit-alt-string.cpp
+5 −5 tests/src/unit-bjdata.cpp
+1 −1 tests/src/unit-bson.cpp
+5 −6 tests/src/unit-cbor.cpp
+1 −1 tests/src/unit-class_lexer.cpp
+0 −1 tests/src/unit-concepts.cpp
+92 −2 tests/src/unit-conversions.cpp
+17 −13 tests/src/unit-deserialization.cpp
+14 −14 tests/src/unit-element_access1.cpp
+10 −10 tests/src/unit-element_access2.cpp
+1 −1 tests/src/unit-json_patch.cpp
+3 −3 tests/src/unit-msgpack.cpp
+1 −1 tests/src/unit-readme.cpp
+65 −6 tests/src/unit-regression2.cpp
+1 −1 tests/src/unit-serialization.cpp
+2 −2 tests/src/unit-testsuites.cpp
+2 −2 tests/src/unit-ubjson.cpp
+189 −4 tests/src/unit-udt_macro.cpp
+1 −1 tests/src/unit-unicode1.cpp
10 changes: 10 additions & 0 deletions main/src/modules/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ void ModuleInterface::AddInputEvent(const ModuleInputEvent &event)

void ModuleInterface::RefreshMainWindow()
{
if(!&Cherry::Application::Get())
{
return;
}

// Remove potential old main window
for (auto &window : Cherry::Application::Get().m_AppWindows)
{
Expand All @@ -67,6 +72,11 @@ void ModuleInterface::RefreshMainWindow()
void ModuleInterface::SetMainWindow(const std::shared_ptr<Cherry::AppWindow> &win)
{
m_main_window = win;

if(&Cherry::Application::Get())
{
RefreshMainWindow();
}
}

/**
Expand Down
20 changes: 19 additions & 1 deletion ui/editor/app/core/modules_utility/modules_utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,23 @@ namespace VortexEditor
truncatedText = name + "\n";
}


const char *originalDesc = module->m_description.c_str();
std::string truncatedDesc = module->m_description;

if (ImGui::CalcTextSize(originalDesc).x > maxTextWidth)
{
truncatedDesc = module->m_description.substr(0, 20);
if (ImGui::CalcTextSize(truncatedDesc.c_str()).x > maxTextWidth)
{
truncatedDesc = module->m_description.substr(0, 10) + "\n" + module->m_description.substr(10, 10);
}
}
else
{
truncatedDesc = module->m_description + "\n";
}

ImVec2 fixedSize(maxTextWidth + padding * 2 + 150.0f, logoSize + extraHeight + padding * 2);

ImVec2 cursorPos = ImGui::GetCursorScreenPos();
Expand Down Expand Up @@ -166,7 +183,8 @@ namespace VortexEditor

ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.5f, 0.5f, 0.5f, 1.0f));
ImGui::PushItemWidth(maxTextWidth);
ImGui::TextWrapped(module->m_description.c_str());

DrawDescription(drawList, descriptionPos, truncatedDesc.c_str(), ModulesSearch, highlightColor, textColor, highlightTextColor);
ImGui::PopItemWidth();
ImGui::PopStyleColor();

Expand Down
39 changes: 35 additions & 4 deletions ui/editor/app/core/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,41 @@ static void MyButton(const std::string &name, int w, int h)
if (cursorPos.x + totalSize.x < windowVisibleX2)
ImGui::SameLine();
}
static void DrawDescription(ImDrawList *drawList, ImVec2 textPos, const char *text, const char *search, ImU32 highlightColor, ImU32 textColor, ImU32 highlightTextColor)
{
if (!text || !search || !*search)
{
drawList->AddText(textPos, textColor, text);
return;
}

const char *start = text;
const char *found = strstr(start, search);
while (found)
{
if (found > start)
{
std::string preText(start, found);
drawList->AddText(textPos, textColor, preText.c_str());
textPos.x += ImGui::CalcTextSize(preText.c_str()).x;
}

ImVec2 highlightPos = textPos;
ImVec2 highlightSize = ImGui::CalcTextSize(search);
drawList->AddRectFilled(highlightPos, ImVec2(highlightPos.x + highlightSize.x, highlightPos.y + highlightSize.y), highlightColor);
drawList->AddText(textPos, highlightTextColor, search);
textPos.x += highlightSize.x;

start = found + strlen(search);
found = strstr(start, search);
}

if (*start)
{
drawList->AddText(textPos, textColor, start);
}
}


static void DrawHighlightedText(ImDrawList *drawList, ImVec2 textPos, const char *text, const char *search, ImU32 highlightColor, ImU32 textColor, ImU32 highlightTextColor)
{
Expand All @@ -261,27 +296,23 @@ static void DrawHighlightedText(ImDrawList *drawList, ImVec2 textPos, const char
const char *found = strstr(start, search);
while (found)
{
// Dessiner le texte avant la correspondance
if (found > start)
{
std::string preText(start, found);
drawList->AddText(textPos, textColor, preText.c_str());
textPos.x += ImGui::CalcTextSize(preText.c_str()).x;
}

// Dessiner la correspondance mise en surbrillance avec un texte noir
ImVec2 highlightPos = textPos;
ImVec2 highlightSize = ImGui::CalcTextSize(search);
drawList->AddRectFilled(highlightPos, ImVec2(highlightPos.x + highlightSize.x, highlightPos.y + highlightSize.y), highlightColor);
drawList->AddText(textPos, highlightTextColor, search);
textPos.x += highlightSize.x;

// Passer à la partie suivante du texte
start = found + strlen(search);
found = strstr(start, search);
}

// Dessiner le texte restant après la dernière correspondance
if (*start)
{
drawList->AddText(textPos, textColor, start);
Expand Down
Loading

0 comments on commit 624ba82

Please sign in to comment.