Blame view

epsilon-master/apps/sequence/values/interval_parameter_controller.cpp 1.1 KB
6663b6c9   adorian   projet complet av...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
  #include "interval_parameter_controller.h"
  #include <cmath>
  
  using namespace Shared;
  
  namespace Sequence {
  
  IntervalParameterController::IntervalParameterController(Responder * parentResponder, Interval * interval) :
    Shared::IntervalParameterController(parentResponder, interval)
  {
  }
  
  void IntervalParameterController::willDisplayCellForIndex(HighlightCell * cell, int index) {
    if (index == numberOfRows()-1) {
      return;
    }
    MessageTableCellWithEditableText * myCell = (MessageTableCellWithEditableText *)cell;
    I18n::Message labels[k_totalNumberOfCell] = {I18n::Message::NStart, I18n::Message::NEnd, I18n::Message::Step};
    myCell->setMessage(labels[index]);
    FloatParameterController::willDisplayCellForIndex(cell, index);
  }
  
  bool IntervalParameterController::setParameterAtIndex(int parameterIndex, double f) {
    if (f < 0) {
      app()->displayWarning(I18n::Message::ForbiddenValue);
      return false;
    }
    double parameter = std::round(f);
    if (parameterIndex == 2 && parameter == 0.0f) {
      parameter = 1.0f;
    }
    return Shared::IntervalParameterController::setParameterAtIndex(parameterIndex, parameter);
  }
  
  }