Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.00 KB | None | 0 0
  1. // Data structure
  2. static float max_time = 10.0f;
  3. struct VEC2 { VEC2(float x, float y) : x(x), y(y) {} float x; float y; };
  4. 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; };
  5.  
  6. struct Widget {
  7. Widget(std::string name, VEC2 pos, VEC2 scale, VEC4 color) :
  8. name(name), pos(pos), scale(scale), color(color) {}
  9. std::string name;
  10. VEC2 pos;
  11. VEC2 scale;
  12. VEC4 color;
  13. };
  14. std::vector<Widget*> _widgets;
  15.  
  16. Widget w1("Widget 1", VEC2(1.0f, 1.0f), VEC2(1.0f, 1.0f), VEC4(1.0, 0.0f, 0.0f, 1.0f));
  17. Widget w2("Widget 2", VEC2(2.0f, 2.0f), VEC2(2.0f, 2.0f), VEC4(0.0, 1.0f, 0.0f, 1.0f));
  18.  
  19. _widgets.push_back(&w1);
  20. _widgets.push_back(&w2);
  21.  
  22. struct Animation {
  23. bool isPosEditing;
  24. bool isScaleEditing;
  25. bool isColorEditing;
  26. };
  27.  
  28. VEC2 test = { 5.0f, 5.0f };
  29. static VEC2 teststatic = { 3.0f, 3.0f };
  30.  
  31. Animation a1;
  32.  
  33. ImGuiColorEditFlags misc_flags = ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_AlphaPreview ;
  34.  
  35. static bool show_columns = true;
  36. if (show_columns)
  37. {
  38. 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)
  39. if (ImGui::TreeNode("Tree"))
  40. {
  41. ImGui::Columns(2, "tree", true);
  42. for (int x = 0; x < _widgets.size(); x++)
  43. {
  44. int ColorPickerID = 0;
  45. if (bool open1 = ImGui::TreeNode((void*)(intptr_t)x, _widgets[x]->name.c_str(), x))
  46. {
  47. ImGui::Text("Position");
  48.  
  49. ImGui::NextColumn();
  50. ImGui::Text("");
  51. ImGui::DragFloat2("##Pos", test.x, 0.01f, 0.0f, 100.0f, "%.2f");
  52.  
  53. ImGui::NextColumn();
  54. ImGui::Text("Scale");
  55.  
  56. ImGui::NextColumn();
  57. ImGui::DragFloat2("##Scale", &_widgets[x]->scale.x, 0.01f, 0.0f, 100.0f, "%.2f");
  58.  
  59. ImGui::NextColumn();
  60. ImGui::Text("Color");
  61.  
  62. ImGui::NextColumn();
  63. float* curr_color = &_widgets[x]->color.x;
  64. std::string idtext = "Widget " + _widgets[x]->name + " color##" + std::to_string(ColorPickerID);
  65. ImGui::ColorEdit4("##ColorPicker", &_widgets[x]->color.x, misc_flags);
  66.  
  67. ImGui::NextColumn();
  68.  
  69. ImGui::TreePop();
  70. }
  71. }
  72. ImGui::Columns(1);
  73. ImGui::TreePop();
  74. }
  75. ImGui::End();
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement