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
41d8e4e4
Commit
41d8e4e4
authored
Aug 14, 2012
by
Aleksei Kanash
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reworked painting of rotation angle for UBGraphicsDelegateFrame. Now angle showed as mouse cursor.
parent
0707f90a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
42 additions
and
92 deletions
+42
-92
UBAngleWidget.cpp
src/domain/UBAngleWidget.cpp
+0
-48
UBAngleWidget.h
src/domain/UBAngleWidget.h
+0
-25
UBGraphicsDelegateFrame.cpp
src/domain/UBGraphicsDelegateFrame.cpp
+41
-13
UBGraphicsDelegateFrame.h
src/domain/UBGraphicsDelegateFrame.h
+1
-4
domain.pri
src/domain/domain.pri
+0
-2
No files found.
src/domain/UBAngleWidget.cpp
deleted
100644 → 0
View file @
0707f90a
#include "UBAngleWidget.h"
#include <QPainter>
#include "core/memcheck.h"
UBAngleWidget
::
UBAngleWidget
(
QWidget
*
parent
)
:
QWidget
(
parent
)
{
this
->
setFixedSize
(
45
,
30
);
this
->
setWindowFlags
(
Qt
::
FramelessWindowHint
|
Qt
::
WindowStaysOnTopHint
);
this
->
setAttribute
(
Qt
::
WA_TranslucentBackground
);
QImage
mask_img
(
width
(),
height
(),
QImage
::
Format_Mono
);
mask_img
.
fill
(
0xff
);
QPainter
mask_ptr
(
&
mask_img
);
mask_ptr
.
setBrush
(
QBrush
(
QColor
(
0
,
0
,
0
)
)
);
mask_ptr
.
drawRoundedRect
(
0
,
0
,
this
->
geometry
().
width
()
-
6
,
this
->
geometry
().
height
()
-
6
,
1
,
1
);
bmpMask
=
QBitmap
::
fromImage
(
mask_img
);
this
->
setMask
(
bmpMask
);
}
UBAngleWidget
::~
UBAngleWidget
()
{
}
void
UBAngleWidget
::
paintEvent
(
QPaintEvent
*
event
)
{
Q_UNUSED
(
event
);
this
->
move
(
this
->
cursor
().
pos
().
x
(),
this
->
cursor
().
pos
().
y
()
-
30
);
QPainter
painter
(
this
);
painter
.
setRenderHints
(
QPainter
::
Antialiasing
|
QPainter
::
SmoothPixmapTransform
);
QBrush
brush
(
Qt
::
white
);
painter
.
setBrush
(
brush
);
painter
.
drawRoundedRect
(
1
,
1
,
this
->
geometry
().
width
()
-
10
,
this
->
geometry
().
height
()
-
10
,
1
,
1
);
painter
.
setPen
(
QColor
(
85
,
50
,
127
));
painter
.
setFont
(
QFont
(
"Arial"
,
10
));
painter
.
drawText
(
1
,
1
,
this
->
geometry
().
width
()
-
10
,
this
->
geometry
().
height
()
-
10
,
Qt
::
AlignCenter
,
text
);
}
void
UBAngleWidget
::
setText
(
QString
newText
)
{
text
=
newText
;
text
.
append
(
QChar
(
176
));
}
\ No newline at end of file
src/domain/UBAngleWidget.h
deleted
100644 → 0
View file @
0707f90a
#ifndef UBANGLEWIDGET_H
#define UBANGLEWIDGET_H
#include <QWidget>
#include <QBitmap>
class
UBAngleWidget
:
public
QWidget
{
Q_OBJECT
public
:
UBAngleWidget
(
QWidget
*
parent
=
0
);
~
UBAngleWidget
();
void
setText
(
QString
);
protected
:
void
paintEvent
(
QPaintEvent
*
event
);
private
:
QString
text
;
QBitmap
bmpMask
;
};
#endif // UBANGLEWIDGET_H
src/domain/UBGraphicsDelegateFrame.cpp
View file @
41d8e4e4
...
...
@@ -21,6 +21,9 @@
#include "core/UBApplication.h"
#include "core/UBSettings.h"
#include "board/UBBoardController.h"
#include "board/UBBoardView.h"
#include "domain/UBGraphicsItemDelegate.h"
#include "domain/UBGraphicsScene.h"
#include "domain/UBGraphicsProxyWidget.h"
...
...
@@ -90,14 +93,11 @@ UBGraphicsDelegateFrame::UBGraphicsDelegateFrame(UBGraphicsItemDelegate* pDelega
positionHandles
();
this
->
setAcceptHoverEvents
(
true
);
angleWidget
=
new
UBAngleWidget
();
}
UBGraphicsDelegateFrame
::~
UBGraphicsDelegateFrame
()
{
delete
angleWidget
;
// NOOP
}
...
...
@@ -226,10 +226,46 @@ void UBGraphicsDelegateFrame::mousePressEvent(QGraphicsSceneMouseEvent *event)
mInitialTransform
=
buildTransform
();
mCurrentTool
=
toolFromPos
(
event
->
pos
());
setCursorFromAngle
(
QString
(
""
));
event
->
accept
();
}
void
UBGraphicsDelegateFrame
::
setCursorFromAngle
(
QString
angle
)
{
if
(
mCurrentTool
==
Rotate
)
{
QWidget
*
controlViewport
=
UBApplication
::
boardController
->
controlView
()
->
viewport
();
QSize
cursorSize
(
45
,
30
);
QImage
mask_img
(
cursorSize
,
QImage
::
Format_Mono
);
mask_img
.
fill
(
0xff
);
QPainter
mask_ptr
(
&
mask_img
);
mask_ptr
.
setBrush
(
QBrush
(
QColor
(
0
,
0
,
0
)
)
);
mask_ptr
.
drawRoundedRect
(
0
,
0
,
cursorSize
.
width
()
-
1
,
cursorSize
.
height
()
-
1
,
6
,
6
);
QBitmap
bmpMask
=
QBitmap
::
fromImage
(
mask_img
);
QPixmap
pixCursor
(
cursorSize
);
pixCursor
.
fill
(
QColor
(
Qt
::
white
));
QPainter
painter
(
&
pixCursor
);
painter
.
setRenderHints
(
QPainter
::
Antialiasing
|
QPainter
::
SmoothPixmapTransform
);
painter
.
setBrush
(
QBrush
(
Qt
::
white
));
painter
.
setPen
(
QPen
(
QColor
(
Qt
::
black
)));
painter
.
drawRoundedRect
(
1
,
1
,
cursorSize
.
width
()
-
2
,
cursorSize
.
height
()
-
2
,
6
,
6
);
painter
.
setFont
(
QFont
(
"Arial"
,
10
));
painter
.
drawText
(
1
,
1
,
cursorSize
.
width
(),
cursorSize
.
height
(),
Qt
::
AlignCenter
,
angle
.
append
(
QChar
(
176
)));
painter
.
end
();
pixCursor
.
setMask
(
bmpMask
);
controlViewport
->
setCursor
(
pixCursor
);
}
}
bool
UBGraphicsDelegateFrame
::
canResizeBottomRight
(
qreal
width
,
qreal
height
,
qreal
scaleFactor
)
{
bool
res
=
false
;
...
...
@@ -427,12 +463,7 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
}
}
if
(
!
angleWidget
->
isVisible
())
angleWidget
->
show
();
angleWidget
->
setText
(
QString
::
number
((
int
)
mAngle
%
360
));
angleWidget
->
update
();
setCursorFromAngle
(
QString
::
number
((
int
)
mAngle
%
360
));
}
else
if
(
moving
())
{
...
...
@@ -525,9 +556,6 @@ QTransform UBGraphicsDelegateFrame::buildTransform()
void
UBGraphicsDelegateFrame
::
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
if
(
angleWidget
->
isVisible
())
angleWidget
->
hide
();
updateResizeCursors
();
mDelegate
->
commitUndoStep
();
...
...
src/domain/UBGraphicsDelegateFrame.h
View file @
41d8e4e4
...
...
@@ -18,7 +18,6 @@
#include <QtGui>
#include "core/UB.h"
#include "domain/UBAngleWidget.h"
class
QGraphicsSceneMouseEvent
;
class
UBGraphicsItemDelegate
;
...
...
@@ -65,6 +64,7 @@ class UBGraphicsDelegateFrame: public QGraphicsRectItem, public QObject
inline
bool
resizingTop
()
const
{
return
mCurrentTool
==
ResizeTop
;
}
inline
bool
rotating
()
const
{
return
mCurrentTool
==
Rotate
;
}
inline
bool
moving
()
const
{
return
mCurrentTool
==
Move
;
}
void
setCursorFromAngle
(
QString
angle
);
bool
canResizeBottomRight
(
qreal
width
,
qreal
height
,
qreal
scaleFactor
);
QTransform
buildTransform
();
...
...
@@ -120,8 +120,5 @@ class UBGraphicsDelegateFrame: public QGraphicsRectItem, public QObject
bool
mResizing
;
bool
mMirroredXAtStart
;
bool
mMirroredYAtStart
;
UBAngleWidget
*
angleWidget
;
};
#endif
/* UBGRAPHICSDELEGATEFRAME_H_ */
src/domain/domain.pri
View file @
41d8e4e4
...
...
@@ -18,7 +18,6 @@ HEADERS += src/domain/UBGraphicsScene.h \
src/domain/UBGraphicsStroke.h \
src/domain/UBGraphicsMediaItem.h \
src/domain/UBAbstractUndoCommand.h\
src/domain/UBAngleWidget.h \
src/domain/UBGraphicsGroupContainerItem.h \
src/domain/UBGraphicsGroupContainerItemDelegate.h \
src/domain/UBGraphicsStrokesGroup.h
...
...
@@ -50,7 +49,6 @@ SOURCES += src/domain/UBGraphicsScene.cpp \
src/domain/UBGraphicsStroke.cpp \
src/domain/UBGraphicsMediaItem.cpp \
src/domain/UBAbstractUndoCommand.cpp \
src/domain/UBAngleWidget.cpp \
src/domain/ubgraphicsgroupcontaineritem.cpp \
src/domain/ubgraphicsgroupcontaineritemdelegate.cpp \
src/domain/UBGraphicsStrokesGroup.cpp
...
...
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