Skip to content

Commit

Permalink
Help tooltip in node graph
Browse files Browse the repository at this point in the history
  • Loading branch information
Auburn committed Aug 3, 2021
1 parent 66795f0 commit 344732d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
2 changes: 1 addition & 1 deletion NoiseTool/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ CPMAddPackage(
"GLFW_INSTALL OFF"
"GLFW_BUILD_TESTS OFF"
"GLFW_BUILD_EXAMPLES OFF"
"GLFW_BULID_DOCS OFF"
"GLFW_BUILD_DOCS OFF"
)

CPMAddPackage(
Expand Down
34 changes: 33 additions & 1 deletion NoiseTool/FastNoiseNodeEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,8 @@ void FastNoiseNodeEditor::Draw( const Matrix4& transformation, const Matrix4& pr
ImGui::TextUnformatted( simdTxt.c_str() );

imnodes::BeginNodeEditor();

DoHelp();

DoContextMenu();

Expand Down Expand Up @@ -398,7 +400,11 @@ void FastNoiseNodeEditor::UpdateSelected()
std::vector<int> linksToDelete;
int selectedLinkCount = imnodes::NumSelectedLinks();

if( selectedLinkCount && ImGui::IsKeyPressed( ImGui::GetKeyIndex( ImGuiKey_Delete ), false ) )
bool delKeyPressed =
ImGui::IsKeyPressed( ImGui::GetKeyIndex( ImGuiKey_Delete ), false ) ||
ImGui::IsKeyPressed( ImGui::GetKeyIndex( ImGuiKey_Backspace ), false );

if( selectedLinkCount && delKeyPressed )
{
linksToDelete.resize( selectedLinkCount );
imnodes::GetSelectedLinks( linksToDelete.data() );
Expand Down Expand Up @@ -713,6 +719,32 @@ bool FastNoiseNodeEditor::AddNodeFromEncodedString( const char* string, ImVec2 n
return false;
}

void FastNoiseNodeEditor::DoHelp()
{
ImGui::Text( " Help" );
if( ImGui::IsItemHovered() )
{
ImGui::PushStyleVar( ImGuiStyleVar_WindowPadding, ImVec2( 4.f, 4.f ) );
constexpr float alignPx = 110;

ImGui::BeginTooltip();
ImGui::Text( "Add nodes" );
ImGui::SameLine( alignPx );
ImGui::Text( "Right mouse click" );

ImGui::Text( "Pan graph" );
ImGui::SameLine( alignPx );
ImGui::Text( "Right mouse drag" );

ImGui::Text( "Delete node/link" );
ImGui::SameLine( alignPx );
ImGui::Text( "Backspace or Delete" );
ImGui::EndTooltip();

ImGui::PopStyleVar();
}
}

void FastNoiseNodeEditor::DoContextMenu()
{
std::string className;
Expand Down
1 change: 1 addition & 0 deletions NoiseTool/FastNoiseNodeEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ namespace Magnum
FastNoise::SmartNode<> GenerateSelectedPreview();
void ChangeSelectedNode( int newId );
void CheckLinks();
void DoHelp();
void DoContextMenu();
void DoNodes();
void UpdateSelected();
Expand Down

0 comments on commit 344732d

Please sign in to comment.