| 1470 | } |
| 1471 | |
| 1472 | bool AlienImGui::ToggleButton(ToggleButtonParameters const& parameters, bool& value) |
| 1473 | { |
| 1474 | auto origValue = value; |
| 1475 | ImVec4* colors = ImGui::GetStyle().Colors; |
| 1476 | ImVec2 p = ImGui::GetCursorScreenPos(); |
| 1477 | ImDrawList* drawList = ImGui::GetWindowDrawList(); |
| 1478 | |
| 1479 | float height = ImGui::GetFrameHeight(); |
| 1480 | float width = height * 1.55f; |
| 1481 | float radius = height * 0.50f*0.8f; |
| 1482 | height = height * 0.8f; |
| 1483 | |
| 1484 | ImGui::InvisibleButton(parameters._name.c_str(), ImVec2(width, height)); |
| 1485 | if (ImGui::IsItemClicked()) { |
| 1486 | value = !value; |
| 1487 | } |
| 1488 | |
| 1489 | auto color = Const::ToggleColor; |
| 1490 | float h, s, v; |
| 1491 | ImGui::ColorConvertRGBtoHSV(color.Value.x, color.Value.y, color.Value.z, h, s, v); |
| 1492 | |
| 1493 | if (ImGui::IsItemHovered()) { |
| 1494 | drawList->AddRectFilled( |
| 1495 | p, |
| 1496 | ImVec2(p.x + width, p.y + height), |
| 1497 | ImGui::GetColorU32(value ? (ImU32)ImColor::HSV(h, s * 0.9f, v * 0.8f) : (ImU32)ImColor::HSV(h, s * 0.9f, v * 0.4f)), |
| 1498 | height * 0.5f); |
| 1499 | } else { |
| 1500 | drawList->AddRectFilled( |
| 1501 | p, |
| 1502 | ImVec2(p.x + width, p.y + height), |
| 1503 | ImGui::GetColorU32(value ? (ImU32)ImColor::HSV(h, s * 0.6f, v * 0.7f) : (ImU32)ImColor::HSV(h, s * 0.6f, v * 0.3f)), |
| 1504 | height * 0.50f); |
| 1505 | } |
| 1506 | drawList->AddCircleFilled(ImVec2(p.x + radius + (value ? 1 : 0) * (width - radius * 2.0f), p.y + radius), radius - 1.5f, IM_COL32(20, 20, 20, 255)); |
| 1507 | drawList->AddCircleFilled(ImVec2(p.x + radius + (value ? 1 : 0) * (width - radius * 2.0f), p.y + radius), radius - 2.5f, IM_COL32(255, 255, 255, 255)); |
| 1508 | |
| 1509 | ImGui::SameLine(); |
| 1510 | AlienImGui::Text(parameters._name.c_str()); |
| 1511 | if (parameters._tooltip) { |
| 1512 | AlienImGui::HelpMarker(*parameters._tooltip); |
| 1513 | } |
| 1514 | |
| 1515 | return value != origValue; |
| 1516 | } |
| 1517 | |
| 1518 | bool AlienImGui::ShowPreviewDescription(PreviewDescription const& desc, float& zoom, std::optional<int>& selectedNode) |
| 1519 | { |