Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "toonzqt/intfield.h"
Toshihiro Shimizu 890ddd
#include "toonzqt/dvdialog.h"
Toshihiro Shimizu 890ddd
#include "toonzqt/gutil.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include <qintvalidator></qintvalidator>
Toshihiro Shimizu 890ddd
#include <qslider></qslider>
Toshihiro Shimizu 890ddd
#include <qhboxlayout></qhboxlayout>
Toshihiro Shimizu 890ddd
#include <qaction></qaction>
Toshihiro Shimizu 890ddd
#include <qfocusevent></qfocusevent>
Toshihiro Shimizu 890ddd
#include <qpainter></qpainter>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
using namespace DVGui;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
// RollerField
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
RollerField::RollerField(QWidget *parent)
Shinya Kitaoka 120a6e
    : QWidget(parent)
Shinya Kitaoka 120a6e
    , m_value(0)
Shinya Kitaoka 120a6e
    , m_minValue(-100000.0)
Shinya Kitaoka 120a6e
    , m_maxValue(100000.0)
Shinya Kitaoka 120a6e
    , m_xPos(0)
Shinya Kitaoka 120a6e
    , m_step(1.0) {
Shinya Kitaoka 120a6e
  setMinimumSize(43, 7);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void RollerField::setValue(double value) {
Shinya Kitaoka 120a6e
  if (m_value == value) return;
Shinya Kitaoka 120a6e
  if (value < m_minValue) m_value = m_minValue;
Shinya Kitaoka 120a6e
  if (value > m_maxValue) m_value = m_maxValue;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_value = value;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
double RollerField::getValue() const { return m_value; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void RollerField::setRange(double minValue, double maxValue) {
Shinya Kitaoka 120a6e
  m_minValue = minValue;
Shinya Kitaoka 120a6e
  m_maxValue = maxValue;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void RollerField::getRange(double &minValue, double &maxValue) {
Shinya Kitaoka 120a6e
  minValue = m_minValue;
Shinya Kitaoka 120a6e
  maxValue = m_maxValue;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void RollerField::paintEvent(QPaintEvent *e) {
Shinya Kitaoka 120a6e
  QPainter p(this);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  int w = width();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  drawArrow(p, QPointF(3, 3), QPointF(5, 5), QPointF(5, 1), true, Qt::black,
Shinya Kitaoka 120a6e
            Qt::black);
Shinya Kitaoka 120a6e
  drawArrow(p, QPointF(w - 4, 3), QPointF(w - 6, 5), QPointF(w - 6, 1), true,
Shinya Kitaoka 120a6e
            Qt::black, Qt::black);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  p.drawLine(QPoint(3, 3), QPoint(w - 4, 3));
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void RollerField::mousePressEvent(QMouseEvent *e) {
Shinya Kitaoka 120a6e
  if (e->buttons() == Qt::LeftButton) {
Shinya Kitaoka 120a6e
    m_xPos = e->pos().x();
Shinya Kitaoka 120a6e
    e->accept();
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void RollerField::mouseMoveEvent(QMouseEvent *e) {
Shinya Kitaoka 120a6e
  if (e->buttons() == Qt::LeftButton) {
Shinya Kitaoka 120a6e
    if (m_xPos < e->pos().x())
Shinya Kitaoka 120a6e
      addValue(true);
Shinya Kitaoka 120a6e
    else if (m_xPos > e->pos().x())
Shinya Kitaoka 120a6e
      removeValue(true);
Shinya Kitaoka 120a6e
    m_xPos = e->pos().x();
Shinya Kitaoka 120a6e
    e->accept();
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void RollerField::mouseReleaseEvent(QMouseEvent *e) {
Shinya Kitaoka 120a6e
  e->accept();
Shinya Kitaoka 120a6e
  emit valueChanged(false);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void RollerField::addValue(bool isDragging) {
Shinya Kitaoka 120a6e
  double newValue = tcrop(m_value + m_step, m_minValue, m_maxValue);
Shinya Kitaoka 120a6e
  if (newValue == m_value) return;
Shinya Kitaoka 120a6e
  m_value = newValue;
Shinya Kitaoka 120a6e
  emit valueChanged(isDragging);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void RollerField::removeValue(bool isDragging) {
Shinya Kitaoka 120a6e
  double newValue = tcrop(m_value - m_step, m_minValue, m_maxValue);
Shinya Kitaoka 120a6e
  if (newValue == m_value) return;
Shinya Kitaoka 120a6e
  m_value = newValue;
Shinya Kitaoka 120a6e
  emit valueChanged(isDragging);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
// IntLineEdit
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
IntLineEdit::IntLineEdit(QWidget *parent, int value, int minValue, int maxValue,
Shinya Kitaoka 120a6e
                         int showedDigits)
Shinya Kitaoka 120a6e
    : LineEdit(parent), m_showedDigits(showedDigits) {
Shinya Kitaoka 120a6e
  setFixedWidth(54);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_validator = new QIntValidator(this);
Shinya Kitaoka 120a6e
  setValue(value);
Shinya Kitaoka 120a6e
  setRange(minValue, maxValue);
Shinya Kitaoka 120a6e
  setValidator(m_validator);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void IntLineEdit::setValue(int value) {
Shinya Kitaoka 120a6e
  int minValue, maxValue;
Shinya Kitaoka 120a6e
  getRange(minValue, maxValue);
Shinya Kitaoka 120a6e
  if (value < minValue) value = minValue;
Shinya Kitaoka 120a6e
  if (value > maxValue) value = maxValue;
Shinya Kitaoka 120a6e
  QString str;
Shinya Kitaoka 120a6e
  str.setNum(value);
Shinya Kitaoka 120a6e
  if (m_showedDigits > 0) {
Shinya Kitaoka 120a6e
    while (str.length() < m_showedDigits) str.push_front("0");
Shinya Kitaoka 120a6e
    while (str.length() > m_showedDigits) str.remove(0, 1);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  setText(str);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  // Faccio in modo che il cursore sia sulla prima cifra, cosi' se la stringa da
Shinya Kitaoka 120a6e
  // visualizzare
Shinya Kitaoka 120a6e
  // e' piu' lunga del campo le cifre che vengono troncate sono le ultime e non
Shinya Kitaoka 120a6e
  // le prime.
Shinya Kitaoka 120a6e
  setCursorPosition(0);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
int IntLineEdit::getValue() { return text().toInt(); }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void IntLineEdit::setRange(int minValue, int maxValue) {
Shinya Kitaoka 120a6e
  m_validator->setRange(minValue, maxValue);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void IntLineEdit::getRange(int &minValue, int &maxValue) {
Shinya Kitaoka 120a6e
  minValue = m_validator->bottom();
Shinya Kitaoka 120a6e
  maxValue = m_validator->top();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void IntLineEdit::setBottomRange(int minValue) {
Shinya Kitaoka 120a6e
  m_validator->setBottom(minValue);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void IntLineEdit::setTopRange(int maxValue) { m_validator->setTop(maxValue); }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void IntLineEdit::focusOutEvent(QFocusEvent *e) {
Shinya Kitaoka 120a6e
  int value = getValue();
Shinya Kitaoka 120a6e
  int minValue, maxValue;
Shinya Kitaoka 120a6e
  getRange(minValue, maxValue);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  if (e->lostFocus()) setValue(value);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  QLineEdit::focusOutEvent(e);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// for fps edit in flip console
Shinya Kitaoka 120a6e
void IntLineEdit::setLineEditBackgroundColor(QColor color) {
Shinya Kitaoka 120a6e
  QString sheet = QString("background-color: rgb(") +
Shinya Kitaoka 120a6e
                  QString::number(color.red()) + QString(",") +
Shinya Kitaoka 120a6e
                  QString::number(color.green()) + QString(",") +
Shinya Kitaoka 120a6e
                  QString::number(color.blue()) + QString(",") +
Shinya Kitaoka 120a6e
                  QString::number(color.alpha()) + QString(");");
Shinya Kitaoka 120a6e
  setStyleSheet(sheet);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
// IntField
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
IntField::IntField(QWidget *parent, bool isMaxRangeLimited, bool isRollerHide)
Shinya Kitaoka 120a6e
    : QWidget(parent)
Shinya Kitaoka 120a6e
    , m_lineEdit(0)
Shinya Kitaoka 120a6e
    , m_slider(0)
Shinya Kitaoka 120a6e
    , m_roller(0)
Shinya Kitaoka 120a6e
    , m_isMaxRangeLimited(isMaxRangeLimited) {
Shinya Kitaoka 120a6e
  setObjectName("IntField");
Shinya Kitaoka 120a6e
  QHBoxLayout *layout = new QHBoxLayout(this);
Shinya Kitaoka 120a6e
  layout->setMargin(0);
Shinya Kitaoka 120a6e
  layout->setSpacing(5);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  QWidget *field = new QWidget(this);
Shinya Kitaoka 120a6e
  field->setMaximumWidth(43);
Shinya Kitaoka 120a6e
  QVBoxLayout *vLayout = new QVBoxLayout(field);
Shinya Kitaoka 120a6e
  vLayout->setMargin(0);
Shinya Kitaoka 120a6e
  vLayout->setSpacing(0);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_lineEdit = new DVGui::IntLineEdit(field);
Shinya Kitaoka 120a6e
  bool ret   = connect(m_lineEdit, SIGNAL(editingFinished()), this,
Shinya Kitaoka 120a6e
                     SLOT(onEditingFinished()));
Shinya Kitaoka 120a6e
  vLayout->addWidget(m_lineEdit);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_roller = new RollerField(field);
Shinya Kitaoka 120a6e
  ret      = ret && connect(m_roller, SIGNAL(valueChanged(bool)), this,
Shinya Kitaoka 120a6e
                       SLOT(onRollerValueChanged(bool)));
Shinya Kitaoka 120a6e
  vLayout->addWidget(m_roller);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  if (isRollerHide) enableRoller(false);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  layout->addWidget(field);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_slider = new QSlider(Qt::Horizontal, this);
Shinya Kitaoka 120a6e
  ret      = ret && connect(m_slider, SIGNAL(valueChanged(int)), this,
Shinya Kitaoka 120a6e
                       SLOT(onSliderChanged(int)));
Shinya Kitaoka 120a6e
  ret = ret && connect(m_slider, SIGNAL(sliderReleased()), this,
Shinya Kitaoka 120a6e
                       SLOT(onSliderReleased()));
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  ret = ret && connect(m_lineEdit, SIGNAL(editingFinished()), this,
Shinya Kitaoka 120a6e
                       SIGNAL(valueEditedByHand()));
Shinya Kitaoka 120a6e
  ret = ret && connect(m_slider, SIGNAL(sliderReleased()), this,
Shinya Kitaoka 120a6e
                       SIGNAL(valueEditedByHand()));
Shinya Kitaoka 120a6e
  layout->addWidget(m_slider);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  setValues(0, 0, 100);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  setLayout(layout);
Shinya Kitaoka 120a6e
  assert(ret);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void IntField::getRange(int &minValue, int &maxValue) {
Shinya Kitaoka 120a6e
  double min, max;
Shinya Kitaoka 120a6e
  m_roller->getRange(min, max);
Shinya Kitaoka 120a6e
  minValue = tround(min);
Shinya Kitaoka 120a6e
  maxValue = tround(max);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void IntField::setRange(int minValue, int maxValue) {
Shinya Kitaoka 120a6e
  m_lineEdit->setRange(minValue, m_isMaxRangeLimited
Shinya Kitaoka 120a6e
                                     ? maxValue
Shinya Kitaoka 120a6e
                                     : (std::numeric_limits<int>::max)());</int>
Shinya Kitaoka 120a6e
  m_slider->setRange(minValue, maxValue);
Shinya Kitaoka 120a6e
  m_roller->setRange(minValue, maxValue);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void IntField::setValue(int value) {
Shinya Kitaoka 120a6e
  if (m_lineEdit->getValue() == value) return;
Shinya Kitaoka 120a6e
  m_lineEdit->setValue(value);
Shinya Kitaoka 120a6e
  m_slider->setSliderPosition(value);
Shinya Kitaoka 120a6e
  m_roller->setValue((double)value);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
int IntField::getValue() { return (m_lineEdit->getValue()); }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void IntField::setValues(int value, int minValue, int maxValue) {
Shinya Kitaoka 120a6e
  setRange(minValue, maxValue);
Shinya Kitaoka 120a6e
  setValue(value);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void IntField::enableSlider(bool enable) {
Shinya Kitaoka 120a6e
  m_slider->setEnabled(enable);
Shinya Kitaoka 120a6e
  if (enable)
Shinya Kitaoka 120a6e
    m_slider->show();
Shinya Kitaoka 120a6e
  else
Shinya Kitaoka 120a6e
    m_slider->hide();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
bool IntField::sliderIsEnabled() { return m_slider->isEnabled(); }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void IntField::enableRoller(bool enable) {
Shinya Kitaoka 120a6e
  m_roller->setEnabled(enable);
Shinya Kitaoka 120a6e
  if (enable)
Shinya Kitaoka 120a6e
    m_roller->show();
Shinya Kitaoka 120a6e
  else
Shinya Kitaoka 120a6e
    m_roller->hide();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
bool IntField::rollerIsEnabled() { return m_roller->isEnabled(); }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void IntField::setLineEditBackgroundColor(QColor color) {
Shinya Kitaoka 120a6e
  m_lineEdit->setLineEditBackgroundColor(color);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void IntField::onSliderChanged(int value) {
Shinya Kitaoka 120a6e
  // Controllo necessario per evitare che il segnale di cambiamento venga emesso
Shinya Kitaoka 120a6e
  // piu' volte.
Shinya Kitaoka 120a6e
  if (m_lineEdit->getValue() == value ||
Shinya Kitaoka 120a6e
      ((int)m_roller->getValue() == value && m_roller->isVisible()))
Shinya Kitaoka 120a6e
    return;
Shinya Kitaoka 120a6e
  m_lineEdit->setValue(value);
Shinya Kitaoka 120a6e
  m_roller->setValue((double)value);
Shinya Kitaoka 120a6e
  // Faccio in modo che il cursore sia sulla prima cifra, cosi' se la stringa
Shinya Kitaoka 120a6e
  // da visualizzare e' piu' lunga del campo le cifre che vengono troncate sono
Shinya Kitaoka 120a6e
  // le ultime e non le prime (dovrebbero essere quelle dopo la virgola).
Shinya Kitaoka 120a6e
  m_lineEdit->setCursorPosition(0);
Shinya Kitaoka 120a6e
  emit valueChanged(true);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void IntField::onEditingFinished() {
Shinya Kitaoka 120a6e
  double value = m_lineEdit->getValue();
Shinya Kitaoka 120a6e
  // Controllo necessario per evitare che il segnale di cambiamento venga emesso
Shinya Kitaoka 120a6e
  // piu' volte.
Shinya Kitaoka 120a6e
  if ((m_slider->value() == value && m_slider->isVisible()) ||
Shinya Kitaoka 120a6e
      (int)m_roller->getValue() == value && m_roller->isVisible())
Shinya Kitaoka 120a6e
    return;
Shinya Kitaoka 120a6e
  m_slider->setValue(value);
Shinya Kitaoka 120a6e
  m_roller->setValue((double)value);
Shinya Kitaoka 120a6e
  emit valueChanged(false);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void IntField::onRollerValueChanged(bool isDragging) {
Shinya Kitaoka 120a6e
  int value = m_roller->getValue();
Shinya Kitaoka 120a6e
  if (value == m_lineEdit->getValue()) {
Shinya Kitaoka 120a6e
    assert(m_slider->value() == value || !m_slider->isVisible());
Shinya Kitaoka 120a6e
    // Se isDragging e' falso e' giusto che venga emessa la notifica di
Shinya Kitaoka 120a6e
    // cambiamento.
Shinya Kitaoka 120a6e
    if (!isDragging) emit valueChanged(isDragging);
Shinya Kitaoka 120a6e
    return;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  m_slider->setValue(value);
Shinya Kitaoka 120a6e
  m_lineEdit->setValue(value);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // Faccio in modo che il cursore sia sulla prima cifra, cosi' se la stringa
Shinya Kitaoka 120a6e
  // da visualizzare e' piu' lunga del campo le cifre che vengono troncate sono
Shinya Kitaoka 120a6e
  // le ultime e non le prime (dovrebbero essere quelle dopo la virgola).
Shinya Kitaoka 120a6e
  m_lineEdit->setCursorPosition(0);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  emit valueChanged(isDragging);
Toshihiro Shimizu 890ddd
}