| 1173 | #endif |
| 1174 | |
| 1175 | bool ImGui::ImageButtonEx(ImGuiID id, ImTextureRef tex_ref, const ImVec2& image_size, const ImVec2& uv0, const ImVec2& uv1, const ImVec4& bg_col, const ImVec4& tint_col, ImGuiButtonFlags flags) |
| 1176 | { |
| 1177 | ImGuiContext& g = *GImGui; |
| 1178 | ImGuiWindow* window = GetCurrentWindow(); |
| 1179 | if (window->SkipItems) |
| 1180 | return false; |
| 1181 | |
| 1182 | const ImVec2 padding = g.Style.FramePadding; |
| 1183 | const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + image_size + padding * 2.0f); |
| 1184 | ItemSize(bb); |
| 1185 | if (!ItemAdd(bb, id)) |
| 1186 | return false; |
| 1187 | |
| 1188 | bool hovered, held; |
| 1189 | bool pressed = ButtonBehavior(bb, id, &hovered, &held, flags); |
| 1190 | |
| 1191 | // Render |
| 1192 | const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button); |
| 1193 | RenderNavCursor(bb, id); |
| 1194 | RenderFrame(bb.Min, bb.Max, col, true, g.Style.FrameRounding); |
| 1195 | if (bg_col.w > 0.0f) |
| 1196 | window->DrawList->AddRectFilled(bb.Min + padding, bb.Max - padding, GetColorU32(bg_col)); |
| 1197 | float image_rounding = ImMax(g.Style.FrameRounding - ImMax(padding.x, padding.y), g.Style.ImageRounding); |
| 1198 | if (image_rounding > 0.0f) |
| 1199 | window->DrawList->AddImageRounded(tex_ref, bb.Min + padding, bb.Max - padding, uv0, uv1, GetColorU32(tint_col), image_rounding); |
| 1200 | else |
| 1201 | window->DrawList->AddImage(tex_ref, bb.Min + padding, bb.Max - padding, uv0, uv1, GetColorU32(tint_col)); |
| 1202 | |
| 1203 | return pressed; |
| 1204 | } |
| 1205 | |
| 1206 | // - ImageButton() adds style.FramePadding*2.0f to provided size. This is in order to facilitate fitting an image in a button. |
| 1207 | // - ImageButton() draws a background based on regular Button() color + optionally an inner background if specified. (#8165) // FIXME: Maybe that's not the best design? |
nothing calls this directly
no test coverage detected