Improvements to display of eraser and highlighter preview circles

- Defined constants in UBSettings for highlighter preview circle colors
- Switch between light and dark colors when changing backgrounds
- For eraser: use color settings that were defined in UBSettings (they
were ignored since the preview circle was added)
preferencesAboutTextFull
Craig Watson 8 years ago
parent 9f3fa2fa86
commit bff9b39a71
  1. 6
      src/core/UBSettings.cpp
  2. 6
      src/core/UBSettings.h
  3. 76
      src/domain/UBGraphicsScene.cpp
  4. 2
      src/domain/UBGraphicsScene.h

@ -78,6 +78,12 @@ QBrush UBSettings::eraserBrushDarkBackground = QBrush(QColor(127, 127, 127, 30))
QPen UBSettings::eraserPenDarkBackground = QPen(QColor(255, 255, 255, 63)); QPen UBSettings::eraserPenDarkBackground = QPen(QColor(255, 255, 255, 63));
QPen UBSettings::eraserPenLightBackground = QPen(QColor(0, 0, 0, 63)); QPen UBSettings::eraserPenLightBackground = QPen(QColor(0, 0, 0, 63));
QColor UBSettings::markerCircleBrushColorDarkBackground = QColor(127, 127, 127, 30);
QColor UBSettings::markerCircleBrushColorLightBackground = QColor(255, 255, 255, 30);
QColor UBSettings::markerCirclePenColorDarkBackground = QColor(255, 255, 255, 63);
QColor UBSettings::markerCirclePenColorLightBackground = QColor(0, 0, 0, 63);
QColor UBSettings::documentSizeMarkColorDarkBackground = QColor(44, 44, 44, 200); QColor UBSettings::documentSizeMarkColorDarkBackground = QColor(44, 44, 44, 200);
QColor UBSettings::documentSizeMarkColorLightBackground = QColor(241, 241, 241); QColor UBSettings::documentSizeMarkColorLightBackground = QColor(241, 241, 241);

@ -172,6 +172,12 @@ class UBSettings : public QObject
static QPen eraserPenDarkBackground; static QPen eraserPenDarkBackground;
static QPen eraserPenLightBackground; static QPen eraserPenLightBackground;
static QColor markerCircleBrushColorDarkBackground;
static QColor markerCircleBrushColorLightBackground;
static QColor markerCirclePenColorDarkBackground;
static QColor markerCirclePenColorLightBackground;
static QColor documentSizeMarkColorDarkBackground; static QColor documentSizeMarkColorDarkBackground;
static QColor documentSizeMarkColorLightBackground; static QColor documentSizeMarkColorLightBackground;

