Allow Changing Parent of Column from XSheet (#68)
This commit is contained in:
parent
a57d5ece0a
commit
5136b21737
3 changed files with 141 additions and 37 deletions
|
@ -344,10 +344,19 @@ void ChangeObjectWidget::mouseMoveEvent(QMouseEvent *event) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void ChangeObjectWidget::wheelEvent(QWheelEvent *event) {
|
||||||
|
QListWidget::wheelEvent(event);
|
||||||
|
event->accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
void ChangeObjectWidget::focusOutEvent(QFocusEvent *e) {
|
void ChangeObjectWidget::focusOutEvent(QFocusEvent *e) {
|
||||||
if (!isVisible()) return;
|
if (!isVisible()) return;
|
||||||
hide();
|
hide();
|
||||||
parentWidget()->update();
|
if (parentWidget()) {
|
||||||
|
parentWidget()->update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -397,18 +406,35 @@ void ChangeObjectParent::refresh() {
|
||||||
QString indexStr(std::to_string(id.getIndex() + 1).c_str());
|
QString indexStr(std::to_string(id.getIndex() + 1).c_str());
|
||||||
QString newText;
|
QString newText;
|
||||||
if (id == parentId) {
|
if (id == parentId) {
|
||||||
if (parentId.isPegbar())
|
if (parentId.isTable())
|
||||||
|
text = QString("Table");
|
||||||
|
else if (parentId.isPegbar())
|
||||||
text = QString("Peg ") + indexStr;
|
text = QString("Peg ") + indexStr;
|
||||||
else if (parentId.isColumn())
|
else if (parentId.isColumn()) {
|
||||||
text = QString("Col ") + indexStr;
|
text = QString("Col ") + indexStr;
|
||||||
|
QString tempText = newText;
|
||||||
|
std::string name = tree->getStageObject(i)->getName();
|
||||||
|
if (name != tempText.replace(" ", "").toStdString()) {
|
||||||
|
text += " (" + QString::fromStdString(name) + " )";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (id == currentObjectId) continue;
|
if (id == currentObjectId) continue;
|
||||||
|
if (id.isTable()) {
|
||||||
|
newText = QString("Table");
|
||||||
|
pegbarList.append(newText);
|
||||||
|
}
|
||||||
if (id.isPegbar()) {
|
if (id.isPegbar()) {
|
||||||
newText = QString("Peg ") + indexStr;
|
newText = QString("Peg ") + indexStr;
|
||||||
pegbarList.append(newText);
|
pegbarList.append(newText);
|
||||||
}
|
}
|
||||||
if (id.isColumn() && (!xsh->isColumnEmpty(index) || index < 2)) {
|
if (id.isColumn() && (!xsh->isColumnEmpty(index) || index < 2)) {
|
||||||
newText = QString("Col ") + indexStr;
|
newText = QString("Col ") + indexStr;
|
||||||
|
QString tempText = newText;
|
||||||
|
std::string name = tree->getStageObject(i)->getName();
|
||||||
|
if (name.length() > 0 && name != tempText.replace(" ", "").toStdString()) {
|
||||||
|
newText += " (" + QString::fromStdString(name) + " )";
|
||||||
|
}
|
||||||
columnList.append(newText);
|
columnList.append(newText);
|
||||||
}
|
}
|
||||||
if (newText.length() > theLongestTxt.length()) theLongestTxt = newText;
|
if (newText.length() > theLongestTxt.length()) theLongestTxt = newText;
|
||||||
|
@ -428,7 +454,8 @@ void ChangeObjectParent::refresh() {
|
||||||
// set font size in pixel
|
// set font size in pixel
|
||||||
font.setPixelSize(XSHEET_FONT_PX_SIZE);
|
font.setPixelSize(XSHEET_FONT_PX_SIZE);
|
||||||
|
|
||||||
m_width = QFontMetrics(font).width(theLongestTxt) + 2;
|
m_width = QFontMetrics(font).width(theLongestTxt) + 22;
|
||||||
|
std::string strText = text.toStdString();
|
||||||
selectCurrent(text);
|
selectCurrent(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -443,22 +470,34 @@ void ChangeObjectParent::onTextChanged(const QString &text) {
|
||||||
}
|
}
|
||||||
bool isPegbar = false;
|
bool isPegbar = false;
|
||||||
if (text.startsWith("Peg")) isPegbar = true;
|
if (text.startsWith("Peg")) isPegbar = true;
|
||||||
|
bool isTable = false;
|
||||||
|
if (text == "Table") isTable = true;
|
||||||
QString number = text;
|
QString number = text;
|
||||||
number.remove(0, 4);
|
number.remove(0, 4);
|
||||||
|
// Remove names from the index
|
||||||
|
int spaceIndex = number.indexOf(" ");
|
||||||
|
if (spaceIndex > -1) number.remove(spaceIndex, 1000);
|
||||||
int index = number.toInt() - 1;
|
int index = number.toInt() - 1;
|
||||||
if (index < 0) {
|
if (!isTable && index < 0) {
|
||||||
hide();
|
hide();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
TXsheet *xsh = m_xsheetHandle->getXsheet();
|
||||||
TStageObjectId currentObjectId = m_objectHandle->getObjectId();
|
TStageObjectId currentObjectId = m_objectHandle->getObjectId();
|
||||||
|
TStageObjectId currentParentId =
|
||||||
|
xsh->getStageObject(currentObjectId)->getParent();
|
||||||
TStageObjectId newStageObjectId;
|
TStageObjectId newStageObjectId;
|
||||||
if (isPegbar)
|
if (isPegbar)
|
||||||
newStageObjectId = TStageObjectId::PegbarId(index);
|
newStageObjectId = TStageObjectId::PegbarId(index);
|
||||||
|
else if (isTable)
|
||||||
|
newStageObjectId = TStageObjectId::TableId;
|
||||||
else
|
else
|
||||||
newStageObjectId = TStageObjectId::ColumnId(index);
|
newStageObjectId = TStageObjectId::ColumnId(index);
|
||||||
|
|
||||||
if (newStageObjectId == currentObjectId) return;
|
if (newStageObjectId == currentObjectId) return;
|
||||||
|
|
||||||
|
if (newStageObjectId == currentParentId) return;
|
||||||
|
|
||||||
TStageObject *stageObject =
|
TStageObject *stageObject =
|
||||||
m_xsheetHandle->getXsheet()->getStageObject(currentObjectId);
|
m_xsheetHandle->getXsheet()->getStageObject(currentObjectId);
|
||||||
TStageObjectCmd::setParent(currentObjectId, newStageObjectId, "B",
|
TStageObjectCmd::setParent(currentObjectId, newStageObjectId, "B",
|
||||||
|
@ -1086,6 +1125,30 @@ void ColumnArea::DrawHeader::drawPegbarName() const {
|
||||||
|
|
||||||
TStageObjectId columnId = m_viewer->getObjectId(col);
|
TStageObjectId columnId = m_viewer->getObjectId(col);
|
||||||
TStageObjectId parentId = xsh->getStageObjectParent(columnId);
|
TStageObjectId parentId = xsh->getStageObjectParent(columnId);
|
||||||
|
std::string strName = xsh->getStageObject(parentId)->getName();
|
||||||
|
QString name = QString(parentId.toString().c_str());
|
||||||
|
if (strName.length() > 0 && parentId.toString() != strName) {
|
||||||
|
name = QString::fromStdString(strName);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString fontName = Preferences::instance()->getInterfaceFont();
|
||||||
|
if (fontName == "") {
|
||||||
|
#ifdef _WIN32
|
||||||
|
fontName = "Arial";
|
||||||
|
#else
|
||||||
|
fontName = "Helvetica";
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
static QFont font(fontName, -1, QFont::Normal);
|
||||||
|
// set font size in pixel
|
||||||
|
font.setPixelSize(XSHEET_FONT_PX_SIZE);
|
||||||
|
|
||||||
|
int width = QFontMetrics(font).width(name);
|
||||||
|
|
||||||
|
while (width > o->rect(PredefinedRect::PEGBAR_NAME).width() - 20) {
|
||||||
|
name.remove(-1, 1000);
|
||||||
|
width = QFontMetrics(font).width(name);
|
||||||
|
}
|
||||||
|
|
||||||
// pegbar name
|
// pegbar name
|
||||||
QRect pegbarnamerect = o->rect(PredefinedRect::PEGBAR_NAME).translated(orig);
|
QRect pegbarnamerect = o->rect(PredefinedRect::PEGBAR_NAME).translated(orig);
|
||||||
|
@ -1099,8 +1162,7 @@ void ColumnArea::DrawHeader::drawPegbarName() const {
|
||||||
p.setPen(m_viewer->getTextColor());
|
p.setPen(m_viewer->getTextColor());
|
||||||
|
|
||||||
p.drawText(pegbarnamerect.adjusted(3, 0, 0, 0),
|
p.drawText(pegbarnamerect.adjusted(3, 0, 0, 0),
|
||||||
Qt::AlignLeft | Qt::AlignVCenter | Qt::TextSingleLine,
|
Qt::AlignLeft | Qt::AlignVCenter | Qt::TextSingleLine, name);
|
||||||
QString(parentId.toString().c_str()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColumnArea::DrawHeader::drawParentHandleName() const {
|
void ColumnArea::DrawHeader::drawParentHandleName() const {
|
||||||
|
@ -1118,15 +1180,16 @@ void ColumnArea::DrawHeader::drawParentHandleName() const {
|
||||||
|
|
||||||
TStageObjectId columnId = m_viewer->getObjectId(col);
|
TStageObjectId columnId = m_viewer->getObjectId(col);
|
||||||
TStageObjectId parentId = xsh->getStageObjectParent(columnId);
|
TStageObjectId parentId = xsh->getStageObjectParent(columnId);
|
||||||
|
p.setPen(m_viewer->getVerticalLineColor());
|
||||||
|
p.drawRect(parenthandleRect.adjusted(2, 0, 0, 0));
|
||||||
p.setPen(m_viewer->getTextColor());
|
p.setPen(m_viewer->getTextColor());
|
||||||
|
|
||||||
std::string handle = xsh->getStageObject(columnId)->getParentHandle();
|
std::string handle = xsh->getStageObject(columnId)->getParentHandle();
|
||||||
if (handle[0] == 'H' && handle.length() > 1) handle = handle.substr(1);
|
if (handle[0] == 'H' && handle.length() > 1) handle = handle.substr(1);
|
||||||
if (parentId != TStageObjectId::TableId)
|
// if (parentId != TStageObjectId::TableId)
|
||||||
p.drawText(parenthandleRect,
|
p.drawText(parenthandleRect,
|
||||||
Qt::AlignHCenter | Qt::AlignVCenter | Qt::TextSingleLine,
|
Qt::AlignHCenter | Qt::AlignVCenter | Qt::TextSingleLine,
|
||||||
QString::fromStdString(handle));
|
QString::fromStdString(handle));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColumnArea::DrawHeader::drawFilterColor() const {
|
void ColumnArea::DrawHeader::drawFilterColor() const {
|
||||||
|
@ -1239,12 +1302,12 @@ ColumnArea::ColumnArea(XsheetViewer *parent, Qt::WFlags flags)
|
||||||
, m_soundColumnPopup(0) {
|
, m_soundColumnPopup(0) {
|
||||||
TXsheetHandle *xsheetHandle = TApp::instance()->getCurrentXsheet();
|
TXsheetHandle *xsheetHandle = TApp::instance()->getCurrentXsheet();
|
||||||
TObjectHandle *objectHandle = TApp::instance()->getCurrentObject();
|
TObjectHandle *objectHandle = TApp::instance()->getCurrentObject();
|
||||||
m_changeObjectParent = new ChangeObjectParent(0);
|
m_changeObjectParent = new ChangeObjectParent(m_viewer);
|
||||||
m_changeObjectParent->setObjectHandle(objectHandle);
|
m_changeObjectParent->setObjectHandle(objectHandle);
|
||||||
m_changeObjectParent->setXsheetHandle(xsheetHandle);
|
m_changeObjectParent->setXsheetHandle(xsheetHandle);
|
||||||
m_changeObjectParent->hide();
|
m_changeObjectParent->hide();
|
||||||
|
|
||||||
m_changeObjectHandle = new ChangeObjectHandle(0);
|
m_changeObjectHandle = new ChangeObjectHandle(m_viewer);
|
||||||
m_changeObjectHandle->setObjectHandle(objectHandle);
|
m_changeObjectHandle->setObjectHandle(objectHandle);
|
||||||
m_changeObjectHandle->setXsheetHandle(xsheetHandle);
|
m_changeObjectHandle->setXsheetHandle(xsheetHandle);
|
||||||
m_changeObjectHandle->hide();
|
m_changeObjectHandle->hide();
|
||||||
|
@ -2201,6 +2264,25 @@ void ColumnArea::mousePressEvent(QMouseEvent *event) {
|
||||||
event->button() == Qt::RightButton)
|
event->button() == Qt::RightButton)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (o->rect(PredefinedRect::PEGBAR_NAME)
|
||||||
|
.adjusted(0, 0, -20, 0)
|
||||||
|
.contains(mouseInCell)) {
|
||||||
|
m_changeObjectParent->refresh();
|
||||||
|
m_changeObjectParent->show(
|
||||||
|
QPoint(o->rect(PredefinedRect::PARENT_HANDLE_NAME).bottomLeft() +
|
||||||
|
m_viewer->positionToXY(CellPosition(0, m_col)) +
|
||||||
|
QPoint(o->rect(PredefinedRect::CAMERA_CELL).width(), 4)));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (o->rect(PredefinedRect::PARENT_HANDLE_NAME).contains(mouseInCell)) {
|
||||||
|
m_changeObjectHandle->refresh();
|
||||||
|
m_changeObjectHandle->show(
|
||||||
|
QPoint(o->rect(PredefinedRect::PARENT_HANDLE_NAME).bottomLeft() +
|
||||||
|
m_viewer->positionToXY(CellPosition(0, m_col + 1)) +
|
||||||
|
QPoint(2, 0)));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
setDragTool(XsheetGUI::DragTool::makeColumnSelectionTool(m_viewer));
|
setDragTool(XsheetGUI::DragTool::makeColumnSelectionTool(m_viewer));
|
||||||
|
|
||||||
if (column) {
|
if (column) {
|
||||||
|
@ -2676,7 +2758,8 @@ void ColumnArea::contextMenuEvent(QContextMenuEvent *event) {
|
||||||
// setMask->setCheckable(true);
|
// setMask->setCheckable(true);
|
||||||
// setMask->setChecked(xsh->getColumn(col)->isMask());
|
// setMask->setChecked(xsh->getColumn(col)->isMask());
|
||||||
// setMask->setToolTip(
|
// setMask->setToolTip(
|
||||||
// tr("Only Toonz Vector levels can be used as masks. \n Masks don't "
|
// tr("Only Toonz Vector levels can be used as masks. \n Masks don't
|
||||||
|
// "
|
||||||
// "show up in final renders."));
|
// "show up in final renders."));
|
||||||
// bool ret = true;
|
// bool ret = true;
|
||||||
// ret = ret &&
|
// ret = ret &&
|
||||||
|
|
|
@ -89,6 +89,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mouseMoveEvent(QMouseEvent *event) override;
|
void mouseMoveEvent(QMouseEvent *event) override;
|
||||||
|
void wheelEvent(QWheelEvent *event) override;
|
||||||
void focusOutEvent(QFocusEvent *e) override;
|
void focusOutEvent(QFocusEvent *e) override;
|
||||||
void focusInEvent(QFocusEvent *e) override {}
|
void focusInEvent(QFocusEvent *e) override {}
|
||||||
void selectCurrent(const QString &text);
|
void selectCurrent(const QString &text);
|
||||||
|
|
|
@ -3427,12 +3427,20 @@ void StyleEditor::onStyleChanged(bool isDragging) {
|
||||||
m_colorParameterSelector->setStyle(*m_editedStyle);
|
m_colorParameterSelector->setStyle(*m_editedStyle);
|
||||||
m_settingsPage->setStyle(m_editedStyle);
|
m_settingsPage->setStyle(m_editedStyle);
|
||||||
m_newColor->setStyle(*m_editedStyle);
|
m_newColor->setStyle(*m_editedStyle);
|
||||||
TPixel32 color = m_editedStyle->getMainColor();
|
int tag = m_editedStyle->getTagId();
|
||||||
QString myColor = QString::number(color.r) + ", " + QString::number(color.g) +
|
if (tag == 4 || tag == 2000 || tag == 2800) {
|
||||||
", " + QString::number(color.b);
|
m_fillColorWidget->hide();
|
||||||
std::string myColorStr = myColor.toStdString();
|
} else {
|
||||||
QString styleSheet = "background-color: rgb(%1);";
|
m_fillColorWidget->show();
|
||||||
m_fillColorWidget->setStyleSheet(styleSheet.arg(myColor));
|
|
||||||
|
TPixel32 color = m_editedStyle->getMainColor();
|
||||||
|
QString myColor = QString::number(color.r) + ", " +
|
||||||
|
QString::number(color.g) + ", " +
|
||||||
|
QString::number(color.b);
|
||||||
|
std::string myColorStr = myColor.toStdString();
|
||||||
|
QString styleSheet = "background-color: rgb(%1);";
|
||||||
|
m_fillColorWidget->setStyleSheet(styleSheet.arg(myColor));
|
||||||
|
}
|
||||||
m_oldColor->setStyle(
|
m_oldColor->setStyle(
|
||||||
*m_oldStyle); // This line is needed for proper undo behavior
|
*m_oldStyle); // This line is needed for proper undo behavior
|
||||||
}
|
}
|
||||||
|
@ -3530,13 +3538,19 @@ void StyleEditor::onColorChanged(const ColorModel &color, bool isDragging) {
|
||||||
}
|
}
|
||||||
|
|
||||||
m_newColor->setStyle(*m_editedStyle);
|
m_newColor->setStyle(*m_editedStyle);
|
||||||
TPixel32 color = m_editedStyle->getMainColor();
|
int tag = m_editedStyle->getTagId();
|
||||||
QString myColor = QString::number(color.r) + ", " +
|
if (tag == 4 || tag == 2000 || tag == 2800) {
|
||||||
QString::number(color.g) + ", " +
|
m_fillColorWidget->hide();
|
||||||
QString::number(color.b);
|
} else {
|
||||||
std::string myColorStr = myColor.toStdString();
|
m_fillColorWidget->show();
|
||||||
QString styleSheet = "background-color: rgb(%1);";
|
TPixel32 color = m_editedStyle->getMainColor();
|
||||||
m_fillColorWidget->setStyleSheet(styleSheet.arg(myColor));
|
QString myColor = QString::number(color.r) + ", " +
|
||||||
|
QString::number(color.g) + ", " +
|
||||||
|
QString::number(color.b);
|
||||||
|
std::string myColorStr = myColor.toStdString();
|
||||||
|
QString styleSheet = "background-color: rgb(%1);";
|
||||||
|
m_fillColorWidget->setStyleSheet(styleSheet.arg(myColor));
|
||||||
|
}
|
||||||
m_colorParameterSelector->setStyle(*m_editedStyle);
|
m_colorParameterSelector->setStyle(*m_editedStyle);
|
||||||
|
|
||||||
if (m_autoButton->isChecked()) {
|
if (m_autoButton->isChecked()) {
|
||||||
|
@ -3678,14 +3692,20 @@ bool StyleEditor::setStyle(TColorStyle *currentStyle) {
|
||||||
m_plainColorPage->setColor(*currentStyle, getColorParam());
|
m_plainColorPage->setColor(*currentStyle, getColorParam());
|
||||||
m_oldColor->setStyle(*currentStyle);
|
m_oldColor->setStyle(*currentStyle);
|
||||||
m_newColor->setStyle(*currentStyle);
|
m_newColor->setStyle(*currentStyle);
|
||||||
TPixel32 color = currentStyle->getMainColor();
|
|
||||||
QString myColor = QString::number(color.r) + ", " +
|
|
||||||
QString::number(color.g) + ", " +
|
|
||||||
QString::number(color.b);
|
|
||||||
std::string myColorStr = myColor.toStdString();
|
|
||||||
QString styleSheet = "background-color: rgb(%1);";
|
|
||||||
m_fillColorWidget->setStyleSheet(styleSheet.arg(myColor));
|
|
||||||
|
|
||||||
|
int tag = currentStyle->getTagId();
|
||||||
|
if (tag == 4 || tag == 2000 || tag == 2800) {
|
||||||
|
m_fillColorWidget->hide();
|
||||||
|
} else {
|
||||||
|
m_fillColorWidget->show();
|
||||||
|
TPixel32 color = currentStyle->getMainColor();
|
||||||
|
QString myColor = QString::number(color.r) + ", " +
|
||||||
|
QString::number(color.g) + ", " +
|
||||||
|
QString::number(color.b);
|
||||||
|
std::string myColorStr = myColor.toStdString();
|
||||||
|
QString styleSheet = "background-color: rgb(%1);";
|
||||||
|
m_fillColorWidget->setStyleSheet(styleSheet.arg(myColor));
|
||||||
|
}
|
||||||
setOldStyleToStyle(currentStyle);
|
setOldStyleToStyle(currentStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue