Merge pull request #2719 from shun-iwasawa/g/hide_inbtwn_values
Option to hide inbetween values in the Function Editor spreadsheet
This commit is contained in:
commit
7d69b3b746
3 changed files with 82 additions and 37 deletions
|
@ -96,6 +96,7 @@ private slots:
|
|||
|
||||
class FunctionSheet final : public SpreadsheetViewer {
|
||||
Q_OBJECT
|
||||
bool m_showIbtwnValue = true;
|
||||
|
||||
public:
|
||||
FunctionSheet(QWidget *parent = 0, bool isFloating = false);
|
||||
|
@ -129,6 +130,12 @@ public:
|
|||
// fx parameter columns.
|
||||
TStageObject *getStageObject(int column);
|
||||
|
||||
bool isIbtwnValueVisible() { return m_showIbtwnValue; }
|
||||
void setIbtwnValueVisible(bool visible) {
|
||||
m_showIbtwnValue = visible;
|
||||
update();
|
||||
}
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *e) override;
|
||||
void hideEvent(QHideEvent *e) override;
|
||||
|
|
|
@ -367,7 +367,7 @@ void FunctionSheetColumnHeadViewer::paintEvent(QPaintEvent *e) {
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
/*! update tooltips
|
||||
*/
|
||||
*/
|
||||
void FunctionSheetColumnHeadViewer::mouseMoveEvent(QMouseEvent *e) {
|
||||
if ((e->buttons() & Qt::MidButton) && m_draggingChannel &&
|
||||
(e->pos() - m_dragStartPosition).manhattanLength() >=
|
||||
|
@ -513,7 +513,7 @@ FunctionSheetCellViewer::FunctionSheetCellViewer(FunctionSheet *parent)
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
/*! Called when the cell panel is left/right-clicked
|
||||
*/
|
||||
*/
|
||||
Spreadsheet::DragTool *FunctionSheetCellViewer::createDragTool(QMouseEvent *e) {
|
||||
CellPosition cellPosition = getViewer()->xyToPosition(e->pos());
|
||||
int row = cellPosition.frame();
|
||||
|
@ -598,7 +598,7 @@ void FunctionSheetCellViewer::drawCells(QPainter &painter, int r0, int c0,
|
|||
? curve->getValue(obj->paramsTime((double)row))
|
||||
: curve->getValue(row);
|
||||
if (unit) value = unit->convertTo(value);
|
||||
enum { None, KeyRange, CycleRange } drawValue = None;
|
||||
enum { None, Key, Inbetween, CycleRange } drawValue = None;
|
||||
|
||||
QRect cellRect(x0, ya, x1 - x0 + 1, yb - ya + 1);
|
||||
QRect borderRect(x0, ya, 7, yb - ya + 1);
|
||||
|
@ -612,6 +612,16 @@ void FunctionSheetCellViewer::drawCells(QPainter &painter, int r0, int c0,
|
|||
} else {
|
||||
cellColor = (isSelected) ? SelectedInBetweenColor : InBetweenColor;
|
||||
borderColor = InBetweenBorderColor;
|
||||
|
||||
// when the inbetween values are hidden, change the cell colors to
|
||||
// semi-transparent if the frame is in middle of the value step
|
||||
if (!m_sheet->isIbtwnValueVisible()) {
|
||||
TDoubleKeyframe kf =
|
||||
curve->getKeyframe(curve->getPrevKeyframe(row));
|
||||
int step = kf.m_step;
|
||||
if (step > 1 && (row - (int)std::floor(kf.m_frame)) % step != 0)
|
||||
cellColor.setAlpha(128);
|
||||
}
|
||||
}
|
||||
painter.setPen(Qt::NoPen);
|
||||
painter.fillRect(cellRect, cellColor);
|
||||
|
@ -633,7 +643,9 @@ void FunctionSheetCellViewer::drawCells(QPainter &painter, int r0, int c0,
|
|||
}
|
||||
}
|
||||
|
||||
drawValue = KeyRange;
|
||||
drawValue = (curve->isKeyframe(row))
|
||||
? Key
|
||||
: (m_sheet->isIbtwnValueVisible()) ? Inbetween : None;
|
||||
|
||||
}
|
||||
// empty cells
|
||||
|
@ -662,7 +674,7 @@ void FunctionSheetCellViewer::drawCells(QPainter &painter, int r0, int c0,
|
|||
|
||||
if (drawValue != None) {
|
||||
// draw cell value
|
||||
if (drawValue == KeyRange)
|
||||
if (drawValue == Key || drawValue == Inbetween)
|
||||
painter.setPen(getViewer()->getTextColor());
|
||||
else {
|
||||
QColor semiTranspTextColor = getViewer()->getTextColor();
|
||||
|
@ -699,7 +711,7 @@ void FunctionSheetCellViewer::drawCells(QPainter &painter, int r0, int c0,
|
|||
#endif
|
||||
}
|
||||
static QFont font(fontName, -1);
|
||||
font.setBold(drawValue == KeyRange);
|
||||
font.setBold(drawValue == Key);
|
||||
font.setPixelSize(12);
|
||||
painter.setFont(font);
|
||||
painter.drawText(cellRect.adjusted(10, 0, 0, 0),
|
||||
|
@ -894,6 +906,8 @@ void FunctionSheetCellViewer::openContextMenu(QMouseEvent *e) {
|
|||
QAction setStep4Action(tr("Step 4"), 0);
|
||||
QAction activateCycleAction(tr("Activate Cycle"), 0);
|
||||
QAction deactivateCycleAction(tr("Deactivate Cycle"), 0);
|
||||
QAction showIbtwnAction(tr("Show Inbetween Values"), 0);
|
||||
QAction hideIbtwnAction(tr("Hide Inbetween Values"), 0);
|
||||
|
||||
CellPosition cellPosition = getViewer()->xyToPosition(e->pos());
|
||||
int row = cellPosition.frame();
|
||||
|
@ -931,26 +945,30 @@ void FunctionSheetCellViewer::openContextMenu(QMouseEvent *e) {
|
|||
|
||||
if (!isEmpty && !isKeyframe && kIndex >= 0) {
|
||||
menu.addSeparator();
|
||||
QMenu *interpMenu = menu.addMenu(tr("Change Interpolation"));
|
||||
TDoubleKeyframe kf = curve->getKeyframe(kIndex);
|
||||
if (kf.m_type != TDoubleKeyframe::Linear) menu.addAction(&setLinearAction);
|
||||
if (kf.m_type != TDoubleKeyframe::Linear)
|
||||
interpMenu->addAction(&setLinearAction);
|
||||
if (kf.m_type != TDoubleKeyframe::SpeedInOut)
|
||||
menu.addAction(&setSpeedInOutAction);
|
||||
interpMenu->addAction(&setSpeedInOutAction);
|
||||
if (kf.m_type != TDoubleKeyframe::EaseInOut)
|
||||
menu.addAction(&setEaseInOutAction);
|
||||
interpMenu->addAction(&setEaseInOutAction);
|
||||
if (kf.m_type != TDoubleKeyframe::EaseInOutPercentage)
|
||||
menu.addAction(&setEaseInOut2Action);
|
||||
interpMenu->addAction(&setEaseInOut2Action);
|
||||
if (kf.m_type != TDoubleKeyframe::Exponential)
|
||||
menu.addAction(&setExponentialAction);
|
||||
interpMenu->addAction(&setExponentialAction);
|
||||
if (kf.m_type != TDoubleKeyframe::Expression)
|
||||
menu.addAction(&setExpressionAction);
|
||||
if (kf.m_type != TDoubleKeyframe::File) menu.addAction(&setFileAction);
|
||||
interpMenu->addAction(&setExpressionAction);
|
||||
if (kf.m_type != TDoubleKeyframe::File)
|
||||
interpMenu->addAction(&setFileAction);
|
||||
if (kf.m_type != TDoubleKeyframe::Constant)
|
||||
menu.addAction(&setConstantAction);
|
||||
menu.addSeparator();
|
||||
if (kf.m_step != 1) menu.addAction(&setStep1Action);
|
||||
if (kf.m_step != 2) menu.addAction(&setStep2Action);
|
||||
if (kf.m_step != 3) menu.addAction(&setStep3Action);
|
||||
if (kf.m_step != 4) menu.addAction(&setStep4Action);
|
||||
interpMenu->addAction(&setConstantAction);
|
||||
|
||||
QMenu *stepMenu = menu.addMenu(tr("Change Step"));
|
||||
if (kf.m_step != 1) stepMenu->addAction(&setStep1Action);
|
||||
if (kf.m_step != 2) stepMenu->addAction(&setStep2Action);
|
||||
if (kf.m_step != 3) stepMenu->addAction(&setStep3Action);
|
||||
if (kf.m_step != 4) stepMenu->addAction(&setStep4Action);
|
||||
}
|
||||
|
||||
menu.addSeparator();
|
||||
|
@ -963,6 +981,14 @@ void FunctionSheetCellViewer::openContextMenu(QMouseEvent *e) {
|
|||
|
||||
menu.addAction(cmdManager->getAction("MI_Insert"));
|
||||
|
||||
if (!isEmpty && kIndex >= 0) {
|
||||
menu.addSeparator();
|
||||
if (m_sheet->isIbtwnValueVisible())
|
||||
menu.addAction(&hideIbtwnAction);
|
||||
else
|
||||
menu.addAction(&showIbtwnAction);
|
||||
}
|
||||
|
||||
FunctionSelection *selection = m_sheet->getSelection();
|
||||
TSceneHandle *sceneHandle = m_sheet->getViewer()->getSceneHandle();
|
||||
// execute menu
|
||||
|
@ -1007,6 +1033,10 @@ void FunctionSheetCellViewer::openContextMenu(QMouseEvent *e) {
|
|||
KeyframeSetter::enableCycle(curve, true, sceneHandle);
|
||||
else if (action == &deactivateCycleAction)
|
||||
KeyframeSetter::enableCycle(curve, false, sceneHandle);
|
||||
else if (action == &hideIbtwnAction)
|
||||
m_sheet->setIbtwnValueVisible(false);
|
||||
else if (action == &showIbtwnAction)
|
||||
m_sheet->setIbtwnValueVisible(true);
|
||||
|
||||
update();
|
||||
}
|
||||
|
@ -1195,7 +1225,7 @@ void FunctionSheet::updateAll() {
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
/*! Display expression name of the current segment
|
||||
*/
|
||||
*/
|
||||
QString FunctionSheet::getSelectedParamName() {
|
||||
if (m_functionTreeModel->getCurrentChannel())
|
||||
return m_functionTreeModel->getCurrentChannel()->getExprRefName();
|
||||
|
@ -1211,7 +1241,7 @@ int FunctionSheet::getColumnIndexByCurve(TDoubleParam *param) const {
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
/*! scroll column to show the current one
|
||||
*/
|
||||
*/
|
||||
void FunctionSheet::onCurrentChannelChanged(
|
||||
FunctionTreeModel::Channel *channel) {
|
||||
if (!channel) return;
|
||||
|
@ -1228,7 +1258,7 @@ void FunctionSheet::onCurrentChannelChanged(
|
|||
//-----------------------------------------------------------------------------
|
||||
/*! Obtains a pointer to the stage object containing the parameter of specified
|
||||
* column
|
||||
*/
|
||||
*/
|
||||
TStageObject *FunctionSheet::getStageObject(int column) {
|
||||
FunctionTreeModel::Channel *channel = getChannel(column);
|
||||
if (!channel) return nullptr;
|
||||
|
|
|
@ -715,6 +715,8 @@ bool FunctionViewer::isExpressionPageActive() {
|
|||
|
||||
void FunctionViewer::save(QSettings &settings) const {
|
||||
settings.setValue("toggleStatus", m_toggleStatus);
|
||||
settings.setValue("showIbtwnValuesInSheet",
|
||||
m_numericalColumns->isIbtwnValueVisible());
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
@ -724,4 +726,10 @@ void FunctionViewer::load(QSettings &settings) {
|
|||
if (toggleStatus.canConvert(QVariant::Int)) {
|
||||
m_toggleStatus = toggleStatus.toInt();
|
||||
}
|
||||
|
||||
bool ibtwnVisible = settings
|
||||
.value("showIbtwnValuesInSheet",
|
||||
m_numericalColumns->isIbtwnValueVisible())
|
||||
.toBool();
|
||||
m_numericalColumns->setIbtwnValueVisible(ibtwnVisible);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue