| 1125 | } |
| 1126 | |
| 1127 | bool 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 | |
| 1161 | PaletteChanges Palette( |
| 1162 | const char* label, |
no test coverage detected