add new snippet 'hourglass'; revision of 'help.htm'

This commit is contained in:
pls.153 2023-09-19 18:45:42 +02:00
parent ec4c140f9c
commit 6a664c9d27
11 changed files with 71 additions and 1 deletions

View file

@ -54,6 +54,8 @@
Meant for passing INTEGER to QML/JS, where we only have floats. The integer
is stored as a hex string in QML, and automatically converted back to a
'qint64' integer when passed with 'Lisp.call()'.
If the conversion to 'qint64' is not possible, the hex string is returned,
which can be passed to READ-FROM-STRING to get arbitrary integer length.
<b>pixel-ratio ()</b>

View file

@ -0,0 +1,40 @@
import QtQuick 2.15
Rectangle {
anchors.fill: parent
visible: animation.running
Image {
id: hourglass1
anchors.centerIn: parent
width: 40
fillMode: Image.PreserveAspectFit
source: "../img/hourglass.png"
}
Image {
id: hourglass2
anchors.centerIn: parent
width: hourglass1.width
fillMode: Image.PreserveAspectFit
source: "../img/hourglass.png"
opacity: 0
}
SequentialAnimation {
id: animation
objectName: "hourglass"
loops: Animation.Infinite
RotationAnimation { target: hourglass1; from: 0; to: 180; duration: 1000; easing.type: Easing.InOutSine }
ParallelAnimation {
NumberAnimation { target: hourglass1; property: "opacity"; from: 1; to: 0; duration: 1500; easing.type: Easing.InOutSine }
NumberAnimation { target: hourglass2; property: "opacity"; from: 0; to: 1; duration: 1500; easing.type: Easing.InOutSine }
}
// reset
NumberAnimation { target: hourglass1; property: "opacity"; to: 1; duration: 0 }
NumberAnimation { target: hourglass2; property: "opacity"; to: 0; duration: 0 }
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View file

@ -0,0 +1,9 @@
import QtQuick 2.15
import 'ext/' as Ext
Rectangle {
width: 300
height: 500
Ext.Hourglass {}
}

View file

@ -0,0 +1,5 @@
Description
-----------
An hourglass animation (written in QML) during a long activity running in
a thread.

View file

@ -0,0 +1,12 @@
(in-package :qml-user)
(defun load-huge-library ()
(q> |running| "hourglass" t) ; start animation
;; run task in thread
(mp:process-run-function
:loading
(lambda ()
(sleep 10) ; loading patiently...
(q> |running| "hourglass" nil)))) ; stop animation
(qsingle-shot 1000 'load-huge-library)

View file

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Before After
Before After

View file

@ -18,7 +18,9 @@
"args: (integer)
Meant for passing INTEGER to QML/JS, where we only have floats. The integer
is stored as a hex string in QML, and automatically converted back to a
'qint64' integer when passed with 'Lisp.call()'."
'qint64' integer when passed with 'Lisp.call()'.
If the conversion to 'qint64' is not possible, the hex string is returned,
which can be passed to READ-FROM-STRING to get arbitrary integer length."
(assert (integerp integer))
(let ((*print-base* 16))
(x:cc "#x" (princ-to-string integer))))