RibbonView and RibbonBlur: Add pull up and pull down signals and use new blur effect.

This commit is contained in:
Mentalflow 2024-02-27 21:45:03 +08:00
parent d8b4b1070c
commit aa3604579b
Signed by: Mentalflow
GPG Key ID: 5AE68D4401A2EE71
2 changed files with 52 additions and 11 deletions

View File

@ -18,8 +18,10 @@ Rectangle {
sourceRect: target_rect
sourceItem: target
layer.enabled: true
layer.effect: FastBlur{
layer.effect: GaussianBlur{
radius: blur_radius
deviation: 8
samples: (radius / 4) * 3
}
}
Rectangle{
@ -29,13 +31,4 @@ Rectangle {
opacity: mask_opacity
radius: control.radius
}
// ShaderEffect{
// id:blur
// anchors.fill: parent
// property var src: effect
// property int radius: blur_radius
// property real deviation: 8
// property var pixelStep: Qt.vector2d(1/src.width, 1/src.height)
// fragmentShader: "qrc:/RibbonUI/effects/gaussianblur.frag.qsb"
// }
}

View File

@ -12,6 +12,10 @@ Item {
property int spacing: 5
property int top_padding: 0
property int bottom_padding: 0
property double pull_threshold: 10
property alias flickview: flickview
signal pull_up_triggered()
signal pull_down_triggered()
z:-2
clip: true
anchors{
@ -84,7 +88,51 @@ Item {
target_rect: Qt.rect(x,y-top_padding,width,height)
}
Timer
{
id: timer
property int type: 0
interval:200
repeat: false
onTriggered: {
if (type == 1)
pull_up_triggered()
else if (type == 2)
pull_down_triggered()
type = 0
}
}
states: [
State {
id: pull_up
name: "pullUp"; when: (flickview.contentY < -pull_threshold)
StateChangeScript {
name: "pullUp_func"
script: {
timer.type = 1
timer.start()
}
}
},
State {
id: pull_bottom
name: "pullBottom"; when: (flickview.contentHeight > 0) && (flickview.contentY > (flickview.contentHeight - flickview.height + pull_threshold))
StateChangeScript {
name: "pullBottom_func"
script: {
timer.type = 2
timer.start()
}
}
}
]
function scroll_to_up(){
flickview.contentY = flickview.height
}
function scroll_to_bottom(){
flickview.contentY = flickview.contentHeight - flickview.height
flickview.contentY = flickview.contentHeight > flickview.height ? flickview.contentHeight - flickview.height : flickview.contentY
}
}