|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzCore includes
|
|
Toshihiro Shimizu |
890ddd |
#include "tpalette.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tcolorstyles.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tundo.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzBase includes
|
|
Toshihiro Shimizu |
890ddd |
#include "tproperty.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzLib includes
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/palettecontroller.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tpalettehandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/tobjecthandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/stage2.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/stageobjectutil.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/doubleparamcmd.h"
|
|
Jeremy Bullock |
3a06bd |
#include "toonz/preferences.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzQt includes
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/gutil.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzTools includes
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/tool.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "rasterselectiontool.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "vectorselectiontool.h"
|
|
Toshihiro Shimizu |
890ddd |
// to enable the increase/decrease shortcuts while hiding the tool option
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/toolhandle.h"
|
|
Toshihiro Shimizu |
890ddd |
// to enable shortcuts only when the viewer is focused
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/tooloptions.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Qt includes
|
|
Toshihiro Shimizu |
890ddd |
#include <qpainter></qpainter>
|
|
Toshihiro Shimizu |
890ddd |
#include <qvboxlayout></qvboxlayout>
|
|
Toshihiro Shimizu |
890ddd |
#include <qmouseevent></qmouseevent>
|
|
Toshihiro Shimizu |
890ddd |
#include <qaction></qaction>
|
|
Toshihiro Shimizu |
890ddd |
#include <qlabel></qlabel>
|
|
Toshihiro Shimizu |
890ddd |
#include <qmainwindow></qmainwindow>
|
|
Toshihiro Shimizu |
890ddd |
#include <qbuttongroup></qbuttongroup>
|
|
Toshihiro Shimizu |
890ddd |
#include <qmenu></qmenu>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tooloptionscontrols.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
using namespace DVGui;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//***********************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// ToolOptionControl implementation
|
|
Toshihiro Shimizu |
890ddd |
//***********************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
ToolOptionControl::ToolOptionControl(TTool *tool, std::string propertyName,
|
|
Shinya Kitaoka |
120a6e |
ToolHandle *toolHandle)
|
|
Shinya Kitaoka |
120a6e |
: m_tool(tool), m_propertyName(propertyName), m_toolHandle(toolHandle) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ToolOptionControl::notifyTool() {
|
|
Shinya Kitaoka |
120a6e |
m_tool->onPropertyChanged(m_propertyName);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
/*! return true if the control is belonging to the visible combo viewer. very
|
|
Shinya Kitaoka |
120a6e |
* dirty implementation.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
bool ToolOptionControl::isInVisibleViewer(QWidget *widget) {
|
|
Shinya Kitaoka |
120a6e |
if (!widget) return false;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (widget->isVisible()) return true;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
ToolOptionsBox *parentTOB =
|
|
Shinya Kitaoka |
120a6e |
dynamic_cast<tooloptionsbox *="">(widget->parentWidget());</tooloptionsbox>
|
|
Shinya Kitaoka |
120a6e |
if (!parentTOB) return false;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
ToolOptions *grandParentTO =
|
|
Shinya Kitaoka |
120a6e |
dynamic_cast<tooloptions *="">(parentTOB->parentWidget());</tooloptions>
|
|
Shinya Kitaoka |
120a6e |
if (!grandParentTO) return false;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// There must be a QFrame between a ComboViewerPanel and a ToolOptions
|
|
Shinya Kitaoka |
120a6e |
QFrame *greatGrandParentFrame =
|
|
Shinya Kitaoka |
120a6e |
dynamic_cast<qframe *="">(grandParentTO->parentWidget());</qframe>
|
|
Shinya Kitaoka |
120a6e |
if (!greatGrandParentFrame) return false;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
return greatGrandParentFrame->isVisible();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//***********************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// ToolOptionControl derivative implementations
|
|
Toshihiro Shimizu |
890ddd |
//***********************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
ToolOptionCheckbox::ToolOptionCheckbox(TTool *tool, TBoolProperty *property,
|
|
Shinya Kitaoka |
120a6e |
ToolHandle *toolHandle, QWidget *parent)
|
|
Shinya Kitaoka |
120a6e |
: CheckBox(parent)
|
|
Shinya Kitaoka |
120a6e |
, ToolOptionControl(tool, property->getName(), toolHandle)
|
|
Shinya Kitaoka |
120a6e |
, m_property(property) {
|
|
Shinya Kitaoka |
120a6e |
setText(property->getQStringName());
|
|
Shinya Kitaoka |
120a6e |
m_property->addListener(this);
|
|
Shinya Kitaoka |
120a6e |
updateStatus();
|
|
Shinya Kitaoka |
120a6e |
// synchronize the state with the same widgets in other tool option bars
|
|
Shinya Kitaoka |
120a6e |
if (toolHandle)
|
|
Shinya Kitaoka |
120a6e |
connect(this, SIGNAL(clicked(bool)), toolHandle, SIGNAL(toolChanged()));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ToolOptionCheckbox::updateStatus() {
|
|
Shinya Kitaoka |
120a6e |
bool check = m_property->getValue();
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun_iwasawa |
b366ef |
if (!actions().isEmpty() && actions()[0]->isCheckable() &&
|
|
shun_iwasawa |
b366ef |
actions()[0]->isChecked() != check)
|
|
shun_iwasawa |
b366ef |
actions()[0]->setChecked(check);
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun_iwasawa |
b366ef |
if (isChecked() == check) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun_iwasawa |
b366ef |
setCheckState(check ? Qt::Checked : Qt::Unchecked);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun_iwasawa |
a39cc7 |
void ToolOptionCheckbox::nextCheckState() {
|
|
shun_iwasawa |
a39cc7 |
QAbstractButton::nextCheckState();
|
|
shun_iwasawa |
a39cc7 |
m_property->setValue(checkState() == Qt::Checked);
|
|
shun_iwasawa |
a39cc7 |
notifyTool();
|
|
shun_iwasawa |
a39cc7 |
}
|
|
shun_iwasawa |
a39cc7 |
|
|
shun_iwasawa |
a39cc7 |
//-----------------------------------------------------------------------------
|
|
shun_iwasawa |
a39cc7 |
|
|
shun_iwasawa |
b366ef |
void ToolOptionCheckbox::doClick(bool checked) {
|
|
Shinya Kitaoka |
120a6e |
if (m_toolHandle && m_toolHandle->getTool() != m_tool) return;
|
|
Shinya Kitaoka |
120a6e |
// active only if the belonging combo-viewer is visible
|
|
Shinya Kitaoka |
120a6e |
if (!isInVisibleViewer(this)) return;
|
|
shun_iwasawa |
b366ef |
|
|
shun_iwasawa |
b366ef |
if (isChecked() == checked) return;
|
|
shun_iwasawa |
b366ef |
|
|
shun_iwasawa |
b366ef |
setChecked(checked);
|
|
shun_iwasawa |
b366ef |
m_property->setValue(checked);
|
|
shun_iwasawa |
b366ef |
notifyTool();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
ToolOptionSlider::ToolOptionSlider(TTool *tool, TDoubleProperty *property,
|
|
Shinya Kitaoka |
120a6e |
ToolHandle *toolHandle)
|
|
Shinya Kitaoka |
120a6e |
: DoubleField()
|
|
Shinya Kitaoka |
120a6e |
, ToolOptionControl(tool, property->getName(), toolHandle)
|
|
Shinya Kitaoka |
120a6e |
, m_property(property) {
|
|
Shinya Kitaoka |
120a6e |
m_property->addListener(this);
|
|
Shinya Kitaoka |
120a6e |
TDoubleProperty::Range range = property->getRange();
|
|
Shinya Kitaoka |
120a6e |
setRange(range.first, range.second);
|
|
shun-iwasawa |
c86c5d |
|
|
Shinya Kitaoka |
d1f6c4 |
// calculate maximum text length which includes length for decimals (for now
|
|
Shinya Kitaoka |
d1f6c4 |
// it's fixed to 2) and period
|
|
Shinya Kitaoka |
d1f6c4 |
int textMaxLength = std::max(QString::number((int)range.first).length(),
|
|
Shinya Kitaoka |
d1f6c4 |
QString::number((int)range.second).length()) +
|
|
Shinya Kitaoka |
d1f6c4 |
m_lineEdit->getDecimals() + 1;
|
|
shun-iwasawa |
c86c5d |
QString txt;
|
|
Shinya Kitaoka |
d1f6c4 |
// set the maximum width of the widget according to the text length (with 5
|
|
Shinya Kitaoka |
d1f6c4 |
// pixels margin)
|
|
shun-iwasawa |
c86c5d |
txt.fill('0', textMaxLength);
|
|
shun-iwasawa |
c86c5d |
int widgetWidth = fontMetrics().width(txt) + 5;
|
|
shun-iwasawa |
c86c5d |
m_lineEdit->parentWidget()->setMaximumWidth(widgetWidth);
|
|
Shinya Kitaoka |
d1f6c4 |
// set the maximum width of the slider to 250 pixels
|
|
shun-iwasawa |
c86c5d |
setMaximumWidth(250 + widgetWidth);
|
|
shun-iwasawa |
c86c5d |
|
|
Shinya Kitaoka |
120a6e |
updateStatus();
|
|
Shinya Kitaoka |
120a6e |
connect(this, SIGNAL(valueChanged(bool)), SLOT(onValueChanged(bool)));
|
|
Shinya Kitaoka |
120a6e |
// synchronize the state with the same widgets in other tool option bars
|
|
Shinya Kitaoka |
120a6e |
if (toolHandle)
|
|
Shinya Kitaoka |
120a6e |
connect(this, SIGNAL(valueEditedByHand()), toolHandle,
|
|
Shinya Kitaoka |
120a6e |
SIGNAL(toolChanged()));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ToolOptionSlider::updateStatus() {
|
|
Shinya Kitaoka |
120a6e |
double v = m_property->getValue();
|
|
Shinya Kitaoka |
120a6e |
if (getValue() == v) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
setValue(v);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ToolOptionSlider::onValueChanged(bool isDragging) {
|
|
Shinya Kitaoka |
120a6e |
m_property->setValue(getValue());
|
|
Shinya Kitaoka |
120a6e |
notifyTool();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ToolOptionSlider::increase() {
|
|
Shinya Kitaoka |
120a6e |
if (m_toolHandle && m_toolHandle->getTool() != m_tool) return;
|
|
Shinya Kitaoka |
120a6e |
// active only if the belonging combo-viewer is visible
|
|
Shinya Kitaoka |
120a6e |
if (!isInVisibleViewer(this)) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double value = getValue();
|
|
Shinya Kitaoka |
120a6e |
double minValue, maxValue;
|
|
Shinya Kitaoka |
120a6e |
getRange(minValue, maxValue);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
value += 1;
|
|
Shinya Kitaoka |
120a6e |
if (value > maxValue) value = maxValue;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
setValue(value);
|
|
Shinya Kitaoka |
120a6e |
m_property->setValue(getValue());
|
|
Shinya Kitaoka |
120a6e |
notifyTool();
|
|
Shinya Kitaoka |
120a6e |
// update the interface
|
|
Shinya Kitaoka |
120a6e |
repaint();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ToolOptionSlider::decrease() {
|
|
Shinya Kitaoka |
120a6e |
if (m_toolHandle && m_toolHandle->getTool() != m_tool) return;
|
|
Shinya Kitaoka |
120a6e |
// active only if the belonging combo-viewer is visible
|
|
Shinya Kitaoka |
120a6e |
if (!isInVisibleViewer(this)) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double value = getValue();
|
|
Shinya Kitaoka |
120a6e |
double minValue, maxValue;
|
|
Shinya Kitaoka |
120a6e |
getRange(minValue, maxValue);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
value -= 1;
|
|
Shinya Kitaoka |
120a6e |
if (value < minValue) value = minValue;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
setValue(value);
|
|
Shinya Kitaoka |
120a6e |
m_property->setValue(getValue());
|
|
Shinya Kitaoka |
120a6e |
notifyTool();
|
|
Shinya Kitaoka |
120a6e |
// update the interface
|
|
Shinya Kitaoka |
120a6e |
repaint();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
ToolOptionPairSlider::ToolOptionPairSlider(TTool *tool,
|
|
Shinya Kitaoka |
120a6e |
TDoublePairProperty *property,
|
|
Shinya Kitaoka |
120a6e |
const QString &leftName,
|
|
Shinya Kitaoka |
120a6e |
const QString &rightName,
|
|
Shinya Kitaoka |
120a6e |
ToolHandle *toolHandle)
|
|
Shinya Kitaoka |
120a6e |
: DoublePairField(0, property->isMaxRangeLimited())
|
|
Shinya Kitaoka |
120a6e |
, ToolOptionControl(tool, property->getName(), toolHandle)
|
|
Shinya Kitaoka |
120a6e |
, m_property(property) {
|
|
Shinya Kitaoka |
120a6e |
m_property->addListener(this);
|
|
Shinya Kitaoka |
120a6e |
TDoublePairProperty::Value value = property->getValue();
|
|
Shinya Kitaoka |
120a6e |
TDoublePairProperty::Range range = property->getRange();
|
|
Shinya Kitaoka |
120a6e |
setRange(range.first, range.second);
|
|
shun-iwasawa |
c86c5d |
|
|
Shinya Kitaoka |
d1f6c4 |
// calculate maximum text length which includes length for decimals (for now
|
|
Shinya Kitaoka |
d1f6c4 |
// it's fixed to 2) and period
|
|
Shinya Kitaoka |
d1f6c4 |
int textMaxLength = std::max(QString::number((int)range.first).length(),
|
|
Shinya Kitaoka |
d1f6c4 |
QString::number((int)range.second).length()) +
|
|
Shinya Kitaoka |
d1f6c4 |
m_leftLineEdit->getDecimals() + 1;
|
|
shun-iwasawa |
c86c5d |
QString txt;
|
|
Shinya Kitaoka |
d1f6c4 |
// set the maximum width of the widget according to the text length (with 5
|
|
Shinya Kitaoka |
d1f6c4 |
// pixels margin)
|
|
shun-iwasawa |
c86c5d |
txt.fill('0', textMaxLength);
|
|
shun-iwasawa |
c86c5d |
int widgetWidth = fontMetrics().width(txt) + 5;
|
|
shun-iwasawa |
c86c5d |
m_leftLineEdit->setFixedWidth(widgetWidth);
|
|
shun-iwasawa |
c86c5d |
m_rightLineEdit->setFixedWidth(widgetWidth);
|
|
Shinya Kitaoka |
d1f6c4 |
m_leftMargin = widgetWidth + 12;
|
|
shun-iwasawa |
c86c5d |
m_rightMargin = widgetWidth + 12;
|
|
Shinya Kitaoka |
d1f6c4 |
// set the maximum width of the slider to 300 pixels
|
|
shun-iwasawa |
c86c5d |
setMaximumWidth(300 + m_leftMargin + m_rightMargin);
|
|
shun-iwasawa |
c86c5d |
|
|
shun-iwasawa |
c86c5d |
setLeftText(leftName);
|
|
shun-iwasawa |
c86c5d |
setRightText(rightName);
|
|
shun-iwasawa |
c86c5d |
|
|
Shinya Kitaoka |
120a6e |
updateStatus();
|
|
Shinya Kitaoka |
120a6e |
connect(this, SIGNAL(valuesChanged(bool)), SLOT(onValuesChanged(bool)));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ToolOptionPairSlider::updateStatus() {
|
|
Shinya Kitaoka |
120a6e |
TDoublePairProperty::Value value = m_property->getValue();
|
|
Shinya Kitaoka |
120a6e |
setValues(value);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ToolOptionPairSlider::onValuesChanged(bool isDragging) {
|
|
Shinya Kitaoka |
120a6e |
m_property->setValue(getValues());
|
|
Shinya Kitaoka |
120a6e |
notifyTool();
|
|
Shinya Kitaoka |
120a6e |
// synchronize the state with the same widgets in other tool option bars
|
|
Shinya Kitaoka |
120a6e |
if (m_toolHandle) m_toolHandle->notifyToolChanged();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ToolOptionPairSlider::increaseMaxValue() {
|
|
Shinya Kitaoka |
120a6e |
if (m_toolHandle && m_toolHandle->getTool() != m_tool) return;
|
|
Shinya Kitaoka |
120a6e |
// active only if the belonging combo-viewer is visible
|
|
Shinya Kitaoka |
120a6e |
if (!isInVisibleViewer(this)) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
std::pair<double, double=""> values = getValues();</double,>
|
|
Shinya Kitaoka |
120a6e |
double minValue, maxValue;
|
|
Shinya Kitaoka |
120a6e |
getRange(minValue, maxValue);
|
|
Shinya Kitaoka |
120a6e |
values.second += 1;
|
|
Shinya Kitaoka |
120a6e |
if (values.second > maxValue) values.second = maxValue;
|
|
Shinya Kitaoka |
120a6e |
setValues(values);
|
|
Shinya Kitaoka |
120a6e |
m_property->setValue(getValues());
|
|
Shinya Kitaoka |
120a6e |
notifyTool();
|
|
Shinya Kitaoka |
120a6e |
// update the interface
|
|
Shinya Kitaoka |
120a6e |
repaint();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ToolOptionPairSlider::decreaseMaxValue() {
|
|
Shinya Kitaoka |
120a6e |
if (m_toolHandle && m_toolHandle->getTool() != m_tool) return;
|
|
Shinya Kitaoka |
120a6e |
// active only if the belonging combo-viewer is visible
|
|
Shinya Kitaoka |
120a6e |
if (!isInVisibleViewer(this)) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
std::pair<double, double=""> values = getValues();</double,>
|
|
Shinya Kitaoka |
120a6e |
values.second -= 1;
|
|
Shinya Kitaoka |
120a6e |
if (values.second < values.first) values.second = values.first;
|
|
Shinya Kitaoka |
120a6e |
setValues(values);
|
|
Shinya Kitaoka |
120a6e |
m_property->setValue(getValues());
|
|
Shinya Kitaoka |
120a6e |
notifyTool();
|
|
Shinya Kitaoka |
120a6e |
// update the interface
|
|
Shinya Kitaoka |
120a6e |
repaint();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ToolOptionPairSlider::increaseMinValue() {
|
|
Shinya Kitaoka |
120a6e |
if (m_toolHandle && m_toolHandle->getTool() != m_tool) return;
|
|
Shinya Kitaoka |
120a6e |
// active only if the belonging combo-viewer is visible
|
|
Shinya Kitaoka |
120a6e |
if (!isInVisibleViewer(this)) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
std::pair<double, double=""> values = getValues();</double,>
|
|
Shinya Kitaoka |
120a6e |
values.first += 1;
|
|
Shinya Kitaoka |
120a6e |
if (values.first > values.second) values.first = values.second;
|
|
Shinya Kitaoka |
120a6e |
setValues(values);
|
|
Shinya Kitaoka |
120a6e |
m_property->setValue(getValues());
|
|
Shinya Kitaoka |
120a6e |
notifyTool();
|
|
Shinya Kitaoka |
120a6e |
// update the interface
|
|
Shinya Kitaoka |
120a6e |
repaint();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ToolOptionPairSlider::decreaseMinValue() {
|
|
Shinya Kitaoka |
120a6e |
if (m_toolHandle && m_toolHandle->getTool() != m_tool) return;
|
|
Shinya Kitaoka |
120a6e |
// active only if the belonging combo-viewer is visible
|
|
Shinya Kitaoka |
120a6e |
if (!isInVisibleViewer(this)) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
std::pair<double, double=""> values = getValues();</double,>
|
|
Shinya Kitaoka |
120a6e |
double minValue, maxValue;
|
|
Shinya Kitaoka |
120a6e |
getRange(minValue, maxValue);
|
|
Shinya Kitaoka |
120a6e |
values.first -= 1;
|
|
Shinya Kitaoka |
120a6e |
if (values.first < minValue) values.first = minValue;
|
|
Shinya Kitaoka |
120a6e |
setValues(values);
|
|
Shinya Kitaoka |
120a6e |
m_property->setValue(getValues());
|
|
Shinya Kitaoka |
120a6e |
notifyTool();
|
|
Shinya Kitaoka |
120a6e |
// update the interface
|
|
Shinya Kitaoka |
120a6e |
repaint();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
ToolOptionIntPairSlider::ToolOptionIntPairSlider(TTool *tool,
|
|
Shinya Kitaoka |
120a6e |
TIntPairProperty *property,
|
|
Shinya Kitaoka |
120a6e |
const QString &leftName,
|
|
Shinya Kitaoka |
120a6e |
const QString &rightName,
|
|
Shinya Kitaoka |
120a6e |
ToolHandle *toolHandle)
|
|
Shinya Kitaoka |
120a6e |
: IntPairField(0, property->isMaxRangeLimited())
|
|
Shinya Kitaoka |
120a6e |
, ToolOptionControl(tool, property->getName(), toolHandle)
|
|
Shinya Kitaoka |
120a6e |
, m_property(property) {
|
|
Shinya Kitaoka |
120a6e |
setLeftText(leftName);
|
|
Shinya Kitaoka |
120a6e |
setRightText(rightName);
|
|
Shinya Kitaoka |
120a6e |
m_property->addListener(this);
|
|
Shinya Kitaoka |
120a6e |
TIntPairProperty::Value value = property->getValue();
|
|
Shinya Kitaoka |
120a6e |
TIntPairProperty::Range range = property->getRange();
|
|
Shinya Kitaoka |
120a6e |
setRange(range.first, range.second);
|
|
shun-iwasawa |
c86c5d |
setMaximumWidth(300);
|
|
Shinya Kitaoka |
120a6e |
updateStatus();
|
|
Shinya Kitaoka |
120a6e |
connect(this, SIGNAL(valuesChanged(bool)), SLOT(onValuesChanged(bool)));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ToolOptionIntPairSlider::updateStatus() {
|
|
Shinya Kitaoka |
120a6e |
TIntPairProperty::Value value = m_property->getValue();
|
|
Shinya Kitaoka |
120a6e |
setValues(value);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ToolOptionIntPairSlider::onValuesChanged(bool isDragging) {
|
|
Shinya Kitaoka |
120a6e |
m_property->setValue(getValues());
|
|
Shinya Kitaoka |
120a6e |
notifyTool();
|
|
Shinya Kitaoka |
120a6e |
// synchronize the state with the same widgets in other tool option bars
|
|
Shinya Kitaoka |
120a6e |
if (m_toolHandle) m_toolHandle->notifyToolChanged();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ToolOptionIntPairSlider::increaseMaxValue() {
|
|
Shinya Kitaoka |
120a6e |
if (m_toolHandle && m_toolHandle->getTool() != m_tool) return;
|
|
Shinya Kitaoka |
120a6e |
// active only if the belonging combo-viewer is visible
|
|
Shinya Kitaoka |
120a6e |
if (!isInVisibleViewer(this)) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
std::pair<int, int=""> values = getValues();</int,>
|
|
Shinya Kitaoka |
120a6e |
int minValue, maxValue;
|
|
Shinya Kitaoka |
120a6e |
getRange(minValue, maxValue);
|
|
Shinya Kitaoka |
120a6e |
values.second += 1;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// a "cross-like shape" of the brush size = 3 is hard to use. so skip it
|
|
Shinya Kitaoka |
120a6e |
if (values.second == 3 && m_tool->isPencilModeActive()) values.second += 1;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (values.second > maxValue) values.second = maxValue;
|
|
Shinya Kitaoka |
120a6e |
setValues(values);
|
|
Shinya Kitaoka |
120a6e |
m_property->setValue(getValues());
|
|
Shinya Kitaoka |
120a6e |
notifyTool();
|
|
Shinya Kitaoka |
120a6e |
// update the interface
|
|
Shinya Kitaoka |
120a6e |
repaint();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ToolOptionIntPairSlider::decreaseMaxValue() {
|
|
Shinya Kitaoka |
120a6e |
if (m_toolHandle && m_toolHandle->getTool() != m_tool) return;
|
|
Shinya Kitaoka |
120a6e |
// active only if the belonging combo-viewer is visible
|
|
Shinya Kitaoka |
120a6e |
if (!isInVisibleViewer(this)) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
std::pair<int, int=""> values = getValues();</int,>
|
|
Shinya Kitaoka |
120a6e |
values.second -= 1;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// a "cross-like shape" of the brush size = 3 is hard to use. so skip it
|
|
Shinya Kitaoka |
120a6e |
if (values.second == 3 && m_tool->isPencilModeActive()) values.second -= 1;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (values.second < values.first) values.second = values.first;
|
|
Shinya Kitaoka |
120a6e |
setValues(values);
|
|
Shinya Kitaoka |
120a6e |
m_property->setValue(getValues());
|
|
Shinya Kitaoka |
120a6e |
notifyTool();
|
|
Shinya Kitaoka |
120a6e |
// update the interface
|
|
Shinya Kitaoka |
120a6e |
repaint();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ToolOptionIntPairSlider::increaseMinValue() {
|
|
Shinya Kitaoka |
120a6e |
if (m_toolHandle && m_toolHandle->getTool() != m_tool) return;
|
|
Shinya Kitaoka |
120a6e |
// active only if the belonging combo-viewer is visible
|
|
Shinya Kitaoka |
120a6e |
if (!isInVisibleViewer(this)) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
std::pair<int, int=""> values = getValues();</int,>
|
|
Shinya Kitaoka |
120a6e |
values.first += 1;
|
|
Shinya Kitaoka |
120a6e |
if (values.first > values.second) values.first = values.second;
|
|
Shinya Kitaoka |
120a6e |
setValues(values);
|
|
Shinya Kitaoka |
120a6e |
m_property->setValue(getValues());
|
|
Shinya Kitaoka |
120a6e |
notifyTool();
|
|
Shinya Kitaoka |
120a6e |
// update the interface
|
|
Shinya Kitaoka |
120a6e |
repaint();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ToolOptionIntPairSlider::decreaseMinValue() {
|
|
Shinya Kitaoka |
120a6e |
if (m_toolHandle && m_toolHandle->getTool() != m_tool) return;
|
|
Shinya Kitaoka |
120a6e |
// active only if the belonging combo-viewer is visible
|
|
Shinya Kitaoka |
120a6e |
if (!isInVisibleViewer(this)) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
std::pair<int, int=""> values = getValues();</int,>
|
|
Shinya Kitaoka |
120a6e |
int minValue, maxValue;
|
|
Shinya Kitaoka |
120a6e |
getRange(minValue, maxValue);
|
|
Shinya Kitaoka |
120a6e |
values.first -= 1;
|
|
Shinya Kitaoka |
120a6e |
if (values.first < minValue) values.first = minValue;
|
|
Shinya Kitaoka |
120a6e |
setValues(values);
|
|
Shinya Kitaoka |
120a6e |
m_property->setValue(getValues());
|
|
Shinya Kitaoka |
120a6e |
notifyTool();
|
|
Shinya Kitaoka |
120a6e |
// update the interface
|
|
Shinya Kitaoka |
120a6e |
repaint();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
ToolOptionIntSlider::ToolOptionIntSlider(TTool *tool, TIntProperty *property,
|
|
Shinya Kitaoka |
120a6e |
ToolHandle *toolHandle)
|
|
Shinya Kitaoka |
120a6e |
: IntField(0, property->isMaxRangeLimited())
|
|
Shinya Kitaoka |
120a6e |
, ToolOptionControl(tool, property->getName(), toolHandle)
|
|
Shinya Kitaoka |
120a6e |
, m_property(property) {
|
|
Shinya Kitaoka |
120a6e |
m_property->addListener(this);
|
|
Shinya Kitaoka |
120a6e |
TIntProperty::Range range = property->getRange();
|
|
Shinya Kitaoka |
120a6e |
setRange(range.first, range.second);
|
|
shun-iwasawa |
c86c5d |
setMaximumWidth(300);
|
|
Shinya Kitaoka |
120a6e |
updateStatus();
|
|
Shinya Kitaoka |
120a6e |
connect(this, SIGNAL(valueChanged(bool)), SLOT(onValueChanged(bool)));
|
|
Shinya Kitaoka |
120a6e |
// synchronize the state with the same widgets in other tool option bars
|
|
Shinya Kitaoka |
120a6e |
if (toolHandle)
|
|
Shinya Kitaoka |
120a6e |
connect(this, SIGNAL(valueEditedByHand()), toolHandle,
|
|
Shinya Kitaoka |
120a6e |
SIGNAL(toolChanged()));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ToolOptionIntSlider::updateStatus() {
|
|
Shinya Kitaoka |
120a6e |
int v = m_property->getValue();
|
|
Shinya Kitaoka |
120a6e |
if (getValue() == v) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
setValue(v);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ToolOptionIntSlider::increase() {
|
|
Shinya Kitaoka |
120a6e |
if (m_toolHandle && m_toolHandle->getTool() != m_tool) return;
|
|
Shinya Kitaoka |
120a6e |
// active only if the belonging combo-viewer is visible
|
|
Shinya Kitaoka |
120a6e |
if (!isInVisibleViewer(this)) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int value = getValue();
|
|
Shinya Kitaoka |
120a6e |
int minValue, maxValue;
|
|
Shinya Kitaoka |
120a6e |
getRange(minValue, maxValue);
|
|
Shinya Kitaoka |
120a6e |
value += 1;
|
|
Shinya Kitaoka |
120a6e |
// a "cross-like shape" of the brush size = 3 is hard to use. so skip it
|
|
Shinya Kitaoka |
120a6e |
if (value == 3 && m_tool->isPencilModeActive()) value += 1;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (value > maxValue) value = maxValue;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
setValue(value);
|
|
Shinya Kitaoka |
120a6e |
m_property->setValue(getValue());
|
|
Shinya Kitaoka |
120a6e |
notifyTool();
|
|
Shinya Kitaoka |
120a6e |
// update the interface
|
|
Shinya Kitaoka |
120a6e |
repaint();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ToolOptionIntSlider::decrease() {
|
|
Shinya Kitaoka |
120a6e |
if (m_toolHandle && m_toolHandle->getTool() != m_tool) return;
|
|
Shinya Kitaoka |
120a6e |
// active only if the belonging combo-viewer is visible
|
|
Shinya Kitaoka |
120a6e |
if (!isInVisibleViewer(this)) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int value = getValue();
|
|
Shinya Kitaoka |
120a6e |
int minValue, maxValue;
|
|
Shinya Kitaoka |
120a6e |
getRange(minValue, maxValue);
|
|
Shinya Kitaoka |
120a6e |
value -= 1;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// a "cross-like shape" of the brush size = 3 is hard to use. so skip it
|
|
Shinya Kitaoka |
120a6e |
if (value == 3 && m_tool->isPencilModeActive()) value -= 1;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (value < minValue) value = minValue;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
setValue(value);
|
|
Shinya Kitaoka |
120a6e |
m_property->setValue(getValue());
|
|
Shinya Kitaoka |
120a6e |
notifyTool();
|
|
Shinya Kitaoka |
120a6e |
// update the interface
|
|
Shinya Kitaoka |
120a6e |
repaint();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ToolOptionIntSlider::onValueChanged(bool isDragging) {
|
|
Shinya Kitaoka |
120a6e |
m_property->setValue(getValue());
|
|
Shinya Kitaoka |
120a6e |
notifyTool();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
ToolOptionCombo::ToolOptionCombo(TTool *tool, TEnumProperty *property,
|
|
Shinya Kitaoka |
120a6e |
ToolHandle *toolHandle)
|
|
Shinya Kitaoka |
120a6e |
: QComboBox()
|
|
Shinya Kitaoka |
120a6e |
, ToolOptionControl(tool, property->getName(), toolHandle)
|
|
Shinya Kitaoka |
120a6e |
, m_property(property) {
|
|
Shinya Kitaoka |
120a6e |
setMinimumWidth(65);
|
|
Shinya Kitaoka |
120a6e |
m_property->addListener(this);
|
|
Shinya Kitaoka |
120a6e |
loadEntries();
|
|
Shinya Kitaoka |
120a6e |
setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
|
Shinya Kitaoka |
120a6e |
connect(this, SIGNAL(activated(int)), this, SLOT(onActivated(int)));
|
|
Shinya Kitaoka |
120a6e |
// synchronize the state with the same widgets in other tool option bars
|
|
Shinya Kitaoka |
120a6e |
if (toolHandle)
|
|
Shinya Kitaoka |
120a6e |
connect(this, SIGNAL(activated(int)), toolHandle, SIGNAL(toolChanged()));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ToolOptionCombo::loadEntries() {
|
|
Shinya Kitaoka |
120a6e |
TEnumProperty::Range range = m_property->getRange();
|
|
Shinya Kitaoka |
120a6e |
TEnumProperty::Range::iterator it;
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
c86c5d |
int maxWidth = 0;
|
|
shun-iwasawa |
c86c5d |
|
|
Shinya Kitaoka |
120a6e |
clear();
|
|
Shinya Kitaoka |
d1f6c4 |
for (it = range.begin(); it != range.end(); ++it) {
|
|
shun-iwasawa |
c86c5d |
QString itemStr = QString::fromStdWString(*it);
|
|
shun-iwasawa |
c86c5d |
addItem(itemStr);
|
|
Shinya Kitaoka |
d1f6c4 |
int tmpWidth = fontMetrics().width(itemStr);
|
|
Shinya Kitaoka |
d1f6c4 |
if (tmpWidth > maxWidth) maxWidth = tmpWidth;
|
|
shun-iwasawa |
c86c5d |
}
|
|
shun-iwasawa |
c86c5d |
|
|
Shinya Kitaoka |
d1f6c4 |
// set the maximum width according to the longest item with 25 pixels for
|
|
Shinya Kitaoka |
d1f6c4 |
// arrow button and margin
|
|
shun-iwasawa |
c86c5d |
setMaximumWidth(maxWidth + 25);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
updateStatus();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ToolOptionCombo::updateStatus() {
|
|
Shinya Kitaoka |
120a6e |
QString value = QString::fromStdWString(m_property->getValue());
|
|
Shinya Kitaoka |
120a6e |
int index = findText(value);
|
|
Shinya Kitaoka |
120a6e |
if (index >= 0 && index != currentIndex()) setCurrentIndex(index);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ToolOptionCombo::onActivated(int index) {
|
|
Shinya Kitaoka |
120a6e |
const TEnumProperty::Range &range = m_property->getRange();
|
|
Shinya Kitaoka |
120a6e |
if (index < 0 || index >= (int)range.size()) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
std::wstring item = range[index];
|
|
Shinya Kitaoka |
120a6e |
m_property->setValue(item);
|
|
Shinya Kitaoka |
120a6e |
notifyTool();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ToolOptionCombo::doShowPopup() {
|
|
Jeremy Bullock |
3a06bd |
if (Preferences::instance()->getDropdownShortcutsCycleOptions()) {
|
|
Jeremy Bullock |
3a06bd |
const TEnumProperty::Range &range = m_property->getRange();
|
|
Jeremy Bullock |
3a06bd |
int theIndex = currentIndex() + 1;
|
|
Jeremy Bullock |
3a06bd |
if (theIndex >= (int)range.size()) theIndex = 0;
|
|
Jeremy Bullock |
3a06bd |
doOnActivated(theIndex);
|
|
Jeremy Bullock |
3a06bd |
} else {
|
|
Jeremy Bullock |
3a06bd |
if (isVisible()) showPopup();
|
|
Jeremy Bullock |
3a06bd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ToolOptionCombo::doOnActivated(int index) {
|
|
Shinya Kitaoka |
120a6e |
if (m_toolHandle && m_toolHandle->getTool() != m_tool) return;
|
|
Shinya Kitaoka |
120a6e |
// active only if the belonging combo-viewer is visible
|
|
Shinya Kitaoka |
120a6e |
if (!isInVisibleViewer(this)) return;
|
|
Jeremy Bullock |
3a06bd |
bool cycleOptions =
|
|
Jeremy Bullock |
3a06bd |
Preferences::instance()->getDropdownShortcutsCycleOptions();
|
|
Shinya Kitaoka |
120a6e |
// Just move the index if the first item is not "Normal"
|
|
Shinya Kitaoka |
120a6e |
if (itemText(0) != "Normal") {
|
|
Shinya Kitaoka |
120a6e |
onActivated(index);
|
|
Shinya Kitaoka |
120a6e |
setCurrentIndex(index);
|
|
Shinya Kitaoka |
120a6e |
// for updating the cursor
|
|
Shinya Kitaoka |
120a6e |
m_toolHandle->notifyToolChanged();
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// If the first item of this combo box is "Normal", enable shortcut key toggle
|
|
Shinya Kitaoka |
120a6e |
// can "back and forth" behavior.
|
|
Shinya Kitaoka |
120a6e |
if (currentIndex() == index) {
|
|
Shinya Kitaoka |
120a6e |
// estimating that the "Normal" option is located at the index 0
|
|
Shinya Kitaoka |
120a6e |
onActivated(0);
|
|
Shinya Kitaoka |
120a6e |
setCurrentIndex(0);
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
onActivated(index);
|
|
Shinya Kitaoka |
120a6e |
setCurrentIndex(index);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// for updating a cursor without any effect to the tool options
|
|
Shinya Kitaoka |
120a6e |
m_toolHandle->notifyToolCursorTypeChanged();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
ToolOptionPopupButton::ToolOptionPopupButton(TTool *tool,
|
|
Shinya Kitaoka |
120a6e |
TEnumProperty *property)
|
|
Shinya Kitaoka |
120a6e |
: PopupButton()
|
|
Shinya Kitaoka |
120a6e |
, ToolOptionControl(tool, property->getName())
|
|
Shinya Kitaoka |
120a6e |
, m_property(property) {
|
|
Shinya Kitaoka |
120a6e |
setObjectName(QString::fromStdString(property->getName()));
|
|
Shinya Kitaoka |
120a6e |
setFixedHeight(20);
|
|
Shinya Kitaoka |
120a6e |
m_property->addListener(this);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TEnumProperty::Range range = property->getRange();
|
|
Shinya Kitaoka |
120a6e |
TEnumProperty::Range::iterator it;
|
|
shun_iwasawa |
4a5f42 |
for (it = range.begin(); it != range.end(); ++it) {
|
|
shun_iwasawa |
4a5f42 |
QString iconName = QString::fromStdWString(*it);
|
|
shun_iwasawa |
4a5f42 |
QAction *action = addItem(createQIcon(iconName.toUtf8()));
|
|
shun_iwasawa |
4a5f42 |
// make the tooltip text
|
|
shun_iwasawa |
4a5f42 |
iconName = iconName.replace('_', ' ');
|
|
shun_iwasawa |
4a5f42 |
iconName = iconName.left(1).toUpper() + iconName.mid(1);
|
|
shun_iwasawa |
4a5f42 |
action->setToolTip(iconName);
|
|
shun_iwasawa |
4a5f42 |
}
|
|
Shinya Kitaoka |
120a6e |
setCurrentIndex(0);
|
|
Shinya Kitaoka |
120a6e |
updateStatus();
|
|
Shinya Kitaoka |
120a6e |
connect(this, SIGNAL(activated(int)), this, SLOT(onActivated(int)));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ToolOptionPopupButton::updateStatus() {
|
|
Shinya Kitaoka |
120a6e |
int index = m_property->getIndex();
|
|
Shinya Kitaoka |
120a6e |
if (index >= 0 && index != currentIndex()) setCurrentIndex(index);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ToolOptionPopupButton::onActivated(int index) {
|
|
Shinya Kitaoka |
120a6e |
const TEnumProperty::Range &range = m_property->getRange();
|
|
Shinya Kitaoka |
120a6e |
if (index < 0 || index >= (int)range.size()) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
std::wstring item = range[index];
|
|
Shinya Kitaoka |
120a6e |
m_property->setValue(item);
|
|
Shinya Kitaoka |
120a6e |
notifyTool();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ToolOptionPopupButton::doShowPopup() {
|
|
Shinya Kitaoka |
120a6e |
if (isVisible()) showMenu();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ToolOptionPopupButton::doSetCurrentIndex(int index) {
|
|
Shinya Kitaoka |
120a6e |
if (isVisible()) setCurrentIndex(index);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ToolOptionPopupButton::doOnActivated(int index) {
|
|
Shinya Kitaoka |
120a6e |
if (isVisible()) onActivated(index);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
ToolOptionTextField::ToolOptionTextField(TTool *tool, TStringProperty *property)
|
|
Shinya Kitaoka |
120a6e |
: LineEdit()
|
|
Shinya Kitaoka |
120a6e |
, ToolOptionControl(tool, property->getName())
|
|
Shinya Kitaoka |
120a6e |
, m_property(property) {
|
|
Shinya Kitaoka |
120a6e |
setFixedSize(100, 23);
|
|
Shinya Kitaoka |
120a6e |
m_property->addListener(this);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
updateStatus();
|
|
Shinya Kitaoka |
120a6e |
connect(this, SIGNAL(editingFinished()), SLOT(onValueChanged()));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ToolOptionTextField::updateStatus() {
|
|
Shinya Kitaoka |
120a6e |
QString newText = QString::fromStdWString(m_property->getValue());
|
|
Shinya Kitaoka |
120a6e |
if (newText == text()) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
setText(newText);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ToolOptionTextField::onValueChanged() {
|
|
Shinya Kitaoka |
120a6e |
m_property->setValue(text().toStdWString());
|
|
Shinya Kitaoka |
120a6e |
notifyTool();
|
|
Shinya Kitaoka |
120a6e |
// synchronize the state with the same widgets in other tool option bars
|
|
Shinya Kitaoka |
120a6e |
if (m_toolHandle) m_toolHandle->notifyToolChanged();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
StyleIndexFieldAndChip::StyleIndexFieldAndChip(TTool *tool,
|
|
Shinya Kitaoka |
120a6e |
TStyleIndexProperty *property,
|
|
Shinya Kitaoka |
120a6e |
TPaletteHandle *pltHandle,
|
|
Shinya Kitaoka |
120a6e |
ToolHandle *toolHandle)
|
|
Shinya Kitaoka |
120a6e |
: StyleIndexLineEdit()
|
|
Shinya Kitaoka |
120a6e |
, ToolOptionControl(tool, property->getName(), toolHandle)
|
|
Shinya Kitaoka |
120a6e |
, m_property(property)
|
|
Shinya Kitaoka |
120a6e |
, m_pltHandle(pltHandle) {
|
|
Shinya Kitaoka |
120a6e |
m_property->addListener(this);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
updateStatus();
|
|
Shinya Kitaoka |
120a6e |
connect(this, SIGNAL(textChanged(const QString &)),
|
|
Shinya Kitaoka |
120a6e |
SLOT(onValueChanged(const QString &)));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
setPaletteHandle(pltHandle);
|
|
Shinya Kitaoka |
120a6e |
connect(pltHandle, SIGNAL(colorStyleSwitched()), SLOT(updateColor()));
|
|
Shinya Kitaoka |
120a6e |
connect(pltHandle, SIGNAL(colorStyleChanged()), SLOT(updateColor()));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void StyleIndexFieldAndChip::updateStatus() {
|
|
Shinya Kitaoka |
120a6e |
QString newText = QString::fromStdWString(m_property->getValue());
|
|
Shinya Kitaoka |
120a6e |
if (newText == text()) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
setText(newText);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void StyleIndexFieldAndChip::onValueChanged(const QString &changedText) {
|
|
Shinya Kitaoka |
120a6e |
QString style;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (!QString("current").contains(changedText)) {
|
|
Shinya Kitaoka |
120a6e |
int index = changedText.toInt();
|
|
Shinya Kitaoka |
120a6e |
TPalette *plt = m_pltHandle->getPalette();
|
|
Shinya Kitaoka |
120a6e |
int indexCount = plt->getStyleCount();
|
|
Shinya Kitaoka |
120a6e |
if (index > indexCount)
|
|
Shinya Kitaoka |
120a6e |
style = QString::number(indexCount - 1);
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
style = text();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
m_property->setValue(style.toStdWString());
|
|
Shinya Kitaoka |
120a6e |
repaint();
|
|
Shinya Kitaoka |
120a6e |
// synchronize the state with the same widgets in other tool option bars
|
|
Shinya Kitaoka |
120a6e |
if (m_toolHandle) m_toolHandle->notifyToolChanged();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void StyleIndexFieldAndChip::updateColor() { repaint(); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
ToolOptionParamRelayField::ToolOptionParamRelayField(
|
|
Shinya Kitaoka |
120a6e |
TTool *tool, TDoubleParamRelayProperty *property, int decimals)
|
|
Shinya Kitaoka |
120a6e |
: MeasuredDoubleLineEdit()
|
|
Shinya Kitaoka |
120a6e |
, ToolOptionControl(tool, property->getName())
|
|
Shinya Kitaoka |
120a6e |
, m_param()
|
|
Shinya Kitaoka |
120a6e |
, m_measure()
|
|
Shinya Kitaoka |
120a6e |
, m_property(property)
|
|
Shinya Kitaoka |
120a6e |
, m_globalKey()
|
|
Shinya Kitaoka |
120a6e |
, m_globalGroup() {
|
|
Shinya Kitaoka |
120a6e |
setFixedSize(70, 20);
|
|
Shinya Kitaoka |
120a6e |
m_property->addListener(this);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
setDecimals(decimals);
|
|
Shinya Kitaoka |
120a6e |
updateStatus();
|
|
Shinya Kitaoka |
120a6e |
connect(this, SIGNAL(valueChanged()), SLOT(onValueChanged()));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ToolOptionParamRelayField::setGlobalKey(TBoolProperty *globalKey,
|
|
Shinya Kitaoka |
120a6e |
TPropertyGroup *globalGroup) {
|
|
Shinya Kitaoka |
120a6e |
m_globalKey = globalKey, m_globalGroup = globalGroup;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ToolOptionParamRelayField::updateStatus() {
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP param(m_property->getParam());
|
|
Shinya Kitaoka |
120a6e |
if (param != m_param) {
|
|
Shinya Kitaoka |
120a6e |
// Initialize param referencing
|
|
Shinya Kitaoka |
120a6e |
m_param = param.getPointer();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (param) {
|
|
Shinya Kitaoka |
120a6e |
m_measure = param->getMeasure();
|
|
Shinya Kitaoka |
120a6e |
setMeasure(m_measure ? m_measure->getName() : "");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
setValue(m_property->getValue());
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (!param) {
|
|
Shinya Kitaoka |
120a6e |
setEnabled(false);
|
|
Shinya Kitaoka |
120a6e |
m_measure = 0;
|
|
Shinya Kitaoka |
120a6e |
setText("");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
setEnabled(true);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TMeasure *measure = param->getMeasure();
|
|
Shinya Kitaoka |
120a6e |
if (measure != m_measure) {
|
|
Shinya Kitaoka |
120a6e |
// Update measure if needed
|
|
Shinya Kitaoka |
120a6e |
m_measure = measure;
|
|
Shinya Kitaoka |
120a6e |
setMeasure(measure ? measure->getName() : "");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double v = m_property->getValue();
|
|
Shinya Kitaoka |
120a6e |
if (getValue() == v) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// Update value if needed
|
|
Shinya Kitaoka |
120a6e |
setValue(v);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ToolOptionParamRelayField::onValueChanged() {
|
|
Shinya Kitaoka |
120a6e |
struct locals {
|
|
Shinya Kitaoka |
120a6e |
static inline void setKeyframe(TDoubleParamRelayProperty *prop) {
|
|
Shinya Kitaoka |
120a6e |
if (!prop) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TDoubleParam *param = prop->getParam().getPointer();
|
|
Shinya Kitaoka |
120a6e |
if (!param) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double frame = prop->frame();
|
|
Shinya Kitaoka |
120a6e |
if (!param->isKeyframe(frame)) {
|
|
Shinya Kitaoka |
120a6e |
KeyframeSetter setter(param, -1, true);
|
|
Shinya Kitaoka |
120a6e |
setter.createKeyframe(frame);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
struct SetValueUndo final : public TUndo {
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP m_param; //!< The referenced param
|
|
Shinya Kitaoka |
120a6e |
double m_oldVal, m_newVal; //!< Values before and after the set action...
|
|
Shinya Kitaoka |
120a6e |
double m_frame; //!< ... at this frame
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
public:
|
|
Shinya Kitaoka |
120a6e |
SetValueUndo(const TDoubleParamP ¶m, double oldVal, double newVal,
|
|
Shinya Kitaoka |
120a6e |
double frame)
|
|
Shinya Kitaoka |
120a6e |
: m_param(param)
|
|
Shinya Kitaoka |
120a6e |
, m_oldVal(oldVal)
|
|
Shinya Kitaoka |
120a6e |
, m_newVal(newVal)
|
|
Shinya Kitaoka |
120a6e |
, m_frame(frame) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int getSize() const {
|
|
Shinya Kitaoka |
120a6e |
return sizeof(SetValueUndo) + sizeof(TDoubleParam);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
void undo() const { m_param->setValue(m_frame, m_oldVal); }
|
|
Shinya Kitaoka |
120a6e |
void redo() const { m_param->setValue(m_frame, m_newVal); }
|
|
Shinya Kitaoka |
120a6e |
};
|
|
Shinya Kitaoka |
120a6e |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// NOTE: Values are extracted upon entry, since setting a keyframe reverts the
|
|
Shinya Kitaoka |
120a6e |
// lineEdit
|
|
Shinya Kitaoka |
120a6e |
// field value back to the original value (due to feedback from the param
|
|
Shinya Kitaoka |
120a6e |
// itself)...
|
|
Shinya Kitaoka |
120a6e |
double oldVal = m_property->getValue(), newVal = getValue(),
|
|
Shinya Kitaoka |
120a6e |
frame = m_property->frame();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TDoubleParamP param = m_property->getParam();
|
|
Shinya Kitaoka |
120a6e |
if (!param) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TUndoManager *manager = TUndoManager::manager();
|
|
Shinya Kitaoka |
120a6e |
manager->beginBlock();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (m_globalKey && m_globalGroup && m_globalKey->getValue()) {
|
|
Shinya Kitaoka |
120a6e |
// Set a keyframe for each of the TDoubleParam relayed in the globalGroup
|
|
Shinya Kitaoka |
120a6e |
int p, pCount = m_globalGroup->getPropertyCount();
|
|
Shinya Kitaoka |
120a6e |
for (p = 0; p != pCount; ++p) {
|
|
Shinya Kitaoka |
120a6e |
TProperty *prop = m_globalGroup->getProperty(p);
|
|
Shinya Kitaoka |
120a6e |
if (TDoubleParamRelayProperty *relProp =
|
|
Shinya Kitaoka |
120a6e |
dynamic_cast<tdoubleparamrelayproperty *="">(prop))</tdoubleparamrelayproperty>
|
|
Shinya Kitaoka |
120a6e |
locals::setKeyframe(relProp);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
// Set a keyframe just for our param
|
|
Shinya Kitaoka |
120a6e |
locals::setKeyframe(m_property);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Assign the edited value to the relayed param
|
|
Shinya Kitaoka |
120a6e |
m_property->setValue(newVal);
|
|
Shinya Kitaoka |
120a6e |
notifyTool();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
manager->add(new locals::SetValueUndo(param, oldVal, newVal, frame));
|
|
Shinya Kitaoka |
120a6e |
manager->endBlock();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
// Widget specifici di ArrowTool (derivati da ToolOptionControl)
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// SPOSTA in un file a parte!
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
using namespace DVGui;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
MeasuredValueField::MeasuredValueField(QWidget *parent, QString name)
|
|
Shinya Kitaoka |
120a6e |
: LineEdit(name, parent)
|
|
Shinya Kitaoka |
120a6e |
, m_isGlobalKeyframe(false)
|
|
Shinya Kitaoka |
120a6e |
, m_modified(false)
|
|
Shinya Kitaoka |
120a6e |
, m_errorHighlighting(false)
|
|
Shinya Kitaoka |
120a6e |
, m_precision(2) {
|
|
Shinya Kitaoka |
120a6e |
setObjectName("MeasuredValueField");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
m_value = new TMeasuredValue("length");
|
|
Shinya Kitaoka |
120a6e |
setText(QString::fromStdWString(m_value->toWideString(m_precision)));
|
|
Shinya Kitaoka |
120a6e |
connect(this, SIGNAL(textChanged(const QString &)), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(onTextChanged(const QString &)));
|
|
Shinya Kitaoka |
120a6e |
connect(this, SIGNAL(editingFinished()), SLOT(commit()));
|
|
Shinya Kitaoka |
120a6e |
connect(&m_errorHighlightingTimer, SIGNAL(timeout()), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(errorHighlightingTick()));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
MeasuredValueField::~MeasuredValueField() { delete m_value; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void MeasuredValueField::setMeasure(std::string name) {
|
|
Shinya Kitaoka |
120a6e |
// for reproducing the precision
|
|
Shinya Kitaoka |
120a6e |
int oldPrec = -1;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
delete m_value;
|
|
Shinya Kitaoka |
120a6e |
m_value = new TMeasuredValue(name != "" ? name : "dummy");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
setText(QString::fromStdWString(m_value->toWideString(m_precision)));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void MeasuredValueField::commit() {
|
|
Shinya Kitaoka |
120a6e |
if (!m_modified && !isReturnPressed()) return;
|
|
Shinya Kitaoka |
120a6e |
int err = 1;
|
|
Shinya Kitaoka |
120a6e |
bool isSet = m_value->setValue(text().toStdWString(), &err);
|
|
Shinya Kitaoka |
120a6e |
m_modified = false;
|
|
Shinya Kitaoka |
120a6e |
if (err != 0) {
|
|
Shinya Kitaoka |
120a6e |
setText(QString::fromStdWString(m_value->toWideString(m_precision)));
|
|
Shinya Kitaoka |
120a6e |
m_errorHighlighting = 1;
|
|
Shinya Kitaoka |
120a6e |
if (!m_errorHighlightingTimer.isActive())
|
|
Shinya Kitaoka |
120a6e |
m_errorHighlightingTimer.start(40);
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
if (m_errorHighlightingTimer.isActive()) m_errorHighlightingTimer.stop();
|
|
Shinya Kitaoka |
120a6e |
m_errorHighlighting = 0;
|
|
Shinya Kitaoka |
120a6e |
setStyleSheet("");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (!isSet && !isReturnPressed()) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
setText(QString::fromStdWString(m_value->toWideString(m_precision)));
|
|
Shinya Kitaoka |
120a6e |
m_modified = false;
|
|
Shinya Kitaoka |
120a6e |
emit measuredValueChanged(m_value);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void MeasuredValueField::onTextChanged(const QString &) { m_modified = true; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void MeasuredValueField::setValue(double v) {
|
|
Shinya Kitaoka |
120a6e |
if (getValue() == v) return;
|
|
Shinya Kitaoka |
120a6e |
m_value->setValue(TMeasuredValue::MainUnit, v);
|
|
Shinya Kitaoka |
120a6e |
setText(QString::fromStdWString(m_value->toWideString(m_precision)));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double MeasuredValueField::getValue() const {
|
|
Shinya Kitaoka |
120a6e |
return m_value->getValue(TMeasuredValue::MainUnit);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void MeasuredValueField::errorHighlightingTick() {
|
|
Shinya Kitaoka |
120a6e |
if (m_errorHighlighting < 0.01) {
|
|
Shinya Kitaoka |
120a6e |
if (m_errorHighlightingTimer.isActive()) m_errorHighlightingTimer.stop();
|
|
Shinya Kitaoka |
120a6e |
m_errorHighlighting = 0;
|
|
Shinya Kitaoka |
120a6e |
setStyleSheet("");
|
|
Shinya Kitaoka |
120a6e |
} else {
|
|
Shinya Kitaoka |
120a6e |
int v = 255 - (int)(m_errorHighlighting * 255);
|
|
Shinya Kitaoka |
120a6e |
m_errorHighlighting = m_errorHighlighting * 0.8;
|
|
Shinya Kitaoka |
120a6e |
int c = 255 << 16 | v << 8 | v;
|
|
Shinya Kitaoka |
120a6e |
setStyleSheet(QString("#MeasuredValueField {background-color:#%1}")
|
|
Shinya Kitaoka |
120a6e |
.arg(c, 6, 16, QLatin1Char('0')));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void MeasuredValueField::setPrecision(int precision) {
|
|
Shinya Kitaoka |
120a6e |
m_precision = precision;
|
|
Shinya Kitaoka |
120a6e |
setText(QString::fromStdWString(m_value->toWideString(m_precision)));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
c86c5d |
namespace {
|
|
Shinya Kitaoka |
d1f6c4 |
// calculate maximum field size (once) with 10 pixels margin
|
|
Shinya Kitaoka |
d1f6c4 |
int getMaximumWidthForEditToolField(QWidget *widget) {
|
|
Shinya Kitaoka |
d1f6c4 |
static int fieldMaxWidth = widget->fontMetrics().width("-0000.00 field") + 10;
|
|
Shinya Kitaoka |
d1f6c4 |
return fieldMaxWidth;
|
|
Shinya Kitaoka |
d1f6c4 |
}
|
|
Shinya Kitaoka |
d1f6c4 |
} // namespace
|
|
shun-iwasawa |
c86c5d |
|
|
Shinya Kitaoka |
120a6e |
PegbarChannelField::PegbarChannelField(TTool *tool,
|
|
Shinya Kitaoka |
120a6e |
enum TStageObject::Channel actionId,
|
|
Shinya Kitaoka |
120a6e |
QString name, TFrameHandle *frameHandle,
|
|
Shinya Kitaoka |
120a6e |
TObjectHandle *objHandle,
|
|
Shinya Kitaoka |
120a6e |
TXsheetHandle *xshHandle,
|
|
Shinya Kitaoka |
120a6e |
QWidget *parent)
|
|
Shinya Kitaoka |
120a6e |
: MeasuredValueField(parent, name)
|
|
Shinya Kitaoka |
120a6e |
, ToolOptionControl(tool, "")
|
|
Shinya Kitaoka |
120a6e |
, m_actionId(actionId)
|
|
Shinya Kitaoka |
120a6e |
, m_frameHandle(frameHandle)
|
|
Shinya Kitaoka |
120a6e |
, m_objHandle(objHandle)
|
|
Shinya Kitaoka |
120a6e |
, m_xshHandle(xshHandle)
|
|
Shinya Kitaoka |
120a6e |
, m_scaleType(eNone) {
|
|
Shinya Kitaoka |
120a6e |
bool ret = connect(this, SIGNAL(measuredValueChanged(TMeasuredValue *)),
|
|
Shinya Kitaoka |
120a6e |
SLOT(onChange(TMeasuredValue *)));
|
|
Shinya Kitaoka |
120a6e |
assert(ret);
|
|
Shinya Kitaoka |
120a6e |
// NOTA: per le unita' di misura controlla anche tpegbar.cpp
|
|
Shinya Kitaoka |
120a6e |
switch (actionId) {
|
|
Shinya Kitaoka |
120a6e |
case TStageObject::T_X:
|
|
Shinya Kitaoka |
120a6e |
setMeasure("length.x");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case TStageObject::T_Y:
|
|
Shinya Kitaoka |
120a6e |
setMeasure("length.y");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case TStageObject::T_Z:
|
|
Shinya Kitaoka |
120a6e |
setMeasure("zdepth");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case TStageObject::T_Path:
|
|
Shinya Kitaoka |
120a6e |
setMeasure("percentage2");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case TStageObject::T_ShearX:
|
|
Shinya Kitaoka |
120a6e |
case TStageObject::T_ShearY:
|
|
Shinya Kitaoka |
120a6e |
setMeasure("shear");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case TStageObject::T_Angle:
|
|
Shinya Kitaoka |
120a6e |
setMeasure("angle");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
case TStageObject::T_ScaleX:
|
|
Shinya Kitaoka |
120a6e |
case TStageObject::T_ScaleY:
|
|
Shinya Kitaoka |
120a6e |
case TStageObject::T_Scale:
|
|
Shinya Kitaoka |
120a6e |
setMeasure("scale");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
default:
|
|
Shinya Kitaoka |
120a6e |
setMeasure("dummy");
|
|
Shinya Kitaoka |
120a6e |
break;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
shun-iwasawa |
c86c5d |
|
|
shun-iwasawa |
c86c5d |
setMaximumWidth(getMaximumWidthForEditToolField(this));
|
|
Shinya Kitaoka |
d1f6c4 |
|
|
Shinya Kitaoka |
120a6e |
updateStatus();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void PegbarChannelField::onChange(TMeasuredValue *fld) {
|
|
Shinya Kitaoka |
120a6e |
if (!m_tool->isEnabled()) return;
|
|
Jeremy Bullock |
fa8f3e |
|
|
Jeremy Bullock |
fa8f3e |
// the camera will crash with a value of 0
|
|
Jeremy Bullock |
fa8f3e |
if (m_tool->getObjectId().isCamera()) {
|
|
Jeremy Bullock |
fa8f3e |
if (fld->getMeasure()->getName() == "scale" &&
|
|
Jeremy Bullock |
fa8f3e |
fld->getValue(TMeasuredValue::MainUnit) == 0) {
|
|
Jeremy Bullock |
fa8f3e |
fld->setValue(TMeasuredValue::MainUnit, 0.0001);
|
|
Jeremy Bullock |
fa8f3e |
}
|
|
Jeremy Bullock |
fa8f3e |
}
|
|
Shinya Kitaoka |
120a6e |
TUndoManager::manager()->beginBlock();
|
|
Shinya Kitaoka |
120a6e |
TStageObjectValues before;
|
|
Shinya Kitaoka |
120a6e |
before.setFrameHandle(m_frameHandle);
|
|
Shinya Kitaoka |
120a6e |
before.setObjectHandle(m_objHandle);
|
|
Shinya Kitaoka |
120a6e |
before.setXsheetHandle(m_xshHandle);
|
|
Shinya Kitaoka |
120a6e |
before.add(m_actionId);
|
|
Shinya Kitaoka |
120a6e |
bool modifyConnectedActionId = false;
|
|
Shinya Kitaoka |
120a6e |
if (m_scaleType != eNone) {
|
|
Shinya Kitaoka |
120a6e |
modifyConnectedActionId = true;
|
|
Shinya Kitaoka |
120a6e |
if (m_actionId == TStageObject::T_ScaleX)
|
|
Shinya Kitaoka |
120a6e |
before.add(TStageObject::T_ScaleY);
|
|
Shinya Kitaoka |
120a6e |
else if (m_actionId == TStageObject::T_ScaleY)
|
|
Shinya Kitaoka |
120a6e |
before.add(TStageObject::T_ScaleX);
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
modifyConnectedActionId = false;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
if (m_isGlobalKeyframe) {
|
|
Shinya Kitaoka |
120a6e |
before.add(TStageObject::T_Angle);
|
|
Shinya Kitaoka |
120a6e |
before.add(TStageObject::T_X);
|
|
Shinya Kitaoka |
120a6e |
before.add(TStageObject::T_Y);
|
|
Shinya Kitaoka |
120a6e |
before.add(TStageObject::T_Z);
|
|
Shinya Kitaoka |
120a6e |
before.add(TStageObject::T_SO);
|
|
Shinya Kitaoka |
120a6e |
before.add(TStageObject::T_ScaleX);
|
|
Shinya Kitaoka |
120a6e |
before.add(TStageObject::T_ScaleY);
|
|
Shinya Kitaoka |
120a6e |
before.add(TStageObject::T_Scale);
|
|
Shinya Kitaoka |
120a6e |
before.add(TStageObject::T_Path);
|
|
Shinya Kitaoka |
120a6e |
before.add(TStageObject::T_ShearX);
|
|
Shinya Kitaoka |
120a6e |
before.add(TStageObject::T_ShearY);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
before.updateValues();
|
|
Shinya Kitaoka |
120a6e |
TStageObjectValues after;
|
|
Shinya Kitaoka |
120a6e |
after = before;
|
|
Shinya Kitaoka |
120a6e |
double v = fld->getValue(TMeasuredValue::MainUnit);
|
|
Shinya Kitaoka |
120a6e |
if (modifyConnectedActionId) {
|
|
Shinya Kitaoka |
120a6e |
double oldv1 = after.getValue(0);
|
|
Shinya Kitaoka |
120a6e |
double oldv2 = after.getValue(1);
|
|
Shinya Kitaoka |
120a6e |
double newV;
|
|
Shinya Kitaoka |
120a6e |
if (m_scaleType == eAR)
|
|
Shinya Kitaoka |
120a6e |
newV = (v / oldv1) * oldv2;
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
newV = (v == 0) ? 10000 : (1 / v) * (oldv1 * oldv2);
|
|
Shinya Kitaoka |
120a6e |
after.setValues(v, newV);
|
|
Shinya Kitaoka |
120a6e |
} else
|
|
Shinya Kitaoka |
120a6e |
after.setValue(v);
|
|
Shinya Kitaoka |
120a6e |
after.applyValues();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TTool::Viewer *viewer = m_tool->getViewer();
|
|
Shinya Kitaoka |
120a6e |
if (viewer) m_tool->invalidate();
|
|
Shinya Kitaoka |
120a6e |
setCursorPosition(0);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
UndoStageObjectMove *undo = new UndoStageObjectMove(before, after);
|
|
Shinya Kitaoka |
120a6e |
undo->setObjectHandle(m_objHandle);
|
|
Shinya Kitaoka |
120a6e |
TUndoManager::manager()->add(undo);
|
|
Shinya Kitaoka |
120a6e |
TUndoManager::manager()->endBlock();
|
|
Shinya Kitaoka |
120a6e |
m_objHandle->notifyObjectIdChanged(false);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void PegbarChannelField::updateStatus() {
|
|
Shinya Kitaoka |
120a6e |
TXsheet *xsh = m_tool->getXsheet();
|
|
Shinya Kitaoka |
120a6e |
int frame = m_tool->getFrame();
|
|
Shinya Kitaoka |
120a6e |
TStageObjectId objId = m_tool->getObjectId();
|
|
Shinya Kitaoka |
120a6e |
if (m_actionId == TStageObject::T_Z)
|
|
Shinya Kitaoka |
120a6e |
setMeasure(objId.isCamera() ? "zdepth.cam" : "zdepth");
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
double v = xsh->getStageObject(objId)->getParam(m_actionId, frame);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (getValue() == v) return;
|
|
Shinya Kitaoka |
120a6e |
setValue(v);
|
|
Shinya Kitaoka |
120a6e |
setCursorPosition(0);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void PegbarChannelField::onScaleTypeChanged(int type) {
|
|
Shinya Kitaoka |
120a6e |
m_scaleType = (ScaleType)type;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
PegbarCenterField::PegbarCenterField(TTool *tool, int index, QString name,
|
|
Shinya Kitaoka |
120a6e |
TObjectHandle *objHandle,
|
|
Shinya Kitaoka |
120a6e |
TXsheetHandle *xshHandle, QWidget *parent)
|
|
Shinya Kitaoka |
120a6e |
: MeasuredValueField(parent, name)
|
|
Shinya Kitaoka |
120a6e |
, ToolOptionControl(tool, "")
|
|
Shinya Kitaoka |
120a6e |
, m_index(index)
|
|
Shinya Kitaoka |
120a6e |
, m_objHandle(objHandle)
|
|
Shinya Kitaoka |
120a6e |
, m_xshHandle(xshHandle) {
|
|
Shinya Kitaoka |
120a6e |
TStageObjectId objId = m_tool->getObjectId();
|
|
Shinya Kitaoka |
120a6e |
setMeasure(m_index == 0 ? "length.x" : "length.y");
|
|
Shinya Kitaoka |
120a6e |
connect(this, SIGNAL(measuredValueChanged(TMeasuredValue *)),
|
|
Shinya Kitaoka |
120a6e |
SLOT(onChange(TMeasuredValue *)));
|
|
Shinya Kitaoka |
120a6e |
updateStatus();
|
|
shun-iwasawa |
c86c5d |
setMaximumWidth(getMaximumWidthForEditToolField(this));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void PegbarCenterField::onChange(TMeasuredValue *fld) {
|
|
Shinya Kitaoka |
120a6e |
if (!m_tool->isEnabled()) return;
|
|
Shinya Kitaoka |
120a6e |
TXsheet *xsh = m_tool->getXsheet();
|
|
Shinya Kitaoka |
120a6e |
int frame = m_tool->getFrame();
|
|
Shinya Kitaoka |
120a6e |
TStageObjectId objId = m_tool->getObjectId();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TStageObject *obj = xsh->getStageObject(objId);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double v = fld->getValue(TMeasuredValue::MainUnit);
|
|
Shinya Kitaoka |
120a6e |
TPointD center = obj->getCenter(frame);
|
|
Shinya Kitaoka |
120a6e |
TPointD oldCenter = center;
|
|
Shinya Kitaoka |
120a6e |
if (m_index == 0)
|
|
Shinya Kitaoka |
120a6e |
center.x = v;
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
center.y = v;
|
|
Shinya Kitaoka |
120a6e |
obj->setCenter(frame, center);
|
|
Shinya Kitaoka |
120a6e |
m_tool->invalidate();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
UndoStageObjectCenterMove *undo =
|
|
Shinya Kitaoka |
120a6e |
new UndoStageObjectCenterMove(objId, frame, oldCenter, center);
|
|
Shinya Kitaoka |
120a6e |
undo->setObjectHandle(m_objHandle);
|
|
Shinya Kitaoka |
120a6e |
undo->setXsheetHandle(m_xshHandle);
|
|
Shinya Kitaoka |
120a6e |
TUndoManager::manager()->add(undo);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
m_objHandle->notifyObjectIdChanged(false);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void PegbarCenterField::updateStatus() {
|
|
Shinya Kitaoka |
120a6e |
TXsheet *xsh = m_tool->getXsheet();
|
|
Shinya Kitaoka |
120a6e |
int frame = m_tool->getFrame();
|
|
Shinya Kitaoka |
120a6e |
TStageObjectId objId = m_tool->getObjectId();
|
|
Shinya Kitaoka |
120a6e |
TStageObject *obj = xsh->getStageObject(objId);
|
|
Shinya Kitaoka |
120a6e |
TPointD center = obj->getCenter(frame);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double v = m_index == 0 ? center.x : center.y;
|
|
Shinya Kitaoka |
120a6e |
if (getValue() == v) return;
|
|
Shinya Kitaoka |
120a6e |
setValue(v);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
NoScaleField::NoScaleField(TTool *tool, QString name)
|
|
Shinya Kitaoka |
120a6e |
: MeasuredValueField(0, name), ToolOptionControl(tool, "") {
|
|
Shinya Kitaoka |
120a6e |
TStageObjectId objId = m_tool->getObjectId();
|
|
Shinya Kitaoka |
120a6e |
setMeasure("zdepth");
|
|
Shinya Kitaoka |
120a6e |
connect(this, SIGNAL(measuredValueChanged(TMeasuredValue *)),
|
|
Shinya Kitaoka |
120a6e |
SLOT(onChange(TMeasuredValue *)));
|
|
Shinya Kitaoka |
120a6e |
updateStatus();
|
|
shun-iwasawa |
c86c5d |
setMaximumWidth(getMaximumWidthForEditToolField(this));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void NoScaleField::onChange(TMeasuredValue *fld) {
|
|
Shinya Kitaoka |
120a6e |
if (!m_tool->isEnabled()) return;
|
|
Shinya Kitaoka |
120a6e |
TXsheet *xsh = m_tool->getXsheet();
|
|
Shinya Kitaoka |
120a6e |
int frame = m_tool->getFrame();
|
|
Shinya Kitaoka |
120a6e |
TStageObjectId objId = m_tool->getObjectId();
|
|
Shinya Kitaoka |
120a6e |
TStageObject *obj = xsh->getStageObject(objId);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (m_isGlobalKeyframe)
|
|
Shinya Kitaoka |
120a6e |
xsh->getStageObject(objId)->setKeyframeWithoutUndo(frame);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double v = fld->getValue(TMeasuredValue::MainUnit);
|
|
Shinya Kitaoka |
120a6e |
obj->setNoScaleZ(v);
|
|
Shinya Kitaoka |
120a6e |
m_tool->invalidate();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void NoScaleField::updateStatus() {
|
|
Shinya Kitaoka |
120a6e |
TXsheet *xsh = m_tool->getXsheet();
|
|
Shinya Kitaoka |
120a6e |
int frame = m_tool->getFrame();
|
|
Shinya Kitaoka |
120a6e |
TStageObjectId objId = m_tool->getObjectId();
|
|
Shinya Kitaoka |
120a6e |
TStageObject *obj = xsh->getStageObject(objId);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double v = obj->getNoScaleZ();
|
|
Shinya Kitaoka |
120a6e |
if (getValue() == v) return;
|
|
Shinya Kitaoka |
120a6e |
setValue(v);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
PropertyMenuButton::PropertyMenuButton(QWidget *parent, TTool *tool,
|
|
Shinya Kitaoka |
120a6e |
QList<tboolproperty *=""> properties,</tboolproperty>
|
|
Shinya Kitaoka |
120a6e |
QIcon icon, QString tooltip)
|
|
Shinya Kitaoka |
120a6e |
: QToolButton(parent)
|
|
Shinya Kitaoka |
120a6e |
, ToolOptionControl(tool, "")
|
|
Shinya Kitaoka |
120a6e |
, m_properties(properties) {
|
|
Shinya Kitaoka |
120a6e |
setPopupMode(QToolButton::InstantPopup);
|
|
Shinya Kitaoka |
120a6e |
setIcon(icon);
|
|
Shinya Kitaoka |
120a6e |
setToolTip(tooltip);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QMenu *menu = new QMenu(tooltip, this);
|
|
Shinya Kitaoka |
120a6e |
if (!tooltip.isEmpty()) tooltip = tooltip + " ";
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QActionGroup *actiongroup = new QActionGroup(this);
|
|
Shinya Kitaoka |
120a6e |
actiongroup->setExclusive(false);
|
|
Shinya Kitaoka |
120a6e |
int i;
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < m_properties.count(); i++) {
|
|
Shinya Kitaoka |
120a6e |
TBoolProperty *prop = m_properties.at(i);
|
|
Shinya Kitaoka |
120a6e |
QString propertyName = prop->getQStringName();
|
|
Shinya Kitaoka |
120a6e |
// Se il tooltip essagnato e' contenuto nel nome della proprieta' lo levo
|
|
Shinya Kitaoka |
120a6e |
// dalla stringa dell'azione
|
|
Shinya Kitaoka |
120a6e |
if (propertyName.contains(tooltip)) propertyName.remove(tooltip);
|
|
Shinya Kitaoka |
120a6e |
QAction *action = menu->addAction(propertyName);
|
|
Shinya Kitaoka |
120a6e |
action->setCheckable(true);
|
|
Shinya Kitaoka |
120a6e |
action->setChecked(prop->getValue());
|
|
Shinya Kitaoka |
120a6e |
action->setData(QVariant(i));
|
|
Shinya Kitaoka |
120a6e |
actiongroup->addAction(action);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
bool ret = connect(actiongroup, SIGNAL(triggered(QAction *)),
|
|
Shinya Kitaoka |
120a6e |
SLOT(onActionTriggered(QAction *)));
|
|
Shinya Kitaoka |
120a6e |
assert(ret);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
setMenu(menu);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void PropertyMenuButton::updateStatus() {
|
|
Shinya Kitaoka |
120a6e |
QMenu *m = menu();
|
|
Shinya Kitaoka |
120a6e |
assert(m);
|
|
Shinya Kitaoka |
120a6e |
QList<qaction *=""> actionList = m->actions();</qaction>
|
|
Shinya Kitaoka |
120a6e |
assert(actionList.count() == m_properties.count());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int i;
|
|
Shinya Kitaoka |
120a6e |
for (i = 0; i < m_properties.count(); i++) {
|
|
Shinya Kitaoka |
120a6e |
TBoolProperty *prop = m_properties.at(i);
|
|
Shinya Kitaoka |
120a6e |
QAction *action = actionList.at(i);
|
|
Shinya Kitaoka |
120a6e |
bool isPropertyLocked = prop->getValue();
|
|
Shinya Kitaoka |
120a6e |
if (action->isChecked() != isPropertyLocked)
|
|
Shinya Kitaoka |
120a6e |
action->setChecked(isPropertyLocked);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void PropertyMenuButton::onActionTriggered(QAction *action) {
|
|
Shinya Kitaoka |
120a6e |
int currentPropertyIndex = action->data().toInt();
|
|
Shinya Kitaoka |
120a6e |
TBoolProperty *prop = m_properties.at(currentPropertyIndex);
|
|
Shinya Kitaoka |
120a6e |
bool isChecked = action->isChecked();
|
|
Shinya Kitaoka |
120a6e |
if (isChecked == prop->getValue()) return;
|
|
Shinya Kitaoka |
120a6e |
prop->setValue(isChecked);
|
|
Shinya Kitaoka |
120a6e |
notifyTool();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
emit onPropertyChanged(QString(prop->getName().c_str()));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Shinya Kitaoka |
d1f6c4 |
namespace {
|
|
Shinya Kitaoka |
d1f6c4 |
// calculate maximum field size (once) with 10 pixels margin
|
|
Shinya Kitaoka |
d1f6c4 |
int getMaximumWidthForSelectionToolField(QWidget *widget) {
|
|
Shinya Kitaoka |
d1f6c4 |
static int fieldMaxWidth = widget->fontMetrics().width("-000.00 %") + 10;
|
|
Shinya Kitaoka |
d1f6c4 |
return fieldMaxWidth;
|
|
Shinya Kitaoka |
d1f6c4 |
}
|
|
Shinya Kitaoka |
d1f6c4 |
} // namespace
|
|
shun-iwasawa |
c86c5d |
|
|
Shinya Kitaoka |
120a6e |
// id == 0 Scale X
|
|
Shinya Kitaoka |
120a6e |
// id == 0 Scale Y
|
|
Shinya Kitaoka |
120a6e |
SelectionScaleField::SelectionScaleField(SelectionTool *tool, int id,
|
|
Shinya Kitaoka |
120a6e |
QString name)
|
|
Shinya Kitaoka |
120a6e |
: MeasuredValueField(0, name), m_tool(tool), m_id(id) {
|
|
Shinya Kitaoka |
120a6e |
bool ret = connect(this, SIGNAL(measuredValueChanged(TMeasuredValue *)),
|
|
Shinya Kitaoka |
120a6e |
SLOT(onChange(TMeasuredValue *)));
|
|
Shinya Kitaoka |
120a6e |
assert(ret);
|
|
Shinya Kitaoka |
120a6e |
setMeasure("scale");
|
|
Shinya Kitaoka |
120a6e |
updateStatus();
|
|
shun-iwasawa |
c86c5d |
|
|
shun-iwasawa |
c86c5d |
setMaximumWidth(getMaximumWidthForSelectionToolField(this));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
bool SelectionScaleField::applyChange() {
|
|
Shinya Kitaoka |
120a6e |
if (!m_tool || (m_tool->isSelectionEmpty() && !m_tool->isLevelType()))
|
|
Shinya Kitaoka |
120a6e |
return false;
|
|
Shinya Kitaoka |
120a6e |
DragSelectionTool::DragTool *scaleTool = createNewScaleTool(m_tool, 0);
|
|
Shinya Kitaoka |
120a6e |
double p = getValue();
|
|
Shinya Kitaoka |
120a6e |
if (p == 0) p = 0.00001;
|
|
Shinya Kitaoka |
120a6e |
DragSelectionTool::FourPoints points = m_tool->getBBox();
|
|
Shinya Kitaoka |
120a6e |
TPointD center = m_tool->getCenter();
|
|
Shinya Kitaoka |
120a6e |
TPointD p0M = points.getPoint(7);
|
|
Shinya Kitaoka |
120a6e |
TPointD p1M = points.getPoint(5);
|
|
Shinya Kitaoka |
120a6e |
TPointD pM1 = points.getPoint(6);
|
|
Shinya Kitaoka |
120a6e |
TPointD pM0 = points.getPoint(4);
|
|
Shinya Kitaoka |
120a6e |
int pointIndex;
|
|
Shinya Kitaoka |
120a6e |
TPointD sign(1, 1);
|
|
Shinya Kitaoka |
120a6e |
TPointD scaleFactor = m_tool->m_deformValues.m_scaleValue;
|
|
Shinya Kitaoka |
120a6e |
TPointD newPos;
|
|
Shinya Kitaoka |
120a6e |
if (m_id == 0) {
|
|
Shinya Kitaoka |
120a6e |
if (p1M == p0M) return false;
|
|
Shinya Kitaoka |
120a6e |
pointIndex = 7;
|
|
Shinya Kitaoka |
120a6e |
TPointD v = normalize(p1M - p0M);
|
|
Shinya Kitaoka |
120a6e |
double currentD = tdistance(p1M, p0M);
|
|
Shinya Kitaoka |
120a6e |
double startD = currentD / scaleFactor.x;
|
|
Shinya Kitaoka |
120a6e |
double d = (currentD - startD * p) * tdistance(center, p0M) / currentD;
|
|
Shinya Kitaoka |
120a6e |
newPos = TPointD(p0M.x + d * v.x, p0M.y + d * v.y);
|
|
Shinya Kitaoka |
120a6e |
scaleFactor.x = p;
|
|
Shinya Kitaoka |
120a6e |
} else if (m_id == 1) {
|
|
Shinya Kitaoka |
120a6e |
if (pM1 == pM0) return false;
|
|
Shinya Kitaoka |
120a6e |
pointIndex = 4;
|
|
Shinya Kitaoka |
120a6e |
TPointD v = normalize(pM1 - pM0);
|
|
Shinya Kitaoka |
120a6e |
double currentD = tdistance(pM1, pM0);
|
|
Shinya Kitaoka |
120a6e |
double startD = currentD / scaleFactor.y;
|
|
Shinya Kitaoka |
120a6e |
double d = (currentD - startD * p) * tdistance(center, pM0) / currentD;
|
|
Shinya Kitaoka |
120a6e |
newPos = TPointD(pM0.x + d * v.x, pM0.y + d * v.y);
|
|
Shinya Kitaoka |
120a6e |
scaleFactor.y = p;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_tool->m_deformValues.m_scaleValue =
|
|
Shinya Kitaoka |
120a6e |
scaleFactor; // Instruction order is relevant
|
|
Shinya Kitaoka |
120a6e |
scaleTool->transform(pointIndex,
|
|
Shinya Kitaoka |
120a6e |
newPos); // This line invokes GUI update using the
|
|
Shinya Kitaoka |
120a6e |
// value set above
|
|
Shinya Kitaoka |
120a6e |
if (!m_tool->isLevelType()) scaleTool->addTransformUndo();
|
|
Shinya Kitaoka |
120a6e |
setCursorPosition(0);
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void SelectionScaleField::onChange(TMeasuredValue *fld) {
|
|
Shinya Kitaoka |
120a6e |
if (!m_tool->isEnabled()) return;
|
|
Shinya Kitaoka |
120a6e |
if (!applyChange()) return;
|
|
Shinya Kitaoka |
120a6e |
emit valueChange();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void SelectionScaleField::updateStatus() {
|
|
Shinya Kitaoka |
120a6e |
if (!m_tool || (m_tool->isSelectionEmpty() && !m_tool->isLevelType())) {
|
|
Shinya Kitaoka |
120a6e |
setValue(0);
|
|
Shinya Kitaoka |
120a6e |
setDisabled(true);
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
setDisabled(false);
|
|
Shinya Kitaoka |
120a6e |
if (m_id == 0)
|
|
Shinya Kitaoka |
120a6e |
setValue(m_tool->m_deformValues.m_scaleValue.x);
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
setValue(m_tool->m_deformValues.m_scaleValue.y);
|
|
Shinya Kitaoka |
120a6e |
setCursorPosition(0);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
SelectionRotationField::SelectionRotationField(SelectionTool *tool,
|
|
Shinya Kitaoka |
120a6e |
QString name)
|
|
Shinya Kitaoka |
120a6e |
: MeasuredValueField(0, name), m_tool(tool) {
|
|
Shinya Kitaoka |
120a6e |
bool ret = connect(this, SIGNAL(measuredValueChanged(TMeasuredValue *)),
|
|
Shinya Kitaoka |
120a6e |
SLOT(onChange(TMeasuredValue *)));
|
|
Shinya Kitaoka |
120a6e |
assert(ret);
|
|
Shinya Kitaoka |
120a6e |
setMeasure("angle");
|
|
Shinya Kitaoka |
120a6e |
updateStatus();
|
|
shun-iwasawa |
c86c5d |
|
|
shun-iwasawa |
c86c5d |
setMaximumWidth(getMaximumWidthForSelectionToolField(this));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SelectionRotationField::onChange(TMeasuredValue *fld) {
|
|
Shinya Kitaoka |
120a6e |
if (!m_tool || !m_tool->isEnabled() ||
|
|
Shinya Kitaoka |
120a6e |
(m_tool->isSelectionEmpty() && !m_tool->isLevelType()))
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
DragSelectionTool::DragTool *rotationTool = createNewRotationTool(m_tool);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
DragSelectionTool::DeformValues &deformValues = m_tool->m_deformValues;
|
|
Shinya Kitaoka |
120a6e |
double p = getValue();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TAffine aff =
|
|
Shinya Kitaoka |
120a6e |
TRotation(m_tool->getCenter(), p - deformValues.m_rotationAngle);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
deformValues.m_rotationAngle = p; // Instruction order is relevant here
|
|
Shinya Kitaoka |
120a6e |
rotationTool->transform(aff, p - deformValues.m_rotationAngle); //
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (!m_tool->isLevelType()) rotationTool->addTransformUndo();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
setCursorPosition(0);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SelectionRotationField::updateStatus() {
|
|
Shinya Kitaoka |
120a6e |
if (!m_tool || (m_tool->isSelectionEmpty() && !m_tool->isLevelType())) {
|
|
Shinya Kitaoka |
120a6e |
setValue(0);
|
|
Shinya Kitaoka |
120a6e |
setDisabled(true);
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
setDisabled(false);
|
|
Shinya Kitaoka |
120a6e |
setValue(m_tool->m_deformValues.m_rotationAngle);
|
|
Shinya Kitaoka |
120a6e |
setCursorPosition(0);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Shinya Kitaoka |
120a6e |
// id == 0 Move X
|
|
Shinya Kitaoka |
120a6e |
// id == 0 Move Y
|
|
Shinya Kitaoka |
120a6e |
SelectionMoveField::SelectionMoveField(SelectionTool *tool, int id,
|
|
Shinya Kitaoka |
120a6e |
QString name)
|
|
Shinya Kitaoka |
120a6e |
: MeasuredValueField(0, name), m_tool(tool), m_id(id) {
|
|
Shinya Kitaoka |
120a6e |
bool ret = connect(this, SIGNAL(measuredValueChanged(TMeasuredValue *)),
|
|
Shinya Kitaoka |
120a6e |
SLOT(onChange(TMeasuredValue *)));
|
|
Shinya Kitaoka |
120a6e |
assert(ret);
|
|
Shinya Kitaoka |
120a6e |
if (m_id == 0)
|
|
Shinya Kitaoka |
120a6e |
setMeasure("length.x");
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
setMeasure("length.y");
|
|
Shinya Kitaoka |
120a6e |
updateStatus();
|
|
shun-iwasawa |
c86c5d |
|
|
Shinya Kitaoka |
d1f6c4 |
// for translation value field, use size for the Edit Tool as it needs more
|
|
Shinya Kitaoka |
d1f6c4 |
// estate
|
|
shun-iwasawa |
c86c5d |
setMaximumWidth(getMaximumWidthForEditToolField(this));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SelectionMoveField::onChange(TMeasuredValue *fld) {
|
|
Shinya Kitaoka |
120a6e |
if (!m_tool || !m_tool->isEnabled() ||
|
|
Shinya Kitaoka |
120a6e |
(m_tool->isSelectionEmpty() && !m_tool->isLevelType()))
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
DragSelectionTool::DragTool *moveTool = createNewMoveSelectionTool(m_tool);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double p = getValue() * Stage::inch;
|
|
Shinya Kitaoka |
120a6e |
TPointD delta = (m_id == 0) ? TPointD(p, 1) : TPointD(1, p),
|
|
Shinya Kitaoka |
120a6e |
oldMove = Stage::inch * m_tool->m_deformValues.m_moveValue,
|
|
Shinya Kitaoka |
120a6e |
oldDelta =
|
|
Shinya Kitaoka |
120a6e |
(m_id == 0) ? TPointD(oldMove.x, 1) : TPointD(1, oldMove.y),
|
|
Shinya Kitaoka |
120a6e |
newMove = (m_id == 0) ? TPointD(delta.x, oldMove.y)
|
|
Shinya Kitaoka |
120a6e |
: TPointD(oldMove.x, delta.y);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TAffine aff = TTranslation(-oldDelta) * TTranslation(delta);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
m_tool->m_deformValues.m_moveValue =
|
|
Shinya Kitaoka |
120a6e |
1 / Stage::inch * newMove; // Instruction order relevant here
|
|
Shinya Kitaoka |
120a6e |
moveTool->transform(aff); //
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (!m_tool->isLevelType()) moveTool->addTransformUndo();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
setCursorPosition(0);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void SelectionMoveField::updateStatus() {
|
|
Shinya Kitaoka |
120a6e |
if (!m_tool || (m_tool->isSelectionEmpty() && !m_tool->isLevelType())) {
|
|
Shinya Kitaoka |
120a6e |
setValue(0);
|
|
Shinya Kitaoka |
120a6e |
setDisabled(true);
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
setDisabled(false);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
if (m_id == 0)
|
|
Shinya Kitaoka |
120a6e |
setValue(m_tool->m_deformValues.m_moveValue.x);
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
setValue(m_tool->m_deformValues.m_moveValue.y);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
setCursorPosition(0);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
ThickChangeField::ThickChangeField(SelectionTool *tool, QString name)
|
|
Shinya Kitaoka |
120a6e |
: MeasuredValueField(0, name), m_tool(tool) {
|
|
Shinya Kitaoka |
120a6e |
bool ret = connect(this, SIGNAL(measuredValueChanged(TMeasuredValue *)),
|
|
Shinya Kitaoka |
120a6e |
SLOT(onChange(TMeasuredValue *)));
|
|
Shinya Kitaoka |
120a6e |
assert(ret);
|
|
Shinya Kitaoka |
120a6e |
setMeasure("");
|
|
Shinya Kitaoka |
120a6e |
updateStatus();
|
|
shun-iwasawa |
c86c5d |
|
|
shun-iwasawa |
c86c5d |
setMaximumWidth(getMaximumWidthForSelectionToolField(this));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ThickChangeField::onChange(TMeasuredValue *fld) {
|
|
Shinya Kitaoka |
120a6e |
if (!m_tool || (m_tool->isSelectionEmpty() && !m_tool->isLevelType())) return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
DragSelectionTool::VectorChangeThicknessTool *changeThickTool =
|
|
Shinya Kitaoka |
120a6e |
new DragSelectionTool::VectorChangeThicknessTool(
|
|
Shinya Kitaoka |
120a6e |
(VectorSelectionTool *)m_tool);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TVectorImageP vi = (TVectorImageP)m_tool->getImage(true);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
double p = 0.5 * getValue();
|
|
Shinya Kitaoka |
120a6e |
double newThickness = p - m_tool->m_deformValues.m_maxSelectionThickness;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
changeThickTool->setThicknessChange(newThickness);
|
|
Shinya Kitaoka |
120a6e |
changeThickTool->changeImageThickness(*vi, newThickness);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// DragSelectionTool::DeformValues deformValues = m_tool->m_deformValues;
|
|
Shinya Kitaoka |
120a6e |
// // Like when I found it - it's a noop.
|
|
Shinya Kitaoka |
120a6e |
// deformValues.m_maxSelectionThickness = p;
|
|
Shinya Kitaoka |
120a6e |
// // Seems that the actual update is performed inside
|
|
Shinya Kitaoka |
120a6e |
// the above change..() instruction... >_<
|
|
Shinya Kitaoka |
120a6e |
changeThickTool->addUndo();
|
|
Shinya Kitaoka |
120a6e |
m_tool->computeBBox();
|
|
Shinya Kitaoka |
120a6e |
m_tool->invalidate();
|
|
Shinya Kitaoka |
120a6e |
m_tool->notifyImageChanged(m_tool->getCurrentFid());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ThickChangeField::updateStatus() {
|
|
Shinya Kitaoka |
120a6e |
if (!m_tool || m_tool->m_deformValues.m_isSelectionModified ||
|
|
Shinya Kitaoka |
120a6e |
(m_tool->isSelectionEmpty() && !m_tool->isLevelType())) {
|
|
Shinya Kitaoka |
120a6e |
setValue(0);
|
|
Shinya Kitaoka |
120a6e |
setDisabled(true);
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
setDisabled(false);
|
|
Shinya Kitaoka |
120a6e |
setValue(2 * m_tool->m_deformValues.m_maxSelectionThickness);
|
|
Shinya Kitaoka |
120a6e |
setCursorPosition(0);
|
|
Toshihiro Shimizu |
890ddd |
}
|