Duplication, paint all the selected items by highlighting them

preferencesAboutTextFull
Ilia Ryabokon 12 years ago
parent 4576b45323
commit 005d30feb9
  1. 1
      src/board/UBBoardView.cpp
  2. 25
      src/core/UB.h
  3. 10
      src/domain/UBGraphicsDelegateFrame.cpp
  4. 16
      src/domain/UBGraphicsGroupContainerItem.cpp
  5. 6
      src/domain/UBGraphicsGroupContainerItemDelegate.cpp
  6. 88
      src/domain/UBGraphicsItemDelegate.cpp
  7. 33
      src/domain/UBGraphicsItemDelegate.h
  8. 1
      src/domain/UBGraphicsItemUndoCommand.cpp
  9. 6
      src/domain/UBGraphicsMediaItem.cpp
  10. 1
      src/domain/UBGraphicsMediaItem.h
  11. 8
      src/domain/UBGraphicsMediaItemDelegate.cpp
  12. 8
      src/domain/UBGraphicsPDFItem.cpp
  13. 1
      src/domain/UBGraphicsPDFItem.h
  14. 13
      src/domain/UBGraphicsPixmapItem.cpp
  15. 4
      src/domain/UBGraphicsProxyWidget.cpp
  16. 1
      src/domain/UBGraphicsProxyWidget.h
  17. 10
      src/domain/UBGraphicsScene.cpp
  18. 1
      src/domain/UBGraphicsScene.h
  19. 21
      src/domain/UBGraphicsStrokesGroup.cpp
  20. 13
      src/domain/UBGraphicsSvgItem.cpp
  21. 7
      src/domain/UBGraphicsTextItem.cpp
  22. 4
      src/domain/UBGraphicsTextItemDelegate.cpp
  23. 3
      src/domain/UBGraphicsWidgetItem.cpp
  24. 4
      src/domain/UBGraphicsWidgetItemDelegate.cpp
  25. 6
      src/domain/UBItem.cpp
  26. 29
      src/domain/UBItem.h
  27. 196
      src/domain/UBSelectionFrame.cpp
  28. 14
      src/domain/UBSelectionFrame.h
  29. 1
      src/pdf/GraphicsPDFItem.cpp
  30. 1
      src/tools/UBGraphicsCurtainItem.cpp
  31. 5
      src/tools/UBGraphicsCurtainItemDelegate.cpp

@ -67,6 +67,7 @@
#include "domain/UBGraphicsSvgItem.h"
#include "domain/UBGraphicsGroupContainerItem.h"
#include "domain/UBGraphicsStrokesGroup.h"
#include "domain/UBGraphicsItemDelegate.h"
#include "document/UBDocumentProxy.h"

