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
4b0a4ab3
Commit
4b0a4ab3
authored
Apr 29, 2013
by
Claudio Valerio
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
restored old graphics delegate behavior and added new stroke smoothing behavior
parent
10a22d7c
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
148 additions
and
140 deletions
+148
-140
UBBoardController.cpp
src/board/UBBoardController.cpp
+3
-1
UBGraphicsDelegateFrame.h
src/domain/UBGraphicsDelegateFrame.h
+2
-3
UBGraphicsItemDelegate.cpp
src/domain/UBGraphicsItemDelegate.cpp
+45
-95
UBGraphicsItemDelegate.h
src/domain/UBGraphicsItemDelegate.h
+1
-2
UBGraphicsPolygonItem.cpp
src/domain/UBGraphicsPolygonItem.cpp
+14
-9
UBGraphicsPolygonItem.h
src/domain/UBGraphicsPolygonItem.h
+1
-0
UBGraphicsScene.cpp
src/domain/UBGraphicsScene.cpp
+13
-1
UBGraphicsScene.h
src/domain/UBGraphicsScene.h
+6
-4
UBGraphicsTextItem.cpp
src/domain/UBGraphicsTextItem.cpp
+8
-10
UBGraphicsTextItemDelegate.cpp
src/domain/UBGraphicsTextItemDelegate.cpp
+10
-13
UBGeometryUtils.cpp
src/frameworks/UBGeometryUtils.cpp
+43
-0
UBGeometryUtils.h
src/frameworks/UBGeometryUtils.h
+1
-0
UBGraphicsCurtainItemDelegate.cpp
src/tools/UBGraphicsCurtainItemDelegate.cpp
+1
-2
No files found.
src/board/UBBoardController.cpp
View file @
4b0a4ab3
...
...
@@ -2068,7 +2068,9 @@ void UBBoardController::grabScene(const QRectF& pSceneRect)
mActiveScene
->
render
(
&
painter
,
targetRect
,
pSceneRect
);
mActiveScene
->
setRenderingContext
(
UBGraphicsScene
::
Screen
);
mActiveScene
->
setRenderingQuality
(
UBItem
::
RenderingQualityNormal
);
// mActiveScene->setRenderingQuality(UBItem::RenderingQualityNormal);
mActiveScene
->
setRenderingQuality
(
UBItem
::
RenderingQualityHigh
);
mPaletteManager
->
addItem
(
QPixmap
::
fromImage
(
image
));
selectedDocument
()
->
setMetaData
(
UBSettings
::
documentUpdatedAt
,
UBStringUtils
::
toUtcIsoDateTime
(
QDateTime
::
currentDateTime
()));
...
...
src/domain/UBGraphicsDelegateFrame.h
View file @
4b0a4ab3
...
...
@@ -39,8 +39,7 @@ class UBGraphicsDelegateFrame: public QGraphicsRectItem, public QObject
UBGraphicsDelegateFrame
(
UBGraphicsItemDelegate
*
pDelegate
,
QRectF
pRect
,
qreal
pFrameWidth
,
bool
respectRatio
=
true
);
virtual
~
UBGraphicsDelegateFrame
();
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
QPainterPath
shape
()
const
;
...
...
@@ -54,7 +53,7 @@ class UBGraphicsDelegateFrame: public QGraphicsRectItem, public QObject
void
positionHandles
();
void
setVisible
(
bool
visible
);
virtual
void
setAntiScale
(
qreal
pAntiScale
);
virtual
void
setAntiScale
(
qreal
pAntiScale
);
enum
OperationMode
{
Scaling
,
Resizing
,
ResizingHorizontally
};
void
setOperationMode
(
OperationMode
pMode
)
{
mOperationMode
=
pMode
;}
...
...
src/domain/UBGraphicsItemDelegate.cpp
View file @
4b0a4ab3
...
...
@@ -179,51 +179,51 @@ UBGraphicsItemDelegate::UBGraphicsItemDelegate(QGraphicsItem* pDelegated, QObjec
void
UBGraphicsItemDelegate
::
init
()
{
//
if (mToolBarUsed)
//
mToolBarItem = new UBGraphicsToolBarItem(mDelegated);
//
mFrame = new UBGraphicsDelegateFrame(this, QRectF(0, 0, 0, 0), mFrameWidth, mRespectRatio);
//
mFrame->hide();
//
mFrame->setFlag(QGraphicsItem::ItemIsSelectable, true);
//
mDeleteButton = new DelegateButton(":/images/close.svg", mDelegated, mFrame, Qt::TopLeftSection);
//
mButtons << mDeleteButton;
//
connect(mDeleteButton, SIGNAL(clicked()), this, SLOT(remove()));
//
if (canDuplicate()){
//
mDuplicateButton = new DelegateButton(":/images/duplicate.svg", mDelegated, mFrame, Qt::TopLeftSection);
//
connect(mDuplicateButton, SIGNAL(clicked(bool)), this, SLOT(duplicate()));
//
mButtons << mDuplicateButton;
//
}
//
mMenuButton = new DelegateButton(":/images/menu.svg", mDelegated, mFrame, Qt::TopLeftSection);
//
connect(mMenuButton, SIGNAL(clicked()), this, SLOT(showMenu()));
//
mButtons << mMenuButton;
//
mZOrderUpButton = new DelegateButton(":/images/z_layer_up.svg", mDelegated, mFrame, 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", mDelegated, mFrame, Qt::BottomLeftSection);
//
mZOrderDownButton->setShowProgressIndicator(true);
//
connect(mZOrderDownButton, SIGNAL(clicked()), this, SLOT(increaseZLevelDown()));
//
connect(mZOrderDownButton, SIGNAL(longClicked()), this, SLOT(increaseZlevelBottom()));
//
mButtons << mZOrderDownButton;
//
buildButtons();
//
foreach(DelegateButton* button, mButtons)
//
{
//
if (button->getSection() != Qt::TitleBarArea)
//
{
//
button->hide();
//
button->setFlag(QGraphicsItem::ItemIsSelectable, true);
//
}
//
}
//
//Wrapper function. Use it to set correct data() to QGraphicsItem as well
//
setFlippable(false);
//
setRotatable(false);
if
(
mToolBarUsed
)
mToolBarItem
=
new
UBGraphicsToolBarItem
(
mDelegated
);
mFrame
=
new
UBGraphicsDelegateFrame
(
this
,
QRectF
(
0
,
0
,
0
,
0
),
mFrameWidth
,
mRespectRatio
);
mFrame
->
hide
();
mFrame
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
mDeleteButton
=
new
DelegateButton
(
":/images/close.svg"
,
mDelegated
,
mFrame
,
Qt
::
TopLeftSection
);
mButtons
<<
mDeleteButton
;
connect
(
mDeleteButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
remove
()));
if
(
canDuplicate
()){
mDuplicateButton
=
new
DelegateButton
(
":/images/duplicate.svg"
,
mDelegated
,
mFrame
,
Qt
::
TopLeftSection
);
connect
(
mDuplicateButton
,
SIGNAL
(
clicked
(
bool
)),
this
,
SLOT
(
duplicate
()));
mButtons
<<
mDuplicateButton
;
}
mMenuButton
=
new
DelegateButton
(
":/images/menu.svg"
,
mDelegated
,
mFrame
,
Qt
::
TopLeftSection
);
connect
(
mMenuButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
showMenu
()));
mButtons
<<
mMenuButton
;
mZOrderUpButton
=
new
DelegateButton
(
":/images/z_layer_up.svg"
,
mDelegated
,
mFrame
,
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"
,
mDelegated
,
mFrame
,
Qt
::
BottomLeftSection
);
mZOrderDownButton
->
setShowProgressIndicator
(
true
);
connect
(
mZOrderDownButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
increaseZLevelDown
()));
connect
(
mZOrderDownButton
,
SIGNAL
(
longClicked
()),
this
,
SLOT
(
increaseZlevelBottom
()));
mButtons
<<
mZOrderDownButton
;
buildButtons
();
foreach
(
DelegateButton
*
button
,
mButtons
)
{
if
(
button
->
getSection
()
!=
Qt
::
TitleBarArea
)
{
button
->
hide
();
button
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
}
}
//Wrapper function. Use it to set correct data() to QGraphicsItem as well
setFlippable
(
false
);
setRotatable
(
false
);
}
...
...
@@ -236,53 +236,6 @@ UBGraphicsItemDelegate::~UBGraphicsItemDelegate()
}
void
UBGraphicsItemDelegate
::
decorate
()
{
if
(
mToolBarUsed
)
mToolBarItem
=
new
UBGraphicsToolBarItem
(
mDelegated
);
if
(
!
mFrame
){
mFrame
=
new
UBGraphicsDelegateFrame
(
this
,
QRectF
(
0
,
0
,
0
,
0
),
mFrameWidth
,
mRespectRatio
);
mFrame
->
hide
();
mFrame
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
mDeleteButton
=
new
DelegateButton
(
":/images/close.svg"
,
mDelegated
,
mFrame
,
Qt
::
TopLeftSection
);
mButtons
<<
mDeleteButton
;
connect
(
mDeleteButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
remove
()));
if
(
canDuplicate
()){
mDuplicateButton
=
new
DelegateButton
(
":/images/duplicate.svg"
,
mDelegated
,
mFrame
,
Qt
::
TopLeftSection
);
connect
(
mDuplicateButton
,
SIGNAL
(
clicked
(
bool
)),
this
,
SLOT
(
duplicate
()));
mButtons
<<
mDuplicateButton
;
}
mMenuButton
=
new
DelegateButton
(
":/images/menu.svg"
,
mDelegated
,
mFrame
,
Qt
::
TopLeftSection
);
connect
(
mMenuButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
showMenu
()));
mButtons
<<
mMenuButton
;
mZOrderUpButton
=
new
DelegateButton
(
":/images/z_layer_up.svg"
,
mDelegated
,
mFrame
,
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"
,
mDelegated
,
mFrame
,
Qt
::
BottomLeftSection
);
mZOrderDownButton
->
setShowProgressIndicator
(
true
);
connect
(
mZOrderDownButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
increaseZLevelDown
()));
connect
(
mZOrderDownButton
,
SIGNAL
(
longClicked
()),
this
,
SLOT
(
increaseZlevelBottom
()));
mButtons
<<
mZOrderDownButton
;
buildButtons
();
foreach
(
DelegateButton
*
button
,
mButtons
)
{
if
(
button
->
getSection
()
!=
Qt
::
TitleBarArea
)
{
button
->
hide
();
button
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
}
}
}
}
QVariant
UBGraphicsItemDelegate
::
itemChange
(
QGraphicsItem
::
GraphicsItemChange
change
,
const
QVariant
&
value
)
{
...
...
@@ -736,11 +689,8 @@ bool UBGraphicsItemDelegate::isFlippable()
void
UBGraphicsItemDelegate
::
updateFrame
()
{
decorate
();
if
(
mFrame
&&
!
mFrame
->
scene
()
&&
mDelegated
->
scene
())
{
mDelegated
->
scene
()
->
addItem
(
mFrame
);
}
mFrame
->
setAntiScale
(
mAntiScaleRatio
);
mFrame
->
positionHandles
();
...
...
src/domain/UBGraphicsItemDelegate.h
View file @
4b0a4ab3
...
...
@@ -220,7 +220,6 @@ class UBGraphicsItemDelegate : public QObject
virtual
~
UBGraphicsItemDelegate
();
void
init
();
void
decorate
();
virtual
bool
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
);
virtual
bool
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
);
...
...
@@ -246,7 +245,7 @@ class UBGraphicsItemDelegate : public QObject
void
startUndoStep
();
void
commitUndoStep
();
UBGraphicsDelegateFrame
*
frame
()
{
if
(
!
mFrame
)
decorate
();
return
mFrame
;
}
UBGraphicsDelegateFrame
*
frame
()
{
return
mFrame
;
}
bool
canRotate
()
const
{
return
mCanRotate
;
}
bool
isLocked
()
const
;
...
...
src/domain/UBGraphicsPolygonItem.cpp
View file @
4b0a4ab3
...
...
@@ -65,6 +65,18 @@ UBGraphicsPolygonItem::UBGraphicsPolygonItem (const QLineF& pLine, qreal pWidth)
initialize
();
}
UBGraphicsPolygonItem
::
UBGraphicsPolygonItem
(
const
QLineF
&
pLine
,
qreal
pStartWidth
,
qreal
pEndWidth
)
:
QGraphicsPolygonItem
(
UBGeometryUtils
::
lineToPolygon
(
pLine
,
pStartWidth
,
pEndWidth
))
,
mOriginalLine
(
pLine
)
,
mOriginalWidth
(
pEndWidth
)
,
mIsNominalLine
(
true
)
,
mStroke
(
0
)
{
// NOOP
initialize
();
}
void
UBGraphicsPolygonItem
::
initialize
()
{
setData
(
UBGraphicsItemData
::
itemLayerType
,
QVariant
(
itemLayerType
::
DrawingItem
));
//Necessary to set if we want z value to be assigned correctly
...
...
@@ -157,11 +169,11 @@ QColor UBGraphicsPolygonItem::color() const
UBItem
*
UBGraphicsPolygonItem
::
deepCopy
()
const
{
{
UBGraphicsPolygonItem
*
copy
=
new
UBGraphicsPolygonItem
(
polygon
(),
0
);
UBGraphicsStroke
*
stroke
=
new
UBGraphicsStroke
();
copyItemParameters
(
copy
);
copy
->
setStroke
(
stroke
);
...
...
@@ -186,7 +198,6 @@ void UBGraphicsPolygonItem::copyItemParameters(UBItem *copy) const
cp
->
setColorOnDarkBackground
(
this
->
colorOnDarkBackground
());
cp
->
setColorOnLightBackground
(
this
->
colorOnLightBackground
());
//cp->setTransform(transform());
cp
->
setData
(
UBGraphicsItemData
::
ItemLayerType
,
this
->
data
(
UBGraphicsItemData
::
ItemLayerType
));
}
...
...
@@ -195,9 +206,7 @@ void UBGraphicsPolygonItem::copyItemParameters(UBItem *copy) const
void
UBGraphicsPolygonItem
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
)
{
if
(
mHasAlpha
&&
scene
()
&&
scene
()
->
isLightBackground
())
{
painter
->
setCompositionMode
(
QPainter
::
CompositionMode_Darken
);
}
QGraphicsPolygonItem
::
paint
(
painter
,
option
,
widget
);
}
...
...
@@ -209,10 +218,6 @@ QPainterPath UBGraphicsPolygonItem::shape() const
path
.
addRect
(
boundingRect
());
return
path
;
// static QPainterPath shapePath = QGraphicsPolygonItem::shape();
// return shapePath;
}
...
...
src/domain/UBGraphicsPolygonItem.h
View file @
4b0a4ab3
...
...
@@ -42,6 +42,7 @@ class UBGraphicsPolygonItem : public QGraphicsPolygonItem, public UBItem
UBGraphicsPolygonItem
(
QGraphicsItem
*
parent
=
0
);
UBGraphicsPolygonItem
(
const
QLineF
&
line
,
qreal
pWidth
);
UBGraphicsPolygonItem
(
const
QLineF
&
pLine
,
qreal
pStartWidth
,
qreal
pEndWidth
);
UBGraphicsPolygonItem
(
const
QPolygonF
&
polygon
,
QGraphicsItem
*
parent
=
0
);
~
UBGraphicsPolygonItem
();
...
...
src/domain/UBGraphicsScene.cpp
View file @
4b0a4ab3
...
...
@@ -707,7 +707,9 @@ void UBGraphicsScene::drawLineTo(const QPointF &pEndPoint, const qreal &pWidth,
if
(
mPreviousWidth
==
-
1.0
)
mPreviousWidth
=
pWidth
;
UBGraphicsPolygonItem
*
polygonItem
=
lineToPolygonItem
(
QLineF
(
mPreviousPoint
,
pEndPoint
),
pWidth
);
// UBGraphicsPolygonItem *polygonItem = lineToPolygonItem(QLineF(mPreviousPoint, pEndPoint), pWidth);
UBGraphicsPolygonItem
*
polygonItem
=
lineToPolygonItem
(
QLineF
(
mPreviousPoint
,
pEndPoint
),
mPreviousWidth
,
pWidth
);
if
(
!
polygonItem
->
brush
().
isOpaque
())
{
...
...
@@ -949,6 +951,16 @@ UBGraphicsPolygonItem* UBGraphicsScene::lineToPolygonItem(const QLineF &pLine, c
return
polygonItem
;
}
UBGraphicsPolygonItem
*
UBGraphicsScene
::
lineToPolygonItem
(
const
QLineF
&
pLine
,
const
qreal
&
pStartWidth
,
const
qreal
&
pEndWidth
)
{
UBGraphicsPolygonItem
*
polygonItem
=
new
UBGraphicsPolygonItem
(
pLine
,
pStartWidth
,
pEndWidth
);
initPolygonItem
(
polygonItem
);
return
polygonItem
;
}
void
UBGraphicsScene
::
initPolygonItem
(
UBGraphicsPolygonItem
*
polygonItem
)
{
QColor
colorOnDarkBG
;
...
...
src/domain/UBGraphicsScene.h
View file @
4b0a4ab3
...
...
@@ -149,7 +149,7 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
UBGraphicsW3CWidgetItem
*
addW3CWidget
(
const
QUrl
&
pWidgetUrl
,
const
QPointF
&
pPos
=
QPointF
(
0
,
0
));
void
addGraphicsWidget
(
UBGraphicsWidgetItem
*
graphicsWidget
,
const
QPointF
&
pPos
=
QPointF
(
0
,
0
));
UBGraphicsMediaItem
*
addMedia
(
const
QUrl
&
pMediaFileUrl
,
bool
shouldPlayAsap
,
const
QPointF
&
pPos
=
QPointF
(
0
,
0
));
UBGraphicsMediaItem
*
addVideo
(
const
QUrl
&
pVideoFileUrl
,
bool
shouldPlayAsap
,
const
QPointF
&
pPos
=
QPointF
(
0
,
0
));
...
...
@@ -320,10 +320,10 @@ public slots:
void
setDrawingMode
(
bool
bModeDesktop
);
void
deselectAllItems
();
UBGraphicsPixmapItem
*
addPixmap
(
const
QPixmap
&
pPixmap
,
UBGraphicsPixmapItem
*
addPixmap
(
const
QPixmap
&
pPixmap
,
QGraphicsItem
*
replaceFor
,
const
QPointF
&
pPos
=
QPointF
(
0
,
0
),
qreal
scaleFactor
=
1
.
0
,
const
QPointF
&
pPos
=
QPointF
(
0
,
0
),
qreal
scaleFactor
=
1
.
0
,
bool
pUseAnimation
=
false
);
void
textUndoCommandAdded
(
UBGraphicsTextItem
*
textItem
);
...
...
@@ -346,6 +346,8 @@ public slots:
protected
:
UBGraphicsPolygonItem
*
lineToPolygonItem
(
const
QLineF
&
pLine
,
const
qreal
&
pWidth
);
UBGraphicsPolygonItem
*
lineToPolygonItem
(
const
QLineF
&
pLine
,
const
qreal
&
pStartWidth
,
const
qreal
&
pEndWidth
);
UBGraphicsPolygonItem
*
arcToPolygonItem
(
const
QLineF
&
pStartRadius
,
qreal
pSpanAngle
,
qreal
pWidth
);
void
initPolygonItem
(
UBGraphicsPolygonItem
*
);
...
...
src/domain/UBGraphicsTextItem.cpp
View file @
4b0a4ab3
...
...
@@ -55,12 +55,10 @@ UBGraphicsTextItem::UBGraphicsTextItem(QGraphicsItem * parent) :
setData
(
UBGraphicsItemData
::
ItemLayerType
,
UBItemLayerType
::
Object
);
// setData(UBGraphicsItemData::ItemEditable, QVariant(true));
setData
(
UBGraphicsItemData
::
itemLayerType
,
QVariant
(
itemLayerType
::
ObjectItem
));
//Necessary to set if we want z value to be assigned correctly
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
// setFlag(QGraphicsItem::ItemIsMovable, true);
setFlag
(
QGraphicsItem
::
ItemSendsGeometryChanges
,
true
);
setTextInteractionFlags
(
Qt
::
TextEditorInteraction
);
...
...
@@ -91,8 +89,8 @@ QVariant UBGraphicsTextItem::itemChange(GraphicsItemChange change, const QVarian
void
UBGraphicsTextItem
::
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
// scene()->itemAt(pos) returns 0 if pos is not over text, but over text item, but mouse press comes.
// It is a cludge...
// scene()->itemAt(pos) returns 0 if pos is not over text, but over text item, but mouse press comes.
// It is a cludge...
if
(
UBStylusTool
::
Play
==
UBDrawingController
::
drawingController
()
->
stylusTool
())
{
event
->
accept
();
...
...
@@ -110,13 +108,13 @@ void UBGraphicsTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
QGraphicsItem
*
curItem
=
group
->
getCurrentItem
();
if
(
curItem
&&
this
!=
curItem
)
{
group
->
deselectCurrentItem
();
}
{
group
->
deselectCurrentItem
();
}
group
->
setCurrentItem
(
this
);
this
->
setSelected
(
true
);
Delegate
()
->
positionHandles
();
}
}
}
else
...
...
@@ -178,8 +176,8 @@ void UBGraphicsTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
void
UBGraphicsTextItem
::
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
// scene()->itemAt(pos) returns 0 if pos is not over text, but over text item, but mouse press comes.
// It is a cludge...
// scene()->itemAt(pos) returns 0 if pos is not over text, but over text item, but mouse press comes.
// It is a cludge...
if
(
UBStylusTool
::
Play
==
UBDrawingController
::
drawingController
()
->
stylusTool
())
{
event
->
accept
();
...
...
src/domain/UBGraphicsTextItemDelegate.cpp
View file @
4b0a4ab3
...
...
@@ -87,14 +87,8 @@ QFont UBGraphicsTextItemDelegate::createDefaultFont()
textFormat
.
setFontItalic
(
true
);
QFont
font
(
fFamily
,
-
1
,
bold
?
QFont
::
Bold
:
-
1
,
italic
);
// int pixSize = UBSettings::settings()->fontPixelSize();
// if (pixSize > 0) {
// mLastFontPixelSize = pixSize;
// font.setPixelSize(pixSize);
// }
int
pointSize
=
UBSettings
::
settings
()
->
fontPointSize
();
if
(
pointSize
>
0
)
{
// mLastFontPixelSize = pointSize;
font
.
setPointSize
(
pointSize
);
}
...
...
@@ -227,8 +221,6 @@ void UBGraphicsTextItemDelegate::pickColor()
{
QColor
selectedColor
=
colorDialog
.
selectedColor
();
delegated
()
->
setDefaultTextColor
(
selectedColor
);
// delegated()->setColorOnDarkBackground(selectedColor);
// delegated()->setColorOnLightBackground(selectedColor);
QTextCursor
curCursor
=
delegated
()
->
textCursor
();
QTextCharFormat
format
;
format
.
setForeground
(
QBrush
(
selectedColor
));
...
...
@@ -257,6 +249,7 @@ UBGraphicsTextItem* UBGraphicsTextItemDelegate::delegated()
{
return
static_cast
<
UBGraphicsTextItem
*>
(
mDelegated
);
}
void
UBGraphicsTextItemDelegate
::
setEditable
(
bool
editable
)
{
if
(
editable
)
{
...
...
@@ -271,6 +264,7 @@ void UBGraphicsTextItemDelegate::setEditable(bool editable)
mDelegated
->
setData
(
UBGraphicsItemData
::
ItemEditable
,
QVariant
(
false
));
}
}
void
UBGraphicsTextItemDelegate
::
remove
(
bool
canUndo
)
{
UBGraphicsItemDelegate
::
remove
(
canUndo
);
...
...
@@ -280,6 +274,7 @@ bool UBGraphicsTextItemDelegate::isEditable()
{
return
mDelegated
->
data
(
UBGraphicsItemData
::
ItemEditable
).
toBool
();
}
void
UBGraphicsTextItemDelegate
::
decorateMenu
(
QMenu
*
menu
)
{
UBGraphicsItemDelegate
::
decorateMenu
(
menu
);
...
...
@@ -289,23 +284,25 @@ void UBGraphicsTextItemDelegate::decorateMenu(QMenu *menu)
mEditableAction
->
setChecked
(
isEditable
());
}
void
UBGraphicsTextItemDelegate
::
updateMenuActionState
()
{
UBGraphicsItemDelegate
::
updateMenuActionState
();
}
void
UBGraphicsTextItemDelegate
::
positionHandles
()
{
UBGraphicsItemDelegate
::
positionHandles
();
if
(
mDelegated
->
isSelected
()
||
(
mDelegated
->
parentItem
()
&&
UBGraphicsGroupContainerItem
::
Type
==
mDelegated
->
parentItem
()
->
type
()))
if
(
mDelegated
->
isSelected
()
||
(
mDelegated
->
parentItem
()
&&
UBGraphicsGroupContainerItem
::
Type
==
mDelegated
->
parentItem
()
->
type
()))
{
if
(
mToolBarItem
->
isVisibleOnBoard
())
{
qreal
AntiScaleRatio
=
1
/
(
UBApplication
::
boardController
->
systemScaleFactor
()
*
UBApplication
::
boardController
->
currentZoom
());
qreal
AntiScaleRatio
=
1
/
(
UBApplication
::
boardController
->
systemScaleFactor
()
*
UBApplication
::
boardController
->
currentZoom
());
mToolBarItem
->
setScale
(
AntiScaleRatio
);
QRectF
toolBarRect
=
mToolBarItem
->
rect
();
toolBarRect
.
setWidth
(
delegated
()
->
boundingRect
().
width
()
/
AntiScaleRatio
);
mToolBarItem
->
setRect
(
toolBarRect
);
mToolBarItem
->
setRect
(
toolBarRect
);
mToolBarItem
->
positionHandles
();
mToolBarItem
->
update
();
if
(
mToolBarItem
->
isShifting
())
...
...
@@ -374,9 +371,9 @@ void UBGraphicsTextItemDelegate::ChangeTextSize(qreal factor, textChangeMode cha
// we search continuous blocks of the text with the same PointSize and allpy new settings for them.
cursor
.
setPosition
(
startPos
,
QTextCursor
::
MoveAnchor
);
while
(
iCursorPos
<
endPos
)
{
{
bEndofTheSameBlock
=
false
;
iBlockLen
=
0
;
iBlockLen
=
0
;
cursor
.
setPosition
(
iCursorPos
+
1
,
QTextCursor
::
KeepAnchor
);
iPointSize
=
cursor
.
charFormat
().
font
().
pointSize
();
...
...
src/frameworks/UBGeometryUtils.cpp
View file @
4b0a4ab3
...
...
@@ -81,6 +81,49 @@ QPolygonF UBGeometryUtils::lineToPolygon(const QLineF& pLine, const qreal& pWidt
return
painterPath
.
toFillPolygon
();
}
QPolygonF
UBGeometryUtils
::
lineToPolygon
(
const
QLineF
&
pLine
,
const
qreal
&
pStartWidth
,
const
qreal
&
pEndWidth
)
{
qreal
x1
=
pLine
.
x1
();
qreal
y1
=
pLine
.
y1
();
qreal
x2
=
pLine
.
x2
();
qreal
y2
=
pLine
.
y2
();
qreal
alpha
=
(
90.0
-
pLine
.
angle
())
*
PI
/
180.0
;
qreal
startHypothenuse
=
pStartWidth
/
2
;
qreal
endHypothenuse
=
pEndWidth
/
2
;
// TODO UB 4.x PERF cache sin/cos table
qreal
startOpposite
=
sin
(
alpha
)
*
startHypothenuse
;
qreal
startAdjacent
=
cos
(
alpha
)
*
startHypothenuse
;
qreal
endOpposite
=
sin
(
alpha
)
*
endHypothenuse
;
qreal
endAdjacent
=
cos
(
alpha
)
*
endHypothenuse
;
QPointF
p1a
(
x1
-
startAdjacent
,
y1
-
startOpposite
);
QPointF
p1b
(
x1
+
startAdjacent
,
y1
+
startOpposite
);
QPointF
p2a
(
x2
-
endAdjacent
,
y2
-
endOpposite
);
QPointF
p2b
(
x2
+
endAdjacent
,
y2
+
endOpposite
);
QPainterPath
painterPath
;
painterPath
.
moveTo
(
p1a
);
painterPath
.
lineTo
(
p2a
);
painterPath
.
arcTo
(
x2
-
endHypothenuse
,
y2
-
endHypothenuse
,
pEndWidth
,
pEndWidth
,
(
90.0
+
pLine
.
angle
()),
-
180.0
);
//painterPath.lineTo(p2b);
painterPath
.
lineTo
(
p1b
);
painterPath
.
arcTo
(
x1
-
startHypothenuse
,
y1
-
startHypothenuse
,
pStartWidth
,
pStartWidth
,
-
1
*
(
90.0
-
pLine
.
angle
()),
-
180.0
);
painterPath
.
closeSubpath
();
return
painterPath
.
toFillPolygon
();
}
QPolygonF
UBGeometryUtils
::
lineToPolygon
(
const
QPointF
&
pStart
,
const
QPointF
&
pEnd
,
const
qreal
&
pStartWidth
,
const
qreal
&
pEndWidth
)
{
...
...
src/frameworks/UBGeometryUtils.h
View file @
4b0a4ab3
...
...
@@ -34,6 +34,7 @@ class UBGeometryUtils
public
:
static
QPolygonF
lineToPolygon
(
const
QLineF
&
pLine
,
const
qreal
&
pWidth
);
static
QPolygonF
lineToPolygon
(
const
QLineF
&
pLine
,
const
qreal
&
pStartWidth
,
const
qreal
&
pEndWidth
);
static
QRectF
lineToInnerRect
(
const
QLineF
&
pLine
,
const
qreal
&
pWidth
);
static
QPolygonF
arcToPolygon
(
const
QLineF
&
startRadius
,
qreal
spanAngle
,
qreal
width
);
...
...
src/tools/UBGraphicsCurtainItemDelegate.cpp
View file @
4b0a4ab3
...
...
@@ -45,8 +45,7 @@ UBGraphicsCurtainItemDelegate::~UBGraphicsCurtainItemDelegate()
void
UBGraphicsCurtainItemDelegate
::
init
()
{
//UBGraphicsItemDelegate::init();
decorate
();
UBGraphicsItemDelegate
::
init
();
mFrame
->
hide
();
mZOrderUpButton
->
hide
();
mZOrderDownButton
->
hide
();
...
...
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