MCPcopy Create free account
hub / github.com/TheForceEngine/TheForceEngine / iconButtonInline

Function iconButtonInline

TheForceEngine/TFE_Editor/editor.cpp:195–228  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

193 }
194
195 bool iconButtonInline(IconId icon, const char* tooltip/*=nullptr*/, const f32* tint/*=nullptr*/, bool small/*=false*/)
196 {
197 void* gpuPtr = TFE_RenderBackend::getGpuPtr(s_iconAtlas);
198 const s32 x = s32(icon) & 7;
199 const s32 y = s32(icon) >> 3;
200
201 const f32 imageScale = 1.0f / 272.0f;
202 const f32 x0 = f32(x) * 34.0f + 1.0f;
203 const f32 x1 = x0 + 32.0f;
204 const f32 y0 = f32(y) * 34.0f + 1.0f;
205 const f32 y1 = y0 + 32.0f;
206 const ImVec4 tintColor = tint ? ImVec4(tint[0], tint[1], tint[2], tint[3]) : ImVec4(1.0f, 1.0f, 1.0f, 1.0f);
207 const ImVec4 tintColor2 = tint ? ImVec4(tint[0]*2.0f, tint[1]*2.0f, tint[2]*2.0f, tint[3]) : ImVec4(1.0f, 1.0f, 1.0f, 1.0f);
208 const ImVec4 bgColor = ImVec4(0, 0, 0, 0);
209
210 // A unique ID formed from: icon + instance*ICON_COUNT + ptr&0xffffffff
211 const s32 id = s_uid + s32(size_t(s_iconAtlas));
212 const ImVec2 size = small ? ImVec2(24, 24) : ImVec2(32, 32);
213 s_uid++;
214
215 ImGui::PushStyleColor(ImGuiCol_Button, { 0,0,0,0 });
216 ImGui::PushStyleColor(ImGuiCol_ButtonHovered, { 0,0,0,0 });
217 ImGui::PushStyleColor(ImGuiCol_ButtonActive, { 0,0,0,0 });
218 ImGui::SetCursorPosY(ImGui::GetCursorPosY() - 2.0f);
219
220 ImGui::PushID(id);
221 bool res = ImGui::ImageButtonDualTint(gpuPtr, size, ImVec2(x0*imageScale, y0*imageScale),
222 ImVec2(x1*imageScale, y1*imageScale), bgColor, tintColor, tintColor2);
223 if (tooltip) { setTooltip(tooltip); }
224 ImGui::PopID();
225 ImGui::PopStyleColor(3);
226
227 return res;
228 }
229
230 void sectionHeader(const char* text)
231 {

Callers 6

editor_infEditElevStopsFunction · 0.85
editor_infEditElevSlavesFunction · 0.85
editor_infEdit_UIFunction · 0.85
infoPanelMapFunction · 0.85

Calls 5

getGpuPtrFunction · 0.85
ImVec2Function · 0.85
ImageButtonDualTintFunction · 0.85
setTooltipFunction · 0.85
ImVec4Class · 0.70

Tested by

no test coverage detected