@ -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
{
enum Enum

@ -92,7 +92,7 @@ UBGraphicsDelegateFrame::UBGraphicsDelegateFrame(UBGraphicsItemDelegate* pDelega
mRotateButton = new QGraphicsSvgItem(":/images/rotate.svg", this);
mRotateButton->setCursor(UBResources::resources()->rotateCursor);
mRotateButton->setVisible(mDelegate->canRotate());
mRotateButton->setVisible(mDelegate->testUBFlags(GF_REVOLVABLE));
updateResizeCursors();
@ -452,7 +452,7 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
}else if(resizingRight()){
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){
bool negative = (scaleX < 0)?true:false;
if(negative){
@ -482,7 +482,7 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
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){
bool negative = (scaleY < 0)?true:false;
if(negative){
@ -883,7 +883,7 @@ void UBGraphicsDelegateFrame::positionHandles()
mLeftResizeGripSvgItem->setVisible(!isLocked && (bShowHorizontalResizers || bShowAllResizers));
mRightResizeGripSvgItem->setVisible(!isLocked && (bShowHorizontalResizers || bShowAllResizers));
mTopResizeGripSvgItem->setVisible(!isLocked && (bShowVerticalResizers || bShowAllResizers));
mRotateButton->setVisible(mDelegate->canRotate() && !isLocked);
mRotateButton->setVisible(mDelegate->testUBFlags(GF_REVOLVABLE) && !isLocked);
mBottomRightResizeGrip->setVisible(!isLocked && bShowAllResizers);
mBottomResizeGrip->setVisible(!isLocked && (bShowVerticalResizers || bShowAllResizers));
@ -947,7 +947,7 @@ UBGraphicsDelegateFrame::FrameTool UBGraphicsDelegateFrame::toolFromPos(QPointF
return ResizeTop;
}
}
else if (rotateButtonBounds().contains(pos) && mDelegate && mDelegate->canRotate())
else if (rotateButtonBounds().contains(pos) && mDelegate && mDelegate->testUBFlags(GF_REVOLVABLE))
return Rotate;
else
return Move;

@ -39,8 +39,7 @@ UBGraphicsGroupContainerItem::UBGraphicsGroupContainerItem(QGraphicsItem *parent
{
setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object);
setDelegate(new UBGraphicsGroupContainerItemDelegate(this, 0));
Delegate()->init();
setDelegate(new UBGraphicsGroupContainerItemDelegate(this, 0));
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
setFlag(QGraphicsItem::ItemIsSelectable, true);
@ -71,14 +70,14 @@ void UBGraphicsGroupContainerItem::addToGroup(QGraphicsItem *item)
//Check if group is allready rotatable or flippable
if (childItems().count()) {
if (UBGraphicsItem::isFlippable(this) && !UBGraphicsItem::isFlippable(item)) {
Delegate()->setFlippable(false);
Delegate()->setUBFlag(GF_FLIPPABLE_ALL_AXIS, false);
}
if (UBGraphicsItem::isRotatable(this) && !UBGraphicsItem::isRotatable(item)) {
Delegate()->setRotatable(false);
Delegate()->setUBFlag(GF_REVOLVABLE, false);
}
} else {
Delegate()->setFlippable(UBGraphicsItem::isFlippable(item));
Delegate()->setRotatable(UBGraphicsItem::isRotatable(item));
Delegate()->setUBFlag(GF_FLIPPABLE_ALL_AXIS, UBGraphicsItem::isFlippable(item));
Delegate()->setUBFlag(GF_REVOLVABLE, UBGraphicsItem::isRotatable(item));
}
// COMBINE
@ -194,6 +193,7 @@ void UBGraphicsGroupContainerItem::paint(QPainter *painter, const QStyleOptionGr
// painter->setPen(tmpPen);
// painter->drawRect(itemsBoundingRect.adjusted(tmpPenWidth / 2, tmpPenWidth / 2, -tmpPenWidth / 2, -tmpPenWidth / 2));
// }
Delegate()->postpaint(painter, option, widget);
}
UBCoreGraphicsScene *UBGraphicsGroupContainerItem::corescene()
@ -334,8 +334,8 @@ void UBGraphicsGroupContainerItem::pRemoveFromGroup(QGraphicsItem *item)
break;
}
}
Delegate()->setFlippable(flippableNow);
Delegate()->setRotatable(rotatableNow);
Delegate()->setUBFlag(GF_FLIPPABLE_ALL_AXIS, flippableNow);
Delegate()->setUBFlag(GF_REVOLVABLE, rotatableNow);
}
}

@ -36,13 +36,9 @@
#include "core/memcheck.h"
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()

