コード例 #1
0
void AnimationForm::jumpEndFrame()
{
	CObjectModel *pModel = m_pEditData->getObjectModel() ;
	QModelIndex index = m_pEditData->getSelIndex() ;
	if ( !pModel->isLayer(index) ) { return ; }
	ObjectItem *pItem = pModel->getItemFromIndex(index) ;
	if ( !pItem ) { return ; }

	int maxFrame = -1 ;
	const QList<FrameData> &datas = pItem->getFrameData() ;
	for ( int i = 0 ; i < datas.size() ; i ++ ) {
		if ( maxFrame < datas.at(i).frame ) {
			maxFrame = datas.at(i).frame ;
		}
	}
	if ( !pItem->getFrameDataPtr(maxFrame) ) { return ; }

	slot_frameChanged(maxFrame) ;
}
コード例 #2
0
void DataMarkerLabel::drawLayer(const QModelIndex &index, QPainter &painter, const QModelIndex selIndex, QList<int> &frames)
{
    if (!index.isValid())
    {
        return;
    }

    ObjectItem *pItem = m_pEditData->getObjectModel()->getItemFromIndex(index);
    if (!pItem)
    {
        return;
    }

    bool bMine = false;
    if (selIndex.isValid() && index == selIndex)
    {
        bMine = true;
    }

    const QList<FrameData> &datas = pItem->getFrameData();
    for (int i = 0; i < datas.size(); i++)
    {
        const FrameData data = datas.at(i);

        if (data.frame < m_frameStart || data.frame > m_frameEnd)
        {
            continue;
        }

        int x0 = getX(data.frame);
        int x1 = getX(data.frame + 1);
        if (x1 < 0)
        {
            continue;
        }
        if (bMine)
        {
            if (m_pressFrame == data.frame)
            {
                continue;
            }
            painter.fillRect(x0, 0, x1 - x0, height() / 3, QColor(255, 0, 0, 128));
        }
        else
        {
            if (frames.indexOf(data.frame) >= 0)
            {
                continue;
            }
            frames.append(data.frame);

            QColor col = QColor(0, 0, 255, 128);
            if (m_pEditData->getObjectModel()->isObject(m_pEditData->getSelIndex()))
            {
                col.setRed(255);
            }
            painter.fillRect(x0, height() / 3, x1 - x0, height() / 3, col);
        }
    }

    for (int i = 0; i < pItem->childCount(); i++)
    {
        QModelIndex child = m_pEditData->getObjectModel()->index(i, 0, index);
        drawLayer(child, painter, selIndex, frames);
    }
}