@ -660,14 +660,14 @@ bool UBGraphicsScene::inputDeviceRelease()
void UBGraphicsScene::drawEraser(const QPointF &pPoint, bool pressed) void UBGraphicsScene::drawEraser(const QPointF &pPoint, bool pressed)
{ {
qreal eraserWidth = UBSettings::settings()->currentEraserWidth(); if (mEraser) {
eraserWidth /= UBApplication::boardController->systemScaleFactor(); qreal eraserWidth = UBSettings::settings()->currentEraserWidth();
eraserWidth /= UBApplication::boardController->currentZoom(); eraserWidth /= UBApplication::boardController->systemScaleFactor();
eraserWidth /= UBApplication::boardController->currentZoom();
qreal eraserRadius = eraserWidth / 2; qreal eraserRadius = eraserWidth / 2;
// TODO UB 4.x optimize - no need to do that every time we move it // TODO UB 4.x optimize - no need to do that every time we move it
if (mEraser) {
mEraser->setRect(QRectF(pPoint.x() - eraserRadius, pPoint.y() - eraserRadius, eraserWidth, eraserWidth)); mEraser->setRect(QRectF(pPoint.x() - eraserRadius, pPoint.y() - eraserRadius, eraserWidth, eraserWidth));
redrawEraser(pressed); redrawEraser(pressed);
} }
@ -676,11 +676,14 @@ void UBGraphicsScene::drawEraser(const QPointF &pPoint, bool pressed)
void UBGraphicsScene::redrawEraser(bool pressed) void UBGraphicsScene::redrawEraser(bool pressed)
{ {
if (mEraser) { if (mEraser) {
QPen pen = mEraser->pen();
if(pressed) if(pressed)
mEraser->setPen(QPen(Qt::SolidLine)); pen.setStyle(Qt::SolidLine);
else else
mEraser->setPen(QPen(Qt::DotLine)); pen.setStyle(Qt::DotLine);
mEraser->setPen(pen);
mEraser->show(); mEraser->show();
} }
} }
@ -947,20 +950,8 @@ void UBGraphicsScene::setBackground(bool pIsDark, bool pIsCrossed)
{ {
mDarkBackground = pIsDark; mDarkBackground = pIsDark;
if (mEraser) updateEraserColor(mDarkBackground);
{ updateMarkerCircleColor(mDarkBackground);
if (mDarkBackground)
{
mEraser->setBrush(UBSettings::eraserBrushDarkBackground);
mEraser->setPen(UBSettings::eraserPenDarkBackground);
}
else
{
mEraser->setBrush(UBSettings::eraserBrushLightBackground);
mEraser->setPen(UBSettings::eraserPenLightBackground);
}
}
recolorAllItems(); recolorAllItems();
needRepaint = true; needRepaint = true;
@ -2534,6 +2525,8 @@ void UBGraphicsScene::createEraiser()
mEraser->setRect(QRect(0, 0, 0, 0)); mEraser->setRect(QRect(0, 0, 0, 0));
mEraser->setVisible(false); mEraser->setVisible(false);
updateEraserColor(mDarkBackground);
mEraser->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control)); mEraser->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control));
mEraser->setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::Eraiser)); //Necessary to set if we want z value to be assigned correctly mEraser->setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::Eraiser)); //Necessary to set if we want z value to be assigned correctly
@ -2566,7 +2559,8 @@ void UBGraphicsScene::createMarkerCircle()
mMarkerCircle->setRect(QRect(0, 0, 0, 0)); mMarkerCircle->setRect(QRect(0, 0, 0, 0));
mMarkerCircle->setVisible(false); mMarkerCircle->setVisible(false);
mMarkerCircle->setPen(Qt::DotLine); // TODO: set line color to black on white, or white on black mMarkerCircle->setPen(Qt::DotLine);
updateMarkerCircleColor(mDarkBackground);
mMarkerCircle->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control)); mMarkerCircle->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control));
mMarkerCircle->setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::Eraiser)); mMarkerCircle->setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::Eraiser));
@ -2576,6 +2570,44 @@ void UBGraphicsScene::createMarkerCircle()
} }
} }
void UBGraphicsScene::updateEraserColor(bool darkBackground)
{
if (!mEraser)
return;
if (darkBackground) {
mEraser->setBrush(UBSettings::eraserBrushDarkBackground);
mEraser->setPen(UBSettings::eraserPenDarkBackground);
}
else {
mEraser->setBrush(UBSettings::eraserBrushLightBackground);
mEraser->setPen(UBSettings::eraserPenLightBackground);
}
}
void UBGraphicsScene::updateMarkerCircleColor(bool darkBackground)
{
if (!mMarkerCircle)
return;
QBrush mcBrush = mMarkerCircle->brush();
QPen mcPen = mMarkerCircle->pen();
if (darkBackground) {
mcBrush.setColor(UBSettings::markerCircleBrushColorDarkBackground);
mcPen.setColor(UBSettings::markerCirclePenColorDarkBackground);
}
else {
mcBrush.setColor(UBSettings::markerCircleBrushColorLightBackground);
mcPen.setColor(UBSettings::markerCirclePenColorLightBackground);
}
mMarkerCircle->setBrush(mcBrush);
mMarkerCircle->setPen(mcPen);
}
void UBGraphicsScene::setToolCursor(int tool) void UBGraphicsScene::setToolCursor(int tool)
{ {
if (tool == (int)UBStylusTool::Selector || if (tool == (int)UBStylusTool::Selector ||

@ -385,6 +385,8 @@ public slots:
void createEraiser(); void createEraiser();
void createPointer(); void createPointer();
void createMarkerCircle(); void createMarkerCircle();
void updateEraserColor(bool darkBackground);
void updateMarkerCircleColor(bool darkBackground);
bool hasTextItemWithFocus(UBGraphicsGroupContainerItem* item); bool hasTextItemWithFocus(UBGraphicsGroupContainerItem* item);
QGraphicsEllipseItem* mEraser; QGraphicsEllipseItem* mEraser;

Loading…
Cancel
Save