diff --git a/CMakeLists.txt b/CMakeLists.txt index f84b551..4cf7662 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,7 +27,13 @@ endif() if(MSVC) add_compile_definitions(SDL_MAIN_HANDLED) - add_compile_options(/W4 /WX) + add_compile_options(/WX) + # replace existing /W to avoid warning + if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]") + string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + else() + add_compile_options(/W4) + endif() else() add_compile_options(-Wall -Wextra -Wpedantic -Werror) endif() diff --git a/example/color_node_editor.cpp b/example/color_node_editor.cpp index af17151..549bd81 100644 --- a/example/color_node_editor.cpp +++ b/example/color_node_editor.cpp @@ -205,8 +205,7 @@ class ColorNodeEditor // These are driven by the user, so we place this code before rendering the nodes { const bool open_popup = ImGui::IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows) && - ImNodes::IsEditorHovered() && - ImGui::IsKeyReleased(ImGuiKey_A); + ImNodes::IsEditorHovered() && ImGui::IsKeyReleased(ImGuiKey_A); ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(8.f, 8.f)); if (!ImGui::IsAnyItemHovered() && open_popup) @@ -513,7 +512,7 @@ class ColorNodeEditor const float label_width = ImGui::CalcTextSize("output").x; ImGui::Indent(node_width - label_width); ImGui::TextUnformatted("output"); - ImNodes::EndInputAttribute(); + ImNodes::EndOutputAttribute(); } ImNodes::EndNode(); diff --git a/imnodes.cpp b/imnodes.cpp index 7dde0f4..35a7546 100644 --- a/imnodes.cpp +++ b/imnodes.cpp @@ -1774,7 +1774,7 @@ static inline void CalcMiniMapLayout() const ImVec2 grid_content_size = editor.GridContentBounds.IsInverted() ? max_size : ImFloor(editor.GridContentBounds.GetSize()); - const float grid_content_aspect_ratio = grid_content_size.x / grid_content_size.y; + const float grid_content_aspect_ratio = grid_content_size.x / grid_content_size.y; mini_map_size = ImFloor( grid_content_aspect_ratio > max_size_aspect_ratio ? ImVec2(max_size.x, max_size.x / grid_content_aspect_ratio) @@ -2766,35 +2766,35 @@ struct ImNodesStyleVarInfo static const ImNodesStyleVarInfo GStyleVarInfo[] = { // ImNodesStyleVar_GridSpacing - {ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImNodesStyle, GridSpacing)}, + {ImGuiDataType_Float, 1, (ImU32)offsetof(ImNodesStyle, GridSpacing)}, // ImNodesStyleVar_NodeCornerRounding - {ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImNodesStyle, NodeCornerRounding)}, + {ImGuiDataType_Float, 1, (ImU32)offsetof(ImNodesStyle, NodeCornerRounding)}, // ImNodesStyleVar_NodePadding - {ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImNodesStyle, NodePadding)}, + {ImGuiDataType_Float, 2, (ImU32)offsetof(ImNodesStyle, NodePadding)}, // ImNodesStyleVar_NodeBorderThickness - {ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImNodesStyle, NodeBorderThickness)}, + {ImGuiDataType_Float, 1, (ImU32)offsetof(ImNodesStyle, NodeBorderThickness)}, // ImNodesStyleVar_LinkThickness - {ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImNodesStyle, LinkThickness)}, + {ImGuiDataType_Float, 1, (ImU32)offsetof(ImNodesStyle, LinkThickness)}, // ImNodesStyleVar_LinkLineSegmentsPerLength - {ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImNodesStyle, LinkLineSegmentsPerLength)}, + {ImGuiDataType_Float, 1, (ImU32)offsetof(ImNodesStyle, LinkLineSegmentsPerLength)}, // ImNodesStyleVar_LinkHoverDistance - {ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImNodesStyle, LinkHoverDistance)}, + {ImGuiDataType_Float, 1, (ImU32)offsetof(ImNodesStyle, LinkHoverDistance)}, // ImNodesStyleVar_PinCircleRadius - {ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImNodesStyle, PinCircleRadius)}, + {ImGuiDataType_Float, 1, (ImU32)offsetof(ImNodesStyle, PinCircleRadius)}, // ImNodesStyleVar_PinQuadSideLength - {ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImNodesStyle, PinQuadSideLength)}, + {ImGuiDataType_Float, 1, (ImU32)offsetof(ImNodesStyle, PinQuadSideLength)}, // ImNodesStyleVar_PinTriangleSideLength - {ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImNodesStyle, PinTriangleSideLength)}, + {ImGuiDataType_Float, 1, (ImU32)offsetof(ImNodesStyle, PinTriangleSideLength)}, // ImNodesStyleVar_PinLineThickness - {ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImNodesStyle, PinLineThickness)}, + {ImGuiDataType_Float, 1, (ImU32)offsetof(ImNodesStyle, PinLineThickness)}, // ImNodesStyleVar_PinHoverRadius - {ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImNodesStyle, PinHoverRadius)}, + {ImGuiDataType_Float, 1, (ImU32)offsetof(ImNodesStyle, PinHoverRadius)}, // ImNodesStyleVar_PinOffset - {ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImNodesStyle, PinOffset)}, + {ImGuiDataType_Float, 1, (ImU32)offsetof(ImNodesStyle, PinOffset)}, // ImNodesStyleVar_MiniMapPadding - {ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImNodesStyle, MiniMapPadding)}, + {ImGuiDataType_Float, 2, (ImU32)offsetof(ImNodesStyle, MiniMapPadding)}, // ImNodesStyleVar_MiniMapOffset - {ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImNodesStyle, MiniMapOffset)}, + {ImGuiDataType_Float, 2, (ImU32)offsetof(ImNodesStyle, MiniMapOffset)}, }; static const ImNodesStyleVarInfo* GetStyleVarInfo(ImNodesStyleVar idx) diff --git a/imnodes_internal.h b/imnodes_internal.h index f1c44e1..5aa11aa 100644 --- a/imnodes_internal.h +++ b/imnodes_internal.h @@ -285,10 +285,11 @@ struct ImNodesEditorContext ImNodesEditorContext() : Nodes(), Pins(), Links(), ZoomScale(1.f), Panning(0.f, 0.f), SelectedNodeIndices(), - SelectedLinkIndices(), SelectedNodeOffsets(), PrimaryNodeOffset(0.f, 0.f), - ClickInteraction(), MiniMapEnabled(false), MiniMapSizeFraction(0.0f), - MiniMapNodeHoveringCallback(NULL), MiniMapNodeHoveringCallbackUserData(NULL), - MiniMapScaling(0.0f) {} + SelectedLinkIndices(), SelectedNodeOffsets(), PrimaryNodeOffset(0.f, 0.f), ClickInteraction(), + MiniMapEnabled(false), MiniMapSizeFraction(0.0f), MiniMapNodeHoveringCallback(NULL), + MiniMapNodeHoveringCallbackUserData(NULL), MiniMapScaling(0.0f) + { + } }; struct ImNodesContext