diff --git a/plugins/builtin/include/content/views/view_theme_manager.hpp b/plugins/builtin/include/content/views/view_theme_manager.hpp index d65e8af70..f049e05b2 100644 --- a/plugins/builtin/include/content/views/view_theme_manager.hpp +++ b/plugins/builtin/include/content/views/view_theme_manager.hpp @@ -19,6 +19,10 @@ namespace hex::plugin::builtin { private: std::string m_themeName; bool m_viewOpen = false; + + std::optional m_startingColor; + std::optional m_hoveredColorId; + std::optional m_hoveredHandlerName; }; } \ No newline at end of file diff --git a/plugins/builtin/source/content/views/view_theme_manager.cpp b/plugins/builtin/source/content/views/view_theme_manager.cpp index 176386460..abee899b4 100644 --- a/plugins/builtin/source/content/views/view_theme_manager.cpp +++ b/plugins/builtin/source/content/views/view_theme_manager.cpp @@ -21,7 +21,9 @@ namespace hex::plugin::builtin { // Draw theme handlers ImGui::PushID(1); + // Loop over each theme handler + bool anyColorHovered = false; for (auto &[name, handler] : ThemeManager::getThemeHandlers()) { // Create a new collapsable header for each category if (ImGui::CollapsingHeader(name.c_str())) { @@ -37,6 +39,32 @@ namespace hex::plugin::builtin { handler.setFunction(colorId, color); EventManager::post(); } + + if (ImGui::IsItemHovered()) { + anyColorHovered = true; + + if (!this->m_hoveredColorId.has_value()) { + this->m_hoveredColorId = colorId; + this->m_startingColor = color; + this->m_hoveredHandlerName = name; + } + } + } + } + + if (this->m_hoveredHandlerName == name && this->m_startingColor.has_value() && this->m_hoveredColorId.has_value()) { + auto flashingColor = this->m_startingColor.value(); + + const float flashProgress = std::min(1.0F, (1.0F + sinf(ImGui::GetTime() * 6) / 2.0F)); + flashingColor.Value.x = std::lerp(flashingColor.Value.x, 1.0F, flashProgress); + flashingColor.Value.y = std::lerp(flashingColor.Value.y, 1.0F, flashProgress);; + + handler.setFunction(*this->m_hoveredColorId, flashingColor); + + if (!anyColorHovered) { + handler.setFunction(this->m_hoveredColorId.value(), this->m_startingColor.value()); + this->m_startingColor.reset(); + this->m_hoveredColorId.reset(); } } }