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
4576b453
Commit
4576b453
authored
Jun 10, 2013
by
Ilia Ryabokon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Graphisc flags added
parent
fd4d2201
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
49 deletions
+65
-49
UBItem.h
src/domain/UBItem.h
+22
-0
UBSelectionFrame.cpp
src/domain/UBSelectionFrame.cpp
+42
-49
UBSelectionFrame.h
src/domain/UBSelectionFrame.h
+1
-0
No files found.
src/domain/UBItem.h
View file @
4576b453
...
...
@@ -95,6 +95,28 @@ 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
{
...
...
src/domain/UBSelectionFrame.cpp
View file @
4576b453
...
...
@@ -42,8 +42,9 @@ UBSelectionFrame::UBSelectionFrame()
// connect(mZOrderDownButton, SIGNAL(longClicked()), this, SLOT(increaseZlevelBottom()));
mButtons
<<
mZOrderDownButton
;
connect
(
UBApplication
::
boardController
,
SIGNAL
(
zoomChanged
(
qreal
)),
this
,
SLOT
(
onZoomChanged
(
qreal
)));
onZoomChanged
(
UBApplication
::
boardController
->
currentZoom
());
}
void
UBSelectionFrame
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
)
...
...
@@ -53,11 +54,11 @@ void UBSelectionFrame::paint(QPainter *painter, const QStyleOptionGraphicsItem *
QPainterPath
path
;
QRectF
shRect
=
option
->
rect
;
path
.
addRoundedRect
(
shRect
,
mThickness
/
2
,
mThickness
/
2
);
path
.
addRoundedRect
(
shRect
,
adjThickness
()
/
2
,
adjThickness
()
/
2
);
if
(
rect
().
width
()
>
1
&&
rect
().
height
()
>
1
)
{
QPainterPath
extruded
;
extruded
.
addRect
(
shRect
.
adjusted
(
mThickness
,
mThickness
,
(
mThickness
*
-
1
),
(
mThickness
*
-
1
)));
extruded
.
addRect
(
shRect
.
adjusted
(
adjThickness
(),
adjThickness
(),
(
adjThickness
()
*
-
1
),
(
adjThickness
()
*
-
1
)));
path
=
path
.
subtracted
(
extruded
);
}
...
...
@@ -66,15 +67,15 @@ void UBSelectionFrame::paint(QPainter *painter, const QStyleOptionGraphicsItem *
QRectF
UBSelectionFrame
::
boundingRect
()
const
{
return
rect
().
adjusted
(
-
mThickness
,
-
mThickness
,
mThickness
,
mThickness
);
return
rect
().
adjusted
(
-
adjThickness
(),
-
adjThickness
(),
adjThickness
(),
adjThickness
()
);
}
QPainterPath
UBSelectionFrame
::
shape
()
const
{
QPainterPath
resShape
;
QRectF
ownRect
=
rect
();
QRectF
shRect
=
ownRect
.
adjusted
(
-
mThickness
,
-
mThickness
,
mThickness
,
mThickness
);
resShape
.
addRoundedRect
(
shRect
,
mThickness
/
2
,
mThickness
/
2
);
QRectF
shRect
=
ownRect
.
adjusted
(
-
adjThickness
(),
-
adjThickness
(),
adjThickness
(),
adjThickness
()
);
resShape
.
addRoundedRect
(
shRect
,
adjThickness
()
/
2
,
adjThickness
()
/
2
);
if
(
rect
().
width
()
>
1
&&
rect
().
height
()
>
1
)
{
QPainterPath
extruded
;
...
...
@@ -89,6 +90,8 @@ void UBSelectionFrame::setEnclosedItems(const QList<QGraphicsItem*> pGraphicsIte
{
mButtons
.
clear
();
mButtons
.
append
(
mDeleteButton
);
mButtons
.
append
(
mZOrderUpButton
);
mButtons
.
append
(
mZOrderDownButton
);
QRegion
resultRegion
;
mEnclosedtems
.
clear
();
...
...
@@ -186,8 +189,15 @@ void UBSelectionFrame::mouseReleaseEvent(QGraphicsSceneMouseEvent */*event*/)
void
UBSelectionFrame
::
onZoomChanged
(
qreal
pZoom
)
{
// mAntiscaleRatio = pZoom;
qDebug
()
<<
"Pzoom"
<<
pZoom
;
qDebug
()
<<
"Board current zoom"
<<
UBApplication
::
boardController
->
currentZoom
();
qDebug
()
<<
"UBApplication::boardController->systemScaleFactor()"
<<
UBApplication
::
boardController
->
systemScaleFactor
();
mAntiscaleRatio
=
1
/
(
UBApplication
::
boardController
->
systemScaleFactor
()
*
pZoom
);
// updateScale();
// QTransform tr;
// tr.scale(mAntiscaleRatio, mAntiscaleRatio);
// this->setTransform(tr);
}
void
UBSelectionFrame
::
remove
()
...
...
@@ -206,55 +216,38 @@ void UBSelectionFrame::translateItem(QGraphicsItem */*item*/, const QPointF &/*t
void
UBSelectionFrame
::
placeButtons
()
{
QTransform
tr
;
// tr.scale(mAntiScaleRatio, mAntiScaleRatio);
tr
.
scale
(
mAntiscaleRatio
,
mAntiscaleRatio
);
mDeleteButton
->
setParentItem
(
this
);
//
mDeleteButton->setTransform(tr);
mDeleteButton
->
setTransform
(
tr
);
qreal
topX
=
rect
().
left
()
-
mDeleteButton
->
renderer
()
->
viewBox
().
width
()
/** mAntiScaleRatio*/
*
1.2
;
qreal
topY
=
rect
().
top
()
-
mDeleteButton
->
renderer
()
->
viewBox
().
height
()
/** mAntiScaleRatio*/
*
1.2
;
QRectF
frRect
=
boundingRect
();
qreal
bottomX
=
rect
().
left
()
-
mDeleteButton
->
renderer
()
->
viewBox
().
width
()
/** mAntiScaleRatio*/
/
2
;
qreal
bottomY
=
rect
().
bottom
()
-
mDeleteButton
->
renderer
()
->
viewBox
().
height
()
/** mAntiScaleRatio*/
/
2
;
qreal
topX
=
frRect
.
left
()
-
mDeleteButton
->
renderer
()
->
viewBox
().
width
()
*
mAntiscaleRatio
/
2
;
qreal
topY
=
frRect
.
top
()
-
mDeleteButton
->
renderer
()
->
viewBox
().
height
()
*
mAntiscaleRatio
/
2
;
mDeleteButton
->
setPos
(
topX
,
topY
)
;
// mDeleteButton->setPos(0, 0)
;
qreal
bottomX
=
topX
;
qreal
bottomY
=
frRect
.
bottom
()
-
mDeleteButton
->
renderer
()
->
viewBox
().
height
()
*
mAntiscaleRatio
/
2
;
// if (!mDeleteButton->scene())
// {
// if (scene())
// scene()->addItem(mDeleteButton);
// }
mDeleteButton
->
setPos
(
topX
,
topY
);
mDeleteButton
->
show
();
// if (showUpdated)
// mDeleteButton->show();
// int i = 1, j = 0, k = 0;
// while ((i + j + k) < mButtons.size()) {
// DelegateButton* button = mButtons[i + j];
// if (button->getSection() == Qt::TopLeftSection) {
// button->setParentItem(mFrame);
// button->setPos(topX + (i++ * 1.6 * mFrameWidth * mAntiScaleRatio), topY);
// button->setTransform(tr);
// } else if (button->getSection() == Qt::BottomLeftSection) {
// button->setParentItem(mFrame);
// button->setPos(bottomX + (++j * 1.6 * mFrameWidth * mAntiScaleRatio), bottomY);
// button->setTransform(tr);
// } else if (button->getSection() == Qt::TitleBarArea || button->getSection() == Qt::NoSection){
// ++k;
// }
// if (!button->scene())
// {
// if (mDelegated->scene())
// mDelegated->scene()->addItem(button);
// }
// if (showUpdated) {
// button->show();
// button->setZValue(delegated()->zValue());
// }
// }
int
i
=
1
,
j
=
0
,
k
=
0
;
while
((
i
+
j
+
k
)
<
mButtons
.
size
())
{
DelegateButton
*
button
=
mButtons
[
i
+
j
];
if
(
button
->
getSection
()
==
Qt
::
TopLeftSection
)
{
button
->
setParentItem
(
this
);
button
->
setPos
(
topX
+
(
i
++
*
1.6
*
adjThickness
()),
topY
);
button
->
setTransform
(
tr
);
}
else
if
(
button
->
getSection
()
==
Qt
::
BottomLeftSection
)
{
button
->
setParentItem
(
this
);
button
->
setPos
(
bottomX
+
(
++
j
*
1.6
*
adjThickness
()),
bottomY
);
button
->
setTransform
(
tr
);
}
else
{
++
k
;
}
button
->
show
();
}
}
void
UBSelectionFrame
::
clearButtons
()
...
...
src/domain/UBSelectionFrame.h
View file @
4576b453
...
...
@@ -40,6 +40,7 @@ private:
void
translateItem
(
QGraphicsItem
*
item
,
const
QPointF
&
translatePoint
);
void
placeButtons
();
void
clearButtons
();
inline
int
adjThickness
()
const
{
return
mThickness
*
mAntiscaleRatio
;}
private
:
int
mThickness
;
...
...
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