From 8cb57e97251defeb2761839d0712118bd8b6101c Mon Sep 17 00:00:00 2001 From: Kaixo Gamorra <21697330-kaixoo@users.noreply.gitlab.com> Date: Mon, 21 Oct 2024 23:19:00 +0200 Subject: [PATCH 1/3] feat: add support for boolean property --- src/core/ShaderEffects/shadervaluehandler.cpp | 5 +++++ src/core/ShaderEffects/shadervaluehandler.h | 1 + 2 files changed, 6 insertions(+) diff --git a/src/core/ShaderEffects/shadervaluehandler.cpp b/src/core/ShaderEffects/shadervaluehandler.cpp index 2a35ffb21..03b136dd7 100644 --- a/src/core/ShaderEffects/shadervaluehandler.cpp +++ b/src/core/ShaderEffects/shadervaluehandler.cpp @@ -36,6 +36,11 @@ UniformSpecifier ShaderValueHandler::create(const GLint loc, { Q_ASSERT(loc >= 0); switch(mType) { + case GLValueType::Boolean: + return [loc, &engine, index](QGL33 * const gl) { + const auto val = engine.getGlValueDouble(index); + gl->glUniform1i(loc, static_cast(qRound(val))); + }; case GLValueType::Float: return [loc, &engine, index](QGL33 * const gl) { const auto val = engine.getGlValueDouble(index); diff --git a/src/core/ShaderEffects/shadervaluehandler.h b/src/core/ShaderEffects/shadervaluehandler.h index 89f9eb9e4..d41dd39ba 100644 --- a/src/core/ShaderEffects/shadervaluehandler.h +++ b/src/core/ShaderEffects/shadervaluehandler.h @@ -36,6 +36,7 @@ typedef std::function UniformSpecifier; enum class GLValueType { Float, Vec2, Vec3, Vec4, Int, iVec2, iVec3, iVec4, + Boolean, none }; From 163da4ed3562fce30a27cdec498e8f363d542f68 Mon Sep 17 00:00:00 2001 From: Kaixo Gamorra <21697330-kaixoo@users.noreply.gitlab.com> Date: Wed, 30 Oct 2024 22:01:53 +0200 Subject: [PATCH 2/3] Revert "feat: add support for boolean property" This reverts commit 8cb57e97251defeb2761839d0712118bd8b6101c. --- src/core/ShaderEffects/shadervaluehandler.cpp | 5 ----- src/core/ShaderEffects/shadervaluehandler.h | 1 - 2 files changed, 6 deletions(-) diff --git a/src/core/ShaderEffects/shadervaluehandler.cpp b/src/core/ShaderEffects/shadervaluehandler.cpp index 03b136dd7..2a35ffb21 100644 --- a/src/core/ShaderEffects/shadervaluehandler.cpp +++ b/src/core/ShaderEffects/shadervaluehandler.cpp @@ -36,11 +36,6 @@ UniformSpecifier ShaderValueHandler::create(const GLint loc, { Q_ASSERT(loc >= 0); switch(mType) { - case GLValueType::Boolean: - return [loc, &engine, index](QGL33 * const gl) { - const auto val = engine.getGlValueDouble(index); - gl->glUniform1i(loc, static_cast(qRound(val))); - }; case GLValueType::Float: return [loc, &engine, index](QGL33 * const gl) { const auto val = engine.getGlValueDouble(index); diff --git a/src/core/ShaderEffects/shadervaluehandler.h b/src/core/ShaderEffects/shadervaluehandler.h index d41dd39ba..89f9eb9e4 100644 --- a/src/core/ShaderEffects/shadervaluehandler.h +++ b/src/core/ShaderEffects/shadervaluehandler.h @@ -36,7 +36,6 @@ typedef std::function UniformSpecifier; enum class GLValueType { Float, Vec2, Vec3, Vec4, Int, iVec2, iVec3, iVec4, - Boolean, none }; From 545709bd366d487402da13c77fbb977a87e62afe Mon Sep 17 00:00:00 2001 From: Kaixo Gamorra <21697330-kaixoo@users.noreply.gitlab.com> Date: Sun, 8 Dec 2024 13:07:58 +0200 Subject: [PATCH 3/3] feat: initial API for infinite mouse movement --- src/ui/CMakeLists.txt | 2 ++ src/ui/misc/infinitemousemovement.cpp | 39 +++++++++++++++++++++++++++ src/ui/misc/infinitemousemovement.h | 16 +++++++++++ 3 files changed, 57 insertions(+) create mode 100644 src/ui/misc/infinitemousemovement.cpp create mode 100644 src/ui/misc/infinitemousemovement.h diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index a9d28bdc1..699331652 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -55,6 +55,7 @@ set( gradientwidgets/displayedgradientswidget.cpp gradientwidgets/gradientslistwidget.cpp gradientwidgets/gradientwidget.cpp + misc/infinitemousemovement.cpp misc/noshortcutaction.cpp misc/keyfocustarget.cpp optimalscrollarena/minimalscrollwidget.cpp @@ -126,6 +127,7 @@ set( gradientwidgets/displayedgradientswidget.h gradientwidgets/gradientslistwidget.h gradientwidgets/gradientwidget.h + misc/infinitemousemovement.h misc/noshortcutaction.h misc/keyfocustarget.h optimalscrollarena/minimalscrollwidget.h diff --git a/src/ui/misc/infinitemousemovement.cpp b/src/ui/misc/infinitemousemovement.cpp new file mode 100644 index 000000000..652aeb1d0 --- /dev/null +++ b/src/ui/misc/infinitemousemovement.cpp @@ -0,0 +1,39 @@ +#include "infinitemousemovement.h" + +#include +#include +#include +#include + +bool isCursorInLeft(int x, QSize *screenSize) { return x == 0; } +bool isCursorInRight(int x, QSize *screenSize) { return x == screenSize->width(); } +bool isCursorInTop(int y, QSize *screenSize) { return y == 0; } +bool isCursorInBottom(int y, QSize *screenSize) { return y == screenSize->height(); } + +void setCursorMovementInfinite(QScreen *screen) { + auto size = screen.availableSize(); + auto point = QCursor::pos(); + auto x = point.x(); + auto y = point.y(); + + // Depending on which border the cursor is at (left, right, top, down) + // Move the cursor to the inverse direction + 1 px (not to get in an infinite loop) + if (isCursorInLeft(point, size)) { + // We set the cursor to the edge of the screen minus 1px + QCursor::setPos(screen, size.width() - 1, y); + }; + if (isCursorInRight(point, size)) { + // We set the cursor to the edge of the screen plus 1px + QCursor::setPos(screen, 1, y); + } + if(isCursorInTop(point, size)) { + // We set the cursor to the edge of the screen minus 1px + QCursor::setPos(screen, x, size.height() - 1); + } + if(isCursorInBottom(point, size)) { + // We set the cursor to the edge of the screen plus 1px + QCursor::setPos(screen, x, 1); + } +} + +void setCursorMovementDefault() {} diff --git a/src/ui/misc/infinitemousemovement.h b/src/ui/misc/infinitemousemovement.h new file mode 100644 index 000000000..f702e542f --- /dev/null +++ b/src/ui/misc/infinitemousemovement.h @@ -0,0 +1,16 @@ +#ifndef FRICTION_H_INFINITE_MOUSE_MOVEMENT +#define FRICTION_H_INFINITE_MOUSE_MOVEMENT + +/// Allows the mouse to move across the border of the screen and return back to the other side. Is useful for e.g. scaling / rotating an object in the canvas. +void setCursorMovementInfinite(); + +/// Blocks the mouse from going across the border of the screen +void setCursorMovementDefault(); + +/// Allows the mouse only to move 1px and returns it to original state +/// (like in a videogame). Could be useful for e.g. blender-style combo boxes. +/// Should additionally be hidden or change the cursor style, +/// and make this function return values depending on how much the mouse moves. +void setCursorMovementLock(); + +#endif