| 1110 | #endif |
| 1111 | |
| 1112 | bool ImGui::ImageButtonEx(ImGuiID id, ImTextureID user_texture_id, const ImVec2& image_size, const ImVec2& uv0, const ImVec2& uv1, const ImVec4& bg_col, const ImVec4& tint_col, ImGuiButtonFlags flags) |
| 1113 | { |
| 1114 | ImGuiContext& g = *GImGui; |
| 1115 | ImGuiWindow* window = GetCurrentWindow(); |
| 1116 | if (window->SkipItems) |
| 1117 | return false; |
| 1118 | |
| 1119 | const ImVec2 padding = g.Style.FramePadding; |
| 1120 | const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + image_size + padding * 2.0f); |
| 1121 | ItemSize(bb); |
| 1122 | if (!ItemAdd(bb, id)) |
| 1123 | return false; |
| 1124 | |
| 1125 | bool hovered, held; |
| 1126 | bool pressed = ButtonBehavior(bb, id, &hovered, &held, flags); |
| 1127 | |
| 1128 | // Render |
| 1129 | const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button); |
| 1130 | RenderNavCursor(bb, id); |
| 1131 | RenderFrame(bb.Min, bb.Max, col, true, ImClamp((float)ImMin(padding.x, padding.y), 0.0f, g.Style.FrameRounding)); |
| 1132 | if (bg_col.w > 0.0f) |
| 1133 | window->DrawList->AddRectFilled(bb.Min + padding, bb.Max - padding, GetColorU32(bg_col)); |
| 1134 | window->DrawList->AddImage(user_texture_id, bb.Min + padding, bb.Max - padding, uv0, uv1, GetColorU32(tint_col)); |
| 1135 | |
| 1136 | return pressed; |
| 1137 | } |
| 1138 | |
| 1139 | // - ImageButton() adds style.FramePadding*2.0f to provided size. This is in order to facilitate fitting an image in a button. |
| 1140 | // - 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