Merge pull request #22340 from maxwxyz/3d-nav-cursors
Gui: Change navigation cursors to SVG
This commit is contained in:
25
src/Gui/Icons/cursor-pan.svg
Normal file
25
src/Gui/Icons/cursor-pan.svg
Normal file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
width="16"
|
||||
height="16"
|
||||
viewBox="0 0 4.2333332 4.2333333"
|
||||
version="1.1"
|
||||
id="svg1"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg">
|
||||
<defs
|
||||
id="defs1" />
|
||||
<g
|
||||
id="layer1">
|
||||
<path
|
||||
id="path70"
|
||||
style="baseline-shift:baseline;display:inline;overflow:visible;vector-effect:none;stroke-linecap:square;stroke-linejoin:round;enable-background:accumulate;stop-color:#000000"
|
||||
d="M 2.1171834,0.01188558 1.083138,1.083138 0.01188558,2.1171834 1.083138,3.1496785 2.1171834,4.2224812 3.1496785,3.1496785 4.2224812,2.1171834 3.1496785,1.083138 Z M 1.2908773,1.2908773 h 0.4299479 v 0.2697509 0.160197 H 1.5606282 1.2908773 Z m 1.2226643,0 H 2.9414225 V 1.7208252 H 2.6737386 2.5135416 V 1.5606282 Z M 1.2908773,2.5135416 h 0.2697509 0.160197 v 0.160197 0.2676839 H 1.2908773 Z m 1.2226643,0 h 0.160197 0.2676839 V 2.9414225 H 2.5135416 V 2.6737386 Z" />
|
||||
<path
|
||||
id="path71"
|
||||
style="baseline-shift:baseline;display:inline;overflow:visible;vector-effect:none;fill:#ffffff;stroke-linecap:square;stroke-linejoin:round;enable-background:accumulate;stop-color:#000000"
|
||||
d="M 2.1171875,0.25390625 1.28125,1.1230469 h 0.6074219 v 0.4375 0.328125 h -0.328125 -0.4375 V 1.2792969 L 0.25390625,2.1171875 1.1230469,2.953125 V 2.3457031 h 0.4375 0.328125 V 2.6738281 3.109375 H 1.2792969 L 2.1171875,3.9804688 2.9550781,3.109375 H 2.3457031 V 2.6738281 2.3457031 h 0.328125 0.4355469 v 0.609375 L 3.9804688,2.1171875 3.109375,1.2792969 v 0.609375 H 2.6738281 2.3457031 v -0.328125 -0.4375 h 0.609375 z" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.7 KiB |
25
src/Gui/Icons/cursor-rotate.svg
Normal file
25
src/Gui/Icons/cursor-rotate.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 2.3 KiB |
26
src/Gui/Icons/cursor-zoom.svg
Normal file
26
src/Gui/Icons/cursor-zoom.svg
Normal file
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
width="16"
|
||||
height="16"
|
||||
viewBox="0 0 4.2333332 4.2333333"
|
||||
version="1.1"
|
||||
id="svg1"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg">
|
||||
<defs
|
||||
id="defs1" />
|
||||
<g
|
||||
id="layer1">
|
||||
<path
|
||||
id="path79"
|
||||
style="baseline-shift:baseline;display:inline;overflow:visible;vector-effect:none;stroke-linecap:square;stroke-linejoin:round;enable-background:accumulate;stop-color:#000000"
|
||||
d="M 2.1177001,0.27595214 0.88315018,1.0257772 H 1.7213419 V 1.2955281 2.4086385 2.6763224 H 0.35398352 L 2.1177001,3.9573811 3.8793497,2.6763224 H 2.5140583 V 2.4086385 1.2955281 1.0257772 H 3.350183 Z" />
|
||||
<path
|
||||
id="path80"
|
||||
style="baseline-shift:baseline;display:inline;overflow:visible;vector-effect:none;fill:#ffffff;stroke-linecap:square;stroke-linejoin:round;enable-background:accumulate;stop-color:#000000"
|
||||
d="M 2.1171875,0.73828125 1.484375,1.1230469 h 0.4042969 v 0.4375 1.1132812 0.4355469 H 0.87304688 L 2.1171875,4.0136719 3.359375,3.109375 H 2.3457031 v -0.4355469 -1.1132812 -0.4375 h 0.4023438 z"
|
||||
transform="translate(5.1673e-4,-0.2651001)" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
@@ -38,7 +38,10 @@
|
||||
<file>clear-selection.svg</file>
|
||||
<file>colors.svg</file>
|
||||
<file>critical-info.svg</file>
|
||||
<file>cursor-pan.svg</file>
|
||||
<file>cursor-through.svg</file>
|
||||
<file>cursor-rotate.svg</file>
|
||||
<file>cursor-zoom.svg</file>
|
||||
<file>dagViewFail.svg</file>
|
||||
<file>dagViewPass.svg</file>
|
||||
<file>dagViewPending.svg</file>
|
||||
|
||||
@@ -103,6 +103,7 @@
|
||||
#include <Base/Tools2D.h>
|
||||
#include <Quarter/devices/InputDevice.h>
|
||||
#include <Quarter/eventhandlers/EventFilter.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
|
||||
#include "View3DInventorViewer.h"
|
||||
#include "Application.h"
|
||||
@@ -149,81 +150,6 @@ FC_LOG_LEVEL_INIT("3DViewer", true, true)
|
||||
|
||||
using namespace Gui;
|
||||
|
||||
// NOLINTBEGIN
|
||||
// clang-format off
|
||||
/*** zoom-style cursor ******/
|
||||
|
||||
#define ZOOM_WIDTH 16
|
||||
#define ZOOM_HEIGHT 16
|
||||
#define ZOOM_BYTES ((ZOOM_WIDTH + 7) / 8) * ZOOM_HEIGHT
|
||||
#define ZOOM_HOT_X 5
|
||||
#define ZOOM_HOT_Y 7
|
||||
|
||||
static unsigned char zoom_bitmap[ZOOM_BYTES] =
|
||||
{
|
||||
0x00, 0x0f, 0x80, 0x1c, 0x40, 0x38, 0x20, 0x70,
|
||||
0x90, 0xe4, 0xc0, 0xcc, 0xf0, 0xfc, 0x00, 0x0c,
|
||||
0x00, 0x0c, 0xf0, 0xfc, 0xc0, 0xcc, 0x90, 0xe4,
|
||||
0x20, 0x70, 0x40, 0x38, 0x80, 0x1c, 0x00, 0x0f
|
||||
};
|
||||
|
||||
static unsigned char zoom_mask_bitmap[ZOOM_BYTES] =
|
||||
{
|
||||
0x00, 0x0f, 0x80, 0x1f, 0xc0, 0x3f, 0xe0, 0x7f,
|
||||
0xf0, 0xff, 0xf0, 0xff, 0xf0, 0xff, 0x00, 0x0f,
|
||||
0x00, 0x0f, 0xf0, 0xff, 0xf0, 0xff, 0xf0, 0xff,
|
||||
0xe0, 0x7f, 0xc0, 0x3f, 0x80, 0x1f, 0x00, 0x0f
|
||||
};
|
||||
|
||||
/*** pan-style cursor *******/
|
||||
|
||||
#define PAN_WIDTH 16
|
||||
#define PAN_HEIGHT 16
|
||||
#define PAN_BYTES ((PAN_WIDTH + 7) / 8) * PAN_HEIGHT
|
||||
#define PAN_HOT_X 7
|
||||
#define PAN_HOT_Y 7
|
||||
|
||||
static unsigned char pan_bitmap[PAN_BYTES] =
|
||||
{
|
||||
0xc0, 0x03, 0x60, 0x02, 0x20, 0x04, 0x10, 0x08,
|
||||
0x68, 0x16, 0x54, 0x2a, 0x73, 0xce, 0x01, 0x80,
|
||||
0x01, 0x80, 0x73, 0xce, 0x54, 0x2a, 0x68, 0x16,
|
||||
0x10, 0x08, 0x20, 0x04, 0x40, 0x02, 0xc0, 0x03
|
||||
};
|
||||
|
||||
static unsigned char pan_mask_bitmap[PAN_BYTES] =
|
||||
{
|
||||
0xc0, 0x03, 0xe0, 0x03, 0xe0, 0x07, 0xf0, 0x0f,
|
||||
0xe8, 0x17, 0xdc, 0x3b, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xdc, 0x3b, 0xe8, 0x17,
|
||||
0xf0, 0x0f, 0xe0, 0x07, 0xc0, 0x03, 0xc0, 0x03
|
||||
};
|
||||
|
||||
/*** rotate-style cursor ****/
|
||||
|
||||
#define ROTATE_WIDTH 16
|
||||
#define ROTATE_HEIGHT 16
|
||||
#define ROTATE_BYTES ((ROTATE_WIDTH + 7) / 8) * ROTATE_HEIGHT
|
||||
#define ROTATE_HOT_X 6
|
||||
#define ROTATE_HOT_Y 8
|
||||
|
||||
static unsigned char rotate_bitmap[ROTATE_BYTES] = {
|
||||
0xf0, 0xef, 0x18, 0xb8, 0x0c, 0x90, 0xe4, 0x83,
|
||||
0x34, 0x86, 0x1c, 0x83, 0x00, 0x81, 0x00, 0xff,
|
||||
0xff, 0x00, 0x81, 0x00, 0xc1, 0x38, 0x61, 0x2c,
|
||||
0xc1, 0x27, 0x09, 0x30, 0x1d, 0x18, 0xf7, 0x0f
|
||||
};
|
||||
|
||||
static unsigned char rotate_mask_bitmap[ROTATE_BYTES] = {
|
||||
0xf0, 0xef, 0xf8, 0xff, 0xfc, 0xff, 0xfc, 0xff,
|
||||
0x3c, 0xfe, 0x1c, 0xff, 0x00, 0xff, 0x00, 0xff,
|
||||
0xff, 0x00, 0xff, 0x00, 0xff, 0x38, 0x7f, 0x3c,
|
||||
0xff, 0x3f, 0xff, 0x3f, 0xff, 0x1f, 0xf7, 0x0f
|
||||
};
|
||||
// clang-format on
|
||||
// NOLINTEND
|
||||
|
||||
|
||||
/*!
|
||||
As ProgressBar has no chance to control the incoming Qt events of Quarter so we need to stop
|
||||
the event handling to prevent the scenegraph from being selected or deselected
|
||||
@@ -681,7 +607,7 @@ void View3DInventorViewer::init()
|
||||
}
|
||||
|
||||
//create the cursors
|
||||
createStandardCursors(devicePixelRatio());
|
||||
createStandardCursors();
|
||||
connect(this, &View3DInventorViewer::devicePixelRatioChanged,
|
||||
this, &View3DInventorViewer::createStandardCursors);
|
||||
|
||||
@@ -766,40 +692,15 @@ View3DInventorViewer::~View3DInventorViewer()
|
||||
delete glAction;
|
||||
}
|
||||
|
||||
static QCursor createCursor(QBitmap &bitmap, QBitmap &mask, int hotX, int hotY, double dpr)
|
||||
void View3DInventorViewer::createStandardCursors()
|
||||
{
|
||||
#if defined(Q_OS_WIN32)
|
||||
bitmap.setDevicePixelRatio(dpr);
|
||||
mask.setDevicePixelRatio(dpr);
|
||||
#else
|
||||
Q_UNUSED(dpr)
|
||||
#endif
|
||||
#ifdef HAS_QTBUG_95434
|
||||
if (qGuiApp->platformName() == QLatin1String("wayland")) {
|
||||
QImage img = bitmap.toImage();
|
||||
img.convertTo(QImage::Format_ARGB32);
|
||||
QPixmap pixmap = QPixmap::fromImage(img);
|
||||
pixmap.setMask(mask);
|
||||
return QCursor(pixmap, hotX, hotY);
|
||||
}
|
||||
#endif
|
||||
QPixmap panPixmap = BitmapFactory().pixmapFromSvg("cursor-pan", QSize(16,16));
|
||||
QPixmap spinPixmap = BitmapFactory().pixmapFromSvg("cursor-rotate", QSize(16,16));
|
||||
QPixmap zoomPixmap = BitmapFactory().pixmapFromSvg("cursor-zoom", QSize(16,16));
|
||||
|
||||
return QCursor(bitmap, mask, hotX, hotY);
|
||||
}
|
||||
|
||||
void View3DInventorViewer::createStandardCursors(double dpr)
|
||||
{
|
||||
QBitmap cursor = QBitmap::fromData(QSize(ROTATE_WIDTH, ROTATE_HEIGHT), rotate_bitmap);
|
||||
QBitmap mask = QBitmap::fromData(QSize(ROTATE_WIDTH, ROTATE_HEIGHT), rotate_mask_bitmap);
|
||||
spinCursor = createCursor(cursor, mask, ROTATE_HOT_X, ROTATE_HOT_Y, dpr);
|
||||
|
||||
cursor = QBitmap::fromData(QSize(ZOOM_WIDTH, ZOOM_HEIGHT), zoom_bitmap);
|
||||
mask = QBitmap::fromData(QSize(ZOOM_WIDTH, ZOOM_HEIGHT), zoom_mask_bitmap);
|
||||
zoomCursor = createCursor(cursor, mask, ZOOM_HOT_X, ZOOM_HOT_Y, dpr);
|
||||
|
||||
cursor = QBitmap::fromData(QSize(PAN_WIDTH, PAN_HEIGHT), pan_bitmap);
|
||||
mask = QBitmap::fromData(QSize(PAN_WIDTH, PAN_HEIGHT), pan_mask_bitmap);
|
||||
panCursor = createCursor(cursor, mask, PAN_HOT_X, PAN_HOT_Y, dpr);
|
||||
this->panCursor = QCursor(panPixmap, 8, 8);
|
||||
this->spinCursor = QCursor(spinPixmap, 8, 8);
|
||||
this->zoomCursor = QCursor(zoomPixmap, 8, 8);
|
||||
}
|
||||
|
||||
void View3DInventorViewer::aboutToDestroyGLContext()
|
||||
|
||||
@@ -510,7 +510,7 @@ private:
|
||||
static void drawSingleBackground(const QColor&);
|
||||
void setCursorRepresentation(int mode);
|
||||
void aboutToDestroyGLContext();
|
||||
void createStandardCursors(double);
|
||||
void createStandardCursors();
|
||||
|
||||
private:
|
||||
NaviCube* naviCube;
|
||||
|
||||
@@ -76,36 +76,6 @@
|
||||
#define INKSCAPE_NS_URI "http://www.inkscape.org/namespaces/inkscape"
|
||||
#define SODIPODI_NS_URI "http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
|
||||
/*** pan-style cursor *******/
|
||||
|
||||
#define PAN_WIDTH 16
|
||||
#define PAN_HEIGHT 16
|
||||
#define PAN_BYTES ((PAN_WIDTH + 7) / 8) * PAN_HEIGHT
|
||||
#define PAN_HOT_X 7
|
||||
#define PAN_HOT_Y 7
|
||||
|
||||
static unsigned char pan_bitmap[PAN_BYTES] = {
|
||||
0xc0, 0x03, 0x60, 0x02, 0x20, 0x04, 0x10, 0x08, 0x68, 0x16, 0x54, 0x2a, 0x73, 0xce, 0x01, 0x80,
|
||||
0x01, 0x80, 0x73, 0xce, 0x54, 0x2a, 0x68, 0x16, 0x10, 0x08, 0x20, 0x04, 0x40, 0x02, 0xc0, 0x03};
|
||||
|
||||
static unsigned char pan_mask_bitmap[PAN_BYTES] = {
|
||||
0xc0, 0x03, 0xe0, 0x03, 0xe0, 0x07, 0xf0, 0x0f, 0xe8, 0x17, 0xdc, 0x3b, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xdc, 0x3b, 0xe8, 0x17, 0xf0, 0x0f, 0xe0, 0x07, 0xc0, 0x03, 0xc0, 0x03};
|
||||
/*** zoom-style cursor ******/
|
||||
|
||||
#define ZOOM_WIDTH 16
|
||||
#define ZOOM_HEIGHT 16
|
||||
#define ZOOM_BYTES ((ZOOM_WIDTH + 7) / 8) * ZOOM_HEIGHT
|
||||
#define ZOOM_HOT_X 5
|
||||
#define ZOOM_HOT_Y 7
|
||||
|
||||
static unsigned char zoom_bitmap[ZOOM_BYTES] = {
|
||||
0x00, 0x0f, 0x80, 0x1c, 0x40, 0x38, 0x20, 0x70, 0x90, 0xe4, 0xc0, 0xcc, 0xf0, 0xfc, 0x00, 0x0c,
|
||||
0x00, 0x0c, 0xf0, 0xfc, 0xc0, 0xcc, 0x90, 0xe4, 0x20, 0x70, 0x40, 0x38, 0x80, 0x1c, 0x00, 0x0f};
|
||||
|
||||
static unsigned char zoom_mask_bitmap[ZOOM_BYTES] = {
|
||||
0x00, 0x0f, 0x80, 0x1f, 0xc0, 0x3f, 0xe0, 0x7f, 0xf0, 0xff, 0xf0, 0xff, 0xf0, 0xff, 0x00, 0x0f,
|
||||
0x00, 0x0f, 0xf0, 0xff, 0xf0, 0xff, 0xf0, 0xff, 0xe0, 0x7f, 0xc0, 0x3f, 0x80, 0x1f, 0x00, 0x0f};
|
||||
using namespace Gui;
|
||||
using namespace TechDraw;
|
||||
using namespace TechDrawGui;
|
||||
@@ -213,7 +183,7 @@ QGVPage::QGVPage(ViewProviderPage* vpPage, QGSPage* scenePage, QWidget* parent)
|
||||
|
||||
initNavigationStyle();
|
||||
|
||||
createStandardCursors(devicePixelRatio());
|
||||
createStandardCursors();
|
||||
}
|
||||
|
||||
QGVPage::~QGVPage()
|
||||
@@ -667,36 +637,13 @@ Base::Type QGVPage::getStyleType(std::string model)
|
||||
return type;
|
||||
}
|
||||
|
||||
static QCursor createCursor(QBitmap &bitmap, QBitmap &mask, int hotX, int hotY, double dpr)
|
||||
void QGVPage::createStandardCursors()
|
||||
{
|
||||
#if defined(Q_OS_WIN32)
|
||||
bitmap.setDevicePixelRatio(dpr);
|
||||
mask.setDevicePixelRatio(dpr);
|
||||
#else
|
||||
Q_UNUSED(dpr)
|
||||
#endif
|
||||
#if defined(Q_OS_LINUX) && QT_VERSION < QT_VERSION_CHECK(6,6,0)
|
||||
if (qGuiApp->platformName() == QLatin1String("wayland")) {
|
||||
QImage img = bitmap.toImage();
|
||||
img.convertTo(QImage::Format_ARGB32);
|
||||
QPixmap pixmap = QPixmap::fromImage(img);
|
||||
pixmap.setMask(mask);
|
||||
return QCursor(pixmap, hotX, hotY);
|
||||
}
|
||||
#endif
|
||||
QPixmap panPixmap = BitmapFactory().pixmapFromSvg("cursor-pan", QSize(16,16));
|
||||
QPixmap zoomPixmap = BitmapFactory().pixmapFromSvg("cursor-zoom", QSize(16,16));
|
||||
|
||||
return QCursor(bitmap, mask, hotX, hotY);
|
||||
}
|
||||
|
||||
void QGVPage::createStandardCursors(double dpr)
|
||||
{
|
||||
QBitmap cursor = QBitmap::fromData(QSize(PAN_WIDTH, PAN_HEIGHT), pan_bitmap);
|
||||
QBitmap mask = QBitmap::fromData(QSize(PAN_WIDTH, PAN_HEIGHT), pan_mask_bitmap);
|
||||
panCursor = createCursor(cursor, mask, PAN_HOT_X, PAN_HOT_Y, dpr);
|
||||
|
||||
cursor = QBitmap::fromData(QSize(ZOOM_WIDTH, ZOOM_HEIGHT), zoom_bitmap);
|
||||
mask = QBitmap::fromData(QSize(ZOOM_WIDTH, ZOOM_HEIGHT), zoom_mask_bitmap);
|
||||
zoomCursor = createCursor(cursor, mask, ZOOM_HOT_X, ZOOM_HOT_Y, dpr);
|
||||
this->panCursor = QCursor(panPixmap, 8, 8);
|
||||
this->zoomCursor = QCursor(zoomPixmap, 8, 8);
|
||||
}
|
||||
|
||||
#include <Mod/TechDraw/Gui/moc_QGVPage.cpp>
|
||||
|
||||
@@ -162,7 +162,7 @@ protected:
|
||||
void initNavigationStyle();
|
||||
void setNavigationStyle(std::string navParm);
|
||||
|
||||
void createStandardCursors(double dpr);
|
||||
void createStandardCursors();
|
||||
|
||||
private:
|
||||
RendererType m_renderer;
|
||||
|
||||
Reference in New Issue
Block a user