Browse Source

Add Param::description and tooltip description

tags/v1.0.0
Andrew Belt 6 years ago
parent
commit
25735a8fd3
2 changed files with 13 additions and 1 deletions
  1. +1
    -0
      include/engine/Param.hpp
  2. +12
    -1
      src/app/ParamWidget.cpp

+ 1
- 0
include/engine/Param.hpp View File

@@ -18,6 +18,7 @@ struct Param {
float displayMultiplier = 1.f;
std::string label;
std::string unit;
std::string description;

void setup(float minValue, float maxValue, float defaultValue, std::string label = "", std::string unit = "", float displayBase = 0.f, float displayMultiplier = 1.f) {
this->value = defaultValue;


+ 12
- 1
src/app/ParamWidget.cpp View File

@@ -2,6 +2,7 @@
#include "ui/MenuOverlay.hpp"
#include "ui/TextField.hpp"
#include "app/Scene.hpp"
#include "app/ParamQuantity.hpp"
#include "context.hpp"
#include "settings.hpp"
#include "random.hpp"
@@ -64,8 +65,18 @@ void ParamWidget::step() {
}

if (tooltip) {
if (quantity)
// Quantity string
if (quantity) {
tooltip->text = quantity->getString();
}
// Param description
ParamQuantity *paramQuantity = dynamic_cast<ParamQuantity*>(quantity);
if (paramQuantity) {
std::string description = paramQuantity->getParam()->description;
if (!description.empty())
tooltip->text += "\n" + description;
}
// Position at bottom-right of parameter
tooltip->box.pos = getAbsoluteOffset(box.size).round();
}



Loading…
Cancel
Save