async parsing + tex caching
This commit is contained in:
@@ -1,32 +1,42 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Templates
|
||||
import qs.Helpers
|
||||
import ZShell.Config
|
||||
import qs.Services
|
||||
|
||||
ScrollBar {
|
||||
id: root
|
||||
|
||||
required property Flickable flickable
|
||||
readonly property bool isHorizontal: flickable && flickable.ScrollBar.horizontal === root
|
||||
readonly property real axisSize: isHorizontal ? flickable.width : flickable.height
|
||||
readonly property real axisContentSize: isHorizontal ? flickable.contentWidth : flickable.contentHeight
|
||||
readonly property real axisContentPos: isHorizontal ? flickable.contentX : flickable.contentY
|
||||
readonly property real axisLength: isHorizontal ? root.width : root.height
|
||||
readonly property real effectiveSize: Math.max(nonAnimHeight, root.minimumSize)
|
||||
readonly property real effectiveTravel: Math.max(0, 1 - root.effectiveSize)
|
||||
required property Flickable flickable
|
||||
readonly property real nonAnimHeight: flickable.height / flickable.contentHeight
|
||||
readonly property real nonAnimY: flickable.contentY / flickable.contentHeight
|
||||
readonly property real nonAnimHeight: root.axisSize / root.axisContentSize
|
||||
readonly property real nonAnimY: root.axisContentPos / root.axisContentSize
|
||||
readonly property real rawTravel: Math.max(0, 1 - root.nonAnimHeight)
|
||||
readonly property bool reversed: flickable instanceof ListView && flickable.verticalLayoutDirection === ListView.BottomToTop
|
||||
readonly property bool reversed: isHorizontal ? (flickable instanceof ListView && flickable.layoutDirection === Qt.RightToLeft) : (flickable instanceof ListView && flickable.verticalLayoutDirection === ListView.BottomToTop)
|
||||
property bool shouldBeActive
|
||||
readonly property real travelScale: root.rawTravel > 0 ? root.effectiveTravel / root.rawTravel : 0
|
||||
|
||||
enabled: !Visibilities.getForActive().isDrawing
|
||||
implicitWidth: Tokens.padding.extraSmall * 2
|
||||
parent: flickable.parent
|
||||
anchors.left: isHorizontal ? flickable.left : undefined
|
||||
anchors.right: flickable.right
|
||||
anchors.top: isHorizontal ? undefined : flickable.top
|
||||
anchors.bottom: flickable.bottom
|
||||
implicitWidth: isHorizontal ? 0 : Tokens.padding.extraSmall * 2
|
||||
implicitHeight: isHorizontal ? Tokens.padding.extraSmall * 2 : 0
|
||||
|
||||
contentItem: Item {
|
||||
}
|
||||
contentItem: Item {}
|
||||
Behavior on position {
|
||||
enabled: !fullMouse.pressed
|
||||
|
||||
Anim {
|
||||
}
|
||||
Anim {}
|
||||
}
|
||||
|
||||
onHoveredChanged: {
|
||||
@@ -47,54 +57,26 @@ ScrollBar {
|
||||
target: root.flickable
|
||||
}
|
||||
|
||||
CustomClippingRect {
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
implicitWidth: handle.implicitWidth
|
||||
radius: Tokens.rounding.full
|
||||
Loader {
|
||||
anchors.fill: parent
|
||||
sourceComponent: root.isHorizontal ? horizontalTrack : verticalTrack
|
||||
}
|
||||
|
||||
CustomRect {
|
||||
id: handle
|
||||
Component {
|
||||
id: verticalTrack
|
||||
|
||||
anchors.right: parent.right
|
||||
color: Colors.palette.m3secondary
|
||||
implicitHeight: root.height * root.effectiveSize
|
||||
implicitWidth: fullMouse.pressed || fullMouse.containsMouse ? Tokens.padding.extraSmall * 2 : Tokens.padding.extraSmall
|
||||
opacity: {
|
||||
if (!root.enabled)
|
||||
return 0;
|
||||
if (root.size === 1)
|
||||
return 0;
|
||||
if (fullMouse.pressed)
|
||||
return 1;
|
||||
if (fullMouse.containsMouse)
|
||||
return 0.8;
|
||||
if (root.policy === ScrollBar.AlwaysOn || root.shouldBeActive)
|
||||
return 0.6;
|
||||
return 0;
|
||||
}
|
||||
radius: Tokens.rounding.full
|
||||
y: root.reversed ? root.height * (1 + root.nonAnimY) * root.travelScale : root.height * root.nonAnimY * root.travelScale
|
||||
VerticalScrollBarTrack {
|
||||
scrollBar: root
|
||||
mouseArea: fullMouse
|
||||
}
|
||||
}
|
||||
|
||||
Behavior on implicitWidth {
|
||||
Anim {
|
||||
}
|
||||
}
|
||||
Behavior on opacity {
|
||||
Anim {
|
||||
type: Anim.DefaultEffects
|
||||
}
|
||||
}
|
||||
Component {
|
||||
id: horizontalTrack
|
||||
|
||||
MouseArea {
|
||||
id: mouse
|
||||
|
||||
acceptedButtons: Qt.NoButton
|
||||
anchors.fill: parent
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
hoverEnabled: true
|
||||
}
|
||||
HorizontalScrollBarTrack {
|
||||
scrollBar: root
|
||||
mouseArea: fullMouse
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,21 +93,25 @@ ScrollBar {
|
||||
|
||||
property real pressOffset: 0
|
||||
|
||||
function contentYFromThumbTop(thumbTop) {
|
||||
var visualPos = root.effectiveTravel > 0 ? thumbTop / root.travelScale : 0;
|
||||
|
||||
return root.reversed ? (visualPos - 1) * root.flickable.contentHeight : visualPos * root.flickable.contentHeight;
|
||||
function contentPosFromThumbStart(thumbStart) {
|
||||
var visualPos = root.effectiveTravel > 0 ? thumbStart / root.travelScale : 0;
|
||||
return root.reversed ? (visualPos - 1) * root.axisContentSize : visualPos * root.axisContentSize;
|
||||
}
|
||||
|
||||
function updateFromEvent(event) {
|
||||
var posInTrack = event.y / root.height;
|
||||
var thumbTop = posInTrack - pressOffset;
|
||||
thumbTop = Math.max(0, Math.min(root.effectiveTravel, thumbTop));
|
||||
var eventPos = root.isHorizontal ? event.x : event.y;
|
||||
var posInTrack = eventPos / root.axisLength;
|
||||
var thumbStart = posInTrack - pressOffset;
|
||||
thumbStart = Math.max(0, Math.min(root.effectiveTravel, thumbStart));
|
||||
|
||||
root.flickable.contentY = contentYFromThumbTop(thumbTop);
|
||||
var newPos = contentPosFromThumbStart(thumbStart);
|
||||
if (root.isHorizontal)
|
||||
root.flickable.contentX = newPos;
|
||||
else
|
||||
root.flickable.contentY = newPos;
|
||||
}
|
||||
|
||||
function visualThumbTop() {
|
||||
function visualThumbStart() {
|
||||
const visualPos = root.reversed ? (1 + root.nonAnimY) : root.nonAnimY;
|
||||
return visualPos * root.travelScale;
|
||||
}
|
||||
@@ -140,22 +126,18 @@ ScrollBar {
|
||||
updateFromEvent(event);
|
||||
}
|
||||
onPressed: event => {
|
||||
var currentTop = visualThumbTop();
|
||||
var currentBottom = currentTop + root.effectiveSize;
|
||||
var clickPos = event.y / root.height;
|
||||
var currentStart = visualThumbStart();
|
||||
var currentEnd = currentStart + root.effectiveSize;
|
||||
var eventPos = root.isHorizontal ? event.x : event.y;
|
||||
var clickPos = eventPos / root.axisLength;
|
||||
|
||||
var clickedInsideThumb = clickPos >= currentTop && clickPos <= currentBottom;
|
||||
|
||||
if (clickedInsideThumb) {
|
||||
pressOffset = clickPos - currentTop;
|
||||
} else {
|
||||
pressOffset = root.effectiveSize / 2;
|
||||
}
|
||||
var clickedInsideThumb = clickPos >= currentStart && clickPos <= currentEnd;
|
||||
pressOffset = clickedInsideThumb ? (clickPos - currentStart) : root.effectiveSize / 2;
|
||||
|
||||
updateFromEvent(event);
|
||||
}
|
||||
onWheel: event => {
|
||||
var delta = event.angleDelta.y > 0 ? -0.1 : 0.1;
|
||||
var delta = (root.isHorizontal ? event.angleDelta.x : event.angleDelta.y) > 0 ? -0.1 : 0.1;
|
||||
var newPos = Math.max(0, Math.min(1 - root.size, root.position + delta));
|
||||
root.position = newPos;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
import QtQuick
|
||||
import ZShell.Config
|
||||
import qs.Services
|
||||
|
||||
CustomClippingRect {
|
||||
id: track
|
||||
|
||||
required property var scrollBar
|
||||
required property var mouseArea
|
||||
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
implicitHeight: handle.implicitHeight
|
||||
radius: Tokens.rounding.full
|
||||
|
||||
CustomRect {
|
||||
id: handle
|
||||
|
||||
anchors.bottom: parent.bottom
|
||||
color: Colors.palette.m3secondary
|
||||
implicitWidth: track.scrollBar.width * track.scrollBar.effectiveSize
|
||||
implicitHeight: track.mouseArea.pressed || track.mouseArea.containsMouse ? Tokens.padding.extraSmall * 2 : Tokens.padding.extraSmall
|
||||
opacity: {
|
||||
if (!track.scrollBar.enabled)
|
||||
return 0;
|
||||
if (track.scrollBar.size === 1)
|
||||
return 0;
|
||||
if (track.mouseArea.pressed)
|
||||
return 1;
|
||||
if (track.mouseArea.containsMouse)
|
||||
return 0.8;
|
||||
if (track.scrollBar.policy === CustomScrollBar.AlwaysOn || track.scrollBar.shouldBeActive)
|
||||
return 0.6;
|
||||
return 0;
|
||||
}
|
||||
radius: Tokens.rounding.full
|
||||
x: track.scrollBar.reversed ? track.scrollBar.width * (1 + track.scrollBar.nonAnimY) * track.scrollBar.travelScale : track.scrollBar.width * track.scrollBar.nonAnimY * track.scrollBar.travelScale
|
||||
|
||||
Behavior on implicitHeight {
|
||||
Anim {}
|
||||
}
|
||||
Behavior on opacity {
|
||||
Anim {
|
||||
type: Anim.DefaultEffects
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
acceptedButtons: Qt.NoButton
|
||||
anchors.fill: parent
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
hoverEnabled: true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
import QtQuick
|
||||
import QtQuick.Templates
|
||||
import ZShell.Config
|
||||
import qs.Services
|
||||
|
||||
TextArea {
|
||||
id: root
|
||||
|
||||
color: Colors.palette.m3onSurface
|
||||
cursorVisible: !readOnly
|
||||
font.pointSize: Tokens.font.size.small
|
||||
implicitHeight: contentHeight + topPadding + bottomPadding
|
||||
implicitWidth: contentWidth + leftPadding + rightPadding
|
||||
placeholderTextColor: Colors.palette.m3onSurfaceVariant // No anim cause placeholder is custom
|
||||
renderType: TextArea.NativeRendering
|
||||
selectedTextColor: color
|
||||
selectionColor: Qt.alpha(Colors.palette.m3primary, 0.4)
|
||||
verticalAlignment: TextInput.AlignVCenter
|
||||
|
||||
Behavior on color {
|
||||
CAnim {}
|
||||
}
|
||||
Behavior on selectionColor {
|
||||
CAnim {}
|
||||
}
|
||||
cursorDelegate: Item {}
|
||||
|
||||
CustomRect {
|
||||
id: cursor
|
||||
|
||||
property bool disableBlink
|
||||
|
||||
color: Colors.palette.m3primary
|
||||
implicitHeight: root.cursorRectangle.height
|
||||
implicitWidth: 1.5
|
||||
radius: Tokens.rounding.largeIncreased
|
||||
x: root.cursorRectangle.x
|
||||
y: root.cursorRectangle.y
|
||||
|
||||
Behavior on x {
|
||||
Anim {
|
||||
duration: Tokens.anim.durations.expressiveFastEffects
|
||||
easing.bezierCurve: [0.2, 1, 0.21, 1, 1, 1]
|
||||
}
|
||||
}
|
||||
Behavior on opacity {
|
||||
Anim {
|
||||
type: Anim.StandardSmall
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
function onCursorPositionChanged(): void {
|
||||
if (root.activeFocus && root.cursorVisible) {
|
||||
cursor.opacity = 1;
|
||||
cursor.disableBlink = true;
|
||||
enableBlink.restart();
|
||||
}
|
||||
}
|
||||
|
||||
target: root
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: enableBlink
|
||||
|
||||
interval: 500
|
||||
|
||||
onTriggered: cursor.disableBlink = false
|
||||
}
|
||||
|
||||
Timer {
|
||||
interval: 500
|
||||
repeat: true
|
||||
running: root.activeFocus && root.cursorVisible && !cursor.disableBlink
|
||||
triggeredOnStart: true
|
||||
|
||||
onTriggered: parent.opacity = parent.opacity === 1 ? 0 : 1
|
||||
}
|
||||
|
||||
Binding {
|
||||
cursor.opacity: 0
|
||||
when: !root.activeFocus || !root.cursorVisible
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
import QtQuick
|
||||
import ZShell.Config
|
||||
import qs.Services
|
||||
|
||||
CustomClippingRect {
|
||||
id: track
|
||||
|
||||
required property var scrollBar
|
||||
required property var mouseArea
|
||||
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
implicitWidth: handle.implicitWidth
|
||||
radius: Tokens.rounding.full
|
||||
|
||||
CustomRect {
|
||||
id: handle
|
||||
|
||||
anchors.right: parent.right
|
||||
color: Colors.palette.m3secondary
|
||||
implicitHeight: track.scrollBar.height * track.scrollBar.effectiveSize
|
||||
implicitWidth: track.mouseArea.pressed || track.mouseArea.containsMouse ? Tokens.padding.extraSmall * 2 : Tokens.padding.extraSmall
|
||||
opacity: {
|
||||
if (!track.scrollBar.enabled)
|
||||
return 0;
|
||||
if (track.scrollBar.size === 1)
|
||||
return 0;
|
||||
if (track.mouseArea.pressed)
|
||||
return 1;
|
||||
if (track.mouseArea.containsMouse)
|
||||
return 0.8;
|
||||
if (track.scrollBar.policy === CustomScrollBar.AlwaysOn || track.scrollBar.shouldBeActive)
|
||||
return 0.6;
|
||||
return 0;
|
||||
}
|
||||
radius: Tokens.rounding.full
|
||||
y: track.scrollBar.reversed ? track.scrollBar.height * (1 + track.scrollBar.nonAnimY) * track.scrollBar.travelScale : track.scrollBar.height * track.scrollBar.nonAnimY * track.scrollBar.travelScale
|
||||
|
||||
Behavior on implicitWidth {
|
||||
Anim {}
|
||||
}
|
||||
Behavior on opacity {
|
||||
Anim {
|
||||
type: Anim.DefaultEffects
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
acceptedButtons: Qt.NoButton
|
||||
anchors.fill: parent
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
hoverEnabled: true
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user