|
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/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>
|
|
shun-iwasawa |
df7bb0 |
#include <qlistview></qlistview>
|
|
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 |
|
|
Jeremy Bullock |
e122a9 |
void ToolOptionControl::notifyTool(bool addToUndo) {
|
|
Jeremy Bullock |
e122a9 |
std::string tempPropertyName = m_propertyName;
|
|
Jeremy Bullock |
e122a9 |
if (addToUndo && m_propertyName == "Maximum Gap")
|
|
Jeremy Bullock |
e122a9 |
tempPropertyName = tempPropertyName + "withUndo";
|
|
Jeremy Bullock |
e122a9 |
m_tool->onPropertyChanged(tempPropertyName);
|
|
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.
|
|
shun-iwasawa |
28a2a8 |
*/
|
|
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();
|
|
shun-iwasawa |
43640b |
|
|
shun-iwasawa |
43640b |
// for updating a cursor without any effect to the tool options
|
|
Jeremy Bullock |
22d9f9 |
if (m_toolHandle) m_toolHandle->notifyToolCursorTypeChanged();
|
|
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) {
|
|
shun-iwasawa |
76d093 |
setLinearSlider(property->isLinearSlider());
|
|
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);
|
|
Jeremy Bullock |
22d9f9 |
setMinimumWidth(50 + widgetWidth);
|
|
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());
|
|
Jeremy Bullock |
e122a9 |
notifyTool(!isDragging);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
manongjohn |
85ae4c |
void ToolOptionSlider::increase(double step) {
|
|
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 |
|
|
manongjohn |
85ae4c |
value += step;
|
|
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 |
|
|
manongjohn |
85ae4c |
void ToolOptionSlider::increaseFractional() { increase(0.06); }
|
|
manongjohn |
85ae4c |
|
|
manongjohn |
85ae4c |
//-----------------------------------------------------------------------------
|
|
manongjohn |
85ae4c |
|
|
manongjohn |
85ae4c |
void ToolOptionSlider::decrease(double step) {
|
|
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 |
|
|
manongjohn |
85ae4c |
value -= step;
|
|
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 |
|
|
manongjohn |
85ae4c |
//-----------------------------------------------------------------------------
|
|
manongjohn |
85ae4c |
|
|
manongjohn |
85ae4c |
void ToolOptionSlider::decreaseFractional() { decrease(0.06); }
|
|
manongjohn |
85ae4c |
|
|
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) {
|
|
shun-iwasawa |
76d093 |
setLinearSlider(property->isLinearSlider());
|
|
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);
|
|
Jeremy Bullock |
22d9f9 |
setMinimumWidth(120 + m_leftMargin + m_rightMargin);
|
|
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) {
|
|
shun-iwasawa |
76d093 |
setLinearSlider(property->isLinearSlider());
|
|
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);
|
|
Jeremy Bullock |
22d9f9 |
setMinimumWidth(200);
|
|
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) {
|
|
shun-iwasawa |
76d093 |
setLinearSlider(property->isLinearSlider());
|
|
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);
|
|
Jeremy Bullock |
22d9f9 |
setMinimumWidth(50);
|
|
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
|
|
manongjohn |
b66bc4 |
if (toolHandle) {
|
|
Shinya Kitaoka |
120a6e |
connect(this, SIGNAL(activated(int)), toolHandle, SIGNAL(toolChanged()));
|
|
manongjohn |
b66bc4 |
}
|
|
manongjohn |
b66bc4 |
}
|
|
manongjohn |
b66bc4 |
|
|
manongjohn |
b66bc4 |
//-----------------------------------------------------------------------------
|
|
manongjohn |
b66bc4 |
|
|
manongjohn |
b66bc4 |
void ToolOptionCombo::reloadComboBoxList(std::string id) {
|
|
manongjohn |
b66bc4 |
if (id == "" || m_property->getName() != id) return;
|
|
manongjohn |
b66bc4 |
loadEntries();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void ToolOptionCombo::loadEntries() {
|
|
shun-iwasawa |
df7bb0 |
const TEnumProperty::Range &range = m_property->getRange();
|
|
shun-iwasawa |
df7bb0 |
const TEnumProperty::Items &items = m_property->getItems();
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
df7bb0 |
const int count = m_property->getCount();
|
|
shun-iwasawa |
df7bb0 |
int maxWidth = 0;
|
|
shun-iwasawa |
c86c5d |
|
|
Shinya Kitaoka |
120a6e |
clear();
|
|
shun-iwasawa |
df7bb0 |
bool hasIcon = false;
|
|
shun-iwasawa |
df7bb0 |
for (int i = 0; i < count; ++i) {
|
|
shun-iwasawa |
df7bb0 |
QString itemStr = QString::fromStdWString(range[i]);
|
|
shun-iwasawa |
df7bb0 |
if (items[i].iconName.isEmpty())
|
|
shun-iwasawa |
df7bb0 |
addItem(items[i].UIName, itemStr);
|
|
shun-iwasawa |
df7bb0 |
else {
|
|
shun-iwasawa |
df7bb0 |
addItem(createQIcon(items[i].iconName.toUtf8()), items[i].UIName,
|
|
shun-iwasawa |
df7bb0 |
itemStr);
|
|
shun-iwasawa |
df7bb0 |
if (!hasIcon) {
|
|
shun-iwasawa |
df7bb0 |
hasIcon = true;
|
|
shun-iwasawa |
df7bb0 |
setIconSize(QSize(17, 17));
|
|
shun-iwasawa |
df7bb0 |
// add margin between items if they are with icons
|
|
shun-iwasawa |
df7bb0 |
setView(new QListView());
|
|
shun-iwasawa |
df7bb0 |
view()->setIconSize(QSize(17, 17));
|
|
shun-iwasawa |
df7bb0 |
setStyleSheet(
|
|
shun-iwasawa |
df7bb0 |
"QComboBox QAbstractItemView::item{ \
|
|
shun-iwasawa |
df7bb0 |
margin: 5 0 0 0;\
|
|
shun-iwasawa |
df7bb0 |
}");
|
|
shun-iwasawa |
df7bb0 |
}
|
|
shun-iwasawa |
df7bb0 |
}
|
|
Jeremy Bullock |
22d9f9 |
int tmpWidth = fontMetrics().width(items[i].UIName);
|
|
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 |
df7bb0 |
setMaximumWidth(maxWidth + 25 + (hasIcon ? 23 : 0));
|
|
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());
|
|
shun-iwasawa |
df7bb0 |
int index = findData(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 |
22d9f9 |
const TEnumProperty::Range &range = m_property->getRange();
|
|
Jeremy Bullock |
22d9f9 |
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"
|
|
shun-iwasawa |
28a2a8 |
if (m_property->indexOf(L"Normal") != 0) {
|
|
Shinya Kitaoka |
120a6e |
onActivated(index);
|
|
Shinya Kitaoka |
120a6e |
setCurrentIndex(index);
|
|
Shinya Kitaoka |
120a6e |
// for updating the cursor
|
|
manongjohn |
6939a3 |
if (m_toolHandle) 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
|
|
manongjohn |
525c4b |
if (m_toolHandle) m_toolHandle->notifyToolCursorTypeChanged();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
manongjohn |
b66bc4 |
ToolOptionFontCombo::ToolOptionFontCombo(TTool *tool, TEnumProperty *property,
|
|
manongjohn |
b66bc4 |
ToolHandle *toolHandle)
|
|
manongjohn |
b66bc4 |
: QFontComboBox()
|
|
manongjohn |
b66bc4 |
, ToolOptionControl(tool, property->getName(), toolHandle)
|
|
manongjohn |
b66bc4 |
, m_property(property) {
|
|
manongjohn |
b66bc4 |
setMaximumWidth(250);
|
|
manongjohn |
b66bc4 |
m_property->addListener(this);
|
|
manongjohn |
b66bc4 |
setSizeAdjustPolicy(QFontComboBox::AdjustToContents);
|
|
manongjohn |
b66bc4 |
connect(this, SIGNAL(activated(int)), this, SLOT(onActivated(int)));
|
|
manongjohn |
b66bc4 |
// synchronize the state with the same widgets in other tool option bars
|
|
manongjohn |
b66bc4 |
if (toolHandle)
|
|
manongjohn |
b66bc4 |
connect(this, SIGNAL(activated(int)), toolHandle, SIGNAL(toolChanged()));
|
|
manongjohn |
b66bc4 |
|
|
manongjohn |
b66bc4 |
updateStatus();
|
|
manongjohn |
b66bc4 |
}
|
|
manongjohn |
b66bc4 |
|
|
manongjohn |
b66bc4 |
//-----------------------------------------------------------------------------
|
|
manongjohn |
b66bc4 |
|
|
manongjohn |
b66bc4 |
void ToolOptionFontCombo::updateStatus() {
|
|
manongjohn |
b66bc4 |
QString value = QString::fromStdWString(m_property->getValue());
|
|
manongjohn |
b66bc4 |
int index = findText(value);
|
|
manongjohn |
b66bc4 |
if (index >= 0 && index != currentIndex()) setCurrentIndex(index);
|
|
manongjohn |
b66bc4 |
}
|
|
manongjohn |
b66bc4 |
|
|
manongjohn |
b66bc4 |
//-----------------------------------------------------------------------------
|
|
manongjohn |
b66bc4 |
|
|
manongjohn |
b66bc4 |
void ToolOptionFontCombo::onActivated(int index) {
|
|
manongjohn |
b66bc4 |
const TEnumProperty::Range &range = m_property->getRange();
|
|
manongjohn |
b66bc4 |
if (index < 0 || index >= (int)range.size()) return;
|
|
manongjohn |
b66bc4 |
|
|
manongjohn |
b66bc4 |
std::wstring item = range[index];
|
|
manongjohn |
b66bc4 |
m_property->setValue(item);
|
|
manongjohn |
b66bc4 |
notifyTool();
|
|
manongjohn |
b66bc4 |
}
|
|
manongjohn |
b66bc4 |
|
|
manongjohn |
b66bc4 |
//-----------------------------------------------------------------------------
|
|
manongjohn |
b66bc4 |
|
|
manongjohn |
b66bc4 |
void ToolOptionFontCombo::doShowPopup() {
|
|
manongjohn |
b66bc4 |
if (!isInVisibleViewer(this)) return;
|
|
manongjohn |
b66bc4 |
if (Preferences::instance()->getDropdownShortcutsCycleOptions()) {
|
|
Jeremy Bullock |
22d9f9 |
const TEnumProperty::Range &range = m_property->getRange();
|
|
Jeremy Bullock |
22d9f9 |
int theIndex = currentIndex() + 1;
|
|
manongjohn |
b66bc4 |
if (theIndex >= (int)range.size()) theIndex = 0;
|
|
manongjohn |
b66bc4 |
onActivated(theIndex);
|
|
manongjohn |
b66bc4 |
setCurrentIndex(theIndex);
|
|
manongjohn |
b66bc4 |
} else {
|
|
manongjohn |
b66bc4 |
if (isVisible()) showPopup();
|
|
manongjohn |
b66bc4 |
}
|
|
manongjohn |
b66bc4 |
}
|
|
manongjohn |
b66bc4 |
|
|
manongjohn |
b66bc4 |
//=============================================================================
|
|
manongjohn |
b66bc4 |
|
|
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 |
|
|
shun-iwasawa |
df7bb0 |
const TEnumProperty::Items &items = m_property->getItems();
|
|
shun-iwasawa |
df7bb0 |
const int count = m_property->getCount();
|
|
shun-iwasawa |
df7bb0 |
for (int i = 0; i < count; ++i) {
|
|
shun-iwasawa |
df7bb0 |
QAction *action = addItem(createQIcon(items[i].iconName.toUtf8()));
|
|
shun_iwasawa |
4a5f42 |
// make the tooltip text
|
|
shun-iwasawa |
df7bb0 |
action->setToolTip(items[i].UIName);
|
|
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()));
|
|
shun_iwasawa |
e553fc |
connect(pltHandle, SIGNAL(colorStyleChanged(bool)), 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 |
|
|
shun-iwasawa |
e87e08 |
// Aware of both "current" and translated string
|
|
shun-iwasawa |
e87e08 |
if (!QString("current").contains(changedText) &&
|
|
shun-iwasawa |
e87e08 |
!StyleIndexLineEdit::tr("current").contains(changedText)) {
|
|
shun-iwasawa |
102e06 |
int index = changedText.toInt();
|
|
shun-iwasawa |
102e06 |
TPalette *plt = m_pltHandle->getPalette();
|
|
shun-iwasawa |
102e06 |
if (plt && index > plt->getStyleCount())
|
|
shun-iwasawa |
102e06 |
style = QString::number(plt->getStyleCount() - 1);
|
|
Shinya Kitaoka |
120a6e |
else
|
|
Shinya Kitaoka |
120a6e |
style = text();
|
|
shun-iwasawa |
102e06 |
m_property->setValue(style.toStdWString());
|
|
shun-iwasawa |
102e06 |
} else
|
|
shun-iwasawa |
102e06 |
m_property->setValue(changedText.toStdWString());
|
|
shun-iwasawa |
102e06 |
|
|
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;
|
|
Jeremy Bullock |
771290 |
// commit is called when the field comes out of focus.
|
|
Jeremy Bullock |
771290 |
// mouse drag will call this - return if coming from mouse drag.
|
|
Jeremy Bullock |
771290 |
// else undo is set twice
|
|
Jeremy Bullock |
771290 |
if (m_mouseEdit) {
|
|
Jeremy Bullock |
771290 |
m_mouseEdit = false;
|
|
Jeremy Bullock |
771290 |
return;
|
|
Jeremy Bullock |
771290 |
}
|
|
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 |
|
|
Jeremy Bullock |
771290 |
//-----------------------------------------------------------------------------
|
|
Jeremy Bullock |
771290 |
|
|
Jeremy Bullock |
771290 |
void MeasuredValueField::mousePressEvent(QMouseEvent *e) {
|
|
Jeremy Bullock |
771290 |
if (!isEnabled()) return;
|
|
Jeremy Bullock |
771290 |
if ((e->buttons() == Qt::MiddleButton) || m_labelClicked) {
|
|
Jeremy Bullock |
771290 |
m_xMouse = e->x();
|
|
Jeremy Bullock |
771290 |
m_mouseEdit = true;
|
|
Jeremy Bullock |
771290 |
m_originalValue = m_value->getValue(TMeasuredValue::CurrentUnit);
|
|
shun_iwasawa |
23727d |
} else {
|
|
Jeremy Bullock |
771290 |
QLineEdit::mousePressEvent(e);
|
|
shun_iwasawa |
23727d |
if (!m_isTyping) { // only the first click will select all
|
|
shun_iwasawa |
23727d |
selectAll();
|
|
shun_iwasawa |
23727d |
m_isTyping = true;
|
|
shun_iwasawa |
23727d |
}
|
|
shun_iwasawa |
23727d |
}
|
|
Jeremy Bullock |
771290 |
}
|
|
Jeremy Bullock |
771290 |
|
|
Jeremy Bullock |
771290 |
//-----------------------------------------------------------------------------
|
|
Jeremy Bullock |
771290 |
|
|
Jeremy Bullock |
771290 |
void MeasuredValueField::mouseMoveEvent(QMouseEvent *e) {
|
|
Jeremy Bullock |
771290 |
if (!isEnabled()) return;
|
|
Jeremy Bullock |
771290 |
if ((e->buttons() == Qt::MiddleButton) || m_labelClicked) {
|
|
Jeremy Bullock |
771290 |
m_value->modifyValue((e->x() - m_xMouse) / 2);
|
|
Jeremy Bullock |
771290 |
setText(QString::fromStdWString(m_value->toWideString(m_precision)));
|
|
Jeremy Bullock |
771290 |
m_xMouse = e->x();
|
|
Jeremy Bullock |
771290 |
// measuredValueChanged to update the UI, but don't add to undo
|
|
Jeremy Bullock |
771290 |
emit measuredValueChanged(m_value, false);
|
|
Jeremy Bullock |
771290 |
} else
|
|
Jeremy Bullock |
771290 |
QLineEdit::mouseMoveEvent(e);
|
|
Jeremy Bullock |
771290 |
}
|
|
Jeremy Bullock |
771290 |
|
|
Jeremy Bullock |
771290 |
//-----------------------------------------------------------------------------
|
|
Jeremy Bullock |
771290 |
|
|
Jeremy Bullock |
771290 |
void MeasuredValueField::mouseReleaseEvent(QMouseEvent *e) {
|
|
Jeremy Bullock |
771290 |
if (!isEnabled()) return;
|
|
Jeremy Bullock |
771290 |
// m_mouseEdit will be set false in commit
|
|
Jeremy Bullock |
771290 |
if (m_mouseEdit) {
|
|
Jeremy Bullock |
771290 |
// This seems redundant, but this is necessary for undo to work
|
|
Jeremy Bullock |
771290 |
double valueToRestore = m_value->getValue(TMeasuredValue::CurrentUnit);
|
|
Jeremy Bullock |
771290 |
m_value->setValue(TMeasuredValue::CurrentUnit, m_originalValue);
|
|
Jeremy Bullock |
771290 |
setText(QString::fromStdWString(m_value->toWideString(m_precision)));
|
|
Jeremy Bullock |
771290 |
emit measuredValueChanged(m_value, false);
|
|
Jeremy Bullock |
771290 |
// add this to undo
|
|
Jeremy Bullock |
771290 |
m_value->setValue(TMeasuredValue::CurrentUnit, valueToRestore);
|
|
Jeremy Bullock |
771290 |
setText(QString::fromStdWString(m_value->toWideString(m_precision)));
|
|
Jeremy Bullock |
771290 |
emit measuredValueChanged(m_value, true);
|
|
Jeremy Bullock |
771290 |
clearFocus();
|
|
shun_iwasawa |
23727d |
} else
|
|
shun_iwasawa |
23727d |
QLineEdit::mouseReleaseEvent(e);
|
|
Jeremy Bullock |
771290 |
}
|
|
Jeremy Bullock |
771290 |
|
|
shun_iwasawa |
23727d |
//-----------------------------------------------------------------------------
|
|
shun_iwasawa |
23727d |
|
|
shun_iwasawa |
23727d |
void MeasuredValueField::focusOutEvent(QFocusEvent *e) {
|
|
shun_iwasawa |
23727d |
DVGui::LineEdit::focusOutEvent(e);
|
|
shun_iwasawa |
23727d |
m_isTyping = false;
|
|
shun_iwasawa |
23727d |
}
|
|
shun_iwasawa |
23727d |
|
|
shun_iwasawa |
23727d |
//-----------------------------------------------------------------------------
|
|
shun_iwasawa |
23727d |
|
|
Jeremy Bullock |
771290 |
void MeasuredValueField::receiveMousePress(QMouseEvent *e) {
|
|
Jeremy Bullock |
771290 |
m_labelClicked = true;
|
|
Jeremy Bullock |
771290 |
mousePressEvent(e);
|
|
Jeremy Bullock |
771290 |
}
|
|
Jeremy Bullock |
771290 |
|
|
Jeremy Bullock |
771290 |
void MeasuredValueField::receiveMouseMove(QMouseEvent *e) { mouseMoveEvent(e); }
|
|
Jeremy Bullock |
771290 |
|
|
Jeremy Bullock |
771290 |
void MeasuredValueField::receiveMouseRelease(QMouseEvent *e) {
|
|
Jeremy Bullock |
771290 |
mouseReleaseEvent(e);
|
|
Jeremy Bullock |
771290 |
m_labelClicked = false;
|
|
Jeremy Bullock |
771290 |
}
|
|
Jeremy Bullock |
771290 |
|
|
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) {
|
|
Jeremy Bullock |
771290 |
bool ret = connect(this, SIGNAL(measuredValueChanged(TMeasuredValue *, bool)),
|
|
Jeremy Bullock |
771290 |
SLOT(onChange(TMeasuredValue *, bool)));
|
|
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 |
|
|
Jeremy Bullock |
771290 |
void PegbarChannelField::onChange(TMeasuredValue *fld, bool addToUndo) {
|
|
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 |
bool modifyConnectedActionId = false;
|
|
Jeremy Bullock |
771290 |
if (addToUndo) TUndoManager::manager()->beginBlock();
|
|
Jeremy Bullock |
771290 |
// m_firstMouseDrag is set to true only if addToUndo is false
|
|
Jeremy Bullock |
771290 |
// and only for the first drag
|
|
Jeremy Bullock |
771290 |
// This should always fire if addToUndo is true
|
|
Jeremy Bullock |
771290 |
if (!m_firstMouseDrag) {
|
|
shun_iwasawa |
023158 |
m_before = TStageObjectValues();
|
|
Jeremy Bullock |
771290 |
m_before.setFrameHandle(m_frameHandle);
|
|
Jeremy Bullock |
771290 |
m_before.setObjectHandle(m_objHandle);
|
|
Jeremy Bullock |
771290 |
m_before.setXsheetHandle(m_xshHandle);
|
|
Jeremy Bullock |
771290 |
m_before.add(m_actionId);
|
|
Jeremy Bullock |
771290 |
if (m_scaleType != eNone) {
|
|
Jeremy Bullock |
771290 |
modifyConnectedActionId = true;
|
|
Jeremy Bullock |
771290 |
if (m_actionId == TStageObject::T_ScaleX)
|
|
Jeremy Bullock |
771290 |
m_before.add(TStageObject::T_ScaleY);
|
|
Jeremy Bullock |
771290 |
else if (m_actionId == TStageObject::T_ScaleY)
|
|
Jeremy Bullock |
771290 |
m_before.add(TStageObject::T_ScaleX);
|
|
Jeremy Bullock |
771290 |
else
|
|
Jeremy Bullock |
771290 |
modifyConnectedActionId = false;
|
|
Jeremy Bullock |
771290 |
}
|
|
Jeremy Bullock |
771290 |
if (m_isGlobalKeyframe) {
|
|
Jeremy Bullock |
771290 |
m_before.add(TStageObject::T_Angle);
|
|
Jeremy Bullock |
771290 |
m_before.add(TStageObject::T_X);
|
|
Jeremy Bullock |
771290 |
m_before.add(TStageObject::T_Y);
|
|
Jeremy Bullock |
771290 |
m_before.add(TStageObject::T_Z);
|
|
Jeremy Bullock |
771290 |
m_before.add(TStageObject::T_SO);
|
|
Jeremy Bullock |
771290 |
m_before.add(TStageObject::T_ScaleX);
|
|
Jeremy Bullock |
771290 |
m_before.add(TStageObject::T_ScaleY);
|
|
Jeremy Bullock |
771290 |
m_before.add(TStageObject::T_Scale);
|
|
Jeremy Bullock |
771290 |
m_before.add(TStageObject::T_Path);
|
|
Jeremy Bullock |
771290 |
m_before.add(TStageObject::T_ShearX);
|
|
Jeremy Bullock |
771290 |
m_before.add(TStageObject::T_ShearY);
|
|
Jeremy Bullock |
771290 |
}
|
|
Jeremy Bullock |
771290 |
m_before.updateValues();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
TStageObjectValues after;
|
|
Jeremy Bullock |
771290 |
after = m_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 |
|
|
Jeremy Bullock |
771290 |
if (addToUndo) {
|
|
Jeremy Bullock |
771290 |
UndoStageObjectMove *undo = new UndoStageObjectMove(m_before, after);
|
|
Jeremy Bullock |
771290 |
undo->setObjectHandle(m_objHandle);
|
|
Jeremy Bullock |
771290 |
TUndoManager::manager()->add(undo);
|
|
Jeremy Bullock |
771290 |
TUndoManager::manager()->endBlock();
|
|
Jeremy Bullock |
771290 |
m_firstMouseDrag = false;
|
|
Jeremy Bullock |
771290 |
}
|
|
Jeremy Bullock |
771290 |
if (!addToUndo && !m_firstMouseDrag) m_firstMouseDrag = true;
|
|
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");
|
|
Jeremy Bullock |
771290 |
connect(this, SIGNAL(measuredValueChanged(TMeasuredValue *, bool)),
|
|
Jeremy Bullock |
771290 |
SLOT(onChange(TMeasuredValue *, bool)));
|
|
Shinya Kitaoka |
120a6e |
updateStatus();
|
|
shun-iwasawa |
c86c5d |
setMaximumWidth(getMaximumWidthForEditToolField(this));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Jeremy Bullock |
771290 |
void PegbarCenterField::onChange(TMeasuredValue *fld, bool addToUndo) {
|
|
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 |
|
|
Jeremy Bullock |
22d9f9 |
double v = fld->getValue(TMeasuredValue::MainUnit);
|
|
Jeremy Bullock |
22d9f9 |
TPointD center = obj->getCenter(frame);
|
|
Jeremy Bullock |
771290 |
if (!m_firstMouseDrag) m_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 |
|
|
Jeremy Bullock |
771290 |
if (addToUndo) {
|
|
Jeremy Bullock |
771290 |
UndoStageObjectCenterMove *undo =
|
|
Jeremy Bullock |
771290 |
new UndoStageObjectCenterMove(objId, frame, m_oldCenter, center);
|
|
Jeremy Bullock |
771290 |
undo->setObjectHandle(m_objHandle);
|
|
Jeremy Bullock |
771290 |
undo->setXsheetHandle(m_xshHandle);
|
|
Jeremy Bullock |
771290 |
TUndoManager::manager()->add(undo);
|
|
Jeremy Bullock |
771290 |
m_firstMouseDrag = false;
|
|
Jeremy Bullock |
771290 |
}
|
|
Jeremy Bullock |
771290 |
if (!addToUndo && !m_firstMouseDrag) m_firstMouseDrag = true;
|
|
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");
|
|
Jeremy Bullock |
771290 |
connect(this, SIGNAL(measuredValueChanged(TMeasuredValue *, bool)),
|
|
Jeremy Bullock |
771290 |
SLOT(onChange(TMeasuredValue *, bool)));
|
|
Shinya Kitaoka |
120a6e |
updateStatus();
|
|
shun-iwasawa |
c86c5d |
setMaximumWidth(getMaximumWidthForEditToolField(this));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Jeremy Bullock |
771290 |
void NoScaleField::onChange(TMeasuredValue *fld, bool addToUndo) {
|
|
Jeremy Bullock |
771290 |
// addToUndo isn't needed here as the field denominator
|
|
Jeremy Bullock |
771290 |
// doesn't have an undo
|
|
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 |
|
|
Jeremy Bullock |
22d9f9 |
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) {
|
|
Jeremy Bullock |
771290 |
bool ret = connect(this, SIGNAL(measuredValueChanged(TMeasuredValue *, bool)),
|
|
Jeremy Bullock |
771290 |
SLOT(onChange(TMeasuredValue *, bool)));
|
|
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 |
|
|
Jeremy Bullock |
771290 |
bool SelectionScaleField::applyChange(bool addToUndo) {
|
|
Shinya Kitaoka |
120a6e |
if (!m_tool || (m_tool->isSelectionEmpty() && !m_tool->isLevelType()))
|
|
Shinya Kitaoka |
120a6e |
return false;
|
|
caryoscelus |
fb92fd |
using namespace DragSelectionTool;
|
|
caryoscelus |
fb92fd |
DragTool *scaleTool = createNewScaleTool(m_tool, ScaleType::GLOBAL);
|
|
Jeremy Bullock |
22d9f9 |
double p = getValue();
|
|
Jeremy Bullock |
22d9f9 |
if (p == 0) p = 0.00001;
|
|
Jeremy Bullock |
22d9f9 |
FourPoints points = m_tool->getBBox();
|
|
Jeremy Bullock |
22d9f9 |
TPointD center = m_tool->getCenter();
|
|
Jeremy Bullock |
22d9f9 |
TPointD p0M = points.getPoint(7);
|
|
Jeremy Bullock |
22d9f9 |
TPointD p1M = points.getPoint(5);
|
|
Jeremy Bullock |
22d9f9 |
TPointD pM1 = points.getPoint(6);
|
|
Jeremy Bullock |
22d9f9 |
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
|
|
Jeremy Bullock |
771290 |
if (!m_tool->isLevelType() && addToUndo) scaleTool->addTransformUndo();
|
|
Shinya Kitaoka |
120a6e |
setCursorPosition(0);
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Jeremy Bullock |
771290 |
void SelectionScaleField::onChange(TMeasuredValue *fld, bool addToUndo) {
|
|
Shinya Kitaoka |
120a6e |
if (!m_tool->isEnabled()) return;
|
|
Jeremy Bullock |
771290 |
if (!applyChange(addToUndo)) return;
|
|
Jeremy Bullock |
771290 |
emit valueChange(addToUndo);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void SelectionScaleField::updateStatus() {
|
|
manongjohn |
6939a3 |
if (!m_tool || !m_tool->isSelectionEditable() ||
|
|
manongjohn |
6939a3 |
(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) {
|
|
Jeremy Bullock |
771290 |
bool ret = connect(this, SIGNAL(measuredValueChanged(TMeasuredValue *, bool)),
|
|
Jeremy Bullock |
771290 |
SLOT(onChange(TMeasuredValue *, bool)));
|
|
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 |
|
|
Jeremy Bullock |
771290 |
void SelectionRotationField::onChange(TMeasuredValue *fld, bool addToUndo) {
|
|
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 |
|
|
Jeremy Bullock |
771290 |
if (!m_tool->isLevelType() && addToUndo) 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() {
|
|
manongjohn |
6939a3 |
if (!m_tool || !m_tool->isSelectionEditable() ||
|
|
manongjohn |
6939a3 |
(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) {
|
|
Jeremy Bullock |
771290 |
bool ret = connect(this, SIGNAL(measuredValueChanged(TMeasuredValue *, bool)),
|
|
Jeremy Bullock |
771290 |
SLOT(onChange(TMeasuredValue *, bool)));
|
|
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 |
|
|
Jeremy Bullock |
771290 |
void SelectionMoveField::onChange(TMeasuredValue *fld, bool addToUndo) {
|
|
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 |
|
|
Jeremy Bullock |
771290 |
if (!m_tool->isLevelType() && addToUndo) 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() {
|
|
manongjohn |
6939a3 |
if (!m_tool || !m_tool->isSelectionEditable() ||
|
|
manongjohn |
6939a3 |
(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) {
|
|
Jeremy Bullock |
771290 |
bool ret = connect(this, SIGNAL(measuredValueChanged(TMeasuredValue *, bool)),
|
|
Jeremy Bullock |
771290 |
SLOT(onChange(TMeasuredValue *, bool)));
|
|
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 |
|
|
Jeremy Bullock |
771290 |
void ThickChangeField::onChange(TMeasuredValue *fld, bool addToUndo) {
|
|
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... >_<
|
|
Jeremy Bullock |
771290 |
if (addToUndo) {
|
|
Jeremy Bullock |
771290 |
changeThickTool->addUndo();
|
|
Jeremy Bullock |
771290 |
}
|
|
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() {
|
|
manongjohn |
6939a3 |
if (!m_tool || !m_tool->isSelectionEditable() ||
|
|
manongjohn |
6939a3 |
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 |
}
|
|
Jeremy Bullock |
771290 |
|
|
Jeremy Bullock |
771290 |
//=============================================================================
|
|
Jeremy Bullock |
771290 |
|
|
Jeremy Bullock |
771290 |
ClickableLabel::ClickableLabel(const QString &text, QWidget *parent,
|
|
Jeremy Bullock |
771290 |
Qt::WindowFlags f)
|
|
Jeremy Bullock |
771290 |
: QLabel(text, parent, f) {}
|
|
Jeremy Bullock |
771290 |
|
|
Jeremy Bullock |
771290 |
//-----------------------------------------------------------------------------
|
|
Jeremy Bullock |
771290 |
|
|
Jeremy Bullock |
771290 |
ClickableLabel::~ClickableLabel() {}
|
|
Jeremy Bullock |
771290 |
|
|
Jeremy Bullock |
771290 |
//-----------------------------------------------------------------------------
|
|
Jeremy Bullock |
771290 |
|
|
Jeremy Bullock |
771290 |
void ClickableLabel::mousePressEvent(QMouseEvent *event) {
|
|
Jeremy Bullock |
771290 |
emit onMousePress(event);
|
|
Jeremy Bullock |
771290 |
}
|
|
Jeremy Bullock |
771290 |
|
|
Jeremy Bullock |
771290 |
//-----------------------------------------------------------------------------
|
|
Jeremy Bullock |
771290 |
|
|
Jeremy Bullock |
771290 |
void ClickableLabel::mouseMoveEvent(QMouseEvent *event) {
|
|
Jeremy Bullock |
771290 |
emit onMouseMove(event);
|
|
Jeremy Bullock |
771290 |
}
|
|
Jeremy Bullock |
771290 |
|
|
Jeremy Bullock |
771290 |
//-----------------------------------------------------------------------------
|
|
Jeremy Bullock |
771290 |
|
|
Jeremy Bullock |
771290 |
void ClickableLabel::mouseReleaseEvent(QMouseEvent *event) {
|
|
Jeremy Bullock |
771290 |
emit onMouseRelease(event);
|
|
caryoscelus |
fb92fd |
}
|