From 18a2257b9773587395475c3c89efe8baf5ab8b1e Mon Sep 17 00:00:00 2001 From: "harry.cpp" Date: Wed, 22 Jan 2025 14:39:25 +0100 Subject: [PATCH] Add GetStyleColorName --- imnodes.cpp | 39 +++++++++++++++++++++++++++++++++++++++ imnodes.h | 2 ++ 2 files changed, 41 insertions(+) diff --git a/imnodes.cpp b/imnodes.cpp index a77c0a9e..efe5622d 100644 --- a/imnodes.cpp +++ b/imnodes.cpp @@ -2195,6 +2195,45 @@ void StyleColorsLight(ImNodesStyle* dest) dest->Colors[ImNodesCol_MiniMapCanvasOutline] = IM_COL32(200, 200, 200, 200); } +const char* GetStyleColorName(ImNodesCol idx) +{ + // Create switch-case from enum with regexp: ImNodesCol_(.*), --> case ImNodesCol_\1: return "\1"; + switch (idx) + { + case ImNodesCol_NodeBackground: return "NodeBackground"; + case ImNodesCol_NodeBackgroundHovered: return "NodeBackgroundHovered"; + case ImNodesCol_NodeBackgroundSelected: return "NodeBackgroundSelected"; + case ImNodesCol_NodeOutline: return "NodeOutline"; + case ImNodesCol_TitleBar: return "TitleBar"; + case ImNodesCol_TitleBarHovered: return "TitleBarHovered"; + case ImNodesCol_TitleBarSelected: return "TitleBarSelected"; + case ImNodesCol_Link: return "Link"; + case ImNodesCol_LinkHovered: return "LinkHovered"; + case ImNodesCol_LinkSelected: return "LinkSelected"; + case ImNodesCol_Pin: return "Pin"; + case ImNodesCol_PinHovered: return "PinHovered"; + case ImNodesCol_BoxSelector: return "BoxSelector"; + case ImNodesCol_BoxSelectorOutline: return "BoxSelectorOutline"; + case ImNodesCol_GridBackground: return "GridBackground"; + case ImNodesCol_GridLine: return "GridLine"; + case ImNodesCol_GridLinePrimary: return "GridLinePrimary"; + case ImNodesCol_MiniMapBackground: return "MiniMapBackground"; + case ImNodesCol_MiniMapBackgroundHovered: return "MiniMapBackgroundHovered"; + case ImNodesCol_MiniMapOutline: return "MiniMapOutline"; + case ImNodesCol_MiniMapOutlineHovered: return "MiniMapOutlineHovered"; + case ImNodesCol_MiniMapNodeBackground: return "MiniMapNodeBackground"; + case ImNodesCol_MiniMapNodeBackgroundHovered: return "MiniMapNodeBackgroundHovered"; + case ImNodesCol_MiniMapNodeBackgroundSelected: return "MiniMapNodeBackgroundSelected"; + case ImNodesCol_MiniMapNodeOutline: return "MiniMapNodeOutline"; + case ImNodesCol_MiniMapLink: return "MiniMapLink"; + case ImNodesCol_MiniMapLinkSelected: return "MiniMapLinkSelected"; + case ImNodesCol_MiniMapCanvas: return "MiniMapCanvas"; + case ImNodesCol_MiniMapCanvasOutline: return "MiniMapCanvasOutline"; + } + IM_ASSERT(0); + return "Unknown"; +} + void BeginNodeEditor() { IM_ASSERT(GImNodes->CurrentScope == ImNodesScope_None); diff --git a/imnodes.h b/imnodes.h index 15ad5ed9..8365f9e4 100644 --- a/imnodes.h +++ b/imnodes.h @@ -264,6 +264,8 @@ ImNodesStyle& GetStyle(); void StyleColorsDark(ImNodesStyle* dest = NULL); // on by default void StyleColorsClassic(ImNodesStyle* dest = NULL); void StyleColorsLight(ImNodesStyle* dest = NULL); +// Get a string corresponding to the enum value (for display, saving, etc.). +const char* GetStyleColorName(ImNodesCol idx); // The top-level function call. Call this before calling BeginNode/EndNode. Calling this function // will result the node editor grid workspace being rendered.