@ -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)
, mDelegated(pDelegated)
, mDeleteButton(NULL)
@ -168,31 +168,19 @@ UBGraphicsItemDelegate::UBGraphicsItemDelegate(QGraphicsItem* pDelegated, QObjec
, mFrameWidth(UBSettings::settings()->objectFrameWidth)
, mAntiScaleRatio(1.0)
, mToolBarItem(NULL)
, mCanRotate(canRotate)
, mCanDuplicate(true)
, mRespectRatio(respectRatio)
, mMimeData(NULL)
, mFlippable(false)
, mToolBarUsed(useToolBar)
, mShowGoContentButton(showGoContentButton)
{
setUBFlags(fls);
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()
{
if (mToolBarUsed && !mToolBarItem)
if (testUBFlags(GF_TOOLBAR_USED) && !mToolBarItem)
mToolBarItem = new UBGraphicsToolBarItem(mDelegated);
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->setFlag(QGraphicsItem::ItemIsSelectable, true);
}
@ -201,7 +189,7 @@ void UBGraphicsItemDelegate::createControls()
mDeleteButton = new DelegateButton(":/images/close.svg", mDelegated, mFrame, Qt::TopLeftSection);
mButtons << mDeleteButton;
connect(mDeleteButton, SIGNAL(clicked()), this, SLOT(remove()));
if (canDuplicate()){
if (testUBFlags(GF_DUPLICATION_ENABLED)){
mDuplicateButton = new DelegateButton(":/images/duplicate.svg", mDelegated, mFrame, Qt::TopLeftSection);
connect(mDuplicateButton, SIGNAL(clicked(bool)), this, SLOT(duplicate()));
mButtons << mDuplicateButton;
@ -319,6 +307,19 @@ UBGraphicsScene *UBGraphicsItemDelegate::castUBGraphicsScene()
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)
{
mDragStartPosition = event->pos();
@ -667,7 +668,7 @@ void UBGraphicsItemDelegate::decorateMenu(QMenu* menu)
showIcon.addPixmap(QPixmap(":/images/eyeClosed.svg"), QIcon::Normal, QIcon::Off);
mShowOnDisplayAction->setIcon(showIcon);
if (mShowGoContentButton)
if (testUBFlags(GF_SHOW_CONTENT_SOURCE))
{
mGotoContentSourceAction = menu->addAction(tr("Go to Content Source"), this, SLOT(gotoContentSource()));
@ -711,32 +712,6 @@ void UBGraphicsItemDelegate::showMenu()
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()
{
if (mFrame && !mFrame->scene() && mDelegated->scene())
@ -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) :
QGraphicsRectItem(parent),

@ -174,7 +174,7 @@ class DelegateMediaControl: public QObject, public QGraphicsRectItem
void positionHandles();
void updateTicker(qint64 time);
void totalTimeChanged(qint64 newTotalTime);
QSizeF lcdAreaSize(){return mLCDTimerArea.size();}
QSizeF lcdAreaSize() {return mLCDTimerArea.size();}
signals:
void used();
@ -235,11 +235,10 @@ class UBGraphicsItemDelegate : public QObject
Q_OBJECT
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();
void init();
virtual void createControls();
virtual void freeControls();
virtual void showControls();
@ -256,13 +255,13 @@ class UBGraphicsItemDelegate : public QObject
virtual QVariant itemChange(QGraphicsItem::GraphicsItemChange change,
const QVariant &value);
virtual UBGraphicsScene *castUBGraphicsScene();
virtual void postpaint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
void printMessage(const QString &mess) {qDebug() << mess;}
QGraphicsItem* delegated();
void setCanDuplicate(bool allow){ mCanDuplicate = allow; }
virtual void positionHandles();
void setZOrderButtonsVisible(bool visible);
@ -271,18 +270,12 @@ class UBGraphicsItemDelegate : public QObject
UBGraphicsDelegateFrame* frame() {return mFrame;}
bool canRotate() const { return mCanRotate; }
bool isLocked() const;
bool canDuplicate() { return mCanDuplicate; }
QMimeData* mimeData(){ return mMimeData; }
void setMimeData(QMimeData* mimeData);
void setDragPixmap(const QPixmap &pix) {mDragPixmap = pix;}
void setFlippable(bool flippable);
void setRotatable(bool pCanRotate);
bool isFlippable();
void setButtonsVisible(bool visible);
UBGraphicsToolBarItem* getToolBarItem() const { return mToolBarItem; }
@ -290,6 +283,12 @@ class UBGraphicsItemDelegate : public QObject
qreal antiScaleRatio() const { return mAntiScaleRatio; }
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:
void showOnDisplayChanged(bool shown);
void lockChanged(bool locked);
@ -314,8 +313,8 @@ class UBGraphicsItemDelegate : public QObject
virtual void freeButtons();
virtual void decorateMenu(QMenu *menu);
virtual void updateMenuActionState();
QList<DelegateButton*> buttons() {return mButtons;}
QList<DelegateButton*> buttons() {return mButtons;}
QGraphicsItem* mDelegated;
//buttons from the top left section of delegate frame
@ -355,19 +354,11 @@ private:
QPointF mDragStartPosition;
qreal mPreviousZValue;
QSizeF mPreviousSize;
bool mCanRotate;
bool mCanDuplicate;
bool mRespectRatio;
QMimeData* mMimeData;
QPixmap mDragPixmap;
/** A boolean saying that this object can be flippable (mirror effect) */
bool mFlippable;
bool mToolBarUsed;
bool mShowGoContentButton;
bool mMoved;
UBGraphicsFlags mFlags;
};

@ -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
mScene->update(mScene->sceneRect());
mScene->updateSelectionFrame();
}

@ -125,7 +125,6 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte
setWidget(mAudioWidget);
// media widget should be created and placed on proxy widget here.
Delegate()->init();
if (mediaType_Audio == mMediaType)
Delegate()->frame()->setOperationMode(UBGraphicsDelegateFrame::ResizingHorizontally);
@ -193,6 +192,11 @@ void UBGraphicsMediaItem::clearSource()
qDebug() << "cannot delete file: " << path;
}
void UBGraphicsMediaItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
UBGraphicsProxyWidget::paint(painter, option, widget);
}
void UBGraphicsMediaItem::toggleMute()
{
mMuted = !mMuted;

@ -121,6 +121,7 @@ protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
virtual void clearSource();
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
Phonon::MediaObject *mMediaObject;
Phonon::VideoWidget *mVideoWidget;

@ -40,7 +40,10 @@
#include "core/memcheck.h"
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)
, mToolBarShowTimer(NULL)
, m_iToolBarShowingInterval(5000)
@ -64,9 +67,6 @@ UBGraphicsMediaItemDelegate::UBGraphicsMediaItemDelegate(UBGraphicsMediaItem* pD
if (delegated()->isMuted())
delegated()->setMute(true);
//Wrapper function. Use it to set correct data() to QGraphicsItem as well
setFlippable(false);
setRotatable(false);
}
bool UBGraphicsMediaItemDelegate::mousePressEvent(QGraphicsSceneMouseEvent *event)

@ -37,8 +37,7 @@ UBGraphicsPDFItem::UBGraphicsPDFItem(PDFRenderer *renderer, int pageNumber, QGra
setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object); //deprecated
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));
Delegate()->init();
setDelegate(new UBGraphicsItemDelegate(this, 0, GF_COMMON));
}
@ -91,6 +90,11 @@ void UBGraphicsPDFItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *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
{

@ -66,6 +66,7 @@ class UBGraphicsPDFItem: public GraphicsPDFItem, public UBItem, public UBGraphic
virtual void mouseMoveEvent(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);
};

