1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-07 03:22:33 +01:00

Fix LineHandle time and Timeline hour marks

This commit is contained in:
Elias Steurer 2024-09-12 12:51:10 +02:00
parent d28edc070e
commit 1db297776c
2 changed files with 42 additions and 37 deletions

View File

@ -1,31 +1,14 @@
import QtQuick
import QtQuick.Controls
import ScreenPlayApp
Item {
id: root
property real lineWidth: 1
property real linePosition: (root.x / lineWidth).toFixed(4)
property real linePosition: Number((root.x / lineWidth).toFixed(6))
property string timeString: {
const normalized = root.x / root.lineWidth;
// Your existing normalization
let totalHours = normalized * 24;
let hours = Math.floor(totalHours);
// Gets the whole hour part
let minutes = Math.round((totalHours - hours) * 60);
// Calculates the minutes
// Check if minutes rolled over to 60, adjust hours and minutes accordingly
if (minutes === 60) {
hours += 1; // Increment hours by 1
minutes = 0; // Reset minutes to 0
}
// Ensure hours wrap correctly at 24
if (hours === 24) {
hours = 0;
}
// Format hours and minutes to always have two digits
return hours.toString().padStart(2, '0') + ":" + minutes.toString().padStart(2, '0');
return App.util.getTimeString(normalized)
}
property real lineMinimum: .5

View File

@ -367,7 +367,7 @@ Control {
// Current time indicator
Rectangle {
id: currentTimeIndicator
color: Material.color(Material.BlueGrey)
color: Qt.alpha(Material.color(Material.BlueGrey), 0.5)
width: 2
height: 30
y: (addHandleWrapper.height - height) / 2 // Vertically center within addHandleWrapper
@ -400,36 +400,58 @@ Control {
}
}
RowLayout {
Item {
id: timelineIndicatorWrapper
height: 30
uniformCellSizes: true
// spacing: 0
anchors {
top: parent.top
right: parent.right
left: parent.left
leftMargin: -5
}
Text {
color: "gray"
text: "0"
anchors {
horizontalCenter: zeroIndicator.horizontalCenter
}
}
Rectangle {
id: zeroIndicator
color: "gray"
width: 1
height: 10
anchors {
right: timelineIndicatorWrapper.left
bottom: timelineIndicatorWrapper.bottom
}
}
Repeater {
model: 25
id: timelineIndicator
model: 24
Item {
width: 20
id: timelineIndicatorItem
width: timelineIndicatorWrapper.width / timelineIndicator.count
height: 30
required property int index
x: timelineIndicatorItem.index * width
Text {
id: txtHours
color: "gray"
text: index
text: timelineIndicatorItem.index + 1
anchors {
horizontalCenter: parent.horizontalCenter
horizontalCenter: indicator.horizontalCenter
}
}
Rectangle {
id: indicator
color: "gray"
width: 1
height: 10
anchors {
horizontalCenter: txtHours.horizontalCenter
right: parent.right
bottom: parent.bottom
}
}
@ -441,8 +463,8 @@ Control {
text: ""
enabled: !App.globalVariables.isBasicVersion()
onClicked: {
const p = this.x / timeline.width;
const position = p.toFixed(4);
const absTimelinePosX = this.x - width *.5// todo
const position = Number(absTimelinePosX / timeline.width).toFixed(6);
const identifier = App.util.generateRandomString(4);
const sectionObject = timeline.addSection(identifier, position);
const addTimelineAtSuccess = App.screenPlayManager.addTimelineAt(sectionObject.index, sectionObject.relativeLinePosition, sectionObject.identifier);
@ -478,18 +500,18 @@ Control {
}
}
Rectangle {
height: 18
color: "#757575"
width: 2
height: 20
color: "gray"
width: 1
anchors {
right: parent.left
verticalCenter: lineIndicatorWrapper.verticalCenter
}
}
Rectangle {
height: 18
width: 2
color: "#757575"
height: 20
width: 1
color: "gray"
anchors {
right: parent.right
verticalCenter: lineIndicatorWrapper.verticalCenter