Commit 005d30fe authored by Ilia Ryabokon's avatar Ilia Ryabokon

Duplication, paint all the selected items by highlighting them

parent 4576b453
...@@ -67,6 +67,7 @@ ...@@ -67,6 +67,7 @@
#include "domain/UBGraphicsSvgItem.h" #include "domain/UBGraphicsSvgItem.h"
#include "domain/UBGraphicsGroupContainerItem.h" #include "domain/UBGraphicsGroupContainerItem.h"
#include "domain/UBGraphicsStrokesGroup.h" #include "domain/UBGraphicsStrokesGroup.h"
#include "domain/UBGraphicsItemDelegate.h"
#include "document/UBDocumentProxy.h" #include "document/UBDocumentProxy.h"
......
...@@ -160,6 +160,31 @@ struct UBGraphicsItemType ...@@ -160,6 +160,31 @@ struct UBGraphicsItemType
}; };
}; };
// Might be fit in int value under most OS
enum UBGraphicsFlag {
GF_NONE = 0x0000 //0000 0000 0000 0000
,GF_FLIPPABLE_X_AXIS = 0x0001 //0000 0000 0000 0001
,GF_FLIPPABLE_Y_AXIS = 0x0002 //0000 0000 0000 0010
,GF_FLIPPABLE_ALL_AXIS = 0x0003 //0000 0000 0000 0011 GF_FLIPPABLE_X_AXIS | GF_FLIPPABLE_Y_AXIS
,GF_REVOLVABLE = 0x0004 //0000 0000 0000 0100
,GF_SCALABLE_X_AXIS = 0x0008 //0000 0000 0000 1000
,GF_SCALABLE_Y_AXIS = 0x0010 //0000 0000 0001 0000
,GF_SCALABLE_ALL_AXIS = 0x0018 //0000 0000 0001 1000 GF_SCALABLE_X_AXIS | GF_SCALABLE_Y_AXIS
,GF_DUPLICATION_ENABLED = 0x0020 //0000 0000 0010 0000
,GF_MENU_SPECIFIED = 0x0040 //0000 0000 0100 0000
,GF_ZORDER_MANIPULATIONS_ALLOWED = 0x0080 //0000 0000 1000 0000
,GF_TOOLBAR_USED = 0x0100 //0000 0001 0000 0000
,GF_SHOW_CONTENT_SOURCE = 0x0200 //0000 0010 0000 0000
,GF_RESPECT_RATIO = 0x0418 //0000 0100 0001 1000
,GF_COMMON = 0x00F8 /*0000 0000 1111 1000 GF_SCALABLE_ALL_AXIS
|GF_DUPLICATION_ENABLED
|GF_MENU_SPECIFIED
|GF_ZORDER_MANIPULATIONS_ALLOWED */
,GF_ALL = 0xFFFF //1111 1111 1111 1111
};
Q_DECLARE_FLAGS(UBGraphicsFlags, UBGraphicsFlag)
Q_DECLARE_OPERATORS_FOR_FLAGS(UBGraphicsFlags )
struct DocumentSizeRatio struct DocumentSizeRatio
{ {
enum Enum enum Enum
......
...@@ -92,7 +92,7 @@ UBGraphicsDelegateFrame::UBGraphicsDelegateFrame(UBGraphicsItemDelegate* pDelega ...@@ -92,7 +92,7 @@ UBGraphicsDelegateFrame::UBGraphicsDelegateFrame(UBGraphicsItemDelegate* pDelega
mRotateButton = new QGraphicsSvgItem(":/images/rotate.svg", this); mRotateButton = new QGraphicsSvgItem(":/images/rotate.svg", this);
mRotateButton->setCursor(UBResources::resources()->rotateCursor); mRotateButton->setCursor(UBResources::resources()->rotateCursor);
mRotateButton->setVisible(mDelegate->canRotate()); mRotateButton->setVisible(mDelegate->testUBFlags(GF_REVOLVABLE));
updateResizeCursors(); updateResizeCursors();
...@@ -452,7 +452,7 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event) ...@@ -452,7 +452,7 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
}else if(resizingRight()){ }else if(resizingRight()){
scaleX = (width + moveX) / width; scaleX = (width + moveX) / width;
} }
if(mDelegate->isFlippable() && qAbs(scaleX) != 0){ if(mDelegate->testUBFlags(GF_FLIPPABLE_ALL_AXIS) && qAbs(scaleX) != 0){
if((qAbs(width * scaleX)) < 2*mFrameWidth){ if((qAbs(width * scaleX)) < 2*mFrameWidth){
bool negative = (scaleX < 0)?true:false; bool negative = (scaleX < 0)?true:false;
if(negative){ if(negative){
...@@ -482,7 +482,7 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event) ...@@ -482,7 +482,7 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
scaleY = (height + moveY) / height; scaleY = (height + moveY) / height;
} }
if(mDelegate->isFlippable() && qAbs(scaleY) != 0){ if(mDelegate->testUBFlags(GF_FLIPPABLE_ALL_AXIS) && qAbs(scaleY) != 0){
if((qAbs(height * scaleY)) < 2*mFrameWidth){ if((qAbs(height * scaleY)) < 2*mFrameWidth){
bool negative = (scaleY < 0)?true:false; bool negative = (scaleY < 0)?true:false;
if(negative){ if(negative){
...@@ -883,7 +883,7 @@ void UBGraphicsDelegateFrame::positionHandles() ...@@ -883,7 +883,7 @@ void UBGraphicsDelegateFrame::positionHandles()
mLeftResizeGripSvgItem->setVisible(!isLocked && (bShowHorizontalResizers || bShowAllResizers)); mLeftResizeGripSvgItem->setVisible(!isLocked && (bShowHorizontalResizers || bShowAllResizers));
mRightResizeGripSvgItem->setVisible(!isLocked && (bShowHorizontalResizers || bShowAllResizers)); mRightResizeGripSvgItem->setVisible(!isLocked && (bShowHorizontalResizers || bShowAllResizers));
mTopResizeGripSvgItem->setVisible(!isLocked && (bShowVerticalResizers || bShowAllResizers)); mTopResizeGripSvgItem->setVisible(!isLocked && (bShowVerticalResizers || bShowAllResizers));
mRotateButton->setVisible(mDelegate->canRotate() && !isLocked); mRotateButton->setVisible(mDelegate->testUBFlags(GF_REVOLVABLE) && !isLocked);
mBottomRightResizeGrip->setVisible(!isLocked && bShowAllResizers); mBottomRightResizeGrip->setVisible(!isLocked && bShowAllResizers);
mBottomResizeGrip->setVisible(!isLocked && (bShowVerticalResizers || bShowAllResizers)); mBottomResizeGrip->setVisible(!isLocked && (bShowVerticalResizers || bShowAllResizers));
...@@ -947,7 +947,7 @@ UBGraphicsDelegateFrame::FrameTool UBGraphicsDelegateFrame::toolFromPos(QPointF ...@@ -947,7 +947,7 @@ UBGraphicsDelegateFrame::FrameTool UBGraphicsDelegateFrame::toolFromPos(QPointF
return ResizeTop; return ResizeTop;
} }
} }
else if (rotateButtonBounds().contains(pos) && mDelegate && mDelegate->canRotate()) else if (rotateButtonBounds().contains(pos) && mDelegate && mDelegate->testUBFlags(GF_REVOLVABLE))
return Rotate; return Rotate;
else else
return Move; return Move;
......
...@@ -39,8 +39,7 @@ UBGraphicsGroupContainerItem::UBGraphicsGroupContainerItem(QGraphicsItem *parent ...@@ -39,8 +39,7 @@ UBGraphicsGroupContainerItem::UBGraphicsGroupContainerItem(QGraphicsItem *parent
{ {
setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object); setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object);
setDelegate(new UBGraphicsGroupContainerItemDelegate(this, 0)); setDelegate(new UBGraphicsGroupContainerItemDelegate(this, 0));
Delegate()->init();
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
setFlag(QGraphicsItem::ItemIsSelectable, true); setFlag(QGraphicsItem::ItemIsSelectable, true);
...@@ -71,14 +70,14 @@ void UBGraphicsGroupContainerItem::addToGroup(QGraphicsItem *item) ...@@ -71,14 +70,14 @@ void UBGraphicsGroupContainerItem::addToGroup(QGraphicsItem *item)
//Check if group is allready rotatable or flippable //Check if group is allready rotatable or flippable
if (childItems().count()) { if (childItems().count()) {
if (UBGraphicsItem::isFlippable(this) && !UBGraphicsItem::isFlippable(item)) { if (UBGraphicsItem::isFlippable(this) && !UBGraphicsItem::isFlippable(item)) {
Delegate()->setFlippable(false); Delegate()->setUBFlag(GF_FLIPPABLE_ALL_AXIS, false);
} }
if (UBGraphicsItem::isRotatable(this) && !UBGraphicsItem::isRotatable(item)) { if (UBGraphicsItem::isRotatable(this) && !UBGraphicsItem::isRotatable(item)) {
Delegate()->setRotatable(false); Delegate()->setUBFlag(GF_REVOLVABLE, false);
} }
} else { } else {
Delegate()->setFlippable(UBGraphicsItem::isFlippable(item)); Delegate()->setUBFlag(GF_FLIPPABLE_ALL_AXIS, UBGraphicsItem::isFlippable(item));
Delegate()->setRotatable(UBGraphicsItem::isRotatable(item)); Delegate()->setUBFlag(GF_REVOLVABLE, UBGraphicsItem::isRotatable(item));
} }
// COMBINE // COMBINE
...@@ -194,6 +193,7 @@ void UBGraphicsGroupContainerItem::paint(QPainter *painter, const QStyleOptionGr ...@@ -194,6 +193,7 @@ void UBGraphicsGroupContainerItem::paint(QPainter *painter, const QStyleOptionGr
// painter->setPen(tmpPen); // painter->setPen(tmpPen);
// painter->drawRect(itemsBoundingRect.adjusted(tmpPenWidth / 2, tmpPenWidth / 2, -tmpPenWidth / 2, -tmpPenWidth / 2)); // painter->drawRect(itemsBoundingRect.adjusted(tmpPenWidth / 2, tmpPenWidth / 2, -tmpPenWidth / 2, -tmpPenWidth / 2));
// } // }
Delegate()->postpaint(painter, option, widget);
} }
UBCoreGraphicsScene *UBGraphicsGroupContainerItem::corescene() UBCoreGraphicsScene *UBGraphicsGroupContainerItem::corescene()
...@@ -334,8 +334,8 @@ void UBGraphicsGroupContainerItem::pRemoveFromGroup(QGraphicsItem *item) ...@@ -334,8 +334,8 @@ void UBGraphicsGroupContainerItem::pRemoveFromGroup(QGraphicsItem *item)
break; break;
} }
} }
Delegate()->setFlippable(flippableNow); Delegate()->setUBFlag(GF_FLIPPABLE_ALL_AXIS, flippableNow);
Delegate()->setRotatable(rotatableNow); Delegate()->setUBFlag(GF_REVOLVABLE, rotatableNow);
} }
} }
......
...@@ -36,13 +36,9 @@ ...@@ -36,13 +36,9 @@
#include "core/memcheck.h" #include "core/memcheck.h"
UBGraphicsGroupContainerItemDelegate::UBGraphicsGroupContainerItemDelegate(QGraphicsItem *pDelegated, QObject *parent) : UBGraphicsGroupContainerItemDelegate::UBGraphicsGroupContainerItemDelegate(QGraphicsItem *pDelegated, QObject *parent) :
UBGraphicsItemDelegate(pDelegated, parent, true, false, false), mDestroyGroupButton(0) UBGraphicsItemDelegate(pDelegated, parent, GF_COMMON | GF_RESPECT_RATIO), mDestroyGroupButton(0)
{ {
//Wrapper function. Use it to set correct data() to QGraphicsItem as well
setFlippable(false);
setRotatable(false);
setCanDuplicate(true);
} }
UBGraphicsGroupContainerItem *UBGraphicsGroupContainerItemDelegate::delegated() UBGraphicsGroupContainerItem *UBGraphicsGroupContainerItemDelegate::delegated()
......
...@@ -152,7 +152,7 @@ void DelegateButton::startShowProgress() ...@@ -152,7 +152,7 @@ void DelegateButton::startShowProgress()
} }
} }
UBGraphicsItemDelegate::UBGraphicsItemDelegate(QGraphicsItem* pDelegated, QObject * parent, bool respectRatio, bool canRotate, bool useToolBar, bool showGoContentButton) UBGraphicsItemDelegate::UBGraphicsItemDelegate(QGraphicsItem* pDelegated, QObject * parent, UBGraphicsFlags fls)
: QObject(parent) : QObject(parent)
, mDelegated(pDelegated) , mDelegated(pDelegated)
, mDeleteButton(NULL) , mDeleteButton(NULL)
...@@ -168,31 +168,19 @@ UBGraphicsItemDelegate::UBGraphicsItemDelegate(QGraphicsItem* pDelegated, QObjec ...@@ -168,31 +168,19 @@ UBGraphicsItemDelegate::UBGraphicsItemDelegate(QGraphicsItem* pDelegated, QObjec
, mFrameWidth(UBSettings::settings()->objectFrameWidth) , mFrameWidth(UBSettings::settings()->objectFrameWidth)
, mAntiScaleRatio(1.0) , mAntiScaleRatio(1.0)
, mToolBarItem(NULL) , mToolBarItem(NULL)
, mCanRotate(canRotate)
, mCanDuplicate(true)
, mRespectRatio(respectRatio)
, mMimeData(NULL) , mMimeData(NULL)
, mFlippable(false)
, mToolBarUsed(useToolBar)
, mShowGoContentButton(showGoContentButton)
{ {
setUBFlags(fls);
connect(UBApplication::boardController, SIGNAL(zoomChanged(qreal)), this, SLOT(onZoomChanged())); connect(UBApplication::boardController, SIGNAL(zoomChanged(qreal)), this, SLOT(onZoomChanged()));
} }
void UBGraphicsItemDelegate::init()
{
//Wrapper function. Use it to set correct data() to QGraphicsItem as well
setFlippable(false);
setRotatable(false);
}
void UBGraphicsItemDelegate::createControls() void UBGraphicsItemDelegate::createControls()
{ {
if (mToolBarUsed && !mToolBarItem) if (testUBFlags(GF_TOOLBAR_USED) && !mToolBarItem)
mToolBarItem = new UBGraphicsToolBarItem(mDelegated); mToolBarItem = new UBGraphicsToolBarItem(mDelegated);
if (!mFrame) { if (!mFrame) {
mFrame = new UBGraphicsDelegateFrame(this, QRectF(0, 0, 0, 0), mFrameWidth, mRespectRatio); mFrame = new UBGraphicsDelegateFrame(this, QRectF(0, 0, 0, 0), mFrameWidth, testUBFlags(GF_RESPECT_RATIO));
mFrame->hide(); mFrame->hide();
mFrame->setFlag(QGraphicsItem::ItemIsSelectable, true); mFrame->setFlag(QGraphicsItem::ItemIsSelectable, true);
} }
...@@ -201,7 +189,7 @@ void UBGraphicsItemDelegate::createControls() ...@@ -201,7 +189,7 @@ void UBGraphicsItemDelegate::createControls()
mDeleteButton = new DelegateButton(":/images/close.svg", mDelegated, mFrame, Qt::TopLeftSection); mDeleteButton = new DelegateButton(":/images/close.svg", mDelegated, mFrame, Qt::TopLeftSection);
mButtons << mDeleteButton; mButtons << mDeleteButton;
connect(mDeleteButton, SIGNAL(clicked()), this, SLOT(remove())); connect(mDeleteButton, SIGNAL(clicked()), this, SLOT(remove()));
if (canDuplicate()){ if (testUBFlags(GF_DUPLICATION_ENABLED)){
mDuplicateButton = new DelegateButton(":/images/duplicate.svg", mDelegated, mFrame, Qt::TopLeftSection); mDuplicateButton = new DelegateButton(":/images/duplicate.svg", mDelegated, mFrame, Qt::TopLeftSection);
connect(mDuplicateButton, SIGNAL(clicked(bool)), this, SLOT(duplicate())); connect(mDuplicateButton, SIGNAL(clicked(bool)), this, SLOT(duplicate()));
mButtons << mDuplicateButton; mButtons << mDuplicateButton;
...@@ -319,6 +307,19 @@ UBGraphicsScene *UBGraphicsItemDelegate::castUBGraphicsScene() ...@@ -319,6 +307,19 @@ UBGraphicsScene *UBGraphicsItemDelegate::castUBGraphicsScene()
return castScene; return castScene;
} }
/** Used to render custom data after the main "Paint" operation is finished */
void UBGraphicsItemDelegate::postpaint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(widget)
if (option->state & QStyle::State_Selected && !controlsExist()) {
painter->save();
painter->setPen(Qt::NoPen);
painter->setBrush(QColor(0x88, 0x88, 0x88, 0x77));
painter->drawRect(option->rect);
painter->restore();
}
}
bool UBGraphicsItemDelegate::mousePressEvent(QGraphicsSceneMouseEvent *event) bool UBGraphicsItemDelegate::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
mDragStartPosition = event->pos(); mDragStartPosition = event->pos();
...@@ -667,7 +668,7 @@ void UBGraphicsItemDelegate::decorateMenu(QMenu* menu) ...@@ -667,7 +668,7 @@ void UBGraphicsItemDelegate::decorateMenu(QMenu* menu)
showIcon.addPixmap(QPixmap(":/images/eyeClosed.svg"), QIcon::Normal, QIcon::Off); showIcon.addPixmap(QPixmap(":/images/eyeClosed.svg"), QIcon::Normal, QIcon::Off);
mShowOnDisplayAction->setIcon(showIcon); mShowOnDisplayAction->setIcon(showIcon);
if (mShowGoContentButton) if (testUBFlags(GF_SHOW_CONTENT_SOURCE))
{ {
mGotoContentSourceAction = menu->addAction(tr("Go to Content Source"), this, SLOT(gotoContentSource())); mGotoContentSourceAction = menu->addAction(tr("Go to Content Source"), this, SLOT(gotoContentSource()));
...@@ -711,32 +712,6 @@ void UBGraphicsItemDelegate::showMenu() ...@@ -711,32 +712,6 @@ void UBGraphicsItemDelegate::showMenu()
mMenu->exec(cv->mapToGlobal(pinPos.bottomRight())); mMenu->exec(cv->mapToGlobal(pinPos.bottomRight()));
} }
void UBGraphicsItemDelegate::setFlippable(bool flippable)
{
mFlippable = flippable;
Q_ASSERT (mDelegated);
if (mDelegated) {
mDelegated->setData(UBGraphicsItemData::ItemFlippable, QVariant(flippable));
}
}
void UBGraphicsItemDelegate::setRotatable(bool pCanRotate)
{
mCanRotate = pCanRotate;
Q_ASSERT(mDelegated);
if (mDelegated) {
mDelegated->setData(UBGraphicsItemData::ItemRotatable, QVariant(pCanRotate));
}
}
bool UBGraphicsItemDelegate::isFlippable()
{
return mFlippable;
}
void UBGraphicsItemDelegate::updateFrame() void UBGraphicsItemDelegate::updateFrame()
{ {
if (mFrame && !mFrame->scene() && mDelegated->scene()) if (mFrame && !mFrame->scene() && mDelegated->scene())
...@@ -805,6 +780,31 @@ void UBGraphicsItemDelegate::setButtonsVisible(bool visible) ...@@ -805,6 +780,31 @@ void UBGraphicsItemDelegate::setButtonsVisible(bool visible)
} }
} }
void UBGraphicsItemDelegate::setUBFlags(UBGraphicsFlags pf)
{
mFlags = pf;
Q_ASSERT (mDelegated);
if (!mDelegated) {
return;
}
if (testUBFlags(GF_FLIPPABLE_ALL_AXIS)) {
mDelegated->setData(UBGraphicsItemData::ItemFlippable, QVariant(testUBFlags(GF_FLIPPABLE_ALL_AXIS)));
}
if (testUBFlags(GF_REVOLVABLE)) {
mDelegated->setData(UBGraphicsItemData::ItemRotatable, QVariant(testUBFlags(GF_REVOLVABLE)));
}
}
void UBGraphicsItemDelegate::setUBFlag(UBGraphicsFlags pf, bool set)
{
UBGraphicsFlags fls = mFlags;
set ? fls |= pf : fls &= ~pf;
setUBFlags(fls);
}
UBGraphicsToolBarItem::UBGraphicsToolBarItem(QGraphicsItem * parent) : UBGraphicsToolBarItem::UBGraphicsToolBarItem(QGraphicsItem * parent) :
QGraphicsRectItem(parent), QGraphicsRectItem(parent),
......
...@@ -174,7 +174,7 @@ class DelegateMediaControl: public QObject, public QGraphicsRectItem ...@@ -174,7 +174,7 @@ class DelegateMediaControl: public QObject, public QGraphicsRectItem
void positionHandles(); void positionHandles();
void updateTicker(qint64 time); void updateTicker(qint64 time);
void totalTimeChanged(qint64 newTotalTime); void totalTimeChanged(qint64 newTotalTime);
QSizeF lcdAreaSize(){return mLCDTimerArea.size();} QSizeF lcdAreaSize() {return mLCDTimerArea.size();}
signals: signals:
void used(); void used();
...@@ -235,11 +235,10 @@ class UBGraphicsItemDelegate : public QObject ...@@ -235,11 +235,10 @@ class UBGraphicsItemDelegate : public QObject
Q_OBJECT Q_OBJECT
public: public:
UBGraphicsItemDelegate(QGraphicsItem* pDelegated, QObject * parent = 0, bool respectRatio = true, bool canRotate = false, bool useToolBar = true, bool showGoContentButton = false); UBGraphicsItemDelegate(QGraphicsItem* pDelegated, QObject * parent = 0, UBGraphicsFlags fls = 0);
virtual ~UBGraphicsItemDelegate(); virtual ~UBGraphicsItemDelegate();
void init();
virtual void createControls(); virtual void createControls();
virtual void freeControls(); virtual void freeControls();
virtual void showControls(); virtual void showControls();
...@@ -256,13 +255,13 @@ class UBGraphicsItemDelegate : public QObject ...@@ -256,13 +255,13 @@ class UBGraphicsItemDelegate : public QObject
virtual QVariant itemChange(QGraphicsItem::GraphicsItemChange change, virtual QVariant itemChange(QGraphicsItem::GraphicsItemChange change,
const QVariant &value); const QVariant &value);
virtual UBGraphicsScene *castUBGraphicsScene(); virtual UBGraphicsScene *castUBGraphicsScene();
virtual void postpaint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
void printMessage(const QString &mess) {qDebug() << mess;} void printMessage(const QString &mess) {qDebug() << mess;}
QGraphicsItem* delegated(); QGraphicsItem* delegated();
void setCanDuplicate(bool allow){ mCanDuplicate = allow; }
virtual void positionHandles(); virtual void positionHandles();
void setZOrderButtonsVisible(bool visible); void setZOrderButtonsVisible(bool visible);
...@@ -271,18 +270,12 @@ class UBGraphicsItemDelegate : public QObject ...@@ -271,18 +270,12 @@ class UBGraphicsItemDelegate : public QObject
UBGraphicsDelegateFrame* frame() {return mFrame;} UBGraphicsDelegateFrame* frame() {return mFrame;}
bool canRotate() const { return mCanRotate; }
bool isLocked() const; bool isLocked() const;
bool canDuplicate() { return mCanDuplicate; }
QMimeData* mimeData(){ return mMimeData; } QMimeData* mimeData(){ return mMimeData; }
void setMimeData(QMimeData* mimeData); void setMimeData(QMimeData* mimeData);
void setDragPixmap(const QPixmap &pix) {mDragPixmap = pix;} void setDragPixmap(const QPixmap &pix) {mDragPixmap = pix;}
void setFlippable(bool flippable);
void setRotatable(bool pCanRotate);
bool isFlippable();
void setButtonsVisible(bool visible); void setButtonsVisible(bool visible);
UBGraphicsToolBarItem* getToolBarItem() const { return mToolBarItem; } UBGraphicsToolBarItem* getToolBarItem() const { return mToolBarItem; }
...@@ -290,6 +283,12 @@ class UBGraphicsItemDelegate : public QObject ...@@ -290,6 +283,12 @@ class UBGraphicsItemDelegate : public QObject
qreal antiScaleRatio() const { return mAntiScaleRatio; } qreal antiScaleRatio() const { return mAntiScaleRatio; }
virtual void update() {positionHandles();} virtual void update() {positionHandles();}
UBGraphicsFlags ubflags() const {return mFlags;}
bool testUBFlags(UBGraphicsFlags pf) const {return mFlags & pf;}
void setUBFlags(UBGraphicsFlags pf);
// void addUBFlags(UBGraphicsFlags pf) {setUBFlags(ubflags() | pf);}
void setUBFlag(UBGraphicsFlags pf, bool set = true);
signals: signals:
void showOnDisplayChanged(bool shown); void showOnDisplayChanged(bool shown);
void lockChanged(bool locked); void lockChanged(bool locked);
...@@ -314,8 +313,8 @@ class UBGraphicsItemDelegate : public QObject ...@@ -314,8 +313,8 @@ class UBGraphicsItemDelegate : public QObject
virtual void freeButtons(); virtual void freeButtons();
virtual void decorateMenu(QMenu *menu); virtual void decorateMenu(QMenu *menu);
virtual void updateMenuActionState(); virtual void updateMenuActionState();
QList<DelegateButton*> buttons() {return mButtons;}
QList<DelegateButton*> buttons() {return mButtons;}
QGraphicsItem* mDelegated; QGraphicsItem* mDelegated;
//buttons from the top left section of delegate frame //buttons from the top left section of delegate frame
...@@ -355,19 +354,11 @@ private: ...@@ -355,19 +354,11 @@ private:
QPointF mDragStartPosition; QPointF mDragStartPosition;
qreal mPreviousZValue; qreal mPreviousZValue;
QSizeF mPreviousSize; QSizeF mPreviousSize;
bool mCanRotate;
bool mCanDuplicate;
bool mRespectRatio;
QMimeData* mMimeData; QMimeData* mMimeData;
QPixmap mDragPixmap; QPixmap mDragPixmap;
/** A boolean saying that this object can be flippable (mirror effect) */
bool mFlippable;
bool mToolBarUsed;
bool mShowGoContentButton;
bool mMoved; bool mMoved;
UBGraphicsFlags mFlags;
}; };
......
...@@ -155,6 +155,7 @@ void UBGraphicsItemUndoCommand::undo() ...@@ -155,6 +155,7 @@ void UBGraphicsItemUndoCommand::undo()
// force refresh, QT is a bit lazy and take a lot of time (nb item ^2 ?) to trigger repaint // force refresh, QT is a bit lazy and take a lot of time (nb item ^2 ?) to trigger repaint
mScene->update(mScene->sceneRect()); mScene->update(mScene->sceneRect());
mScene->updateSelectionFrame();
} }
......
...@@ -125,7 +125,6 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte ...@@ -125,7 +125,6 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte
setWidget(mAudioWidget); setWidget(mAudioWidget);
// media widget should be created and placed on proxy widget here. // media widget should be created and placed on proxy widget here.
Delegate()->init();
if (mediaType_Audio == mMediaType) if (mediaType_Audio == mMediaType)
Delegate()->frame()->setOperationMode(UBGraphicsDelegateFrame::ResizingHorizontally); Delegate()->frame()->setOperationMode(UBGraphicsDelegateFrame::ResizingHorizontally);
...@@ -193,6 +192,11 @@ void UBGraphicsMediaItem::clearSource() ...@@ -193,6 +192,11 @@ void UBGraphicsMediaItem::clearSource()
qDebug() << "cannot delete file: " << path; qDebug() << "cannot delete file: " << path;
} }
void UBGraphicsMediaItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
UBGraphicsProxyWidget::paint(painter, option, widget);
}
void UBGraphicsMediaItem::toggleMute() void UBGraphicsMediaItem::toggleMute()
{ {
mMuted = !mMuted; mMuted = !mMuted;
......
...@@ -121,6 +121,7 @@ protected: ...@@ -121,6 +121,7 @@ protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event); virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
virtual void clearSource(); virtual void clearSource();
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
Phonon::MediaObject *mMediaObject; Phonon::MediaObject *mMediaObject;
Phonon::VideoWidget *mVideoWidget; Phonon::VideoWidget *mVideoWidget;
......
...@@ -40,7 +40,10 @@ ...@@ -40,7 +40,10 @@
#include "core/memcheck.h" #include "core/memcheck.h"
UBGraphicsMediaItemDelegate::UBGraphicsMediaItemDelegate(UBGraphicsMediaItem* pDelegated, Phonon::MediaObject* pMedia, QObject * parent) UBGraphicsMediaItemDelegate::UBGraphicsMediaItemDelegate(UBGraphicsMediaItem* pDelegated, Phonon::MediaObject* pMedia, QObject * parent)
: UBGraphicsItemDelegate(pDelegated, parent, true, false, true, true) : UBGraphicsItemDelegate(pDelegated, parent, GF_COMMON
| GF_RESPECT_RATIO
| GF_TOOLBAR_USED
| GF_SHOW_CONTENT_SOURCE)
, mMedia(pMedia) , mMedia(pMedia)
, mToolBarShowTimer(NULL) , mToolBarShowTimer(NULL)
, m_iToolBarShowingInterval(5000) , m_iToolBarShowingInterval(5000)
...@@ -64,9 +67,6 @@ UBGraphicsMediaItemDelegate::UBGraphicsMediaItemDelegate(UBGraphicsMediaItem* pD ...@@ -64,9 +67,6 @@ UBGraphicsMediaItemDelegate::UBGraphicsMediaItemDelegate(UBGraphicsMediaItem* pD
if (delegated()->isMuted()) if (delegated()->isMuted())
delegated()->setMute(true); delegated()->setMute(true);
//Wrapper function. Use it to set correct data() to QGraphicsItem as well
setFlippable(false);
setRotatable(false);
} }
bool UBGraphicsMediaItemDelegate::mousePressEvent(QGraphicsSceneMouseEvent *event) bool UBGraphicsMediaItemDelegate::mousePressEvent(QGraphicsSceneMouseEvent *event)
......
...@@ -37,8 +37,7 @@ UBGraphicsPDFItem::UBGraphicsPDFItem(PDFRenderer *renderer, int pageNumber, QGra ...@@ -37,8 +37,7 @@ UBGraphicsPDFItem::UBGraphicsPDFItem(PDFRenderer *renderer, int pageNumber, QGra
setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object); //deprecated setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object); //deprecated
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::BackgroundItem)); //Necessary to set if we want z value to be assigned correctly setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::BackgroundItem)); //Necessary to set if we want z value to be assigned correctly
setDelegate(new UBGraphicsItemDelegate(this,0, true, false, false)); setDelegate(new UBGraphicsItemDelegate(this, 0, GF_COMMON));
Delegate()->init();
} }
...@@ -91,6 +90,11 @@ void UBGraphicsPDFItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) ...@@ -91,6 +90,11 @@ void UBGraphicsPDFItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
GraphicsPDFItem::mouseReleaseEvent(event); GraphicsPDFItem::mouseReleaseEvent(event);
} }
void UBGraphicsPDFItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
GraphicsPDFItem::paint(painter, option, widget);
Delegate()->postpaint(painter, option, widget);
}
UBItem* UBGraphicsPDFItem::deepCopy() const UBItem* UBGraphicsPDFItem::deepCopy() const
{ {
......
...@@ -66,6 +66,7 @@ class UBGraphicsPDFItem: public GraphicsPDFItem, public UBItem, public UBGraphic ...@@ -66,6 +66,7 @@ class UBGraphicsPDFItem: public GraphicsPDFItem, public UBItem, public UBGraphic
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event); virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value); virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);
}; };
......
...@@ -36,10 +36,12 @@ ...@@ -36,10 +36,12 @@
UBGraphicsPixmapItem::UBGraphicsPixmapItem(QGraphicsItem* parent) UBGraphicsPixmapItem::UBGraphicsPixmapItem(QGraphicsItem* parent)
: QGraphicsPixmapItem(parent) : QGraphicsPixmapItem(parent)
{ {
setDelegate(new UBGraphicsItemDelegate(this, 0, true, false, true, true)); setDelegate(new UBGraphicsItemDelegate(this, 0, GF_COMMON
Delegate()->init(); | GF_FLIPPABLE_ALL_AXIS
Delegate()->setFlippable(true); | GF_REVOLVABLE
Delegate()->setRotatable(true); | GF_RESPECT_RATIO
| GF_TOOLBAR_USED
| GF_SHOW_CONTENT_SOURCE));
setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object); setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object);
setTransformationMode(Qt::SmoothTransformation); setTransformationMode(Qt::SmoothTransformation);
...@@ -110,9 +112,10 @@ void UBGraphicsPixmapItem::paint(QPainter *painter, const QStyleOptionGraphicsIt ...@@ -110,9 +112,10 @@ void UBGraphicsPixmapItem::paint(QPainter *painter, const QStyleOptionGraphicsIt
{ {
// Never draw the rubber band, we draw our custom selection with the DelegateFrame // Never draw the rubber band, we draw our custom selection with the DelegateFrame
QStyleOptionGraphicsItem styleOption = QStyleOptionGraphicsItem(*option); QStyleOptionGraphicsItem styleOption = QStyleOptionGraphicsItem(*option);
styleOption.state &= ~QStyle::State_Selected;
styleOption.state &= ~QStyle::State_Selected;
QGraphicsPixmapItem::paint(painter, &styleOption, widget); QGraphicsPixmapItem::paint(painter, &styleOption, widget);
Delegate()->postpaint(painter, option, widget);
} }
......
...@@ -51,6 +51,10 @@ UBGraphicsProxyWidget::~UBGraphicsProxyWidget() ...@@ -51,6 +51,10 @@ UBGraphicsProxyWidget::~UBGraphicsProxyWidget()
{ {
} }
void UBGraphicsProxyWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Delegate()->postpaint(painter, option, widget);
}
QVariant UBGraphicsProxyWidget::itemChange(GraphicsItemChange change, const QVariant &value) QVariant UBGraphicsProxyWidget::itemChange(GraphicsItemChange change, const QVariant &value)
{ {
......
...@@ -58,6 +58,7 @@ class UBGraphicsProxyWidget: public QGraphicsProxyWidget, public UBItem, public ...@@ -58,6 +58,7 @@ class UBGraphicsProxyWidget: public QGraphicsProxyWidget, public UBItem, public
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value); virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);
}; };
......
...@@ -318,6 +318,7 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent, bool enableUndoRedoSta ...@@ -318,6 +318,7 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent, bool enableUndoRedoSta
// Just for debug. Do not delete please // Just for debug. Do not delete please
// connect(this, SIGNAL(selectionChanged()), this, SLOT(selectionChangedProcessing())); // connect(this, SIGNAL(selectionChanged()), this, SLOT(selectionChangedProcessing()));
connect(this, SIGNAL(selectionChanged()), this, SLOT(updateGroupButtonState())); connect(this, SIGNAL(selectionChanged()), this, SLOT(updateGroupButtonState()));
connect(UBApplication::undoStack.data(), SIGNAL(indexChanged(int)), this, SLOT(updateSelectionFrameWrapper(int)));
} }
UBGraphicsScene::~UBGraphicsScene() UBGraphicsScene::~UBGraphicsScene()
...@@ -1078,6 +1079,11 @@ void UBGraphicsScene::updateSelectionFrame() ...@@ -1078,6 +1079,11 @@ void UBGraphicsScene::updateSelectionFrame()
} }
} }
void UBGraphicsScene::updateSelectionFrameWrapper(int)
{
updateSelectionFrame();
}
UBGraphicsPolygonItem* UBGraphicsScene::polygonToPolygonItem(const QPolygonF pPolygon) UBGraphicsPolygonItem* UBGraphicsScene::polygonToPolygonItem(const QPolygonF pPolygon)
{ {
UBGraphicsPolygonItem *polygonItem = new UBGraphicsPolygonItem(pPolygon); UBGraphicsPolygonItem *polygonItem = new UBGraphicsPolygonItem(pPolygon);
...@@ -1736,6 +1742,10 @@ void UBGraphicsScene::deselectAllItems() ...@@ -1736,6 +1742,10 @@ void UBGraphicsScene::deselectAllItems()
foreach(QGraphicsItem *gi, selectedItems ()) foreach(QGraphicsItem *gi, selectedItems ())
{ {
gi->setSelected(false); gi->setSelected(false);
// Hide selection frame
if (mSelectionFrame) {
mSelectionFrame->setEnclosedItems(QList<QGraphicsItem*>());
}
} }
} }
......
...@@ -316,6 +316,7 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem ...@@ -316,6 +316,7 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
public slots: public slots:
void updateSelectionFrame(); void updateSelectionFrame();
void updateSelectionFrameWrapper(int);
void initStroke(); void initStroke();
void hideEraser(); void hideEraser();
......
...@@ -30,11 +30,10 @@ ...@@ -30,11 +30,10 @@
UBGraphicsStrokesGroup::UBGraphicsStrokesGroup(QGraphicsItem *parent) UBGraphicsStrokesGroup::UBGraphicsStrokesGroup(QGraphicsItem *parent)
:QGraphicsItemGroup(parent), UBGraphicsItem() :QGraphicsItemGroup(parent), UBGraphicsItem()
{ {
setDelegate(new UBGraphicsItemDelegate(this, 0, true, true, false)); setDelegate(new UBGraphicsItemDelegate(this, 0, GF_COMMON
Delegate()->init(); | GF_RESPECT_RATIO
Delegate()->setFlippable(true); | GF_REVOLVABLE
Delegate()->setRotatable(true); | GF_FLIPPABLE_ALL_AXIS));
setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object); setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object);
...@@ -186,15 +185,13 @@ void UBGraphicsStrokesGroup::paint(QPainter *painter, const QStyleOptionGraphics ...@@ -186,15 +185,13 @@ void UBGraphicsStrokesGroup::paint(QPainter *painter, const QStyleOptionGraphics
if (styleOption.state & QStyle::State_Selected) { if (styleOption.state & QStyle::State_Selected) {
selectedState = true; selectedState = true;
} }
QStyle::State svState = option->state;
styleOption.state &= ~QStyle::State_Selected; styleOption.state &= ~QStyle::State_Selected;
QGraphicsItemGroup::paint(painter, &styleOption, widget); QGraphicsItemGroup::paint(painter, &styleOption, widget);
if (selectedState && !Delegate()->controlsExist()) { //Restoring state
painter->save(); styleOption.state |= svState;
painter->setPen(Qt::NoPen);
painter->setBrush(QColor(0x88, 0x88, 0x88, 0x77)); Delegate()->postpaint(painter, &styleOption, widget);
painter->drawRect(boundingRect());
painter->restore();
}
} }
QVariant UBGraphicsStrokesGroup::itemChange(GraphicsItemChange change, const QVariant &value) QVariant UBGraphicsStrokesGroup::itemChange(GraphicsItemChange change, const QVariant &value)
......
...@@ -61,11 +61,12 @@ void UBGraphicsSvgItem::init() ...@@ -61,11 +61,12 @@ void UBGraphicsSvgItem::init()
{ {
setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object); setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object);
setDelegate(new UBGraphicsItemDelegate(this, 0, true, true, false, true)); setDelegate(new UBGraphicsItemDelegate(this, 0, GF_COMMON
Delegate()->init(); | GF_RESPECT_RATIO
Delegate()->setFlippable(true); | GF_REVOLVABLE
Delegate()->setRotatable(true); | GF_SHOW_CONTENT_SOURCE));
UBGraphicsFlags dfl = Delegate()->ubflags();
Delegate()->setUBFlags(dfl | GF_FLIPPABLE_ALL_AXIS | GF_REVOLVABLE);
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
...@@ -77,7 +78,6 @@ void UBGraphicsSvgItem::init() ...@@ -77,7 +78,6 @@ void UBGraphicsSvgItem::init()
setUuid(QUuid::createUuid()); setUuid(QUuid::createUuid());
} }
UBGraphicsSvgItem::~UBGraphicsSvgItem() UBGraphicsSvgItem::~UBGraphicsSvgItem()
{ {
} }
...@@ -139,6 +139,7 @@ void UBGraphicsSvgItem::paint(QPainter *painter, const QStyleOptionGraphicsItem ...@@ -139,6 +139,7 @@ void UBGraphicsSvgItem::paint(QPainter *painter, const QStyleOptionGraphicsItem
styleOption.state &= ~QStyle::State_Selected; styleOption.state &= ~QStyle::State_Selected;
QGraphicsSvgItem::paint(painter, &styleOption, widget); QGraphicsSvgItem::paint(painter, &styleOption, widget);
Delegate()->postpaint(painter, option, widget);
} }
......
...@@ -45,11 +45,10 @@ UBGraphicsTextItem::UBGraphicsTextItem(QGraphicsItem * parent) : ...@@ -45,11 +45,10 @@ UBGraphicsTextItem::UBGraphicsTextItem(QGraphicsItem * parent) :
, mLastMousePressTime(QTime::currentTime()) , mLastMousePressTime(QTime::currentTime())
{ {
setDelegate(new UBGraphicsTextItemDelegate(this, 0)); setDelegate(new UBGraphicsTextItemDelegate(this, 0));
Delegate()->init();
Delegate()->frame()->setOperationMode(UBGraphicsDelegateFrame::Resizing); Delegate()->frame()->setOperationMode(UBGraphicsDelegateFrame::Resizing);
Delegate()->setFlippable(false); Delegate()->setUBFlag(GF_FLIPPABLE_ALL_AXIS, false);
Delegate()->setRotatable(true); Delegate()->setUBFlag(GF_REVOLVABLE, true);
mTypeTextHereLabel = tr("<Type Text Here>"); mTypeTextHereLabel = tr("<Type Text Here>");
...@@ -218,6 +217,8 @@ void UBGraphicsTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem ...@@ -218,6 +217,8 @@ void UBGraphicsTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem
painter->setPen(UBSettings::paletteColor); painter->setPen(UBSettings::paletteColor);
painter->drawText(boundingRect(), Qt::AlignCenter, mTypeTextHereLabel); painter->drawText(boundingRect(), Qt::AlignCenter, mTypeTextHereLabel);
} }
Delegate()->postpaint(painter, option, widget);
} }
......
...@@ -41,8 +41,8 @@ ...@@ -41,8 +41,8 @@
const int UBGraphicsTextItemDelegate::sMinPixelSize = 8; const int UBGraphicsTextItemDelegate::sMinPixelSize = 8;
const int UBGraphicsTextItemDelegate::sMinPointSize = 8; const int UBGraphicsTextItemDelegate::sMinPointSize = 8;
UBGraphicsTextItemDelegate::UBGraphicsTextItemDelegate(UBGraphicsTextItem* pDelegated, QObject * parent) UBGraphicsTextItemDelegate::UBGraphicsTextItemDelegate(UBGraphicsTextItem* pDelegated, QObject *)
: UBGraphicsItemDelegate(pDelegated,0, parent, true) : UBGraphicsItemDelegate(pDelegated,0, GF_COMMON | GF_REVOLVABLE)
, mLastFontPixelSize(-1) , mLastFontPixelSize(-1)
, delta(5) , delta(5)
{ {
......
...@@ -93,7 +93,6 @@ UBGraphicsWidgetItem::UBGraphicsWidgetItem(const QUrl &pWidgetUrl, QGraphicsItem ...@@ -93,7 +93,6 @@ UBGraphicsWidgetItem::UBGraphicsWidgetItem(const QUrl &pWidgetUrl, QGraphicsItem
setPalette(viewPalette); setPalette(viewPalette);
setDelegate(new UBGraphicsWidgetItemDelegate(this)); setDelegate(new UBGraphicsWidgetItemDelegate(this));
Delegate()->init();
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
QGraphicsWebView::setAcceptHoverEvents(true); QGraphicsWebView::setAcceptHoverEvents(true);
...@@ -587,6 +586,8 @@ void UBGraphicsWidgetItem::paint( QPainter *painter, const QStyleOptionGraphicsI ...@@ -587,6 +586,8 @@ void UBGraphicsWidgetItem::paint( QPainter *painter, const QStyleOptionGraphicsI
painter->setPen(Qt::white); painter->setPen(Qt::white);
painter->drawText(rect(), Qt::AlignCenter, message); painter->drawText(rect(), Qt::AlignCenter, message);
} }
Delegate()->postpaint(painter, option, widget);
} }
void UBGraphicsWidgetItem::geometryChangeRequested(const QRect& geom) void UBGraphicsWidgetItem::geometryChangeRequested(const QRect& geom)
......
...@@ -38,7 +38,9 @@ ...@@ -38,7 +38,9 @@
#include "core/memcheck.h" #include "core/memcheck.h"
UBGraphicsWidgetItemDelegate::UBGraphicsWidgetItemDelegate(UBGraphicsWidgetItem* pDelegated, int widgetType) UBGraphicsWidgetItemDelegate::UBGraphicsWidgetItemDelegate(UBGraphicsWidgetItem* pDelegated, int widgetType)
: UBGraphicsItemDelegate(pDelegated, 0, true, false, false, true) : UBGraphicsItemDelegate(pDelegated, 0, GF_COMMON
| GF_RESPECT_RATIO
| GF_SHOW_CONTENT_SOURCE)
, freezeAction(0) , freezeAction(0)
, setAsToolAction(0) , setAsToolAction(0)
{ {
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "domain/UBGraphicsGroupContainerItem.h" #include "domain/UBGraphicsGroupContainerItem.h"
#include "domain/UBGraphicsWidgetItem.h" #include "domain/UBGraphicsWidgetItem.h"
#include "tools/UBGraphicsCurtainItem.h" #include "tools/UBGraphicsCurtainItem.h"
#include "domain/UBGraphicsItemDelegate.h"
UBItem::UBItem() UBItem::UBItem()
: mUuid(QUuid()) : mUuid(QUuid())
...@@ -58,6 +59,11 @@ void UBGraphicsItem::setDelegate(UBGraphicsItemDelegate* delegate) ...@@ -58,6 +59,11 @@ void UBGraphicsItem::setDelegate(UBGraphicsItemDelegate* delegate)
mDelegate = delegate; mDelegate = delegate;
} }
UBGraphicsItemDelegate *UBGraphicsItem::Delegate() const
{
return mDelegate;
}
void UBGraphicsItem::assignZValue(QGraphicsItem *item, qreal value) void UBGraphicsItem::assignZValue(QGraphicsItem *item, qreal value)
{ {
item->setZValue(value); item->setZValue(value);
......
...@@ -25,8 +25,8 @@ ...@@ -25,8 +25,8 @@
#define UBITEM_H #define UBITEM_H
#include <QtGui> #include <QtGui>
#include "domain/UBGraphicsItemDelegate.h"
#include "core/UB.h" #include "core/UB.h"
#include "domain/UBGraphicsItemDelegate.h"
class UBGraphicsScene; class UBGraphicsScene;
class UBGraphicsItem; class UBGraphicsItem;
...@@ -38,7 +38,6 @@ class UBItem ...@@ -38,7 +38,6 @@ class UBItem
UBItem(); UBItem();
public: public:
virtual ~UBItem(); virtual ~UBItem();
enum RenderingQuality enum RenderingQuality
...@@ -95,29 +94,6 @@ class UBItem ...@@ -95,29 +94,6 @@ class UBItem
}; };
// Might be fit in int value under most OS
enum UBGraphicsFlag {
GF_NONE = 0x0000 //0000 0000 0000 0000
,GF_FLIPPABLE_X_AXIS = 0x0001 //0000 0000 0000 0001
,GF_FLIPPABLE_Y_AXIS = 0x0002 //0000 0000 0000 0010
,GF_FLIPPABLE_ALL_AXIS = 0x0003 //0000 0000 0000 0011 GF_FLIPPABLE_X_AXIS | GF_FLIPPABLE_Y_AXIS
,GF_REVOLVABLE = 0x0004 //0000 0000 0000 0100
,GF_SCALABLE_X_AXIS = 0x0008 //0000 0000 0000 1000
,GF_SCALABLE_Y_AXIS = 0x0010 //0000 0000 0001 0000
,GF_SCALABLE_ALL_AXIS = 0x0018 //0000 0000 0001 1000 GF_SCALABLE_X_AXIS | GF_SCALABLE_Y_AXIS
,GF_DUPLICATION_ENABLED = 0x0020 //0000 0000 0010 0000
,GF_MENU_SPECIFIED = 0x0040 //0000 0000 0100 0000
,GF_ZORDER_MANIPULATIONS_ALLOWED = 0x0080 //0000 0000 1000 0000
,GF_TOOLBAR_USED = 0x0100 //0000 0001 0000 0000
,GF_SHOW_CONTENT_SOURCE = 0x0200 //0000 0010 0000 0000
,GF_COMMON = 0x00F8 /*0000 0000 1111 1000 GF_FLIPPABLE_ALL_AXIS
|GF_DUPLICATION_ENABLED
|GF_MENU_SPECIFIED
|GF_ZORDER_MANIPULATIONS_ALLOWED */
,GF_ALL = 0xFFFF //1111 1111 1111 1111
};
Q_DECLARE_FLAGS(UBGraphicsFlags, UBGraphicsFlag)
class UBGraphicsItem class UBGraphicsItem
{ {
protected: protected:
...@@ -129,10 +105,9 @@ protected: ...@@ -129,10 +105,9 @@ protected:
void setDelegate(UBGraphicsItemDelegate* mDelegate); void setDelegate(UBGraphicsItemDelegate* mDelegate);
public: public:
virtual int type() const = 0; virtual int type() const = 0;
inline UBGraphicsItemDelegate *Delegate() const { return mDelegate; } UBGraphicsItemDelegate *Delegate() const;
static void assignZValue(QGraphicsItem*, qreal value); static void assignZValue(QGraphicsItem*, qreal value);
static bool isRotatable(QGraphicsItem *item); static bool isRotatable(QGraphicsItem *item);
......
This diff is collapsed.
...@@ -3,15 +3,19 @@ ...@@ -3,15 +3,19 @@
#include <QGraphicsRectItem> #include <QGraphicsRectItem>
#include <QtGui> #include <QtGui>
#include <core/UB.h>
class DelegateButton; class DelegateButton;
class UBGraphicsItemDelegate; class UBGraphicsItemDelegate;
class UBGraphicsScene;
class UBSelectionFrame : public QObject, public QGraphicsRectItem class UBSelectionFrame : public QObject, public QGraphicsRectItem
{ {
Q_OBJECT Q_OBJECT
public: public:
enum {om_idle, om_moving, om_rotating} mOperationMode;
UBSelectionFrame(); UBSelectionFrame();
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
...@@ -35,12 +39,18 @@ private slots: ...@@ -35,12 +39,18 @@ private slots:
void setAntiScaleRatio(qreal pAntiscaleRatio) {mAntiscaleRatio = pAntiscaleRatio;} void setAntiScaleRatio(qreal pAntiscaleRatio) {mAntiscaleRatio = pAntiscaleRatio;}
void onZoomChanged(qreal pZoom); void onZoomChanged(qreal pZoom);
void remove(); void remove();
void duplicate();
private: private:
void translateItem(QGraphicsItem *item, const QPointF &translatePoint); void translateItem(QGraphicsItem *item, const QPointF &translatePoint);
void placeButtons(); void placeButtons();
void placeExceptionButton(DelegateButton *pButton, QTransform pTransform);
void clearButtons(); void clearButtons();
inline int adjThickness() const {return mThickness * mAntiscaleRatio;} inline int adjThickness() const {return mThickness * mAntiscaleRatio;}
inline UBGraphicsScene* ubscene();
QList<DelegateButton*> buttonsForFlags(UBGraphicsFlags fls);
private: private:
int mThickness; int mThickness;
...@@ -51,6 +61,7 @@ private: ...@@ -51,6 +61,7 @@ private:
QPointF mPressedPos; QPointF mPressedPos;
QPointF mLastMovedPos; QPointF mLastMovedPos;
QPointF mLastTranslateOffset; QPointF mLastTranslateOffset;
qreal mRotationAngle;
QList<DelegateButton*> mButtons; QList<DelegateButton*> mButtons;
...@@ -58,6 +69,9 @@ private: ...@@ -58,6 +69,9 @@ private:
DelegateButton *mDuplicateButton; DelegateButton *mDuplicateButton;
DelegateButton *mZOrderUpButton; DelegateButton *mZOrderUpButton;
DelegateButton *mZOrderDownButton; DelegateButton *mZOrderDownButton;
DelegateButton *mRotateButton;
}; };
#endif // UBSELECTIONFRAME_H #endif // UBSELECTIONFRAME_H
...@@ -67,4 +67,5 @@ void GraphicsPDFItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *o ...@@ -67,4 +67,5 @@ void GraphicsPDFItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
mRenderer->render(painter, mPageNumber, option->exposedRect); mRenderer->render(painter, mPageNumber, option->exposedRect);
else else
qWarning("GraphicsPDFItem::paint: option is null, ignoring painting"); qWarning("GraphicsPDFItem::paint: option is null, ignoring painting");
} }
...@@ -135,6 +135,7 @@ void UBGraphicsCurtainItem::paint(QPainter *painter, const QStyleOptionGraphicsI ...@@ -135,6 +135,7 @@ void UBGraphicsCurtainItem::paint(QPainter *painter, const QStyleOptionGraphicsI
styleOption.state &= ~QStyle::State_Selected; styleOption.state &= ~QStyle::State_Selected;
painter->fillRect(rect(), color); painter->fillRect(rect(), color);
Delegate()->postpaint(painter, option, widget);
} }
......
...@@ -32,9 +32,9 @@ ...@@ -32,9 +32,9 @@
#include "core/memcheck.h" #include "core/memcheck.h"
UBGraphicsCurtainItemDelegate::UBGraphicsCurtainItemDelegate(UBGraphicsCurtainItem* pDelegated, QObject * parent) UBGraphicsCurtainItemDelegate::UBGraphicsCurtainItemDelegate(UBGraphicsCurtainItem* pDelegated, QObject * parent)
: UBGraphicsItemDelegate(pDelegated, parent, false, false, false) : UBGraphicsItemDelegate(pDelegated, parent, GF_SCALABLE_ALL_AXIS | GF_MENU_SPECIFIED | GF_ZORDER_MANIPULATIONS_ALLOWED)
{ {
setCanDuplicate(false); //NOOP
} }
...@@ -45,7 +45,6 @@ UBGraphicsCurtainItemDelegate::~UBGraphicsCurtainItemDelegate() ...@@ -45,7 +45,6 @@ UBGraphicsCurtainItemDelegate::~UBGraphicsCurtainItemDelegate()
void UBGraphicsCurtainItemDelegate::init() void UBGraphicsCurtainItemDelegate::init()
{ {
UBGraphicsItemDelegate::init();
mFrame->hide(); mFrame->hide();
mZOrderUpButton->hide(); mZOrderUpButton->hide();
mZOrderDownButton->hide(); mZOrderDownButton->hide();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment