Added preview circle around highlighter tool

preferencesAboutTextFull
Craig Watson 9 years ago
parent a8f2ef6699
commit 35000fe7d2
  1. 6
      src/board/UBBoardPaletteManager.cpp
  2. 67
      src/domain/UBGraphicsScene.cpp
  3. 9
      src/domain/UBGraphicsScene.h

@ -540,7 +540,7 @@ void UBBoardPaletteManager::activeSceneChanged()
int pageIndex = UBApplication::boardController->activeSceneIndex();
if (mStylusPalette)
connect(mStylusPalette, SIGNAL(mouseEntered()), activeScene, SLOT(hideEraser()));
connect(mStylusPalette, SIGNAL(mouseEntered()), activeScene, SLOT(hideTool()));
if (mpPageNavigWidget)
{
@ -548,10 +548,10 @@ void UBBoardPaletteManager::activeSceneChanged()
}
if (mZoomPalette)
connect(mZoomPalette, SIGNAL(mouseEntered()), activeScene, SLOT(hideEraser()));
connect(mZoomPalette, SIGNAL(mouseEntered()), activeScene, SLOT(hideTool()));
if (mBackgroundsPalette)
connect(mBackgroundsPalette, SIGNAL(mouseEntered()), activeScene, SLOT(hideEraser()));
connect(mBackgroundsPalette, SIGNAL(mouseEntered()), activeScene, SLOT(hideTool()));
}

@ -314,6 +314,7 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent, bool enableUndoRedoSta
: UBCoreGraphicsScene(parent)
, mEraser(0)
, mPointer(0)
, mMarkerCircle(0)
, mDocument(parent)
, mDarkBackground(false)
, mCrossedBackground(false)
@ -341,6 +342,7 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent, bool enableUndoRedoSta
setDocument(parent);
createEraiser();
createPointer();
createMarkerCircle();
if (UBApplication::applicationController)
{
@ -399,6 +401,10 @@ bool UBGraphicsScene::inputDevicePress(const QPointF& scenePos, const qreal& pre
mCurrentStroke = NULL;
}
// hide the marker preview circle
if (currentTool == UBStylusTool::Marker)
hideMarkerCircle();
// ---------------------------------------------------------------
// Create a new Stroke. A Stroke is a collection of QGraphicsLines
// ---------------------------------------------------------------
@ -470,6 +476,15 @@ bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pres
accepted = true;
}
else if (currentTool == UBStylusTool::Marker) {
if (mInputDeviceIsPressed)
hideMarkerCircle();
else {
drawMarkerCircle(position);
accepted = true;
}
}
if (mInputDeviceIsPressed)
{
if (dc->isDrawingTool())
@ -670,6 +685,12 @@ void UBGraphicsScene::redrawEraser(bool pressed)
}
}
void UBGraphicsScene::hideEraser()
{
if (mEraser)
mEraser->hide();
}
void UBGraphicsScene::drawPointer(const QPointF &pPoint, bool isFirstDraw)
{
qreal pointerDiameter = UBSettings::pointerDiameter / UBApplication::boardController->currentZoom();
@ -687,6 +708,28 @@ void UBGraphicsScene::drawPointer(const QPointF &pPoint, bool isFirstDraw)
}
}
void UBGraphicsScene::drawMarkerCircle(const QPointF &pPoint)
{
if (mMarkerCircle) {
qreal markerDiameter = UBSettings::settings()->currentMarkerWidth();
markerDiameter /= UBApplication::boardController->systemScaleFactor();
markerDiameter /= UBApplication::boardController->currentZoom();
qreal markerRadius = markerDiameter/2;
mMarkerCircle->setRect(QRectF(pPoint.x() - markerRadius, pPoint.y() - markerRadius,
markerDiameter, markerDiameter));
mMarkerCircle->show();
}
}
void UBGraphicsScene::hideMarkerCircle()
{
if (mMarkerCircle) {
mMarkerCircle->hide();
}
}
// call this function when user release mouse button in Magnifier mode
void UBGraphicsScene::DisposeMagnifierQWidgets()
{
@ -1105,16 +1148,16 @@ UBGraphicsPolygonItem* UBGraphicsScene::polygonToPolygonItem(const QPolygonF pPo
return polygonItem;
}
void UBGraphicsScene::hideEraser()
void UBGraphicsScene::hideTool()
{
if (mEraser)
mEraser->hide();
hideEraser();
hideMarkerCircle();
}
void UBGraphicsScene::leaveEvent(QEvent * event)
{
Q_UNUSED(event);
hideEraser();
hideTool();
}
UBGraphicsScene* UBGraphicsScene::sceneDeepCopy() const
@ -2514,6 +2557,22 @@ void UBGraphicsScene::createPointer()
addItem(mPointer);
}
void UBGraphicsScene::createMarkerCircle()
{
mMarkerCircle = new QGraphicsEllipseItem();
mMarkerCircle->setRect(QRect(0, 0, 0, 0));
mMarkerCircle->setVisible(false);
mMarkerCircle->setPen(Qt::DotLine); // TODO: set line color to black on white, or white on black
mMarkerCircle->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control));
mMarkerCircle->setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::Eraiser));
mTools << mMarkerCircle;
addItem(mMarkerCircle);
}
void UBGraphicsScene::setToolCursor(int tool)
{
if (tool == (int)UBStylusTool::Selector ||

@ -323,7 +323,7 @@ public slots:
void updateSelectionFrame();
void updateSelectionFrameWrapper(int);
void initStroke();
void hideEraser();
void hideTool();
void setBackground(bool pIsDark, bool pIsCrossed);
void setBackgroundZoomFactor(qreal zoom);
@ -361,7 +361,10 @@ public slots:
void drawEraser(const QPointF& pEndPoint, bool pressed = true);
void redrawEraser(bool pressed);
void hideEraser();
void drawPointer(const QPointF& pEndPoint, bool isFirstDraw = false);
void drawMarkerCircle(const QPointF& pEndPoint);
void hideMarkerCircle();
void DisposeMagnifierQWidgets();
@ -381,10 +384,12 @@ public slots:
void setDocumentUpdated();
void createEraiser();
void createPointer();
void createMarkerCircle();
bool hasTextItemWithFocus(UBGraphicsGroupContainerItem* item);
QGraphicsEllipseItem* mEraser;
QGraphicsEllipseItem* mPointer;
QGraphicsEllipseItem* mPointer; // "laser" pointer
QGraphicsEllipseItem* mMarkerCircle; // dotted circle around marker
QSet<QGraphicsItem*> mAddedItems;
QSet<QGraphicsItem*> mRemovedItems;

Loading…
Cancel
Save