Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Data structure
- static float max_time = 10.0f;
- struct VEC2 { VEC2(float x, float y) : x(x), y(y) {} float x; float y; };
- struct VEC4 { VEC4(float x, float y, float z, float w) : x(x), y(y), z(z), w(w) {} float x; float y; float z; float w; };
- struct Widget {
- Widget(std::string name, VEC2 pos, VEC2 scale, VEC4 color) :
- name(name), pos(pos), scale(scale), color(color) {}
- std::string name;
- VEC2 pos;
- VEC2 scale;
- VEC4 color;
- };
- std::vector<Widget*> _widgets;
- Widget w1("Widget 1", VEC2(1.0f, 1.0f), VEC2(1.0f, 1.0f), VEC4(1.0, 0.0f, 0.0f, 1.0f));
- Widget w2("Widget 2", VEC2(2.0f, 2.0f), VEC2(2.0f, 2.0f), VEC4(0.0, 1.0f, 0.0f, 1.0f));
- _widgets.push_back(&w1);
- _widgets.push_back(&w2);
- struct Animation {
- bool isPosEditing;
- bool isScaleEditing;
- bool isColorEditing;
- };
- VEC2 test = { 5.0f, 5.0f };
- static VEC2 teststatic = { 3.0f, 3.0f };
- Animation a1;
- ImGuiColorEditFlags misc_flags = ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_AlphaPreview ;
- static bool show_columns = true;
- if (show_columns)
- {
- ImGui::Begin("Columns", &show_columns); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
- if (ImGui::TreeNode("Tree"))
- {
- ImGui::Columns(2, "tree", true);
- for (int x = 0; x < _widgets.size(); x++)
- {
- int ColorPickerID = 0;
- if (bool open1 = ImGui::TreeNode((void*)(intptr_t)x, _widgets[x]->name.c_str(), x))
- {
- ImGui::Text("Position");
- ImGui::NextColumn();
- ImGui::Text("");
- ImGui::DragFloat2("##Pos", test.x, 0.01f, 0.0f, 100.0f, "%.2f");
- ImGui::NextColumn();
- ImGui::Text("Scale");
- ImGui::NextColumn();
- ImGui::DragFloat2("##Scale", &_widgets[x]->scale.x, 0.01f, 0.0f, 100.0f, "%.2f");
- ImGui::NextColumn();
- ImGui::Text("Color");
- ImGui::NextColumn();
- float* curr_color = &_widgets[x]->color.x;
- std::string idtext = "Widget " + _widgets[x]->name + " color##" + std::to_string(ColorPickerID);
- ImGui::ColorEdit4("##ColorPicker", &_widgets[x]->color.x, misc_flags);
- ImGui::NextColumn();
- ImGui::TreePop();
- }
- }
- ImGui::Columns(1);
- ImGui::TreePop();
- }
- ImGui::End();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement