Merge pull request #854 from manongjohn/various_bug_fixes

Various bug fixes
This commit is contained in:
manongjohn 2022-01-15 07:02:47 -05:00 committed by GitHub
commit 27a054a6a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 108 additions and 47 deletions

View file

@ -111,12 +111,14 @@ void copyCellsWithoutUndo(int r0, int c0, int r1, int c1) {
bool pasteCellsWithoutUndo(const TCellData *cellData, int &r0, int &c0, int &r1,
int &c1, bool insert = true,
bool doZeraryClone = true) {
bool doZeraryClone = true,
bool skipEmptyCells = true) {
TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet();
if (!cellData) return false;
if (r0 < 0 || c0 < 0) return false;
bool ret = cellData->getCells(xsh, r0, c0, r1, c1, insert, doZeraryClone);
bool ret = cellData->getCells(xsh, r0, c0, r1, c1, insert, doZeraryClone,
skipEmptyCells);
if (!ret) return false;
return true;
@ -360,7 +362,7 @@ public:
int r0, c0, r1, c1;
m_selection->getSelectedCells(r0, c0, r1, c1);
pasteCellsWithoutUndo(m_data, r0, c0, r1, c1, true);
pasteCellsWithoutUndo(m_data, r0, c0, r1, c1, true, true, false);
TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();
}

View file

@ -544,6 +544,9 @@ void EachUndo::undo() const {
void TCellSelection::eachCells(int each) {
if (isEmpty() || areAllColSelectedLocked()) return;
// Do nothing if they select less than Each #
if ((m_range.m_r1 - m_range.m_r0 + 1) < each) return;
TUndo *undo = new EachUndo(m_range.m_r0, m_range.m_c0, m_range.m_r1,
m_range.m_c1, each);
TUndoManager::manager()->add(undo);

View file

@ -1700,7 +1700,7 @@ void Filmstrip::updateCurrentLevelComboItem() {
TXshSimpleLevel *currentLevel =
TApp::instance()->getCurrentLevel()->getSimpleLevel();
if (!currentLevel) {
int noLevelIndex = m_chooseLevelCombo->findText(tr("- No Current Level -"));
int noLevelIndex = m_chooseLevelCombo->findText(tr("- No Level -"));
m_chooseLevelCombo->setCurrentIndex(noLevelIndex);
return;
}
@ -1718,7 +1718,7 @@ void Filmstrip::updateCurrentLevelComboItem() {
}
}
int noLevelIndex = m_chooseLevelCombo->findText(tr("- No Current Level -"));
int noLevelIndex = m_chooseLevelCombo->findText(tr("- No Level -"));
m_chooseLevelCombo->setCurrentIndex(noLevelIndex);
}

View file

@ -329,8 +329,8 @@ bool beforeCellsInsert(TXsheet *xsh, int row, int &col, int rowCount,
int type = (column && !column->isEmpty()) ? column->getColumnType()
: newLevelColumnType;
// If some used cells in range or column type mismatch must insert a column.
if (col < 0 || i < rowCount || newLevelColumnType != type) {
col += 1;
if (col < 0 || i < rowCount || newLevelColumnType != type || !column) {
if (column) col += 1;
TApp::instance()->getCurrentColumn()->setColumnIndex(col);
shiftColumn = true;
xsh->insertColumn(col);

View file

@ -96,8 +96,11 @@ public:
TXsheet *xsh = scene->getXsheet();
if (m_areColumnsShifted)
xsh->removeColumn(m_columnIndex);
else if (m_frameCount > 0)
else if (m_frameCount > 0) {
// remove the cells and add back blank ones
xsh->removeCells(m_rowIndex, m_columnIndex, m_frameCount);
xsh->insertCells(m_rowIndex, m_columnIndex, m_frameCount);
}
TLevelSet *levelSet = scene->getLevelSet();
if (levelSet) {

View file

@ -1594,6 +1594,8 @@ void CellArea::drawSoundCell(QPainter &p, int row, int col, bool isReference) {
int maxNumFrame = soundColumn->getMaxFrame() + 1;
int startFrame = soundColumn->getFirstRow();
TXshCell cell = soundColumn->getSoundCell(row);
TXshCell prevCell;
if (row > 0) prevCell = soundColumn->getSoundCell(row - 1);
if (soundColumn->isCellEmpty(row) || cell.isEmpty() || row > maxNumFrame ||
row < startFrame) {
drawCellMarker(p, markId, rect, false, isNextEmpty);
@ -1614,7 +1616,7 @@ void CellArea::drawSoundCell(QPainter &p, int row, int col, bool isReference) {
drawCellMarker(p, markId, rect, true, isNextEmpty);
return;
}
bool isFirstRow = (row == r0);
bool isFirstRow = (row > 0 && row == r0);
bool isLastRow = (row == r1);
TCellSelection *cellSelection = m_viewer->getCellSelection();
@ -1653,9 +1655,9 @@ void CellArea::drawSoundCell(QPainter &p, int row, int col, bool isReference) {
Preferences::instance()->isCurrentTimelineIndicatorEnabled())
drawCurrentTimeIndicator(p, xy);
drawDragHandle(p, xy, sideColor);
drawDragHandle(p, isFirstRow, xy, sideColor);
drawEndOfDragHandle(p, isLastRow, xy, cellColor);
drawLockedDottedLine(p, soundColumn->isLocked(), xy, cellColor);
drawLockedDottedLine(p, soundColumn->isLocked(), isFirstRow, xy, cellColor);
QRect trackRect = o->rect(PredefinedRect::SOUND_TRACK)
.adjusted(0, 0, -frameAdj.x(), -frameAdj.y())
@ -1762,13 +1764,19 @@ void CellArea::drawSoundCell(QPainter &p, int row, int col, bool isReference) {
//-----------------------------------------------------------------------------
// paint side bar
void CellArea::drawDragHandle(QPainter &p, const QPoint &xy,
void CellArea::drawDragHandle(QPainter &p, bool isStart, const QPoint &xy,
const QColor &sideColor) const {
QPoint frameAdj = m_viewer->getFrameZoomAdjustment();
QRect dragHandleRect = m_viewer->orientation()
->rect(PredefinedRect::DRAG_HANDLE_CORNER)
.adjusted(0, 0, -frameAdj.x(), -frameAdj.y())
.translated(xy);
if (isStart) {
if (m_viewer->orientation()->isVerticalTimeline())
dragHandleRect.adjust(0, 1, 0, 0);
else
dragHandleRect.adjust(1, 0, 0, 0);
}
p.fillRect(dragHandleRect, QBrush(sideColor));
}
@ -1784,7 +1792,7 @@ void CellArea::drawEndOfDragHandle(QPainter &p, bool isEnd, const QPoint &xy,
}
// draw dot line if the column is locked
void CellArea::drawLockedDottedLine(QPainter &p, bool isLocked,
void CellArea::drawLockedDottedLine(QPainter &p, bool isLocked, bool isStart,
const QPoint &xy,
const QColor &cellColor) const {
if (!isLocked) return;
@ -1792,6 +1800,12 @@ void CellArea::drawLockedDottedLine(QPainter &p, bool isLocked,
QPoint frameAdj = m_viewer->getFrameZoomAdjustment();
QLine dottedLine =
m_viewer->orientation()->line(PredefinedLine::LOCKED).translated(xy);
if (isStart) {
if (m_viewer->orientation()->isVerticalTimeline())
dottedLine.setP1(QPoint(dottedLine.x1(), dottedLine.y1() + 2));
else
dottedLine.setP1(QPoint(dottedLine.x1() + 2, dottedLine.y1()));
}
dottedLine.setP2(QPoint(dottedLine.x2(), dottedLine.y2()) - frameAdj);
p.drawLine(dottedLine);
}
@ -1861,21 +1875,30 @@ void CellArea::drawFrameMarker(QPainter &p, const QPoint &xy, QColor color,
//-----------------------------------------------------------------------------
void CellArea::drawEndOfLevelMarker(QPainter &p, QRect rect, bool isStopFrame) {
void CellArea::drawEndOfLevelMarker(QPainter &p, QRect rect, bool isNextEmpty,
bool isStopFrame) {
const Orientation *o = m_viewer->orientation();
QColor levelEndColor = m_viewer->getTextColor();
QPoint topLeft = rect.topLeft();
QPoint topRight = rect.topRight();
if (!o->isVerticalTimeline() && isStopFrame) {
QRect dragRect = o->rect(PredefinedRect::DRAG_AREA);
topLeft.setY(topLeft.y() + dragRect.height());
topRight.setY(topRight.y() + dragRect.height());
QPoint bottomLeft = rect.bottomLeft();
QPoint bottomRight = rect.bottomRight();
if (!o->isVerticalTimeline()) {
if (isStopFrame) {
QRect dragRect = o->rect(PredefinedRect::DRAG_AREA);
topLeft.setY(topLeft.y() + dragRect.height());
topRight.setY(topRight.y() + dragRect.height());
}
if (!isNextEmpty) {
topRight.setX(topRight.x() - 2);
bottomRight.setX(bottomRight.x() - 2);
}
}
levelEndColor.setAlphaF(0.3);
p.setPen(levelEndColor);
p.drawLine(topLeft, rect.bottomRight());
p.drawLine(topRight, rect.bottomLeft());
p.drawLine(topLeft, bottomRight);
p.drawLine(topRight, bottomLeft);
}
//-----------------------------------------------------------------------------
@ -2038,7 +2061,7 @@ void CellArea::drawLevelCell(QPainter &p, int row, int col, bool isReference,
// Implicit holds use Stop Frame Hold to denote end of level
if (!Preferences::instance()->isImplicitHoldEnabled())
drawEndOfLevelMarker(p, rect);
drawEndOfLevelMarker(p, rect, nextCell.isEmpty() || isImplicitCellNext);
drawFrameSeparator(p, row, col, false, heldFrame);
@ -2098,7 +2121,9 @@ void CellArea::drawLevelCell(QPainter &p, int row, int col, bool isReference,
nextCell.isEmpty() || isImplicitCellNext);
// Implicit holds use Stop Frame Hold to denote end of level
if (isStopFrame) drawEndOfLevelMarker(p, rect, true);
if (isStopFrame)
drawEndOfLevelMarker(p, rect, nextCell.isEmpty() || isImplicitCellNext,
true);
drawFrameSeparator(p, row, col, false, heldFrame);
@ -2109,13 +2134,15 @@ void CellArea::drawLevelCell(QPainter &p, int row, int col, bool isReference,
drawCurrentTimeIndicator(p, xy);
if (!isImplicitCell) {
drawDragHandle(p, xy, sideColor);
bool isStart = row > 0 && (prevCell.isEmpty() || prevIsImplicit);
drawDragHandle(p, isStart, xy, sideColor);
bool isLastRow = nextCell.isEmpty() ||
cell.m_level.getPointer() != nextCell.m_level.getPointer();
drawEndOfDragHandle(p, isLastRow, xy, cellColor);
drawLockedDottedLine(p, xsh->getColumn(col)->isLocked(), xy, cellColor);
drawLockedDottedLine(p, xsh->getColumn(col)->isLocked(), isStart, xy,
cellColor);
}
int distance, offset;
@ -2261,14 +2288,18 @@ void CellArea::drawSoundTextCell(QPainter &p, int row, int col) {
TXsheet *xsh = m_viewer->getXsheet();
TXshCell cell = xsh->getCell(row, col);
TXshCell prevCell;
bool prevIsImplicit = false;
TCellSelection *cellSelection = m_viewer->getCellSelection();
TColumnSelection *columnSelection = m_viewer->getColumnSelection();
bool isSelected = cellSelection->isCellSelected(row, col) ||
columnSelection->isColumnSelected(col);
if (row > 0) prevCell = xsh->getCell(row - 1, col); // cell in previous frame
// nothing to draw
if (row > 0) {
prevCell = xsh->getCell(row - 1, col); // cell in previous frame
// nothing to draw
prevIsImplicit = xsh->isImplicitCell(row - 1, col);
}
bool sameLevel = prevCell.m_level.getPointer() == cell.m_level.getPointer();
@ -2312,7 +2343,7 @@ void CellArea::drawSoundTextCell(QPainter &p, int row, int col) {
// cell mark
drawCellMarker(p, markId, rect);
drawEndOfLevelMarker(p, rect);
drawEndOfLevelMarker(p, rect, nextCell.isEmpty());
drawFrameSeparator(p, row, col, false, heldFrame);
@ -2350,13 +2381,15 @@ void CellArea::drawSoundTextCell(QPainter &p, int row, int col) {
Preferences::instance()->isCurrentTimelineIndicatorEnabled())
drawCurrentTimeIndicator(p, xy);
drawDragHandle(p, xy, sideColor);
bool isStart = row > 0 && (prevCell.isEmpty() || prevIsImplicit);
drawDragHandle(p, isStart, xy, sideColor);
bool isLastRow = nextCell.isEmpty() ||
cell.m_level.getPointer() != nextCell.m_level.getPointer();
drawEndOfDragHandle(p, isLastRow, xy, cellColor);
drawLockedDottedLine(p, xsh->getColumn(col)->isLocked(), xy, cellColor);
drawLockedDottedLine(p, xsh->getColumn(col)->isLocked(), isStart, xy,
cellColor);
TFrameId fid = cell.m_frameId;
if (fid.getNumber() - 1 < 0) return;
@ -2455,7 +2488,8 @@ void CellArea::drawSoundTextColumn(QPainter &p, int r0, int r1, int col) {
TXshCell nextCell = xsh->getCell(r + 1, col);
ret.isEndOfRange = nextCell.isEmpty();
ret.rect = cellRect.adjusted(
(!m_viewer->orientation()->isVerticalTimeline() && r == 0 ? 0 : 1), 1,
(!m_viewer->orientation()->isVerticalTimeline() && r == 0 ? 0 : 1),
(m_viewer->orientation()->isVerticalTimeline() && r == 0 ? 0 : 1),
(!m_viewer->orientation()->isVerticalTimeline() && !nextCell.isEmpty()
? 2
: 0),
@ -2515,15 +2549,22 @@ void CellArea::drawSoundTextColumn(QPainter &p, int r0, int r1, int col) {
for (int row = rStart; row <= rEnd; row++) {
TXshCell cell = xsh->getCell(row, col);
TXshCell prevCell;
bool prevIsImplicit = false;
if (row > 0) {
prevCell = xsh->getCell(row - 1, col);
prevIsImplicit = xsh->isImplicitCell(row - 1, col);
}
TXshCell nextCell = xsh->getCell(row + 1, col);
// if the cell is empty
if (cell.isEmpty()) {
CellInfo info = getCellInfo(row);
// cell mark
drawCellMarker(p, info.markId, info.rect);
// draw X shape after the occupied cell
TXshCell prevCell;
if (row > 0) prevCell = xsh->getCell(row - 1, col);
if (!prevCell.isEmpty()) drawEndOfLevelMarker(p, info.rect);
if (!prevCell.isEmpty())
drawEndOfLevelMarker(p, info.rect, nextCell.isEmpty());
drawFrameSeparator(p, row, col, true);
if (TApp::instance()->getCurrentFrame()->isEditingScene() &&
!m_viewer->orientation()->isVerticalTimeline() &&
@ -2537,7 +2578,8 @@ void CellArea::drawSoundTextColumn(QPainter &p, int r0, int r1, int col) {
QList<CellInfo> infoList;
// check how long the same content continues
int rowTo = row;
int rowFrom = row;
int rowTo = row;
infoList.append(getCellInfo(row));
while (xsh->getCell(rowTo + 1, col) == cell) {
rowTo++;
@ -2573,9 +2615,11 @@ void CellArea::drawSoundTextColumn(QPainter &p, int r0, int r1, int col) {
Preferences::instance()->isCurrentTimelineIndicatorEnabled())
drawCurrentTimeIndicator(p, info.xy);
drawDragHandle(p, info.xy, sideColor);
bool isStart = row > 0 && (prevCell.isEmpty() || prevIsImplicit ||
info.row == rowFrom);
drawDragHandle(p, isStart, info.xy, sideColor);
drawEndOfDragHandle(p, info.isEndOfRange, info.xy, tmpCellColor);
drawLockedDottedLine(p, xsh->getColumn(col)->isLocked(), info.xy,
drawLockedDottedLine(p, xsh->getColumn(col)->isLocked(), isStart, info.xy,
tmpCellColor);
}
@ -2691,14 +2735,18 @@ void CellArea::drawPaletteCell(QPainter &p, int row, int col,
TXsheet *xsh = m_viewer->getXsheet();
TXshCell cell = xsh->getCell(row, col);
TXshCell prevCell;
bool prevIsImplicit = false;
TCellSelection *cellSelection = m_viewer->getCellSelection();
bool isSelected = cellSelection->isCellSelected(row, col);
bool isImplicitCell = xsh->isImplicitCell(row, col);
bool isStopFrame = isImplicitCell ? false : cell.getFrameId().isStopFrame();
if (row > 0) prevCell = xsh->getCell(row - 1, col);
TXshCell nextCell = xsh->getCell(row + 1, col);
if (row > 0) {
prevCell = xsh->getCell(row - 1, col);
prevIsImplicit = xsh->isImplicitCell(row - 1, col);
}
TXshCell nextCell = xsh->getCell(row + 1, col);
bool isImplicitCellNext = xsh->isImplicitCell(row + 1, col);
bool sameLevel = prevCell.m_level.getPointer() == cell.m_level.getPointer();
@ -2766,7 +2814,7 @@ void CellArea::drawPaletteCell(QPainter &p, int row, int col,
// Implicit holds use Stop Frame Hold to denote end of level
if (!Preferences::instance()->isImplicitHoldEnabled())
drawEndOfLevelMarker(p, rect);
drawEndOfLevelMarker(p, rect, nextCell.isEmpty() || isImplicitCellNext);
drawFrameSeparator(p, row, col, false, heldFrame);
@ -2806,7 +2854,9 @@ void CellArea::drawPaletteCell(QPainter &p, int row, int col,
nextCell.isEmpty() || isImplicitCellNext);
// Implicit holds use Stop Frame Hold to denote end of level
if (isStopFrame) drawEndOfLevelMarker(p, rect, true);
if (isStopFrame)
drawEndOfLevelMarker(p, rect, nextCell.isEmpty() || isImplicitCellNext,
true);
drawFrameSeparator(p, row, col, false, heldFrame);
@ -2817,11 +2867,13 @@ void CellArea::drawPaletteCell(QPainter &p, int row, int col,
drawCurrentTimeIndicator(p, xy);
if (!isImplicitCell) {
drawDragHandle(p, xy, sideColor);
bool isStart = row > 0 && (prevCell.isEmpty() || prevIsImplicit);
drawDragHandle(p, isStart, xy, sideColor);
bool isLastRow = nextCell.isEmpty() ||
cell.m_level.getPointer() != nextCell.m_level.getPointer();
drawEndOfDragHandle(p, isLastRow, xy, cellColor);
drawLockedDottedLine(p, xsh->getColumn(col)->isLocked(), xy, cellColor);
drawLockedDottedLine(p, xsh->getColumn(col)->isLocked(), isStart, xy,
cellColor);
}
if (o->isVerticalTimeline() && isAfterMarkers) {

View file

@ -103,12 +103,12 @@ class CellArea final : public QWidget {
void drawSelectionBackground(QPainter &p) const;
void drawExtenderHandles(QPainter &p);
void drawDragHandle(QPainter &p, const QPoint &xy,
void drawDragHandle(QPainter &p, bool isStart, const QPoint &xy,
const QColor &sideColor) const;
void drawEndOfDragHandle(QPainter &p, bool isEnd, const QPoint &xy,
const QColor &cellColor) const;
void drawLockedDottedLine(QPainter &p, bool isLocked, const QPoint &xy,
const QColor &cellColor) const;
void drawLockedDottedLine(QPainter &p, bool isLocked, bool isStart,
const QPoint &xy, const QColor &cellColor) const;
void drawFrameSeparator(QPainter &p, int row, int col, bool emptyFrame,
bool heldFrame = false);
@ -131,7 +131,8 @@ class CellArea final : public QWidget {
void drawFrameMarker(QPainter &p, const QPoint &xy, QColor color,
bool isKeyFrame = false, bool isCamera = false);
void drawEndOfLevelMarker(QPainter &p, QRect rect, bool isStopFrame = false);
void drawEndOfLevelMarker(QPainter &p, QRect rect, bool isNextEmpty,
bool isStopFrame = false);
void drawCellMarker(QPainter &p, int markId, QRect rect,
bool hasFrame = false, bool isNextEmpty = true);

View file

@ -654,7 +654,7 @@ void Preferences::definePreferenceItems() {
// Others (not appeared in the popup)
// Shortcut popup settings
define(shortcutPreset, "shortcutPreset", QMetaType::QString, "defopentoonz");
define(shortcutPreset, "shortcutPreset", QMetaType::QString, "deftahoma2d");
// Viewer context menu
define(guidedDrawingType, "guidedDrawingType", QMetaType::Int, 0); // Off
define(guidedAutoInbetween, "guidedAutoInbetween", QMetaType::Bool,