@ -36,10 +36,12 @@
UBGraphicsPixmapItem::UBGraphicsPixmapItem(QGraphicsItem* parent)
: QGraphicsPixmapItem(parent)
{
setDelegate(new UBGraphicsItemDelegate(this, 0, true, false, true, true));
Delegate()->init();
Delegate()->setFlippable(true);
Delegate()->setRotatable(true);
setDelegate(new UBGraphicsItemDelegate(this, 0, GF_COMMON
| GF_FLIPPABLE_ALL_AXIS
| GF_REVOLVABLE
| GF_RESPECT_RATIO
| GF_TOOLBAR_USED
| GF_SHOW_CONTENT_SOURCE));
setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object);
setTransformationMode(Qt::SmoothTransformation);
@ -110,9 +112,10 @@ void UBGraphicsPixmapItem::paint(QPainter *painter, const QStyleOptionGraphicsIt
{
// Never draw the rubber band, we draw our custom selection with the DelegateFrame
QStyleOptionGraphicsItem styleOption = QStyleOptionGraphicsItem(*option);
styleOption.state &= ~QStyle::State_Selected;
styleOption.state &= ~QStyle::State_Selected;
QGraphicsPixmapItem::paint(painter, &styleOption, widget);
Delegate()->postpaint(painter, option, widget);
}

@ -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)
{

@ -58,6 +58,7 @@ class UBGraphicsProxyWidget: public QGraphicsProxyWidget, public UBItem, public
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);
};

@ -318,6 +318,7 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent, bool enableUndoRedoSta
// Just for debug. Do not delete please
// connect(this, SIGNAL(selectionChanged()), this, SLOT(selectionChangedProcessing()));
connect(this, SIGNAL(selectionChanged()), this, SLOT(updateGroupButtonState()));
connect(UBApplication::undoStack.data(), SIGNAL(indexChanged(int)), this, SLOT(updateSelectionFrameWrapper(int)));
}
UBGraphicsScene::~UBGraphicsScene()
@ -1078,6 +1079,11 @@ void UBGraphicsScene::updateSelectionFrame()
}
}
void UBGraphicsScene::updateSelectionFrameWrapper(int)
{
updateSelectionFrame();
}
UBGraphicsPolygonItem* UBGraphicsScene::polygonToPolygonItem(const QPolygonF pPolygon)
{
UBGraphicsPolygonItem *polygonItem = new UBGraphicsPolygonItem(pPolygon);
@ -1736,6 +1742,10 @@ void UBGraphicsScene::deselectAllItems()
foreach(QGraphicsItem *gi, selectedItems ())
{
gi->setSelected(false);
// Hide selection frame
if (mSelectionFrame) {
mSelectionFrame->setEnclosedItems(QList<QGraphicsItem*>());
}
}
}

@ -316,6 +316,7 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
public slots:
void updateSelectionFrame();
void updateSelectionFrameWrapper(int);
void initStroke();
void hideEraser();

@ -30,11 +30,10 @@
UBGraphicsStrokesGroup::UBGraphicsStrokesGroup(QGraphicsItem *parent)
:QGraphicsItemGroup(parent), UBGraphicsItem()
{
setDelegate(new UBGraphicsItemDelegate(this, 0, true, true, false));
Delegate()->init();
Delegate()->setFlippable(true);
Delegate()->setRotatable(true);
setDelegate(new UBGraphicsItemDelegate(this, 0, GF_COMMON
| GF_RESPECT_RATIO
| GF_REVOLVABLE
| GF_FLIPPABLE_ALL_AXIS));
setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object);
@ -186,15 +185,13 @@ void UBGraphicsStrokesGroup::paint(QPainter *painter, const QStyleOptionGraphics
if (styleOption.state & QStyle::State_Selected) {
selectedState = true;
}
QStyle::State svState = option->state;
styleOption.state &= ~QStyle::State_Selected;
QGraphicsItemGroup::paint(painter, &styleOption, widget);
if (selectedState && !Delegate()->controlsExist()) {
painter->save();
painter->setPen(Qt::NoPen);
painter->setBrush(QColor(0x88, 0x88, 0x88, 0x77));
painter->drawRect(boundingRect());
painter->restore();
}
//Restoring state
styleOption.state |= svState;
Delegate()->postpaint(painter, &styleOption, widget);
}
QVariant UBGraphicsStrokesGroup::itemChange(GraphicsItemChange change, const QVariant &value)

