From 153aee5040133f38a5aa26a32ca2edd304773862 Mon Sep 17 00:00:00 2001 From: Aloshi Date: Tue, 24 Sep 2013 14:44:18 -0500 Subject: [PATCH] Use RatingComponent in the metadata editor. --- src/MetaData.cpp | 12 ++++++++++++ src/components/RatingComponent.cpp | 13 +++++++++++++ src/components/RatingComponent.h | 1 + 3 files changed, 26 insertions(+) diff --git a/src/MetaData.cpp b/src/MetaData.cpp index d8870f81e..c966364e8 100644 --- a/src/MetaData.cpp +++ b/src/MetaData.cpp @@ -1,7 +1,9 @@ #include "MetaData.h" #include "components/TextComponent.h" #include "Log.h" + #include "components/TextEditComponent.h" +#include "components/RatingComponent.h" MetaDataList::MetaDataList() { @@ -98,6 +100,11 @@ GuiComponent* MetaDataList::makeDisplay(Window* window, MetaDataType as) { switch(as) { + case MD_RATING: + { + RatingComponent* comp = new RatingComponent(window); + return comp; + } default: TextComponent* comp = new TextComponent(window); return comp; @@ -108,6 +115,11 @@ GuiComponent* MetaDataList::makeEditor(Window* window, MetaDataType as) { switch(as) { + case MD_RATING: + { + RatingComponent* comp = new RatingComponent(window); + return comp; + } case MD_MULTILINE_STRING: { TextEditComponent* comp = new TextEditComponent(window); diff --git a/src/components/RatingComponent.cpp b/src/components/RatingComponent.cpp index 01dd40b03..63ce05a4a 100644 --- a/src/components/RatingComponent.cpp +++ b/src/components/RatingComponent.cpp @@ -92,3 +92,16 @@ void RatingComponent::render(const Eigen::Affine3f& parentTrans) renderChildren(trans); } +bool RatingComponent::input(InputConfig* config, Input input) +{ + if(config->isMappedTo("a", input) && input.value != 0) + { + mValue += 0.2f; + if(mValue > 1.0f) + mValue = 0.0f; + + updateVertices(); + } + + return GuiComponent::input(config, input); +} diff --git a/src/components/RatingComponent.h b/src/components/RatingComponent.h index 041f1d98b..bf2ce2071 100644 --- a/src/components/RatingComponent.h +++ b/src/components/RatingComponent.h @@ -11,6 +11,7 @@ public: std::string getValue() const override; void setValue(const std::string& value) override; + bool input(InputConfig* config, Input input) override; void render(const Eigen::Affine3f& parentTrans); void onSizeChanged() override;