MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / Link

Function Link

source/MRViewer/ImGuiHelpers.cpp:1127–1159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1125}
1126
1127bool Link( const char* label, uint32_t color )
1128{
1129 auto window = GetCurrentContext()->CurrentWindow;
1130 assert( window );
1131 if ( !window )
1132 return false;
1133
1134 auto linkSize = CalcTextSize( label );
1135
1136 auto basePos = ImVec2( window->DC.CursorPos.x,
1137 window->DC.CursorPos.y + window->DC.CurrLineTextBaseOffset );
1138 ImVec2 linkBbMaxPoint( basePos.x + linkSize.x, basePos.y + linkSize.y );
1139 ImRect linkRect( basePos, linkBbMaxPoint );
1140
1141 auto linkId = window->GetID( label );
1142 ItemAdd( linkRect, linkId );
1143 bool hovered, held;
1144 bool pressed = ButtonBehavior( linkRect, linkId, &hovered, &held );
1145
1146 if ( hovered )
1147 {
1148 SetMouseCursor( ImGuiMouseCursor_Hand );
1149 window->DrawList->AddLine( ImVec2( basePos.x, linkBbMaxPoint.y - 1.0f ),
1150 ImVec2( linkBbMaxPoint.x, linkBbMaxPoint.y - 1.0f ),
1151 color );
1152 }
1153
1154 PushStyleColor( ImGuiCol_Text, color );
1155 ImGui::Text( "%s", label );
1156 PopStyleColor();
1157
1158 return pressed;
1159}
1160
1161PaletteChanges Palette(
1162 const char* label,

Callers 1

drawApplicationTab_Method · 0.85

Calls 2

ImVec2Class · 0.85
TextClass · 0.85

Tested by

no test coverage detected