MCPcopy Create free account
hub / github.com/BoomingTech/Piccolo / DrawVecControl

Function DrawVecControl

engine/source/editor/source/editor_ui.cpp:980–1034  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

978 void EditorUI::preRender() { showEditorUI(); }
979
980 void DrawVecControl(const std::string& label, Piccolo::Vector3& values, float resetValue, float columnWidth)
981 {
982 ImGui::PushID(label.c_str());
983
984 ImGui::Columns(2);
985 ImGui::SetColumnWidth(0, columnWidth);
986 ImGui::Text("%s", label.c_str());
987 ImGui::NextColumn();
988
989 ImGui::PushMultiItemsWidths(3, ImGui::CalcItemWidth());
990 ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2 {0, 0});
991
992 float lineHeight = GImGui->Font->FontSize + GImGui->Style.FramePadding.y * 2.0f;
993 ImVec2 buttonSize = {lineHeight + 3.0f, lineHeight};
994
995 ImGui::PushStyleColor(ImGuiCol_Button, ImVec4 {0.8f, 0.1f, 0.15f, 1.0f});
996 ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4 {0.9f, 0.2f, 0.2f, 1.0f});
997 ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4 {0.8f, 0.1f, 0.15f, 1.0f});
998 if (ImGui::Button("X", buttonSize))
999 values.x = resetValue;
1000 ImGui::PopStyleColor(3);
1001
1002 ImGui::SameLine();
1003 ImGui::DragFloat("##X", &values.x, 0.1f, 0.0f, 0.0f, "%.2f");
1004 ImGui::PopItemWidth();
1005 ImGui::SameLine();
1006
1007 ImGui::PushStyleColor(ImGuiCol_Button, ImVec4 {0.2f, 0.45f, 0.2f, 1.0f});
1008 ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4 {0.3f, 0.55f, 0.3f, 1.0f});
1009 ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4 {0.2f, 0.45f, 0.2f, 1.0f});
1010 if (ImGui::Button("Y", buttonSize))
1011 values.y = resetValue;
1012 ImGui::PopStyleColor(3);
1013
1014 ImGui::SameLine();
1015 ImGui::DragFloat("##Y", &values.y, 0.1f, 0.0f, 0.0f, "%.2f");
1016 ImGui::PopItemWidth();
1017 ImGui::SameLine();
1018
1019 ImGui::PushStyleColor(ImGuiCol_Button, ImVec4 {0.1f, 0.25f, 0.8f, 1.0f});
1020 ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4 {0.2f, 0.35f, 0.9f, 1.0f});
1021 ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4 {0.1f, 0.25f, 0.8f, 1.0f});
1022 if (ImGui::Button("Z", buttonSize))
1023 values.z = resetValue;
1024 ImGui::PopStyleColor(3);
1025
1026 ImGui::SameLine();
1027 ImGui::DragFloat("##Z", &values.z, 0.1f, 0.0f, 0.0f, "%.2f");
1028 ImGui::PopItemWidth();
1029
1030 ImGui::PopStyleVar();
1031
1032 ImGui::Columns(1);
1033 ImGui::PopID();
1034 }
1035
1036 void DrawVecControl(const std::string& label, Piccolo::Quaternion& values, float resetValue, float columnWidth)
1037 {

Callers 1

EditorUIMethod · 0.85

Calls 6

PushIDFunction · 0.85
ColumnsClass · 0.85
TextClass · 0.85
DragFloatFunction · 0.85
PopIDFunction · 0.85
c_strMethod · 0.45

Tested by

no test coverage detected