Inital commit of the Komplex Hub
This commit is contained in:
@@ -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,8 @@
|
||||
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 qmltyperegistrar.
|
||||
|
||||
Module {}
|
||||
@@ -0,0 +1,6 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file alias="/qt-project.org/imports/QtQuick/Studio/DesignEffects">/home/parametheus/Projects/QtDesigner/KomplexHub/build/qml/QtQuick/Studio/DesignEffects</file>
|
||||
|
||||
</qresource>
|
||||
</RCC>
|
||||
Binary file not shown.
@@ -0,0 +1,32 @@
|
||||
module QtQuick.Studio.DesignEffects
|
||||
linktarget QuickStudioDesignEffectsplugin
|
||||
optional plugin QuickStudioDesignEffectsplugin
|
||||
classname QtQuick_Studio_DesignEffectsPlugin
|
||||
designersupported
|
||||
typeinfo QuickStudioDesignEffects.qmltypes
|
||||
prefer :/qt-project.org/imports/QtQuick/Studio/DesignEffects/
|
||||
DesignBackgroundBlurPrivate 254.0 DesignBackgroundBlurPrivate.qml
|
||||
DesignBackgroundBlurPrivate 1.0 DesignBackgroundBlurPrivate.qml
|
||||
DesignBackgroundBlurPrivate 1.0 DesignBackgroundBlurPrivate.qml
|
||||
DesignDropShadow 254.0 DesignDropShadow.qml
|
||||
DesignDropShadow 1.0 DesignDropShadow.qml
|
||||
DesignDropShadow 1.0 DesignDropShadow.qml
|
||||
DesignDropShadowPrivate 254.0 DesignDropShadowPrivate.qml
|
||||
DesignDropShadowPrivate 1.0 DesignDropShadowPrivate.qml
|
||||
DesignDropShadowPrivate 1.0 DesignDropShadowPrivate.qml
|
||||
DesignEffect 254.0 DesignEffect.qml
|
||||
DesignEffect 1.0 DesignEffect.qml
|
||||
DesignEffect 1.0 DesignEffect.qml
|
||||
DesignEffectPrivate 254.0 DesignEffectPrivate.qml
|
||||
DesignEffectPrivate 1.0 DesignEffectPrivate.qml
|
||||
DesignEffectPrivate 1.0 DesignEffectPrivate.qml
|
||||
DesignInnerShadow 254.0 DesignInnerShadow.qml
|
||||
DesignInnerShadow 1.0 DesignInnerShadow.qml
|
||||
DesignInnerShadow 1.0 DesignInnerShadow.qml
|
||||
DesignInnerShadowPrivate 254.0 DesignInnerShadowPrivate.qml
|
||||
DesignInnerShadowPrivate 1.0 DesignInnerShadowPrivate.qml
|
||||
DesignInnerShadowPrivate 1.0 DesignInnerShadowPrivate.qml
|
||||
DesignLayerBlurPrivate 254.0 DesignLayerBlurPrivate.qml
|
||||
DesignLayerBlurPrivate 1.0 DesignLayerBlurPrivate.qml
|
||||
DesignLayerBlurPrivate 1.0 DesignLayerBlurPrivate.qml
|
||||
|
||||
Reference in New Issue
Block a user