@ -61,11 +61,12 @@ void UBGraphicsSvgItem::init()
{
setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object);
setDelegate(new UBGraphicsItemDelegate(this, 0, true, true, false, true));
Delegate()->init();
Delegate()->setFlippable(true);
Delegate()->setRotatable(true);
setDelegate(new UBGraphicsItemDelegate(this, 0, GF_COMMON
| GF_RESPECT_RATIO
| GF_REVOLVABLE
| GF_SHOW_CONTENT_SOURCE));
UBGraphicsFlags dfl = Delegate()->ubflags();
Delegate()->setUBFlags(dfl | GF_FLIPPABLE_ALL_AXIS | GF_REVOLVABLE);
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
@ -77,7 +78,6 @@ void UBGraphicsSvgItem::init()
setUuid(QUuid::createUuid());
}
UBGraphicsSvgItem::~UBGraphicsSvgItem()
{
}
@ -139,6 +139,7 @@ void UBGraphicsSvgItem::paint(QPainter *painter, const QStyleOptionGraphicsItem
styleOption.state &= ~QStyle::State_Selected;
QGraphicsSvgItem::paint(painter, &styleOption, widget);
Delegate()->postpaint(painter, option, widget);
}

@ -45,11 +45,10 @@ UBGraphicsTextItem::UBGraphicsTextItem(QGraphicsItem * parent) :
, mLastMousePressTime(QTime::currentTime())
{
setDelegate(new UBGraphicsTextItemDelegate(this, 0));
Delegate()->init();
Delegate()->frame()->setOperationMode(UBGraphicsDelegateFrame::Resizing);
Delegate()->setFlippable(false);
Delegate()->setRotatable(true);
Delegate()->setUBFlag(GF_FLIPPABLE_ALL_AXIS, false);
Delegate()->setUBFlag(GF_REVOLVABLE, true);
mTypeTextHereLabel = tr("<Type Text Here>");
@ -218,6 +217,8 @@ void UBGraphicsTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem
painter->setPen(UBSettings::paletteColor);
painter->drawText(boundingRect(), Qt::AlignCenter, mTypeTextHereLabel);
}
Delegate()->postpaint(painter, option, widget);
}

