Commit c36f903f authored by Aleksei Kanash's avatar Aleksei Kanash

Small boarder for possibility to move item and select it without rubber band added.

Audio items cannot be resized in vertical dimension because there are no useful content.

Audio and Video items has minimal dimensions.
parent 88f65224
...@@ -359,7 +359,7 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event) ...@@ -359,7 +359,7 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
} }
} }
} }
else if (mOperationMode == Resizing) else if (mOperationMode == Resizing || mOperationMode == ResizingHorizontally)
{ {
mTranslateX = moveX; mTranslateX = moveX;
UBResizableGraphicsItem* resizableItem = dynamic_cast<UBResizableGraphicsItem*>(delegated()); UBResizableGraphicsItem* resizableItem = dynamic_cast<UBResizableGraphicsItem*>(delegated());
...@@ -675,19 +675,22 @@ void UBGraphicsDelegateFrame::positionHandles() ...@@ -675,19 +675,22 @@ void UBGraphicsDelegateFrame::positionHandles()
QVariant vLocked = delegated()->data(UBGraphicsItemData::ItemLocked); QVariant vLocked = delegated()->data(UBGraphicsItemData::ItemLocked);
bool isLocked = (vLocked.isValid() && vLocked.toBool()); bool isLocked = (vLocked.isValid() && vLocked.toBool());
bool bShowHorizontalResizers = ResizingHorizontally == mOperationMode;
mBottomRightResizeGripSvgItem->setVisible(!isLocked); bool bShowVerticalResizers = ResizingHorizontally != mOperationMode;
mBottomResizeGripSvgItem->setVisible(!isLocked); bool bShowAllResizers = Resizing == mOperationMode || Scaling == mOperationMode ;
mLeftResizeGripSvgItem->setVisible(!isLocked);
mRightResizeGripSvgItem->setVisible(!isLocked); mBottomRightResizeGripSvgItem->setVisible(!isLocked && bShowAllResizers);
mTopResizeGripSvgItem->setVisible(!isLocked); mBottomResizeGripSvgItem->setVisible(!isLocked && (bShowVerticalResizers || bShowAllResizers));
mLeftResizeGripSvgItem->setVisible(!isLocked && (bShowHorizontalResizers || bShowAllResizers));
mRightResizeGripSvgItem->setVisible(!isLocked && (bShowHorizontalResizers || bShowAllResizers));
mTopResizeGripSvgItem->setVisible(!isLocked && (bShowVerticalResizers || bShowAllResizers));
mRotateButton->setVisible(mDelegate->canRotate() && !isLocked); mRotateButton->setVisible(mDelegate->canRotate() && !isLocked);
mBottomRightResizeGrip->setVisible(!isLocked); mBottomRightResizeGrip->setVisible(!isLocked && bShowAllResizers);
mBottomResizeGrip->setVisible(!isLocked); mBottomResizeGrip->setVisible(!isLocked && (bShowVerticalResizers || bShowAllResizers));
mLeftResizeGrip->setVisible(!isLocked); mLeftResizeGrip->setVisible(!isLocked && (bShowHorizontalResizers || bShowAllResizers));
mRightResizeGrip->setVisible(!isLocked); mRightResizeGrip->setVisible(!isLocked && (bShowHorizontalResizers || bShowAllResizers));
mTopResizeGrip->setVisible(!isLocked); mTopResizeGrip->setVisible(!isLocked && (bShowVerticalResizers || bShowAllResizers));
if (isLocked) if (isLocked)
{ {
...@@ -714,9 +717,9 @@ UBGraphicsDelegateFrame::FrameTool UBGraphicsDelegateFrame::toolFromPos(QPointF ...@@ -714,9 +717,9 @@ UBGraphicsDelegateFrame::FrameTool UBGraphicsDelegateFrame::toolFromPos(QPointF
{ {
if(mDelegate->isLocked()) if(mDelegate->isLocked())
return None; return None;
else if (bottomRightResizeGripRect().contains(pos)) else if (bottomRightResizeGripRect().contains(pos) && ResizingHorizontally != mOperationMode)
return ResizeBottomRight; return ResizeBottomRight;
else if (bottomResizeGripRect().contains(pos)){ else if (bottomResizeGripRect().contains(pos) && ResizingHorizontally != mOperationMode){
if(mMirrorY){ if(mMirrorY){
return ResizeTop; return ResizeTop;
}else{ }else{
...@@ -738,7 +741,7 @@ UBGraphicsDelegateFrame::FrameTool UBGraphicsDelegateFrame::toolFromPos(QPointF ...@@ -738,7 +741,7 @@ UBGraphicsDelegateFrame::FrameTool UBGraphicsDelegateFrame::toolFromPos(QPointF
return ResizeRight; return ResizeRight;
} }
} }
else if (topResizeGripRect().contains(pos)){ else if (topResizeGripRect().contains(pos) && ResizingHorizontally != mOperationMode){
if(mMirrorY){ if(mMirrorY){
return ResizeBottom; return ResizeBottom;
}else{ }else{
......
...@@ -46,7 +46,7 @@ class UBGraphicsDelegateFrame: public QGraphicsRectItem, public QObject ...@@ -46,7 +46,7 @@ class UBGraphicsDelegateFrame: public QGraphicsRectItem, public QObject
virtual void setAntiScale(qreal pAntiScale); virtual void setAntiScale(qreal pAntiScale);
enum OperationMode {Scaling, Resizing}; enum OperationMode {Scaling, Resizing, ResizingHorizontally};
void setOperationMode(OperationMode pMode) {mOperationMode = pMode;} void setOperationMode(OperationMode pMode) {mOperationMode = pMode;}
bool isResizing(){return mResizing;} bool isResizing(){return mResizing;}
......
...@@ -56,6 +56,7 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte ...@@ -56,6 +56,7 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte
if(mVideoWidget->sizeHint() == QSize(1,1)){ if(mVideoWidget->sizeHint() == QSize(1,1)){
mVideoWidget->resize(320,240); mVideoWidget->resize(320,240);
mVideoWidget->setMinimumSize(131,26);
} }
setWidget(mVideoWidget); setWidget(mVideoWidget);
haveLinkedImage = true; haveLinkedImage = true;
...@@ -67,8 +68,10 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte ...@@ -67,8 +68,10 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte
mAudioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this); mAudioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);
mMediaObject->setTickInterval(1000); mMediaObject->setTickInterval(1000);
mAudioWidget = new QWidget(); mAudioWidget = new UBGraphicsMediaItem::UBAudioPresentationWidget();
mAudioWidget->resize(320,26); int borderSize = dynamic_cast<UBGraphicsMediaItem::UBAudioPresentationWidget*>(mAudioWidget)->borderSize();
mAudioWidget->resize(320+2*borderSize,26+2*borderSize);
mAudioWidget->setMinimumSize(147,26+2*borderSize);
setWidget(mAudioWidget); setWidget(mAudioWidget);
haveLinkedImage = false; haveLinkedImage = false;
} }
...@@ -82,7 +85,10 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte ...@@ -82,7 +85,10 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte
itemDelegate->init(); itemDelegate->init();
setDelegate(itemDelegate); setDelegate(itemDelegate);
mDelegate->frame()->setOperationMode(UBGraphicsDelegateFrame::Resizing); if (mediaType_Audio == mMediaType)
mDelegate->frame()->setOperationMode(UBGraphicsDelegateFrame::ResizingHorizontally);
else
mDelegate->frame()->setOperationMode(UBGraphicsDelegateFrame::Resizing);
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::ObjectItem)); //Necessary to set if we want z value to be assigned correctly setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::ObjectItem)); //Necessary to set if we want z value to be assigned correctly
...@@ -284,4 +290,4 @@ void UBGraphicsMediaItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) ...@@ -284,4 +290,4 @@ void UBGraphicsMediaItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
event->accept(); event->accept();
} }
\ No newline at end of file
...@@ -27,6 +27,29 @@ class UBGraphicsMediaItem : public UBGraphicsProxyWidget ...@@ -27,6 +27,29 @@ class UBGraphicsMediaItem : public UBGraphicsProxyWidget
{ {
Q_OBJECT Q_OBJECT
public:
class UBAudioPresentationWidget : public QWidget
{
public:
UBAudioPresentationWidget::UBAudioPresentationWidget(QWidget *parent = NULL)
:QWidget(parent)
, mBorderSize(7)
{}
int borderSize(){return mBorderSize;}
private:
virtual void paintEvent(QPaintEvent *event)
{
QPainter painter(this);
painter.fillRect(rect(), QBrush(Qt::black));
QWidget::paintEvent(event);
}
int mBorderSize;
};
public: public:
typedef enum{ typedef enum{
mediaType_Video, mediaType_Video,
...@@ -118,15 +141,6 @@ private: ...@@ -118,15 +141,6 @@ private:
QPointF mMouseMovePos; QPointF mMouseMovePos;
bool haveLinkedImage; bool haveLinkedImage;
QGraphicsPixmapItem *mLinkedImage; QGraphicsPixmapItem *mLinkedImage;
}; };
class UBGraphicsUnitedMediaItem : public UBGraphicsMediaItem
{
public:
UBGraphicsUnitedMediaItem(const QUrl& pMediaFileUrl, QGraphicsItem *parent = 0);
};
#endif // UBGRAPHICSMEDIAITEM_H #endif // UBGRAPHICSMEDIAITEM_H
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "UBGraphicsMediaItem.h" #include "UBGraphicsMediaItem.h"
#include "UBGraphicsMediaItemDelegate.h" #include "UBGraphicsMediaItemDelegate.h"
#include "UBGraphicsDelegateFrame.h"
#include "UBGraphicsScene.h" #include "UBGraphicsScene.h"
...@@ -125,19 +126,25 @@ void UBGraphicsMediaItemDelegate::positionHandles() ...@@ -125,19 +126,25 @@ void UBGraphicsMediaItemDelegate::positionHandles()
UBGraphicsMediaItem *mediaItem = dynamic_cast<UBGraphicsMediaItem*>(mDelegated); UBGraphicsMediaItem *mediaItem = dynamic_cast<UBGraphicsMediaItem*>(mDelegated);
if (mediaItem) if (mediaItem)
{ {
if (mediaItem->getMediaType() != UBGraphicsMediaItem::mediaType_Audio)
{ mToolBarItem->setPos(0, delegated()->boundingRect().height()-mToolBarItem->rect().height()*AntiScaleRatio);
mToolBarItem->setPos(0, delegated()->boundingRect().height()-mToolBarItem->rect().height()*AntiScaleRatio); mToolBarItem->setScale(AntiScaleRatio);
mToolBarItem->setScale(AntiScaleRatio); QRectF toolBarRect = mToolBarItem->rect();
QRectF toolBarRect = mToolBarItem->rect(); toolBarRect.setWidth(delegated()->boundingRect().width()/AntiScaleRatio);
toolBarRect.setWidth(delegated()->boundingRect().width()/AntiScaleRatio);
mToolBarItem->setRect(toolBarRect); if (mediaItem->getMediaType() == UBGraphicsMediaItem::mediaType_Audio)
}
else
{ {
mToolBarItem->setPos(0, 0); int borderSize = 0;
UBGraphicsMediaItem::UBAudioPresentationWidget *audioWidget = dynamic_cast<UBGraphicsMediaItem::UBAudioPresentationWidget*>(delegated()->widget());
if (audioWidget)
borderSize = audioWidget->borderSize();
toolBarRect.setWidth(delegated()->boundingRect().width()/AntiScaleRatio-2*borderSize);
mToolBarItem->setPos(borderSize,borderSize);
mToolBarItem->show(); mToolBarItem->show();
} }
mToolBarItem->setRect(toolBarRect);
} }
int mediaItemWidth = mToolBarItem->boundingRect().width(); int mediaItemWidth = mToolBarItem->boundingRect().width();
......
...@@ -153,10 +153,30 @@ void UBGraphicsProxyWidget::resize(const QSizeF & pSize) ...@@ -153,10 +153,30 @@ void UBGraphicsProxyWidget::resize(const QSizeF & pSize)
{ {
if (pSize != size()) if (pSize != size())
{ {
QGraphicsProxyWidget::setMaximumSize(pSize.width(), pSize.height()); qreal sizeX = 0;
QGraphicsProxyWidget::resize(pSize.width(), pSize.height()); qreal sizeY = 0;
if (widget())
{
QSizeF minimumItemSize(widget()->minimumSize());
if (minimumItemSize.width() > pSize.width())
sizeX = minimumItemSize.width();
else
sizeX = pSize.width();
if (minimumItemSize.height() > pSize.height())
sizeY = minimumItemSize.height();
else
sizeY = pSize.height();
}
QSizeF size(sizeX, sizeY);
QGraphicsProxyWidget::setMaximumSize(size.width(), size.height());
QGraphicsProxyWidget::resize(size.width(), size.height());
if (widget()) if (widget())
widget()->resize(pSize.width(), pSize.height()); widget()->resize(size.width(), size.height());
if (mDelegate) if (mDelegate)
mDelegate->positionHandles(); mDelegate->positionHandles();
if (scene()) if (scene())
......
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