From fc96849f08e3f54abcb1385100aad9beee31c4da Mon Sep 17 00:00:00 2001 From: Aloshi Date: Sun, 27 Apr 2014 22:03:55 -0500 Subject: [PATCH] Fixed input not getting passed to DateTimeComponents in GuiMetaDataEd. Fixed vertex rounding for RatingComponent. Rating no longer "wiggles" as you change the value in GuiMetaDataEd. --- src/components/RatingComponent.cpp | 9 +++------ src/guis/GuiMetaDataEd.cpp | 13 ++++++++++++- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/components/RatingComponent.cpp b/src/components/RatingComponent.cpp index 980a4f3d2..df77bb642 100644 --- a/src/components/RatingComponent.cpp +++ b/src/components/RatingComponent.cpp @@ -60,9 +60,9 @@ void RatingComponent::updateVertices() { const float numStars = NUM_RATING_STARS; - const float h = getSize().y(); // is the same as a single star's width - const float w = h * mValue * numStars; - const float fw = h * numStars; + const float h = round(getSize().y()); // is the same as a single star's width + const float w = round(h * mValue * numStars); + const float fw = round(h * numStars); mVertices[0].pos << 0.0f, 0.0f; mVertices[0].tex << 0.0f, 1.0f; @@ -85,9 +85,6 @@ void RatingComponent::updateVertices() mVertices[10].pos << fw, 0.0f; mVertices[10].tex << numStars, 1.0f; mVertices[11] = mVertices[7]; - - for(int i = 0; i < 12; i++) - mVertices[i].pos = roundVector(mVertices[i].pos); } void RatingComponent::render(const Eigen::Affine3f& parentTrans) diff --git a/src/guis/GuiMetaDataEd.cpp b/src/guis/GuiMetaDataEd.cpp index 331dda0f2..ea2977b89 100644 --- a/src/guis/GuiMetaDataEd.cpp +++ b/src/guis/GuiMetaDataEd.cpp @@ -62,8 +62,16 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, MetaDataList* md, const std::vector { ed = std::make_shared(window); const float height = lbl->getSize().y() * 0.71f; - ed->setSize(height * 4.9f, height); + ed->setSize(0, height); row.addElement(ed, false, true); + + auto spacer = std::make_shared(mWindow); + spacer->setSize(Renderer::getScreenWidth() * 0.0025f, 0); + row.addElement(spacer, false); + + // pass input to the actual RatingComponent instead of the spacer + row.input_handler = std::bind(&GuiComponent::input, ed.get(), std::placeholders::_1, std::placeholders::_2); + break; } case MD_DATE: @@ -75,6 +83,9 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, MetaDataList* md, const std::vector spacer->setSize(Renderer::getScreenWidth() * 0.0025f, 0); row.addElement(spacer, false); + // pass input to the actual DateTimeComponent instead of the spacer + row.input_handler = std::bind(&GuiComponent::input, ed.get(), std::placeholders::_1, std::placeholders::_2); + break; } case MD_TIME: