Skip to content

OpenToonz - An open-source full-featured 2D animation creation software

C

Add always free column to Timeline

Rodneyb661104a40a0
diff --git a/toonz/sources/toonz/xshcellmover.cpp b/toonz/sources/toonz/xshcellmover.cpp
index 9c84817f6..f32ccbf02 100644
--- a/toonz/sources/toonz/xshcellmover.cpp
+++ b/toonz/sources/toonz/xshcellmover.cpp
@@ -278,7 +278,7 @@ bool CellsMover::canMoveCells(const TPoint &pos) {
cStart = m_startPos.y;
}
if (c < 0 ||
- (!m_orientation->isVerticalTimeline() && c >= xsh->getColumnCount()))
+ (!m_orientation->isVerticalTimeline() && c > xsh->getColumnCount()))
return false;
if (c != cStart) {
int count = 0;
@@ -469,6 +469,7 @@ LevelMoverTool::LevelMoverTool(XsheetViewer *viewer)
: XsheetGUI::DragTool(viewer)
, m_range(0, 0)
, m_qualifiers(0)
+ , m_columnLimit(0)
, m_validPos(false)
, m_undo(0)
, m_moved(false)
@@ -507,7 +508,7 @@ bool LevelMoverTool::canMoveColumns(const TPoint &pos) {
cLast = m_lastPos.y;
cRange = m_range.ly;
}
- if (c < 0 || (!o->isVerticalTimeline() && c >= xsh->getColumnCount()))
+ if (c < 0 || (!o->isVerticalTimeline() && c > xsh->getColumnCount()))
return false;
if (c != cLast) {
int count = 0;
@@ -515,7 +516,7 @@ bool LevelMoverTool::canMoveColumns(const TPoint &pos) {
for (int i = 0; i < cRange; i++) {
int srcIndex = cLast + i;
int dstIndex = c + i;
- if (!o->isVerticalTimeline() && dstIndex >= xsh->getColumnCount())
+ if (!o->isVerticalTimeline() && dstIndex > xsh->getColumnCount())
return false;
TXshColumn *srcColumn = xsh->getColumn(srcIndex);
if (srcColumn && srcColumn->isLocked()) continue;
@@ -553,6 +554,8 @@ void LevelMoverTool::onClick(const QMouseEvent *e) {
int r0, c0, r1, c1;
getViewer()->getCellSelection()->getSelectedCells(r0, c0, r1, c1);
+ // Filling the free column must not extend this drag into another one.
+ m_columnLimit = xsh->getColumnCount();
m_qualifiers = 0;
if (Preferences::instance()->getDragCellsBehaviour() == 1)
m_qualifiers |= CellsMover::eMoveColumns;
@@ -618,7 +621,7 @@ void LevelMoverTool::onCellChange(int row, int col) {
m_grabOffset;
int origX = pos.x;
int origY = pos.y;
- int currEnd = xsh->getColumnCount() - 1;
+ int currEnd = m_columnLimit;
if (pos.y < 0)
pos.y = 0;
diff --git a/toonz/sources/toonz/xshcellmover.h b/toonz/sources/toonz/xshcellmover.h
index 2f9871449..70446fcd8 100644
--- a/toonz/sources/toonz/xshcellmover.h
+++ b/toonz/sources/toonz/xshcellmover.h
@@ -106,6 +106,7 @@ protected:
TDimension m_range;
int m_qualifiers;
+ int m_columnLimit;
bool m_validPos;
LevelMoverUndo *m_undo;
bool m_moved;
diff --git a/toonz/sources/toonz/xshcellviewer.cpp b/toonz/sources/toonz/xshcellviewer.cpp
index f44e64341..ff25f0973 100644
--- a/toonz/sources/toonz/xshcellviewer.cpp
+++ b/toonz/sources/toonz/xshcellviewer.cpp
@@ -1280,12 +1280,16 @@ void CellArea::drawCells(QPainter &p, const QRect toBeUpdated) {
c0 = visible.from().layer();
c1 = visible.to().layer();
if (!m_viewer->orientation()->isVerticalTimeline()) {
- int colCount = std::max(1, xsh->getColumnCount());
- c1 = std::min(c1, colCount - 1);
+ c1 = std::min(c1, xsh->getColumnCount());
}
drawNonEmptyBackground(p);
+ if (!o->isVerticalTimeline()) {
+ int y = m_viewer->positionToXY(CellPosition(0, xsh->getColumnCount())).y();
+ p.fillRect(0, y, width(), o->cellHeight(), FreeColumnTint);
+ }
+
drawSelectionBackground(p);
int currentRow = m_viewer->getCurrentRow();
diff --git a/toonz/sources/toonz/xshcolumnviewer.cpp b/toonz/sources/toonz/xshcolumnviewer.cpp
index d31e6718c..9a278a639 100644
--- a/toonz/sources/toonz/xshcolumnviewer.cpp
+++ b/toonz/sources/toonz/xshcolumnviewer.cpp
@@ -909,6 +909,9 @@ void ColumnArea::DrawHeader::drawBaseFill(const QColor &columnColor,
}
}
+ if (!o->isVerticalTimeline() && col == xsh->getColumnCount())
+ p.fillRect(rect, FreeColumnTint);
+
p.setPen(m_viewer->getVerticalLineHeadColor());
QLine vertical =
o->verticalLine(m_viewer->columnToLayerAxis(col), o->frameSide(rect));
@@ -1861,8 +1864,7 @@ void ColumnArea::paintEvent(QPaintEvent *event) { // AREA
c0 = cellRange.from().layer();
c1 = cellRange.to().layer();
if (!m_viewer->orientation()->isVerticalTimeline()) {
- int colCount = std::max(1, xsh->getColumnCount());
- c1 = std::min(c1, colCount - 1);
+ c1 = std::min(c1, xsh->getColumnCount());
}
ColumnFan *columnFan = xsh->getColumnFan(m_viewer->orientation());
diff --git a/toonz/sources/toonz/xsheetdragtool.cpp b/toonz/sources/toonz/xsheetdragtool.cpp
index 151e8c87f..d4fb50878 100644
--- a/toonz/sources/toonz/xsheetdragtool.cpp
+++ b/toonz/sources/toonz/xsheetdragtool.cpp
@@ -186,7 +186,7 @@ public:
int firstCol =
Preferences::instance()->isXsheetCameraColumnVisible() ? -1 : 0;
if (col < firstCol || (!getViewer()->orientation()->isVerticalTimeline() &&
- col >= xsh->getColumnCount()))
+ col > xsh->getColumnCount()))
return;
if (row < 0) row = 0;
if (m_modifier & Qt::ControlModifier)
@@ -1591,7 +1591,7 @@ public:
int firstCol =
Preferences::instance()->isXsheetCameraColumnVisible() ? -1 : 0;
if (col < firstCol || (!getViewer()->orientation()->isVerticalTimeline() &&
- col >= xsh->getColumnCount()))
+ col > xsh->getColumnCount()))
return;
TColumnSelection *selection = getViewer()->getColumnSelection();
selection->selectNone();
@@ -1687,7 +1687,7 @@ public:
//-----------------------------------------------------------------------------
class ColumnMoveDragTool final : public XsheetGUI::DragTool {
- int m_offset, m_firstCol, m_lastCol, m_origOffset;
+ int m_offset, m_firstCol, m_lastCol, m_origOffset, m_columnLimit;
public:
ColumnMoveDragTool(XsheetViewer *viewer)
@@ -1695,7 +1695,8 @@ public:
, m_firstCol(-1)
, m_lastCol(-1)
, m_offset(0)
- , m_origOffset(0) {}
+ , m_origOffset(0)
+ , m_columnLimit(0) {}
void onClick(const QMouseEvent *event) override {
QPoint xy = event->pos();
@@ -1725,6 +1726,7 @@ public:
if (indices.empty()) return;
m_firstCol = m_lastCol = *indices.begin();
assert(m_firstCol >= 0);
+ m_columnLimit = getViewer()->getXsheet()->getColumnCount();
m_origOffset = m_offset = m_firstCol - col;
assert(m_lastCol == *indices.begin());
getViewer()->update();
@@ -1744,7 +1746,7 @@ public:
assert(m_lastCol == *indices.begin());
- int currEnd = xsh->getColumnCount() - 1;
+ int currEnd = m_columnLimit;
int origCol = col;
if (col < 0)
col = 0;
diff --git a/toonz/sources/toonz/xsheetviewer.cpp b/toonz/sources/toonz/xsheetviewer.cpp
index 40b28c411..645055a48 100644
--- a/toonz/sources/toonz/xsheetviewer.cpp
+++ b/toonz/sources/toonz/xsheetviewer.cpp
@@ -848,9 +848,7 @@ int XsheetViewer::colToTimelineLayerAxis(int layer) const {
int yBottom = o->colToLayerAxis(layer, fan) +
(fan->isActive(layer) ? o->cellHeight() : o->foldedCellSize()) -
1;
- int columnCount = std::max(1, xsh->getColumnCount());
- int layerHeightActual =
- m_columnArea->height() - 2; // o->colToLayerAxis(columnCount, fan) - 1;
+ int layerHeightActual = m_columnArea->height() - 2;
return layerHeightActual - yBottom;
}
@@ -876,7 +874,7 @@ CellPosition XsheetViewer::xyToPosition(const QPoint &point) const {
// For timeline mode, we need to base the Y axis on the bottom of the column
// area
// since the layers are flipped
- int columnCount = std::max(1, xsh->getColumnCount());
+ int columnCount = xsh->getColumnCount() + 1;
int colAreaHeight = o->colToLayerAxis(columnCount, fan);
usePoint.setY(colAreaHeight - usePoint.y());
@@ -918,7 +916,7 @@ QPoint XsheetViewer::positionToXY(const CellPosition &pos) const {
usePoint.setY(
usePoint.y() - o->cellHeight() +
(fan->isActive(pos.layer()) ? o->cellHeight() : o->foldedCellSize()));
- int columnCount = std::max(1, xsh->getColumnCount());
+ int columnCount = xsh->getColumnCount() + 1;
int colsHeight = o->colToLayerAxis(columnCount, fan);
if (colsHeight)
diff --git a/toonz/sources/toonz/xsheetviewer.h b/toonz/sources/toonz/xsheetviewer.h
index 906c7e85d..57f5b1fdd 100644
--- a/toonz/sources/toonz/xsheetviewer.h
+++ b/toonz/sources/toonz/xsheetviewer.h
@@ -121,6 +121,7 @@ const QColor SelectedMetaColumnColor(216, 180, 245);
// Empty column
const QColor EmptyColumnColor(124, 124, 124);
+const QColor FreeColumnTint(255, 255, 255, 16);
// Occupied column
const QColor NotEmptyColumnColor(164, 164, 164);