Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpenBoard
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lifo
Nicolas Ollinger
OpenBoard
Commits
8176e098
Commit
8176e098
authored
May 09, 2012
by
Ivan Ilyin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sankore groups elements are now interactable
parent
56eceb66
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
152 additions
and
27 deletions
+152
-27
UBBoardView.cpp
src/board/UBBoardView.cpp
+2
-1
UBGraphicsItemDelegate.cpp
src/domain/UBGraphicsItemDelegate.cpp
+18
-6
UBGraphicsItemDelegate.h
src/domain/UBGraphicsItemDelegate.h
+1
-4
UBGraphicsScene.cpp
src/domain/UBGraphicsScene.cpp
+2
-2
UBGraphicsWidgetItem.cpp
src/domain/UBGraphicsWidgetItem.cpp
+0
-1
ubgraphicsgroupcontaineritem.cpp
src/domain/ubgraphicsgroupcontaineritem.cpp
+121
-11
ubgraphicsgroupcontaineritem.h
src/domain/ubgraphicsgroupcontaineritem.h
+8
-2
No files found.
src/board/UBBoardView.cpp
View file @
8176e098
...
@@ -50,6 +50,7 @@
...
@@ -50,6 +50,7 @@
#include "domain/UBGraphicsVideoItem.h"
#include "domain/UBGraphicsVideoItem.h"
#include "domain/UBGraphicsAudioItem.h"
#include "domain/UBGraphicsAudioItem.h"
#include "domain/UBGraphicsSvgItem.h"
#include "domain/UBGraphicsSvgItem.h"
#include "domain/ubgraphicsgroupcontaineritem.h"
#include "document/UBDocumentProxy.h"
#include "document/UBDocumentProxy.h"
...
@@ -435,7 +436,7 @@ void UBBoardView::mousePressEvent (QMouseEvent *event)
...
@@ -435,7 +436,7 @@ void UBBoardView::mousePressEvent (QMouseEvent *event)
||
movingItem
->
type
()
==
UBGraphicsCache
::
Type
||
movingItem
->
type
()
==
UBGraphicsCache
::
Type
||
movingItem
->
type
()
==
UBGraphicsTriangle
::
Type
||
movingItem
->
type
()
==
UBGraphicsTriangle
::
Type
||
movingItem
==
this
->
scene
()
->
backgroundObject
()
||
movingItem
==
this
->
scene
()
->
backgroundObject
()
||
movingItem
->
group
(
))
||
(
movingItem
->
parentItem
()
&&
movingItem
->
parentItem
()
->
type
()
==
UBGraphicsGroupContainerItem
::
Type
))
{
{
movingItem
=
NULL
;
movingItem
=
NULL
;
...
...
src/domain/UBGraphicsItemDelegate.cpp
View file @
8176e098
...
@@ -40,6 +40,7 @@
...
@@ -40,6 +40,7 @@
#include "domain/UBGraphicsTextItem.h"
#include "domain/UBGraphicsTextItem.h"
#include "domain/UBGraphicsAudioItem.h"
#include "domain/UBGraphicsAudioItem.h"
#include "domain/UBGraphicsVideoItem.h"
#include "domain/UBGraphicsVideoItem.h"
#include "domain/ubgraphicsgroupcontaineritem.h"
#include "web/UBWebController.h"
#include "web/UBWebController.h"
...
@@ -217,10 +218,9 @@ bool UBGraphicsItemDelegate::mousePressEvent(QGraphicsSceneMouseEvent *event)
...
@@ -217,10 +218,9 @@ bool UBGraphicsItemDelegate::mousePressEvent(QGraphicsSceneMouseEvent *event)
startUndoStep
();
startUndoStep
();
if
(
!
mDelegated
->
isSelected
())
if
(
!
delegated
()
->
isSelected
())
{
{
mDelegated
->
setSelected
(
true
);
delegated
()
->
setSelected
(
true
);
positionHandles
();
return
true
;
return
true
;
}
}
else
else
...
@@ -262,7 +262,7 @@ bool UBGraphicsItemDelegate::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
...
@@ -262,7 +262,7 @@ bool UBGraphicsItemDelegate::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
bool
UBGraphicsItemDelegate
::
weelEvent
(
QGraphicsSceneWheelEvent
*
event
)
bool
UBGraphicsItemDelegate
::
weelEvent
(
QGraphicsSceneWheelEvent
*
event
)
{
{
Q_UNUSED
(
event
);
Q_UNUSED
(
event
);
if
(
mDelegated
->
isSelected
()
)
if
(
delegated
()
->
isSelected
()
)
{
{
// event->accept();
// event->accept();
return
true
;
return
true
;
...
@@ -310,6 +310,18 @@ void UBGraphicsItemDelegate::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
...
@@ -310,6 +310,18 @@ void UBGraphicsItemDelegate::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
// }
// }
}
}
QGraphicsItem
*
UBGraphicsItemDelegate
::
delegated
()
{
QGraphicsItem
*
curDelegate
=
0
;
if
(
mDelegated
->
parentItem
()
&&
mDelegated
->
parentItem
()
->
type
()
==
UBGraphicsGroupContainerItem
::
Type
)
{
curDelegate
=
mDelegated
->
parentItem
();
// considering delegated item as an item's group which contains everything
}
else
{
curDelegate
=
mDelegated
;
}
return
curDelegate
;
}
void
UBGraphicsItemDelegate
::
positionHandles
()
void
UBGraphicsItemDelegate
::
positionHandles
()
{
{
if
(
mDelegated
->
isSelected
())
{
if
(
mDelegated
->
isSelected
())
{
...
@@ -363,7 +375,7 @@ void UBGraphicsItemDelegate::setZOrderButtonsVisible(bool visible)
...
@@ -363,7 +375,7 @@ void UBGraphicsItemDelegate::setZOrderButtonsVisible(bool visible)
void
UBGraphicsItemDelegate
::
remove
(
bool
canUndo
)
void
UBGraphicsItemDelegate
::
remove
(
bool
canUndo
)
{
{
// QGraphicsScene* scene = mDelegated->scene();
// QGraphicsScene* scene = mDelegated->scene();
UBGraphicsScene
*
scene
=
(
UBGraphicsScene
*
)
(
mDelegated
->
scene
());
UBGraphicsScene
*
scene
=
dynamic_cast
<
UBGraphicsScene
*>
(
mDelegated
->
scene
());
if
(
scene
)
if
(
scene
)
{
{
foreach
(
DelegateButton
*
button
,
mButtons
)
foreach
(
DelegateButton
*
button
,
mButtons
)
...
@@ -699,4 +711,4 @@ void UBGraphicsToolBarItem::paint(QPainter *painter, const QStyleOptionGraphicsI
...
@@ -699,4 +711,4 @@ void UBGraphicsToolBarItem::paint(QPainter *painter, const QStyleOptionGraphicsI
path
.
addRoundedRect
(
rect
(),
10
,
10
);
path
.
addRoundedRect
(
rect
(),
10
,
10
);
painter
->
fillPath
(
path
,
brush
());
painter
->
fillPath
(
path
,
brush
());
}
}
\ No newline at end of file
src/domain/UBGraphicsItemDelegate.h
View file @
8176e098
...
@@ -121,10 +121,7 @@ class UBGraphicsItemDelegate : public QObject
...
@@ -121,10 +121,7 @@ class UBGraphicsItemDelegate : public QObject
void
printMessage
(
const
QString
&
mess
)
{
qDebug
()
<<
mess
;}
void
printMessage
(
const
QString
&
mess
)
{
qDebug
()
<<
mess
;}
QGraphicsItem
*
delegated
()
QGraphicsItem
*
delegated
();
{
return
mDelegated
;
}
void
setCanDuplicate
(
bool
allow
){
mCanDuplicate
=
allow
;
}
void
setCanDuplicate
(
bool
allow
){
mCanDuplicate
=
allow
;
}
...
...
src/domain/UBGraphicsScene.cpp
View file @
8176e098
...
@@ -383,9 +383,9 @@ void UBGraphicsScene::processGroupItems()
...
@@ -383,9 +383,9 @@ void UBGraphicsScene::processGroupItems()
foreach
(
QGraphicsItem
*
item
,
selectedItems
())
{
foreach
(
QGraphicsItem
*
item
,
selectedItems
())
{
item
->
setSelected
(
false
);
item
->
setSelected
(
false
);
item
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
fals
e
);
item
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
tru
e
);
item
->
setFlag
(
QGraphicsItem
::
ItemIsMovable
,
false
);
item
->
setFlag
(
QGraphicsItem
::
ItemIsMovable
,
false
);
item
->
setFlag
(
QGraphicsItem
::
ItemIsFocusable
);
item
->
setFlag
(
QGraphicsItem
::
ItemIsFocusable
,
true
);
groupItem
->
addToGroup
(
item
);
groupItem
->
addToGroup
(
item
);
}
}
...
...
src/domain/UBGraphicsWidgetItem.cpp
View file @
8176e098
...
@@ -93,7 +93,6 @@ void UBGraphicsWidgetItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
...
@@ -93,7 +93,6 @@ void UBGraphicsWidgetItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
}
}
void
UBGraphicsWidgetItem
::
hoverMoveEvent
(
QGraphicsSceneHoverEvent
*
event
)
void
UBGraphicsWidgetItem
::
hoverMoveEvent
(
QGraphicsSceneHoverEvent
*
event
)
{
{
qDebug
()
<<
"hover move catched"
;
UBGraphicsProxyWidget
::
hoverMoveEvent
(
event
);
UBGraphicsProxyWidget
::
hoverMoveEvent
(
event
);
}
}
...
...
src/domain/ubgraphicsgroupcontaineritem.cpp
View file @
8176e098
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
#include "core/memcheck.h"
#include "core/memcheck.h"
UBGraphicsGroupContainerItem
::
UBGraphicsGroupContainerItem
(
QGraphicsItem
*
parent
)
UBGraphicsGroupContainerItem
::
UBGraphicsGroupContainerItem
(
QGraphicsItem
*
parent
)
:
QGraphicsItem
Group
(
parent
)
:
QGraphicsItem
(
parent
)
{
{
setData
(
UBGraphicsItemData
::
ItemLayerType
,
UBItemLayerType
::
Object
);
setData
(
UBGraphicsItemData
::
ItemLayerType
,
UBItemLayerType
::
Object
);
...
@@ -23,8 +23,123 @@ UBGraphicsGroupContainerItem::UBGraphicsGroupContainerItem(QGraphicsItem *parent
...
@@ -23,8 +23,123 @@ UBGraphicsGroupContainerItem::UBGraphicsGroupContainerItem(QGraphicsItem *parent
UBGraphicsGroupContainerItem
::
setAcceptHoverEvents
(
true
);
UBGraphicsGroupContainerItem
::
setAcceptHoverEvents
(
true
);
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
}
void
UBGraphicsGroupContainerItem
::
addToGroup
(
QGraphicsItem
*
item
)
{
if
(
!
item
)
{
qWarning
(
"UBGraphicsGroupContainerItem::addToGroup: cannot add null item"
);
return
;
}
if
(
item
==
this
)
{
qWarning
(
"UBGraphicsGroupContainerItem::addToGroup: cannot add a group to itself"
);
return
;
}
// COMBINE
bool
ok
;
QTransform
itemTransform
=
item
->
itemTransform
(
this
,
&
ok
);
if
(
!
ok
)
{
qWarning
(
"UBGraphicsGroupContainerItem::addToGroup: could not find a valid transformation from item to group coordinates"
);
return
;
}
QTransform
newItemTransform
(
itemTransform
);
item
->
setPos
(
mapFromItem
(
item
,
0
,
0
));
item
->
setParentItem
(
this
);
// removing position from translation component of the new transform
if
(
!
item
->
pos
().
isNull
())
newItemTransform
*=
QTransform
::
fromTranslate
(
-
item
->
x
(),
-
item
->
y
());
// removing additional transformations properties applied with itemTransform()
QPointF
origin
=
item
->
transformOriginPoint
();
QMatrix4x4
m
;
QList
<
QGraphicsTransform
*>
transformList
=
item
->
transformations
();
for
(
int
i
=
0
;
i
<
transformList
.
size
();
++
i
)
transformList
.
at
(
i
)
->
applyTo
(
&
m
);
newItemTransform
*=
m
.
toTransform
().
inverted
();
newItemTransform
.
translate
(
origin
.
x
(),
origin
.
y
());
newItemTransform
.
rotate
(
-
item
->
rotation
());
newItemTransform
.
scale
(
1
/
item
->
scale
(),
1
/
item
->
scale
());
newItemTransform
.
translate
(
-
origin
.
x
(),
-
origin
.
y
());
// ### Expensive, we could maybe use dirtySceneTransform bit for optimization
item
->
setTransform
(
newItemTransform
);
// item->d_func()->setIsMemberOfGroup(true);
prepareGeometryChange
();
itemsBoundingRect
|=
itemTransform
.
mapRect
(
item
->
boundingRect
()
|
item
->
childrenBoundingRect
());
update
();
}
void
UBGraphicsGroupContainerItem
::
removeFromGroup
(
QGraphicsItem
*
item
)
{
if
(
!
item
)
{
qWarning
(
"QGraphicsItemGroup::removeFromGroup: cannot remove null item"
);
return
;
}
QGraphicsItem
*
newParent
=
parentItem
();
// COMBINE
bool
ok
;
QTransform
itemTransform
;
if
(
newParent
)
itemTransform
=
item
->
itemTransform
(
newParent
,
&
ok
);
else
itemTransform
=
item
->
sceneTransform
();
QPointF
oldPos
=
item
->
mapToItem
(
newParent
,
0
,
0
);
item
->
setParentItem
(
newParent
);
item
->
setPos
(
oldPos
);
// removing position from translation component of the new transform
if
(
!
item
->
pos
().
isNull
())
itemTransform
*=
QTransform
::
fromTranslate
(
-
item
->
x
(),
-
item
->
y
());
// removing additional transformations properties applied
// with itemTransform() or sceneTransform()
QPointF
origin
=
item
->
transformOriginPoint
();
QMatrix4x4
m
;
QList
<
QGraphicsTransform
*>
transformList
=
item
->
transformations
();
for
(
int
i
=
0
;
i
<
transformList
.
size
();
++
i
)
transformList
.
at
(
i
)
->
applyTo
(
&
m
);
itemTransform
*=
m
.
toTransform
().
inverted
();
itemTransform
.
translate
(
origin
.
x
(),
origin
.
y
());
itemTransform
.
rotate
(
-
item
->
rotation
());
itemTransform
.
scale
(
1
/
item
->
scale
(),
1
/
item
->
scale
());
itemTransform
.
translate
(
-
origin
.
x
(),
-
origin
.
y
());
// ### Expensive, we could maybe use dirtySceneTransform bit for optimization
item
->
setTransform
(
itemTransform
);
// item->d_func()->setIsMemberOfGroup(item->group() != 0);
// ### Quite expensive. But removeFromGroup() isn't called very often.
prepareGeometryChange
();
itemsBoundingRect
=
childrenBoundingRect
();
}
}
QRectF
UBGraphicsGroupContainerItem
::
boundingRect
()
const
{
return
itemsBoundingRect
;
}
void
UBGraphicsGroupContainerItem
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
)
{
Q_UNUSED
(
widget
);
if
(
option
->
state
&
QStyle
::
State_Selected
)
{
painter
->
setBrush
(
Qt
::
NoBrush
);
QPen
tmpPen
;
qreal
tmpPenWidth
=
1.0
;
tmpPen
.
setWidth
(
tmpPenWidth
);
tmpPen
.
setColor
(
Qt
::
lightGray
);
painter
->
setPen
(
tmpPen
);
painter
->
drawRect
(
itemsBoundingRect
.
adjusted
(
tmpPenWidth
/
2
,
tmpPenWidth
/
2
,
-
tmpPenWidth
/
2
,
-
tmpPenWidth
/
2
));
}
}
UBGraphicsScene
*
UBGraphicsGroupContainerItem
::
scene
()
UBGraphicsScene
*
UBGraphicsGroupContainerItem
::
scene
()
{
{
...
@@ -60,23 +175,18 @@ void UBGraphicsGroupContainerItem::destroy() {
...
@@ -60,23 +175,18 @@ void UBGraphicsGroupContainerItem::destroy() {
foreach
(
QGraphicsItem
*
item
,
childItems
())
{
foreach
(
QGraphicsItem
*
item
,
childItems
())
{
removeFromGroup
(
item
);
removeFromGroup
(
item
);
item
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
item
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
item
->
setFlag
(
QGraphicsItem
::
ItemIsFocusable
,
true
);
}
}
mDelegate
->
remove
(
true
);
mDelegate
->
remove
(
true
);
}
}
void
UBGraphicsGroupContainerItem
::
hoverMoveEvent
(
QGraphicsSceneHoverEvent
*
event
)
{
qDebug
()
<<
"hover move group"
;
QGraphicsItemGroup
::
hoverMoveEvent
(
event
);
}
void
UBGraphicsGroupContainerItem
::
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
)
void
UBGraphicsGroupContainerItem
::
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
{
if
(
mDelegate
->
mousePressEvent
(
event
))
{
if
(
mDelegate
->
mousePressEvent
(
event
))
{
//NOOP
//NOOP
}
else
{
}
else
{
QGraphicsItem
Group
::
mousePressEvent
(
event
);
QGraphicsItem
::
mousePressEvent
(
event
);
setSelected
(
true
);
setSelected
(
true
);
}
}
}
}
...
@@ -86,18 +196,18 @@ void UBGraphicsGroupContainerItem::mouseMoveEvent(QGraphicsSceneMouseEvent *even
...
@@ -86,18 +196,18 @@ void UBGraphicsGroupContainerItem::mouseMoveEvent(QGraphicsSceneMouseEvent *even
if
(
mDelegate
->
mouseMoveEvent
(
event
))
{
if
(
mDelegate
->
mouseMoveEvent
(
event
))
{
// NOOP;
// NOOP;
}
else
{
}
else
{
QGraphicsItem
Group
::
mouseMoveEvent
(
event
);
QGraphicsItem
::
mouseMoveEvent
(
event
);
}
}
}
}
void
UBGraphicsGroupContainerItem
::
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*
event
)
void
UBGraphicsGroupContainerItem
::
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
{
mDelegate
->
mouseReleaseEvent
(
event
);
mDelegate
->
mouseReleaseEvent
(
event
);
QGraphicsItem
Group
::
mouseReleaseEvent
(
event
);
QGraphicsItem
::
mouseReleaseEvent
(
event
);
}
}
QVariant
UBGraphicsGroupContainerItem
::
itemChange
(
GraphicsItemChange
change
,
const
QVariant
&
value
)
QVariant
UBGraphicsGroupContainerItem
::
itemChange
(
GraphicsItemChange
change
,
const
QVariant
&
value
)
{
{
QVariant
newValue
=
mDelegate
->
itemChange
(
change
,
value
);
QVariant
newValue
=
mDelegate
->
itemChange
(
change
,
value
);
return
QGraphicsItem
Group
::
itemChange
(
change
,
newValue
);
return
QGraphicsItem
::
itemChange
(
change
,
newValue
);
}
}
src/domain/ubgraphicsgroupcontaineritem.h
View file @
8176e098
...
@@ -5,11 +5,17 @@
...
@@ -5,11 +5,17 @@
#include "domain/UBItem.h"
#include "domain/UBItem.h"
class
UBGraphicsGroupContainerItem
:
public
QGraphicsItem
Group
,
public
UBItem
,
public
UBGraphicsItem
class
UBGraphicsGroupContainerItem
:
public
QGraphicsItem
,
public
UBItem
,
public
UBGraphicsItem
{
{
public
:
public
:
UBGraphicsGroupContainerItem
(
QGraphicsItem
*
parent
=
0
);
UBGraphicsGroupContainerItem
(
QGraphicsItem
*
parent
=
0
);
void
addToGroup
(
QGraphicsItem
*
item
);
void
removeFromGroup
(
QGraphicsItem
*
item
);
QRectF
boundingRect
()
const
;
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
virtual
UBGraphicsItemDelegate
*
Delegate
()
const
{
return
mDelegate
;}
virtual
UBGraphicsItemDelegate
*
Delegate
()
const
{
return
mDelegate
;}
virtual
UBGraphicsScene
*
scene
();
virtual
UBGraphicsScene
*
scene
();
...
@@ -26,7 +32,6 @@ public:
...
@@ -26,7 +32,6 @@ public:
protected
:
protected
:
virtual
void
hoverMoveEvent
(
QGraphicsSceneHoverEvent
*
event
);
virtual
void
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
);
virtual
void
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
);
virtual
void
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
);
virtual
void
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
);
virtual
void
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*
event
);
virtual
void
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*
event
);
...
@@ -34,6 +39,7 @@ protected:
...
@@ -34,6 +39,7 @@ protected:
virtual
QVariant
itemChange
(
GraphicsItemChange
change
,
const
QVariant
&
value
);
virtual
QVariant
itemChange
(
GraphicsItemChange
change
,
const
QVariant
&
value
);
private
:
private
:
QRectF
itemsBoundingRect
;
};
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment