diff --git a/src/graphics/core/Batch2D.cpp b/src/graphics/core/Batch2D.cpp index 38224a3f..19dfb7c4 100644 --- a/src/graphics/core/Batch2D.cpp +++ b/src/graphics/core/Batch2D.cpp @@ -333,6 +333,15 @@ void Batch2D::rect( vertex(v1, glm::vec2(0, 0), r2,g2,b2,1.0f); } +void Batch2D::triangle(float x1, float y1, float x2, float y2, float x3, float y3) { + if (index + 3 >= capacity) { + flush(); + } + vertex({x1, y1}, {x1, y1}, color.r, color.g, color.b, color.a); + vertex({x2, y2}, {x2, y2}, color.r, color.g, color.b, color.a); + vertex({x3, y3}, {x3, y3}, color.r, color.g, color.b, color.a); +} + void Batch2D::sprite(float x, float y, float w, float h, const UVRegion& region, glm::vec4 tint){ rect(x, y, w, h, region.u1, region.v1, region.u2-region.u1, region.v2-region.v1, tint.r, tint.g, tint.b, tint.a); } diff --git a/src/graphics/core/Batch2D.hpp b/src/graphics/core/Batch2D.hpp index 6f29a1df..ec181a6f 100644 --- a/src/graphics/core/Batch2D.hpp +++ b/src/graphics/core/Batch2D.hpp @@ -117,6 +117,8 @@ public: float r4, float g4, float b4, int sh ); + void triangle(float x1, float y1, float x2, float y2, float x3, float y3); + void flush() override; void lineWidth(float width); diff --git a/src/graphics/ui/elements/SelectBox.cpp b/src/graphics/ui/elements/SelectBox.cpp index 103c432e..828a5a8a 100644 --- a/src/graphics/ui/elements/SelectBox.cpp +++ b/src/graphics/ui/elements/SelectBox.cpp @@ -1,6 +1,11 @@ #include "SelectBox.hpp" #include "Label.hpp" +#include "assets/Assets.hpp" +#include "graphics/ui/GUI.hpp" +#include "graphics/ui/elements/Panel.hpp" +#include "graphics/core/Batch2D.hpp" +#include "graphics/core/DrawContext.hpp" using namespace gui; @@ -13,4 +18,43 @@ SelectBox::SelectBox( ) : Button(gui, selected.text, padding, nullptr, glm::vec2(contentWidth, -1)), elements(std::move(elements)) { + + listenAction([this](GUI& gui) { + auto panel = std::make_shared(gui, getSize()); + panel->setPos(calcPos() + glm::vec2(0, size.y)); + for (const auto& option : this->elements) { + auto button = std::make_shared