Skip to content

Commit

Permalink
Don't zoom node editor when scrolling enums
Browse files Browse the repository at this point in the history
  • Loading branch information
Auburn committed Dec 15, 2024
1 parent 57973f6 commit e257d4d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 7 additions & 4 deletions tools/NodeEditor/FastNoiseNodeEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ FastNoiseNodeEditor::FastNoiseNodeEditor( NodeEditorApp& nodeEditorApp ) :
state = FastNoise::Metadata::DebugCheckVectorStorageSize( debugMetadataVectorCheckIdx++ );
if( state.first > 0 )
{
Error{} << "Non-optimal metadata vector, in FastNoise Metadata.cpp adjust gMetadataVectorSize " << state.second << " to: " << state.first;
Error{} << "Non-optimal metadata vector, in FastNoise Metadata.cpp adjust gMetadataVectorSize<" << state.second << "> to: " << state.first;
}

} while( state.second );
Expand Down Expand Up @@ -838,13 +838,16 @@ void FastNoiseNodeEditor::Draw( const Matrix4& transformation, const Matrix4& pr

ImNodes::MiniMap( 0.2f, ImNodesMiniMapLocation_BottomLeft );

// Capture in the editor imgui context
float editorMouseWheel = ImGui::GetIO().MouseWheel;

ImNodes::EndNodeEditor();

// Zoom
if( ImNodes::IsEditorHovered() && ImGui::GetIO().MouseWheel != 0 )
if( ImNodes::IsEditorHovered() && editorMouseWheel != 0 )
{
float zoom = ImNodes::EditorContextGetZoom();
if( ImGui::GetIO().MouseWheel > 0 )
if( editorMouseWheel > 0 )
{
zoom *= 1.5f;
if( zoom > 0.9f )
Expand Down Expand Up @@ -1111,7 +1114,7 @@ void FastNoiseNodeEditor::DoNodes()
}
ImGui::PopStyleVar();

ImGui::PushItemWidth( 60.0f );
ImGui::PushItemWidth( 90.0f );

ImNodes::PushAttributeFlag( ImNodesAttributeFlags_EnableLinkCreationOnSnap );
ImNodes::PushAttributeFlag( ImNodesAttributeFlags_EnableLinkDetachWithDragClick );
Expand Down
2 changes: 2 additions & 0 deletions tools/NodeEditor/util/ImGuiExtra.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ namespace ImGuiExtra
if( ImGui::GetIO().MouseWheel < 0 && *comboIndex < comboCount - 1 )
{
(*comboIndex)++;
ImGui::GetIO().MouseWheel = 0;
return true;
}

if( ImGui::GetIO().MouseWheel > 0 && *comboIndex > 0 )
{
(*comboIndex)--;
ImGui::GetIO().MouseWheel = 0;
return true;
}
}
Expand Down

0 comments on commit e257d4d

Please sign in to comment.