MCPcopy Create free account
hub / github.com/XorTroll/uLaunch / LoadEditableElement

Function LoadEditableElement

projects/uDesigner/source/main.cpp:1660–1730  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1658 }
1659
1660 void LoadEditableElement(Element *elem, const std::vector<Element*> &modifiable_elems = {}) {
1661 const auto has_settings = !elem->ui_name.empty();
1662 std::string name;
1663 if(has_settings) {
1664 name = elem->ui_name;
1665 if(elem->type == ul::design::ElementType::Image) {
1666 name += " (" + elem->load_ctx.img_path + ", " + std::to_string(elem->el_img.width) + "x" + std::to_string(elem->el_img.height) + ")";
1667 }
1668 }
1669 else {
1670 name = elem->load_ctx.img_path + ", " + std::to_string(elem->el_img.width) + "x" + std::to_string(elem->el_img.height);
1671 }
1672 const auto id_name = std::to_string(elem->id);
1673 if(ImGui::CollapsingHeader(name.c_str())) {
1674 ImGui::Indent();
1675 if(has_settings) {
1676 if(ImGui::InputInt(("X##inc" + id_name).c_str(), &elem->x) || ImGui::SliderInt(("X##sld" + id_name).c_str(), &elem->x, 0, ul::design::ScreenWidth)) {
1677 for(auto &mod_elem: modifiable_elems) {
1678 mod_elem->x = elem->x;
1679 }
1680 }
1681 if(ImGui::InputInt(("Y##inc" + id_name).c_str(), &elem->y) || ImGui::SliderInt(("Y##sld" + id_name).c_str(), &elem->y, 0, ul::design::ScreenHeight)) {
1682 for(auto &mod_elem: modifiable_elems) {
1683 mod_elem->y = elem->y;
1684 }
1685 }
1686 if(ImGui::Combo(("Horizontal align##" + id_name).c_str(), &elem->h_align, HorizontalAlignNames, std::size(HorizontalAlignNames))) {
1687 for(auto &mod_elem: modifiable_elems) {
1688 mod_elem->h_align = elem->h_align;
1689 }
1690 }
1691 if(ImGui::Combo(("Vertical align##" + id_name).c_str(), &elem->v_align, VerticalAlignNames, std::size(VerticalAlignNames))) {
1692 for(auto &mod_elem: modifiable_elems) {
1693 mod_elem->v_align = elem->v_align;
1694 }
1695 }
1696 }
1697 switch(elem->type) {
1698 case ul::design::ElementType::Image: {
1699 if(!elem->ImageIsBuiltin()) {
1700 if(ImGui::Button(("Change image##" + id_name).c_str())) {
1701 LoadElementImage(elem);
1702 }
1703 }
1704 break;
1705 }
1706 case ul::design::ElementType::Text: {
1707 ImGui::Combo(("Font size##" + id_name).c_str(), &elem->el_text.font_size, FontSizeNames, std::size(FontSizeNames));
1708 if(ImGui::InputInt(("Clamp width##inc" + id_name).c_str(), &elem->el_text.clamp_width) || ImGui::SliderInt(("Clamp width##sld" + id_name).c_str(), &elem->el_text.clamp_width, 0, ul::design::ScreenWidth)) {
1709 for(auto &mod_elem: modifiable_elems) {
1710 mod_elem->el_text.clamp_width = elem->el_text.clamp_width;
1711 }
1712 }
1713 if(ImGui::InputInt(("Clamp speed##inc" + id_name).c_str(), &elem->el_text.clamp_speed) || ImGui::SliderInt(("Clamp speed##sld" + id_name).c_str(), &elem->el_text.clamp_speed, 0, 500)) {
1714 for(auto &mod_elem: modifiable_elems) {
1715 mod_elem->el_text.clamp_speed = elem->el_text.clamp_speed;
1716 }
1717 }

Callers 1

MainLoopFunction · 0.85

Calls 2

LoadElementImageFunction · 0.85
ImageIsBuiltinMethod · 0.80

Tested by

no test coverage detected