Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 40 additions & 5 deletions shell.qml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ PanelWindow {
property real slideOffset: Config.c.slideOffset ?? 30
property real animationDuration: Config.c.animationDuration ?? 600
property real titleDuration: Config.c.titleDuration ?? 7000
property real calculatedWidth: 100

width: textRow.width
width: textContainer.width // ?? calculatedWidth
height: MusicTitleFont.fontInfo.lineHeight

opacity: 0.0
Expand Down Expand Up @@ -163,9 +164,26 @@ PanelWindow {
}
}

Row {
id: textRow
spacing: bitmapTitle.characterSpacing
Item {
id: textContainer
width: calculateTextWidth()
height: MusicTitleFont.fontInfo.lineHeight

function calculateTextWidth() {
var totalWidth = 0;
for (var i = 0; i < bitmapTitle.text.length; i++) {
var charCode = bitmapTitle.text.charCodeAt(i);
var fontData = bitmapTitle.getFontForChar(charCode);
var charData = fontData.getCharData(charCode);
totalWidth += charData.xadvance;

if (i < bitmapTitle.text.length - 1) {
totalWidth += bitmapTitle.characterSpacing;
}
}
bitmapTitle.calculatedWidth = totalWidth;
return totalWidth;
}

Repeater {
model: bitmapTitle.text.length
Expand All @@ -175,20 +193,36 @@ PanelWindow {
property var fontData: bitmapTitle.getFontForChar(charCode)
property var charData: fontData.getCharData(charCode)
property real configScale: Config.c.scale ?? 2
property real calculatedX: bitmapTitle.calculateCharacterX(index)

source: fontData.fontImage
sourceClipRect: Qt.rect(charData.x, charData.y, charData.width, charData.height)

width: charData.width * configScale
height: charData.height * configScale
x: charData.xoffset * configScale
x: calculatedX + charData.xoffset
y: charData.yoffset // * configScale

smooth: false
}
}
}

function calculateCharacterX(charIndex) {
var xPos = 0;
for (var i = 0; i < charIndex; i++) {
var charCode = text.charCodeAt(i);
var fontData = getFontForChar(charCode);
var charData = fontData.getCharData(charCode);
xPos += charData.xadvance;

if (i < text.length - 1) {
xPos += charData.width;
}
}
return xPos;
}

function updateMusicInfo() {
var statusProc = Qt.createQmlObject(`
import Quickshell.Io
Expand Down Expand Up @@ -234,6 +268,7 @@ PanelWindow {

function showTitle() {
hideTimer.stop();
textContainer.calculateTextWidth();
isAnimating = true;
opacity = 0.0;
x = baseX - slideOffset;
Expand Down