Ejemplo n.º 1
0
void DataMarkerLabel::mousePressEvent(QMouseEvent *ev)
{
    m_bMouseMove = false;
    m_bPressLeft = false;
    m_moveMode = kMoveMode_None;
#if 0
	if ( ev->button() != Qt::LeftButton ) {
		ev->ignore();
		return ;
	}
#endif
    m_oldMousePos = ev->pos();
    m_bPressLeft = true;
    m_pressFrame = m_pressCurrentFrame = -1;

    ObjectModel *pModel = m_pEditData->getObjectModel();
    QModelIndex index = m_pEditData->getSelIndex();
    ObjectItem *pItem = pModel->getItemFromIndex(index);

    // 移動予定のフレームデータ取得
    if (ev->y() < height() / 3)
    {
        if (pModel->isLayer(index))
        {
            for (int i = m_frameStart; i <= m_frameEnd; i++)
            {
                if (ev->pos().x() >= getX(i) && ev->pos().x() < getX(i + 1))
                {
                    if (pItem->getFrameDataPtr(i))
                    {
                        m_pressCurrentFrame = m_pressFrame = i;
                        m_moveMode = kMoveMode_Layer;
                    }
                    break;
                }
            }
        }
    }
    else if (pModel->isObject(index) && ev->y() < height() * 2 / 3)
    {
        for (int i = m_frameStart; i <= m_frameEnd; i++)
        {
            if (ev->pos().x() >= getX(i) && ev->pos().x() < getX(i + 1))
            {
                if (pItem->getFrameDataPtr(i, true))
                {
                    m_pressCurrentFrame = m_pressFrame = i;
                    m_moveMode = kMoveMode_Object;
                }
                break;
            }
        }
    }
}
Ejemplo n.º 2
0
void DataMarkerLabel::paintEvent(QPaintEvent * /*event*/)
{
    QPainter painter(this);
    painter.drawRect(0, 0, width() - 1, height() - 1);

    if (m_frameEnd - m_frameStart < 1)
    {
        return;
    }

    drawFrameBase(painter);

    ObjectModel *pModel = m_pEditData->getObjectModel();
    QModelIndex index = m_pEditData->getSelIndex();
    ObjectItem *obj = pModel->getObject(index);
    if (!obj)
    {
        return;
    }

    QList<int> frames;
    drawLayer(obj->getIndex(), painter, index, frames);
    if (m_pressCurrentFrame >= 0)
    {
        int x0 = getX(m_pressCurrentFrame);
        int x1 = getX(m_pressCurrentFrame + 1);
        int y0 = 0;
        QColor col = QColor(255, 0, 0, 128);
        if (pModel->isObject(index))
        {
            y0 = height() / 3;
            col.setRed(255);
        }
        painter.fillRect(x0, y0, x1 - x0, height() / 3, col);
    }
}