Inital commit of the Komplex Hub

This commit is contained in:
Digital Artifex
2026-06-02 15:11:36 -04:00
commit 15a625008e
2911 changed files with 655555 additions and 0 deletions
@@ -0,0 +1,40 @@
qt_add_library(QuickStudioDesignEffects STATIC)
qt6_add_qml_module(QuickStudioDesignEffects
URI "QtQuick.Studio.DesignEffects"
VERSION "${PROJECT_VERSION}"
DESIGNER_SUPPORTED
RESOURCE_PREFIX "/qt-project.org/imports"
PAST_MAJOR_VERSIONS 1
${qds_qml_extra_args}
PAST_MAJOR_VERSIONS 1
QML_FILES
DesignBackgroundBlurPrivate.qml
DesignDropShadow.qml
DesignDropShadowPrivate.qml
DesignEffect.qml
DesignEffectPrivate.qml
DesignInnerShadow.qml
DesignInnerShadowPrivate.qml
DesignLayerBlurPrivate.qml
)
set_target_properties(QuickStudioDesignEffects PROPERTIES
QT_QMLCACHEGEN_EXECUTABLE qmlcachegen
)
qt6_add_shaders(QuickStudioDesignEffects "designeffectsshaders"
BATCHABLE
PRECOMPILE
OPTIMIZED
PREFIX
"/qt-project.org/imports/QtQuick/Studio/DesignEffects"
FILES
"shaders/dropShadow.frag"
"shaders/dropShadowClip.frag"
"shaders/gaussianBlur.frag"
"shaders/innerShadow.frag"
"shaders/innerShadowClip.frag"
"shaders/opacityMask.frag"
)
register_plugin(QuickStudioDesignEffects)
@@ -0,0 +1,177 @@
/****************************************************************************
**
** Copyright (C) 2024 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Quick Studio Components.
**
** $QT_BEGIN_LICENSE:GPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 or (at your option) any later version
** approved by the KDE Free Qt Foundation. The licenses are as published by
** the Free Software Foundation and appearing in the file LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
import QtQuick
Item {
id: root
property real radius: 10
/*required*/ property Item source
/*required*/ property Item background
readonly property real sourceRotation: root.source.rotation
readonly property size textureSize: Qt.size(root.targetRect.width,
root.targetRect.height)
readonly property vector2d pixelSize: Qt.vector2d(1.0 / root.textureSize.width,
1.0 / root.textureSize.height)
readonly property real sigma: root.radius / 2.7
visible: true
width: root.source.width
height: root.source.height
rotation: -root.sourceRotation
property rect targetRect: Qt.rect(0, 0, 0, 0)
Connections {
target: root.background
function onXChanged() { root.sizeStuff() }
function onYChanged() { root.sizeStuff() }
function onWidthChanged() { root.sizeStuff() }
function onHeightChanged() { root.sizeStuff() }
}
Connections {
target: root.source
function onXChanged() { root.sizeStuff() }
function onYChanged() { root.sizeStuff() }
function onWidthChanged() { root.sizeStuff() }
function onHeightChanged() { root.sizeStuff() }
function onRotationChanged() { root.sizeStuff() }
}
onSourceChanged: root.sizeStuff()
onBackgroundChanged: root.sizeStuff()
function sizeStuff() {
if (root.background === null)
return
let tRect = Qt.rect(0, 0, root.source.width, root.source.height)
root.targetRect = root.background.mapFromItem(root.source, tRect)
}
//Component.onCompleted: console.log("Background Blur created!")
// TODO
// Check if target and background overlap
// Check if target is actually transparent
ShaderEffectSource {
id: shaderEffectSource
visible: false
width: root.width
height: root.height
sourceItem: root.background
sourceRect: root.targetRect
}
ShaderEffect {
id: blurHorizontal
property real blurKernel: root.radius
property real sigma: root.sigma
property var src: shaderEffectSource
property vector2d pixelSize: root.pixelSize.times(Qt.vector2d(1, 0))
property bool useOffscreenColor: false
property color offscreenColor: "transparent"
visible: false
width: root.textureSize.width
height: root.textureSize.height
anchors.centerIn: parent
layer.enabled: true
fragmentShader: "shaders/gaussianBlur.frag.qsb"
}
ShaderEffect {
id: blurVertical
property real blurKernel: root.radius
property real sigma: root.sigma
property var src: blurHorizontal
property vector2d pixelSize: root.pixelSize.times(Qt.vector2d(0, 1))
property bool useOffscreenColor: false
property color offscreenColor: "transparent"
visible: false
width: root.textureSize.width
height: root.textureSize.height
anchors.centerIn: parent
layer.enabled: true
fragmentShader: "shaders/gaussianBlur.frag.qsb"
}
Item {
id: wrapper
anchors.centerIn: parent
width: root.textureSize.width
height: root.textureSize.height
visible: false
layer.enabled: true
ShaderEffectSource {
id: shaderEffectSource2
visible: true
anchors.centerIn: parent
rotation: root.sourceRotation
width: root.source.width
height: root.source.height
sourceItem: root.source
}
}
ShaderEffect {
id: mask
property var source: blurVertical
property var maskSource: wrapper
visible: true
width: root.textureSize.width
height: root.textureSize.height
anchors.centerIn: parent
fragmentShader: "shaders/opacityMask.frag.qsb"
}
}
@@ -0,0 +1,43 @@
/****************************************************************************
**
** Copyright (C) 2024 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Quick Studio Components.
**
** $QT_BEGIN_LICENSE:GPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 or (at your option) any later version
** approved by the KDE Free Qt Foundation. The licenses are as published by
** the Free Software Foundation and appearing in the file LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
import QtQuick
import QtQuick.Controls
QtObject {
property real blur: 4
property int offsetX: 0
property int offsetY: 4
property int spread: 0
property color color: "#3f000000" // black 25%
property bool showBehind: false
property bool visible: true
property string type: "DropShadow"
}
@@ -0,0 +1,204 @@
/****************************************************************************
**
** Copyright (C) 2024 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Quick Studio Components.
**
** $QT_BEGIN_LICENSE:GPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 or (at your option) any later version
** approved by the KDE Free Qt Foundation. The licenses are as published by
** the Free Software Foundation and appearing in the file LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
import QtQuick
Item {
id: root
property int horizontalOffset: 10
property int verticalOffset: 30
property int spread: 0
property color color: "black"
property real radius: 10
property bool showBehind: false
required property Item source
readonly property real sourceRotation: root.source.rotation
readonly property real radiusCeiled: Math.ceil(root.radius)
readonly property size orginialTextureSize: Qt.size(root.width + root.spread * 2,
root.height + root.spread * 2)
readonly property real sigma: root.radius / 2.7
visible: true
width: root.source.width
height: root.source.height
//Component.onCompleted: console.log("Drop Shadow created!")
onSourceRotationChanged: root.calculateOffset()
onRadiusCeiledChanged: root.calculateOffset()
onSpreadChanged: root.calculateOffset()
onHorizontalOffsetChanged: root.calculateOffset()
onVerticalOffsetChanged: root.calculateOffset()
signal geometryChanged()
property point __offset: Qt.point(0, 0)
function calculateOffset() {
let mat = Qt.matrix4x4()
mat.translate(Qt.vector3d(-root.spread, -root.spread, 0))
mat.translate(Qt.vector3d(-root.radiusCeiled, -root.radiusCeiled, 0))
mat.rotate(-root.sourceRotation, Qt.vector3d(0, 0, 1))
root.__offset = mat.map(Qt.point(root.horizontalOffset, root.verticalOffset))
root.__offset = Qt.point(Math.round(root.__offset.x), Math.round(root.__offset.y))
root.geometryChanged()
}
readonly property bool copyActive: root.source instanceof Rectangle && root.spread !== 0
Rectangle {
id: sourceCopy
visible: false
width: Math.max(0, root.source.width + root.spread * 2)
height: Math.max(0, root.source.height + root.spread * 2)
radius: Math.max(0, root.source.radius !== 0 ? root.source.radius + root.spread : 0)
color: "black"
}
ShaderEffectSource {
id: shaderEffectSource
visible: false
width: root.orginialTextureSize.width
height: root.orginialTextureSize.height
sourceItem: root.copyActive ? sourceCopy : root.source
}
ShaderEffect {
id: shadow
property color color: root.color
property var src: shaderEffectSource
visible: false
width: root.orginialTextureSize.width
height: root.orginialTextureSize.height
layer.enabled: true
layer.sourceRect: Qt.rect(-root.radiusCeiled, -root.radiusCeiled,
root.bluredTextureSize.width, root.bluredTextureSize.height)
fragmentShader: "shaders/dropShadow.frag.qsb"
}
readonly property size bluredTextureSize: Qt.size(root.orginialTextureSize.width + root.radiusCeiled * 2,
root.orginialTextureSize.height + root.radiusCeiled * 2)
readonly property vector2d bluredPixelSize: Qt.vector2d(1.0 / root.bluredTextureSize.width,
1.0 / root.bluredTextureSize.height)
ShaderEffect {
id: blurHorizontal
property real blurKernel: root.radius
property real sigma: root.sigma
property var src: shadow
property vector2d pixelSize: root.bluredPixelSize.times(Qt.vector2d(1, 0))
property bool useOffscreenColor: false
property color offscreenColor: "transparent"
visible: false
width: root.bluredTextureSize.width
height: root.bluredTextureSize.height
layer.enabled: true
layer.smooth: true // Otherwise bluring artifacts
fragmentShader: "shaders/gaussianBlur.frag.qsb"
}
ShaderEffect {
id: blurVertical
property real blurKernel: root.radius
property real sigma: root.sigma
property var src: blurHorizontal
property vector2d pixelSize: root.bluredPixelSize.times(Qt.vector2d(0, 1))
property bool useOffscreenColor: false
property color offscreenColor: "transparent"
visible: root.showBehind
x: root.showBehind ? root.__offset.x : 0
y: root.showBehind ? root.__offset.y : 0
width: root.bluredTextureSize.width
height: root.bluredTextureSize.height
layer.enabled: !root.showBehind
layer.sourceRect: Qt.rect(Math.min(0, -root.__offset.x),
Math.min(0, -root.__offset.y),
root.offsetTextureSize.width,
root.offsetTextureSize.height)
fragmentShader: "shaders/gaussianBlur.frag.qsb"
}
readonly property size offsetTextureSize: Qt.size(root.bluredTextureSize.width + Math.abs(root.__offset.x),
root.bluredTextureSize.height + Math.abs(root.__offset.y))
ShaderEffectSource {
id: originalSource
visible: false
width: root.offsetTextureSize.width
height: root.offsetTextureSize.height
sourceItem: root.source
sourceRect: Qt.rect(Math.min(0, root.__offset.x),
Math.min(0, root.__offset.y),
root.offsetTextureSize.width,
root.offsetTextureSize.height)
}
ShaderEffect {
id: result
property var shadow: blurVertical
property var original: originalSource
visible: !root.showBehind
x: -Math.max(0, -root.__offset.x)
y: -Math.max(0, -root.__offset.y)
width: root.offsetTextureSize.width
height: root.offsetTextureSize.height
fragmentShader: "shaders/dropShadowClip.frag.qsb"
}
readonly property rect boundingBox: Qt.rect(result.x, result.y, result.width, result.height)
onBoundingBoxChanged: root.geometryChanged()
}
@@ -0,0 +1,107 @@
/****************************************************************************
**
** Copyright (C) 2024 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Quick Studio Components.
**
** $QT_BEGIN_LICENSE:GPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 or (at your option) any later version
** approved by the KDE Free Qt Foundation. The licenses are as published by
** the Free Software Foundation and appearing in the file LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
import QtQuick
Item {
id: root
// Use visible property to show and hide the effect.
visible: true
// This is an internal property used to manage the effect. Do not modify.
property Item __oldParent: null
// This is the main source for the effect. Set internally to the current parent item. Do not modify.
property Item source: null
property list<QtObject> effects
property bool layerBlurVisible: true
property real layerBlurRadius: 0
property bool backgroundBlurVisible: true
property real backgroundBlurRadius: 0
property Item backgroundLayer: null
property bool _isEffectItem: true
onParentChanged: {
if (root.__oldParent && root.__oldParent !== root.parent) {
root.__oldParent.layer.enabled = false
root.__oldParent.layer.effect = null
root.source = null
root.__oldParent.update()
root.__oldParent = null
}
if (root.parent) {
root.__oldParent = root.parent
if (root.visible) {
root.parent.layer.enabled = true
root.parent.layer.effect = effectComponent
}
root.source = root.parent
}
}
onVisibleChanged: {
if (root.parent == null)
return
if (root.visible) {
root.source = root.parent
root.parent.layer.enabled = true
root.parent.layer.effect = effectComponent
} else {
root.parent.layer.enabled = false
root.parent.layer.effect = null
root.source = null
}
root.parent.update()
}
Component {
id: effectComponent
DesignEffectPrivate {
id: effect
property bool __effect: true
source: root.source
effects: root.effects
layerBlurVisible: root.layerBlurVisible
layerBlurRadius: root.layerBlurRadius
backgroundBlurVisible: root.backgroundBlurVisible
backgroundBlurRadius: root.backgroundBlurRadius
background: root.backgroundLayer
}
}
}
@@ -0,0 +1,185 @@
/****************************************************************************
**
** Copyright (C) 2024 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Quick Studio Components.
**
** $QT_BEGIN_LICENSE:GPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 or (at your option) any later version
** approved by the KDE Free Qt Foundation. The licenses are as published by
** the Free Software Foundation and appearing in the file LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
import QtQuick
import Qt.labs.qmlmodels
Item {
id: root
required property Item source
property list<QtObject> effects
property Item background: null
property bool layerBlurVisible: true
property real layerBlurRadius: 0
property bool backgroundBlurVisible: true
property real backgroundBlurRadius: 0
onSourceChanged: root.source.antialiasing = false // Workaround
width: root.source.width
height: root.source.height
Component.onCompleted: root.calculateBoundingBox()
function clamp(input: real, min: real, max: real): real {
if (isNaN(input))
return 0
return Math.max(min, Math.min(input, max))
}
property rect effectBoundingBox: Qt.rect(0, 0, 0, 0)
function calculateBoundingBox() {
let x = 0
let y = 0
let width = root.width
let height = root.height
for (let i = 0; i < repeater.count; ++i) {
let item = repeater.itemAt(i)
if (item === null || !(item instanceof DesignDropShadowPrivate))
continue
let childRect = item.boundingBox
x = Math.min(x, childRect.x)
y = Math.min(y, childRect.y)
width = Math.max(width, childRect.width)
height = Math.max(height, childRect.height)
width += Math.max(0, -x) // TODO Understand
height += Math.max(0, -y)
}
root.effectBoundingBox = Qt.rect(x, y, width, height)
}
DesignLayerBlurPrivate {
id: layerBlur
visible: root.layerBlurVisible
radius: root.clamp(root.layerBlurRadius, 0, 250)
source: layerBlurSource
x: root.effectBoundingBox.x - Math.ceil(layerBlur.radius)
y: root.effectBoundingBox.y - Math.ceil(layerBlur.radius)
}
ShaderEffectSource {
id: layerBlurSource
visible: false
width: root.effectBoundingBox.width
height: root.effectBoundingBox.height
sourceItem: wrapper
sourceRect: root.effectBoundingBox
hideSource: root.layerBlurVisible
//samples: 4 // Workaround
//smooth: true
}
Item {
id: wrapper
anchors.fill: parent
DesignBackgroundBlurPrivate {
visible: root.backgroundBlurVisible
&& root.background !== null
&& root.backgroundBlurRadius !== 0
source: root.source
background: root.background
radius: root.clamp(root.backgroundBlurRadius, 0, 250)
}
ShaderEffectSource {
id: shaderEffectSource
visible: true
width: root.width
height: root.height
sourceItem: root.source
hideSource: true
z: 1
//samples: 4 // Workaround
}
Repeater {
id: repeater
model: root.effects
delegate: DelegateChooser {
role: "type"
DelegateChoice {
roleValue: "DropShadow"
DesignDropShadowPrivate {
required property var modelData
source: root.source
horizontalOffset: root.clamp(modelData.offsetX, -0xffff, 0xffff)
verticalOffset: root.clamp(modelData.offsetY, -0xffff, 0xffff)
spread: root.clamp(modelData.spread, -2048, 2048)
color: modelData.color
radius: root.clamp(modelData.blur, 0, 250)
showBehind: modelData.showBehind
visible: modelData.visible
onGeometryChanged: root.calculateBoundingBox()
}
}
DelegateChoice {
roleValue: "InnerShadow"
DesignInnerShadowPrivate {
required property var modelData
source: root.source
horizontalOffset: root.clamp(modelData.offsetX, -0xffff, 0xffff)
verticalOffset: root.clamp(modelData.offsetY, -0xffff, 0xffff)
spread: root.clamp(modelData.spread, -2048, 2048)
color: modelData.color
radius: root.clamp(modelData.blur, 0, 250)
visible: modelData.visible
z: 10
}
}
}
}
}
}
@@ -0,0 +1,43 @@
/****************************************************************************
**
** Copyright (C) 2024 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Quick Studio Components.
**
** $QT_BEGIN_LICENSE:GPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 or (at your option) any later version
** approved by the KDE Free Qt Foundation. The licenses are as published by
** the Free Software Foundation and appearing in the file LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
import QtQuick
import QtQuick.Controls
QtObject {
property real blur: 4
property int offsetX: 0
property int offsetY: 4
property int spread: 0
property color color: "#3f000000" // black 25%
property bool showBehind: false // This is a dummy property mirroring DropShadow
property bool visible: true
property string type: "InnerShadow"
}
@@ -0,0 +1,179 @@
/****************************************************************************
**
** Copyright (C) 2024 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Quick Studio Components.
**
** $QT_BEGIN_LICENSE:GPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 or (at your option) any later version
** approved by the KDE Free Qt Foundation. The licenses are as published by
** the Free Software Foundation and appearing in the file LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
import QtQuick
Item {
id: root
property int horizontalOffset: 10
property int verticalOffset: 30
property int spread: 0
property color color: "black"
property real radius: 10
required property Item source
readonly property real sourceRotation: root.source.rotation
readonly property size textureSize: Qt.size(Math.max(root.width, root.width - root.spread * 2) + Math.abs(root.__offset.x),
Math.max(root.height, root.height - root.spread * 2) + Math.abs(root.__offset.y))
readonly property vector2d pixelSize: Qt.vector2d(1.0 / root.textureSize.width,
1.0 / root.textureSize.height)
readonly property real sigma: root.radius / 2.7
visible: true
width: root.source.width
height: root.source.height
//Component.onCompleted: console.log("Inner Shadow created!")
onSourceRotationChanged: root.calculateOffset()
onSpreadChanged: root.calculateOffset()
onHorizontalOffsetChanged: root.calculateOffset()
onVerticalOffsetChanged: root.calculateOffset()
property point __offset: Qt.point(0, 0)
function calculateOffset() {
let mat = Qt.matrix4x4()
mat.rotate(-root.sourceRotation, Qt.vector3d(0, 0, 1))
root.__offset = mat.map(Qt.point(root.horizontalOffset, root.verticalOffset))
root.__offset = Qt.point(Math.round(root.__offset.x), Math.round(root.__offset.y))
}
readonly property bool copyActive: root.source instanceof Rectangle && root.spread !== 0
Rectangle {
id: sourceCopy
visible: false
width: Math.max(0, root.source.width - root.spread * 2)
height: Math.max(0, root.source.height - root.spread * 2)
radius: Math.max(0, root.source.radius !== 0 ? root.source.radius - root.spread : 0)
color: "black"
}
ShaderEffectSource {
id: shaderEffectSource
visible: false
width: root.textureSize.width
height: root.textureSize.height
sourceItem: root.copyActive ? sourceCopy : root.source
sourceRect: Qt.rect(Math.min(0, -root.__offset.x) - Math.max(0, root.spread),
Math.min(0, -root.__offset.y) - Math.max(0, root.spread),
root.textureSize.width,
root.textureSize.height)
}
ShaderEffect {
id: shadow
property color color: root.color
property var src: shaderEffectSource
visible: false
width: root.textureSize.width
height: root.textureSize.height
layer.enabled: true
fragmentShader: "shaders/innerShadow.frag.qsb"
}
ShaderEffect {
id: blurHorizontal
property real blurKernel: root.radius
property real sigma: root.sigma
property var src: shadow
property vector2d pixelSize: root.pixelSize.times(Qt.vector2d(1, 0))
property bool useOffscreenColor: true
property color offscreenColor: root.color
visible: false
width: root.textureSize.width
height: root.textureSize.height
layer.enabled: true
layer.smooth: true // Otherwise bluring artifacts
fragmentShader: "shaders/gaussianBlur.frag.qsb"
}
ShaderEffect {
id: blurVertical
property real blurKernel: root.radius
property real sigma: root.sigma
property var src: blurHorizontal
property vector2d pixelSize: root.pixelSize.times(Qt.vector2d(0, 1))
property bool useOffscreenColor: true
property color offscreenColor: root.color
visible: false
width: root.textureSize.width
height: root.textureSize.height
layer.enabled: true
layer.smooth: true // Otherwise bluring artifacts
fragmentShader: "shaders/gaussianBlur.frag.qsb"
}
ShaderEffectSource {
id: originalSource
visible: false
hideSource: true
width: root.textureSize.width
height: root.textureSize.height
sourceItem: root.source
sourceRect: Qt.rect(Math.min(0, root.__offset.x) + Math.min(0, root.spread),
Math.min(0, root.__offset.y) + Math.min(0, root.spread),
root.textureSize.width,
root.textureSize.height)
}
ShaderEffect {
property var shadow: blurVertical
property var original: originalSource
visible: true
x: -Math.max(0, -root.__offset.x) + Math.min(0, root.spread)
y: -Math.max(0, -root.__offset.y) + Math.min(0, root.spread)
width: root.textureSize.width
height: root.textureSize.height
fragmentShader: "shaders/innerShadowClip.frag.qsb"
}
}
@@ -0,0 +1,102 @@
/****************************************************************************
**
** Copyright (C) 2024 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Quick Studio Components.
**
** $QT_BEGIN_LICENSE:GPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 or (at your option) any later version
** approved by the KDE Free Qt Foundation. The licenses are as published by
** the Free Software Foundation and appearing in the file LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
import QtQuick
Item {
id: root
property real radius: 10
required property Item source
readonly property real radiusCeiled: Math.ceil(root.radius)
readonly property size textureSize: Qt.size(root.width + root.radiusCeiled * 2,
root.height + root.radiusCeiled * 2)
readonly property vector2d pixelSize: Qt.vector2d(1.0 / root.textureSize.width,
1.0 / root.textureSize.height)
readonly property real sigma: root.radius / 2.7
visible: true
width: root.source?.width
height: root.source?.height
//Component.onCompleted: console.log("Layer Blur created!")
ShaderEffectSource {
id: shaderEffectSource
visible: false
width: root.width
height: root.height
sourceItem: root.source
sourceRect: Qt.rect(-root.radiusCeiled, -root.radiusCeiled,
root.textureSize.width, root.textureSize.height)
}
ShaderEffect {
id: blurHorizontal
property real blurKernel: root.radius
property real sigma: root.sigma
property var src: shaderEffectSource
property vector2d pixelSize: root.pixelSize.times(Qt.vector2d(1, 0))
property bool useOffscreenColor: false
property color offscreenColor: "transparent"
visible: false
width: root.textureSize.width
height: root.textureSize.height
layer.enabled: true
layer.smooth: true // Otherwise bluring artifacts
fragmentShader: "shaders/gaussianBlur.frag.qsb"
}
ShaderEffect {
id: blurVertical
property real blurKernel: root.radius
property real sigma: root.sigma
property var src: blurHorizontal
property vector2d pixelSize: root.pixelSize.times(Qt.vector2d(0, 1))
property bool useOffscreenColor: false
property color offscreenColor: "transparent"
width: root.textureSize.width
height: root.textureSize.height
visible: true
fragmentShader: "shaders/gaussianBlur.frag.qsb"
}
}
@@ -0,0 +1,13 @@
import QtQuick.tooling 1.2
// This file describes the plugin-supplied types contained in the library.
// It is used for QML tooling purposes only.
//
// This file was auto-generated by:
// 'qmlplugindump -nonrelocatable -dependencies dependencies.json QtQuick.Controls 2.15'
Module {
dependencies: [
"QtQuick 2.11"
]
}
+9
View File
@@ -0,0 +1,9 @@
DesignBackgroundBlurPrivate 1.0 DesignBackgroundBlurPrivate.qml
DesignDropShadow 1.0 DesignDropShadow.qml
DesignDropShadowPrivate 1.0 DesignDropShadowPrivate.qml
DesignEffect 1.0 DesignEffect.qml
DesignEffectPrivate 1.0 DesignEffectPrivate.qml
DesignInnerShadow 1.0 DesignInnerShadow.qml
DesignInnerShadowPrivate 1.0 DesignInnerShadowPrivate.qml
DesignLayerBlurPrivate 1.0 DesignLayerBlurPrivate.qml
@@ -0,0 +1,55 @@
/****************************************************************************
**
** Copyright (C) 2024 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Quick Designer Components.
**
** $QT_BEGIN_LICENSE:GPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 or (at your option) any later version
** approved by the KDE Free Qt Foundation. The licenses are as published by
** the Free Software Foundation and appearing in the file LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <QtQml/qqmlextensionplugin.h>
QT_BEGIN_NAMESPACE
class QtStudioDesignEffectsPlugin: public QQmlExtensionPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
public:
QtStudioDesignEffectsPlugin(QObject *parent = nullptr);
void registerTypes(const char *uri) override;
};
QtStudioDesignEffectsPlugin::QtStudioDesignEffectsPlugin(QObject *parent)
: QQmlExtensionPlugin(parent)
{
}
void QtStudioDesignEffectsPlugin::registerTypes(const char *)
{
}
QT_END_NAMESPACE
#include "qtstudiodesigneffectsplugin.moc"
@@ -0,0 +1,19 @@
#version 440
layout(location = 0) in vec2 qt_TexCoord0;
layout(location = 0) out vec4 fragColor;
layout(std140, binding = 0) uniform buf {
mat4 qt_Matrix;
float qt_Opacity;
vec4 color;
};
layout(binding = 1) uniform sampler2D src;
void main() {
vec4 p = texture(src, qt_TexCoord0);
if (p.a == 0) // Otherwise background is affected
discard;
fragColor = color * qt_Opacity;
}
@@ -0,0 +1,19 @@
#version 440
layout(location = 0) in vec2 qt_TexCoord0;
layout(location = 0) out vec4 fragColor;
layout(std140, binding = 0) uniform buf {
mat4 qt_Matrix;
float qt_Opacity;
};
layout(binding = 1) uniform sampler2D shadow;
layout(binding = 2) uniform sampler2D original;
void main() {
vec4 o = texture(original, qt_TexCoord0); // original
if (o.a != 0.0)
discard;
vec4 s = texture(shadow, qt_TexCoord0); // shadow
fragColor = s;
}
@@ -0,0 +1,52 @@
#version 440
layout(location = 0) in vec2 qt_TexCoord0;
layout(location = 0) out vec4 fragColor;
layout(std140, binding = 0) uniform buf {
mat4 qt_Matrix;
float qt_Opacity;
float blurKernel;
float sigma;
vec2 pixelSize;
int useOffscreenColor; // bool
vec4 offscreenColor;
};
layout(binding = 1) uniform sampler2D src;
const float PI = 3.14159265359;
const float sqrtDoublePI = sqrt(2.0 * PI);
vec4 gaussianBlur(sampler2D tex, int miplevel) {
vec4 col = vec4(0.0);
float sum = 0;
float k = ceil(blurKernel);
// Normalize kernel weights
for (float i = -k; i <= k; ++i) {
sum += exp(-0.5 * pow(i / sigma, 2.0)) / (sqrtDoublePI * sigma);
}
for (float i = -k; i <= k; ++i) {
vec2 coord = qt_TexCoord0 + (pixelSize * float(i));
float weight = exp(-0.5 * pow(i / sigma, 2.0)) / (sqrtDoublePI * sigma);
if (useOffscreenColor != 0
&& (coord.x > 1.0 || coord.y > 1.0
|| coord.x < 0.0 || coord.y < 0.0)) {
col += offscreenColor * weight / sum;
} else {
col += texture(tex, coord) * weight / sum;
}
}
return col;
}
void main() {
vec4 p = (blurKernel > 0) ? gaussianBlur(src, 0)
: texture(src, qt_TexCoord0);
fragColor = p * qt_Opacity;
}
@@ -0,0 +1,19 @@
#version 440
layout(location = 0) in vec2 qt_TexCoord0;
layout(location = 0) out vec4 fragColor;
layout(std140, binding = 0) uniform buf {
mat4 qt_Matrix;
float qt_Opacity;
vec4 color;
};
layout(binding = 1) uniform sampler2D src;
void main() {
vec4 p = texture(src, qt_TexCoord0);
if (p.a != 0)
discard;
fragColor = color * qt_Opacity;
}
@@ -0,0 +1,27 @@
#version 440
layout(location = 0) in vec2 qt_TexCoord0;
layout(location = 0) out vec4 fragColor;
layout(std140, binding = 0) uniform buf {
mat4 qt_Matrix;
float qt_Opacity;
};
layout(binding = 1) uniform sampler2D shadow;
layout(binding = 2) uniform sampler2D original;
void main() {
vec4 o = texture(original, qt_TexCoord0); // original
if (o.a == 0)
discard;
vec4 s = texture(shadow, qt_TexCoord0); // shadow
if (s.a == 0)
discard;
fragColor = s;
//} else {
// fragColor.rgb = mix(s.rgb, o.rgb, (1.0 - s.a));
// fragColor.a = s.a + (o.a * (1.0 - s.a));
//}
}
@@ -0,0 +1,27 @@
#version 440
layout(location = 0) in vec2 qt_TexCoord0;
layout(location = 0) out vec4 fragColor;
layout(std140, binding = 0) uniform buf {
// qt_Matrix and qt_Opacity must always be both present
// if the built-in vertex shader is used.
mat4 qt_Matrix;
float qt_Opacity;
};
layout(binding = 1) uniform sampler2D source;
layout(binding = 2) uniform sampler2D maskSource;
void main()
{
if (texture(maskSource, qt_TexCoord0.st).a == 0.0) {
fragColor = vec4(0);
} else {
fragColor = texture(source, qt_TexCoord0.st);
}
//fragColor = texture(source, qt_TexCoord0.st)
// * (texture(maskSource, qt_TexCoord0.st).a)
// * qt_Opacity;
}