@ -41,8 +41,8 @@
const int UBGraphicsTextItemDelegate::sMinPixelSize = 8;
const int UBGraphicsTextItemDelegate::sMinPointSize = 8;
UBGraphicsTextItemDelegate::UBGraphicsTextItemDelegate(UBGraphicsTextItem* pDelegated, QObject * parent)
: UBGraphicsItemDelegate(pDelegated,0, parent, true)
UBGraphicsTextItemDelegate::UBGraphicsTextItemDelegate(UBGraphicsTextItem* pDelegated, QObject *)
: UBGraphicsItemDelegate(pDelegated,0, GF_COMMON | GF_REVOLVABLE)
, mLastFontPixelSize(-1)
, delta(5)
{

@ -93,7 +93,6 @@ UBGraphicsWidgetItem::UBGraphicsWidgetItem(const QUrl &pWidgetUrl, QGraphicsItem
setPalette(viewPalette);
setDelegate(new UBGraphicsWidgetItemDelegate(this));
Delegate()->init();
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
QGraphicsWebView::setAcceptHoverEvents(true);
@ -587,6 +586,8 @@ void UBGraphicsWidgetItem::paint( QPainter *painter, const QStyleOptionGraphicsI
painter->setPen(Qt::white);
painter->drawText(rect(), Qt::AlignCenter, message);
}
Delegate()->postpaint(painter, option, widget);
}
void UBGraphicsWidgetItem::geometryChangeRequested(const QRect& geom)

@ -38,7 +38,9 @@
#include "core/memcheck.h"
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)
, setAsToolAction(0)
{

@ -33,6 +33,7 @@
#include "domain/UBGraphicsGroupContainerItem.h"
#include "domain/UBGraphicsWidgetItem.h"
#include "tools/UBGraphicsCurtainItem.h"
#include "domain/UBGraphicsItemDelegate.h"
UBItem::UBItem()
: mUuid(QUuid())
@ -58,6 +59,11 @@ void UBGraphicsItem::setDelegate(UBGraphicsItemDelegate* delegate)
mDelegate = delegate;
}
UBGraphicsItemDelegate *UBGraphicsItem::Delegate() const
{
return mDelegate;
}
void UBGraphicsItem::assignZValue(QGraphicsItem *item, qreal value)
{
item->setZValue(value);

@ -25,8 +25,8 @@
#define UBITEM_H
#include <QtGui>
#include "domain/UBGraphicsItemDelegate.h"
#include "core/UB.h"
#include "domain/UBGraphicsItemDelegate.h"
class UBGraphicsScene;
class UBGraphicsItem;
@ -38,7 +38,6 @@ class UBItem
UBItem();
public:
virtual ~UBItem();
enum RenderingQuality
@ -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
{
protected:
@ -129,10 +105,9 @@ protected:
void setDelegate(UBGraphicsItemDelegate* mDelegate);
public:
virtual int type() const = 0;
inline UBGraphicsItemDelegate *Delegate() const { return mDelegate; }
UBGraphicsItemDelegate *Delegate() const;
static void assignZValue(QGraphicsItem*, qreal value);
static bool isRotatable(QGraphicsItem *item);

@ -2,46 +2,29 @@
#include <QtGui>
#include "core/UB.h"
#include "domain/UBItem.h"
#include "board/UBBoardController.h"
#include "core/UBSettings.h"
#include "core/UBApplication.h"
#include "gui/UBResources.h"
#include "core/UBApplication.h"
#include "domain/UBGraphicsScene.h"
UBSelectionFrame::UBSelectionFrame()
: mThickness(UBSettings::settings()->objectFrameWidth)
, mAntiscaleRatio(1.0)
, mRotationAngle(0)
, mDeleteButton(0)
, mDuplicateButton(0)
, mZOrderUpButton(0)
, mZOrderDownButton(0)
, mRotateButton(0)
{
setLocalBrush(QBrush(UBSettings::paletteColor));
setPen(Qt::NoPen);
setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control));
setFlags(QGraphicsItem::ItemSendsGeometryChanges | QGraphicsItem::ItemIsSelectable | ItemIsMovable);
mDeleteButton = new DelegateButton(":/images/close.svg", this, 0, Qt::TopLeftSection);
mButtons << mDeleteButton;
connect(mDeleteButton, SIGNAL(clicked()), this, SLOT(remove()));
mDuplicateButton = new DelegateButton(":/images/duplicate.svg", this, 0, Qt::TopLeftSection);
// connect(mDuplicateButton, SIGNAL(clicked(bool)), this, SLOT(duplicate()));
mButtons << mDuplicateButton;
mZOrderUpButton = new DelegateButton(":/images/z_layer_up.svg", this, 0, Qt::BottomLeftSection);
mZOrderUpButton->setShowProgressIndicator(true);
// connect(mZOrderUpButton, SIGNAL(clicked()), this, SLOT(increaseZLevelUp()));
// connect(mZOrderUpButton, SIGNAL(longClicked()), this, SLOT(increaseZlevelTop()));
mButtons << mZOrderUpButton;
mZOrderDownButton = new DelegateButton(":/images/z_layer_down.svg", this, 0, Qt::BottomLeftSection);
mZOrderDownButton->setShowProgressIndicator(true);
// connect(mZOrderDownButton, SIGNAL(clicked()), this, SLOT(increaseZLevelDown()));
// connect(mZOrderDownButton, SIGNAL(longClicked()), this, SLOT(increaseZlevelBottom()));
mButtons << mZOrderDownButton;
connect(UBApplication::boardController, SIGNAL(zoomChanged(qreal)), this, SLOT(onZoomChanged(qreal)));
onZoomChanged(UBApplication::boardController->currentZoom());
@ -90,25 +73,26 @@ void UBSelectionFrame::setEnclosedItems(const QList<QGraphicsItem*> pGraphicsIte
{
mButtons.clear();
mButtons.append(mDeleteButton);
mButtons.append(mZOrderUpButton);
mButtons.append(mZOrderDownButton);
mRotationAngle = 0;
QRegion resultRegion;
UBGraphicsFlags resultFlags;
mEnclosedtems.clear();
foreach (QGraphicsItem *nextItem, pGraphicsItems) {
UBGraphicsItemDelegate *nextDelegate = UBGraphicsItem::Delegate(nextItem);
if (nextDelegate) {
mEnclosedtems.append(nextDelegate);
resultRegion |= nextItem->boundingRegion(nextItem->sceneTransform());
resultFlags |= nextDelegate->ubflags();
}
}
QRectF resultRect = resultRegion.boundingRect();
setRect(resultRect);
mButtons = buttonsForFlags(resultFlags);
placeButtons();
if (resultRect.isEmpty()) {
hide();
}
@ -141,6 +125,12 @@ void UBSelectionFrame::mousePressEvent(QGraphicsSceneMouseEvent *event)
mPressedPos = mLastMovedPos = event->pos();
mLastTranslateOffset = QPointF();
if (scene()->itemAt(event->scenePos()) == mRotateButton) {
mOperationMode = om_rotating;
} else {
mOperationMode = om_moving;
}
// foreach (UBGraphicsItemDelegate *curDelegate, mEnclosedtems) {
// qDebug() << "TransformBefore" << curDelegate->delegated()->transform();
// }
@ -154,23 +144,50 @@ void UBSelectionFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
foreach (UBGraphicsItemDelegate *curDelegate, mEnclosedtems) {
QGraphicsItem *item = curDelegate->delegated();
QTransform ownTransform = item->transform();
QTransform dTransform(
ownTransform.m11()
, ownTransform.m12()
, ownTransform.m13()
switch (static_cast<int>(mOperationMode)) {
case om_moving : {
QGraphicsItem *item = curDelegate->delegated();
QTransform ownTransform = item->transform();
QTransform dTransform(
ownTransform.m11()
, ownTransform.m12()
, ownTransform.m13()
, ownTransform.m21()
, ownTransform.m22()
, ownTransform.m23()
, ownTransform.m31() + (dp - mLastTranslateOffset).x()
, ownTransform.m32() + (dp - mLastTranslateOffset).y()
, ownTransform.m33()
);
item->setTransform(dTransform);
} break;
case om_rotating : {
QLineF startLine(sceneBoundingRect().center(), event->lastScenePos());
QLineF currentLine(sceneBoundingRect().center(), event->scenePos());
qreal dAngle = startLine.angleTo(currentLine);
QGraphicsItem *item = curDelegate->delegated();
QTransform ownTransform = item->transform();
qreal cntrX = item->boundingRect().center().x();
qreal cntrY = item->boundingRect().center().y();
, ownTransform.m21()
, ownTransform.m22()
, ownTransform.m23()
ownTransform.translate(cntrX, cntrY);
mRotationAngle -= dAngle;
ownTransform.rotate(mRotationAngle);
ownTransform.translate(-cntrX, -cntrY);
, ownTransform.m31() + (dp - mLastTranslateOffset).x()
, ownTransform.m32() + (dp - mLastTranslateOffset).y()
, ownTransform.m33()
);
item->setTransform(ownTransform);
qDebug() << "curAngle" << dAngle;
} break;
}
item->setTransform(dTransform);
}
updateRect();
@ -181,6 +198,17 @@ void UBSelectionFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
void UBSelectionFrame::mouseReleaseEvent(QGraphicsSceneMouseEvent */*event*/)
{
mPressedPos = mLastMovedPos = mLastTranslateOffset = QPointF();
if (mOperationMode == om_moving || mOperationMode == om_rotating) {
UBApplication::undoStack->beginMacro("TransformationMacro");
foreach (UBGraphicsItemDelegate *d, mEnclosedtems) {
d->commitUndoStep();
}
UBApplication::undoStack->endMacro();
}
mOperationMode = om_idle;
// foreach (UBGraphicsItemDelegate *curDelegate, mEnclosedtems) {
// qDebug() << "TransformBefore" << curDelegate->delegated()->transform();
// }
@ -202,9 +230,22 @@ void UBSelectionFrame::onZoomChanged(qreal pZoom)
void UBSelectionFrame::remove()
{
UBApplication::undoStack->beginMacro("RemovingSelected");
foreach (UBGraphicsItemDelegate *d, mEnclosedtems) {
d->remove(true);
}
UBApplication::undoStack->endMacro();
updateRect();
}
void UBSelectionFrame::duplicate()
{
UBApplication::undoStack->beginMacro("RemovingSelected");
foreach (UBGraphicsItemDelegate *d, mEnclosedtems) {
d->duplicate();
}
UBApplication::undoStack->endMacro();
updateRect();
}
@ -215,6 +256,10 @@ void UBSelectionFrame::translateItem(QGraphicsItem */*item*/, const QPointF &/*t
void UBSelectionFrame::placeButtons()
{
if (!mButtons.count()) {
return;
}
QTransform tr;
tr.scale(mAntiscaleRatio, mAntiscaleRatio);
mDeleteButton->setParentItem(this);
@ -243,6 +288,10 @@ void UBSelectionFrame::placeButtons()
button->setParentItem(this);
button->setPos(bottomX + (++j * 1.6 * adjThickness()), bottomY);
button->setTransform(tr);
} else if (button->getSection() == Qt::NoSection) {
button->setParentItem(this);
placeExceptionButton(button, tr);
k++;
} else {
++k;
}
@ -250,6 +299,18 @@ void UBSelectionFrame::placeButtons()
}
}
void UBSelectionFrame::placeExceptionButton(DelegateButton *pButton, QTransform pTransform)
{
QRectF frRect = boundingRect();
if (pButton == mRotateButton) {
qreal topX = frRect.right() - (mRotateButton->renderer()->viewBox().width()) * mAntiscaleRatio - 5;
qreal topY = frRect.top() + 5;
mRotateButton->setPos(topX, topY);
mRotateButton->setTransform(pTransform);
}
}
void UBSelectionFrame::clearButtons()
{
foreach (DelegateButton *b, mButtons)
@ -261,4 +322,61 @@ void UBSelectionFrame::clearButtons()
mButtons.clear();
}
inline UBGraphicsScene *UBSelectionFrame::ubscene()
{
return qobject_cast<UBGraphicsScene*>(scene());
}
QList<DelegateButton*> UBSelectionFrame::buttonsForFlags(UBGraphicsFlags fls) {
qDebug() << "buttons for flags" << QString::number((int)fls, 2);
QList<DelegateButton*> result;
if (!mDeleteButton) {
mDeleteButton = new DelegateButton(":/images/close.svg", this, 0, Qt::TopLeftSection);
mButtons << mDeleteButton;
connect(mDeleteButton, SIGNAL(clicked()), this, SLOT(remove()));
}
result << mDeleteButton;
if (fls | GF_DUPLICATION_ENABLED) {
if (!mDuplicateButton) {
mDuplicateButton = new DelegateButton(":/images/duplicate.svg", this, 0, Qt::TopLeftSection);
connect(mDuplicateButton, SIGNAL(clicked(bool)), this, SLOT(duplicate()));
}
result << mDuplicateButton;
}
if (fls | GF_ZORDER_MANIPULATIONS_ALLOWED) {
if (!mZOrderUpButton) {
mZOrderUpButton = new DelegateButton(":/images/z_layer_up.svg", this, 0, Qt::BottomLeftSection);
mZOrderUpButton->setShowProgressIndicator(true);
// connect(mZOrderUpButton, SIGNAL(clicked()), this, SLOT(increaseZLevelUp()));
// connect(mZOrderUpButton, SIGNAL(longClicked()), this, SLOT(increaseZlevelTop()));
}
if (!mZOrderDownButton) {
mZOrderDownButton = new DelegateButton(":/images/z_layer_down.svg", this, 0, Qt::BottomLeftSection);
mZOrderDownButton->setShowProgressIndicator(true);
// connect(mZOrderDownButton, SIGNAL(clicked()), this, SLOT(increaseZLevelDown()));
// connect(mZOrderDownButton, SIGNAL(longClicked()), this, SLOT(increaseZlevelBottom()));
}
result << mZOrderUpButton;
result << mZOrderDownButton;
}
if (fls | GF_REVOLVABLE) {
if (!mRotateButton) {
mRotateButton = new DelegateButton(":/images/rotate.svg", this, 0, Qt::NoSection);
mRotateButton->setCursor(UBResources::resources()->rotateCursor);
mRotateButton->setShowProgressIndicator(false);
mRotateButton->setTransparentToMouseEvent(true);
}
result << mRotateButton;
}
return result;
}

@ -3,15 +3,19 @@
#include <QGraphicsRectItem>
#include <QtGui>
#include <core/UB.h>
class DelegateButton;
class UBGraphicsItemDelegate;
class UBGraphicsScene;
class UBSelectionFrame : public QObject, public QGraphicsRectItem
{
Q_OBJECT
public:
enum {om_idle, om_moving, om_rotating} mOperationMode;
UBSelectionFrame();
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
@ -35,12 +39,18 @@ private slots:
void setAntiScaleRatio(qreal pAntiscaleRatio) {mAntiscaleRatio = pAntiscaleRatio;}
void onZoomChanged(qreal pZoom);
void remove();
void duplicate();
private:
void translateItem(QGraphicsItem *item, const QPointF &translatePoint);
void placeButtons();
void placeExceptionButton(DelegateButton *pButton, QTransform pTransform);
void clearButtons();
inline int adjThickness() const {return mThickness * mAntiscaleRatio;}
inline UBGraphicsScene* ubscene();
QList<DelegateButton*> buttonsForFlags(UBGraphicsFlags fls);
private:
int mThickness;
@ -51,6 +61,7 @@ private:
QPointF mPressedPos;
QPointF mLastMovedPos;
QPointF mLastTranslateOffset;
qreal mRotationAngle;
QList<DelegateButton*> mButtons;
@ -58,6 +69,9 @@ private:
DelegateButton *mDuplicateButton;
DelegateButton *mZOrderUpButton;
DelegateButton *mZOrderDownButton;
DelegateButton *mRotateButton;
};
#endif // UBSELECTIONFRAME_H

@ -67,4 +67,5 @@ void GraphicsPDFItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
mRenderer->render(painter, mPageNumber, option->exposedRect);
else
qWarning("GraphicsPDFItem::paint: option is null, ignoring painting");
}

@ -135,6 +135,7 @@ void UBGraphicsCurtainItem::paint(QPainter *painter, const QStyleOptionGraphicsI
styleOption.state &= ~QStyle::State_Selected;
painter->fillRect(rect(), color);
Delegate()->postpaint(painter, option, widget);
}

@ -32,9 +32,9 @@
#include "core/memcheck.h"
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()
void UBGraphicsCurtainItemDelegate::init()
{
UBGraphicsItemDelegate::init();
mFrame->hide();
mZOrderUpButton->hide();
mZOrderDownButton->hide();

Loading…
Cancel
Save