import QtQuick 2.15
import QtQuick.Controls 2.15

// Root visual element for the QuickWidget
Rectangle {
    // 1. Scene Setup
    color: "black"
    clip: true

    // Calculate the total pixel offset based on the exposed C++ property
    property real visibleStartX: width - (glWidget.rightEndBar * glWidget.pixelsPerBar)
    
    // 2. Scene Container (Moves the entire content area)
    // The X position is bound directly to the calculated offset (visibleStartX)
    Rectangle {
        id: sceneContainer
        x: visibleStartX // This is the core animation driver
        y: 0
        width: 10000 // Arbitrarily large to hold all ribbons
        height: parent.height
        color: "transparent" // The container itself is invisible

        // 3. Renderer: Repeater to render all the chord/lyric elements
        Repeater {
            model: glWidget.ribbonData // Binds to the QVariantList from C++

            // The delegate defines how each item in the list is rendered
            delegate: Text {
                // Positional properties
                x: model.xPosAbsolute // Absolute X from C++
                y: model.yPos
                
                // Text properties
                text: model.text
                font.pixelSize: model.fontSize
                
                // Color properties (Matching the original OpenGL code's colors)
                color: model.isChord ? "#0000ff" : "#ffffff" // Blue for Chords, White for Lyrics
                
                // Note: QML handles clipping and culling automatically based on the parent's clip: true
                // so the C++ culling logic is no longer strictly necessary here.
            }
        }
    }
}