summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-01-26 22:15:16 +0100
committerStanislaw Halik <sthalik@misaki.pl>2023-01-26 22:15:16 +0100
commit484a705e0daf95c95679ad7599278f102f1fe558 (patch)
treed3b012d45bce3f1fbb55954f681439c8d5153802
parent29ec855c58bd4e8f20f061056626c1060126dc26 (diff)
pose-widget: add grid lines
-rw-r--r--gui/init.cpp5
-rw-r--r--opentrack/main-window.cpp3
-rw-r--r--pose-widget/images/grid-dark.pngbin0 -> 26862 bytes
-rw-r--r--pose-widget/images/grid-light.pngbin0 -> 29026 bytes
-rw-r--r--pose-widget/pose-widget.cpp11
-rw-r--r--pose-widget/pose-widget.hpp3
-rw-r--r--pose-widget/posewidget.qrc2
7 files changed, 23 insertions, 1 deletions
diff --git a/gui/init.cpp b/gui/init.cpp
index b54a085e..431ad04c 100644
--- a/gui/init.cpp
+++ b/gui/init.cpp
@@ -37,6 +37,9 @@ using namespace options;
extern "C" __declspec(dllimport) unsigned __cdecl _controlfp(unsigned, unsigned);
#endif
+extern "C" OTR_GENERIC_EXPORT bool opentrack_using_dark_theme;
+bool opentrack_using_dark_theme = false;
+
static void set_fp_mask()
{
#if defined OTR_ARCH_DENORM_DAZ
@@ -188,6 +191,7 @@ static void apply_dark_windows_theme_if_needed()
qApp->setPalette(darkPalette);
qApp->setStyleSheet("QToolTip { color: #ffffff; background-color: #2a82da; border: 1px solid white; }");
+ opentrack_using_dark_theme = true;
}
}
@@ -345,4 +349,3 @@ int otr_main(int argc, char** argv, std::function<std::unique_ptr<QWidget>()> co
return ret;
}
-
diff --git a/opentrack/main-window.cpp b/opentrack/main-window.cpp
index 4806951f..4c8ae381 100644
--- a/opentrack/main-window.cpp
+++ b/opentrack/main-window.cpp
@@ -33,6 +33,7 @@
#include <QDateTime>
extern "C" const char* const opentrack_version;
+extern "C" OTR_GENERIC_IMPORT bool opentrack_using_dark_theme;
using namespace options::globals;
using namespace options;
@@ -58,6 +59,8 @@ main_window::main_window() : State(OPENTRACK_BASE_PATH + OPENTRACK_LIBRARY_PATH)
setVisible(!start_in_tray());
ensure_tray();
+ ui.pose_display->set_grid_background(opentrack_using_dark_theme);
+
connect(&pose_update_timer, &QTimer::timeout,
this, &main_window::show_pose, Qt::DirectConnection);
connect(&det_timer, &QTimer::timeout,
diff --git a/pose-widget/images/grid-dark.png b/pose-widget/images/grid-dark.png
new file mode 100644
index 00000000..8665fc30
--- /dev/null
+++ b/pose-widget/images/grid-dark.png
Binary files differ
diff --git a/pose-widget/images/grid-light.png b/pose-widget/images/grid-light.png
new file mode 100644
index 00000000..83b844c0
--- /dev/null
+++ b/pose-widget/images/grid-light.png
Binary files differ
diff --git a/pose-widget/pose-widget.cpp b/pose-widget/pose-widget.cpp
index 7c1f19c0..51d86609 100644
--- a/pose-widget/pose-widget.cpp
+++ b/pose-widget/pose-widget.cpp
@@ -22,6 +22,7 @@ namespace pose_widget_impl {
pose_widget::pose_widget(QWidget* parent) : QWidget(parent)
{
QPainter p;
+ p.setRenderHint(QPainter::SmoothPixmapTransform);
#ifdef TEST
//draw rectangle frame around of Octopus, only if TEST defined
p.begin(&front);
@@ -56,6 +57,14 @@ pose_widget::pose_widget(QWidget* parent) : QWidget(parent)
#endif
}
+void pose_widget::set_grid_background(bool dark_theme)
+{
+ if (dark_theme)
+ background = QImage(":/images/grid-dark.png");
+ else
+ background = QImage(":/images/grid-light.png");
+}
+
void pose_widget::present(double yaw, double pitch, double roll, double x, double y, double z)
{
T = { x, y, z };
@@ -94,6 +103,8 @@ void pose_widget::paintEvent(QPaintEvent*)
{
p.fillRect(rect(), palette().brush(backgroundRole()));
+ if (!background.isNull())
+ p.drawImage(rect(), background);
// draw axes
p.save();
p.setPen(QPen(Qt::gray, 1, Qt::SolidLine));
diff --git a/pose-widget/pose-widget.hpp b/pose-widget/pose-widget.hpp
index 9152e960..53ecc644 100644
--- a/pose-widget/pose-widget.hpp
+++ b/pose-widget/pose-widget.hpp
@@ -27,6 +27,7 @@ public:
explicit pose_widget(QWidget *parent = nullptr);
void present(double xAngle, double yAngle, double zAngle, double x, double y, double z);
QCheckBox mirror{"Mirror", this};
+ void set_grid_background(bool dark_theme);
private:
void resizeEvent(QResizeEvent *event) override;
void paintEvent(QPaintEvent*) override;
@@ -35,6 +36,8 @@ private:
QImage front{QImage{":/images/side1.png"}.convertToFormat(QImage::Format_ARGB32)};
QImage back {QImage{":/images/side6.png"}.convertToFormat(QImage::Format_ARGB32)
.mirrored(true,false)};
+ QImage background;
+
QImage shine {QImage{front.width(), front.height(), QImage::Format_ARGB32}};
QImage shadow{QImage{front.width(), front.height(), QImage::Format_ARGB32}};
};
diff --git a/pose-widget/posewidget.qrc b/pose-widget/posewidget.qrc
index e799432f..636151e0 100644
--- a/pose-widget/posewidget.qrc
+++ b/pose-widget/posewidget.qrc
@@ -2,5 +2,7 @@
<qresource prefix="/">
<file>images/side1.png</file>
<file>images/side6.png</file>
+ <file>images/grid-light.png</file>
+ <file>images/grid-dark.png</file>
</qresource>
</RCC>