| 164 | } |
| 165 | |
| 166 | bool iconButton(IconId icon, const char* tooltip/*=nullptr*/, bool highlight/*=false*/, const f32* tint/*=nullptr*/) |
| 167 | { |
| 168 | void* gpuPtr = TFE_RenderBackend::getGpuPtr(s_iconAtlas); |
| 169 | const s32 x = s32(icon) & 7; |
| 170 | const s32 y = s32(icon) >> 3; |
| 171 | |
| 172 | const f32 imageScale = 1.0f / 272.0f; |
| 173 | const f32 x0 = f32(x) * 34.0f + 1.0f; |
| 174 | const f32 x1 = x0 + 32.0f; |
| 175 | const f32 y0 = f32(y) * 34.0f + 1.0f; |
| 176 | const f32 y1 = y0 + 32.0f; |
| 177 | const ImVec4 tintColor = tint ? ImVec4(tint[0], tint[1], tint[2], tint[3]) : ImVec4(1.0f, 1.0f, 1.0f, 1.0f); |
| 178 | const ImVec4 bgColor = ImVec4(0, 0, 0, highlight ? 0.75f : 0.25f); |
| 179 | const s32 padding = 1; |
| 180 | |
| 181 | // A unique ID formed from: icon + instance*ICON_COUNT + ptr&0xffffffff |
| 182 | const s32 id = s_uid + s32(size_t(s_iconAtlas)); |
| 183 | const ImVec2 size = ImVec2(32, 32); |
| 184 | s_uid++; |
| 185 | |
| 186 | ImGui::PushID(id); |
| 187 | bool res = ImGui::ImageButton(gpuPtr, size, ImVec2(x0*imageScale, y0*imageScale), |
| 188 | ImVec2(x1*imageScale, y1*imageScale), padding, bgColor, tintColor); |
| 189 | if (tooltip) { setTooltip(tooltip); } |
| 190 | ImGui::PopID(); |
| 191 | |
| 192 | return res; |
| 193 | } |
| 194 | |
| 195 | bool iconButtonInline(IconId icon, const char* tooltip/*=nullptr*/, const f32* tint/*=nullptr*/, bool small/*=false*/) |
| 196 | { |
no test coverage detected