Skip to content
Merged
Show file tree
Hide file tree
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
77 changes: 10 additions & 67 deletions examples/SimpleViewer/ControlPanel.qml
Original file line number Diff line number Diff line change
@@ -1,81 +1,24 @@
// SPDX-FileCopyrightText: 2023 Jonas Kalinka <jonas.kalinka@basyskom.com>
// SPDX-FileCopyrightText: 2023 basysKom GmbH

//
// SPDX-License-Identifier: LGPL-3.0-or-later

import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15

Rectangle {
id: root
GroupBox {
id: container

signal clicked(var modelData)
property alias model: buttonList.model
property alias delegate: buttonList.delegate

property alias model: buttonRepeater.model
property alias delegate: buttonRepeater.delegate
property alias title: title.text
property int highlightedIndex: -1
implicitWidth: 200

clip: true
color: "white"
ListView {
id: buttonList

ColumnLayout {
anchors.fill: parent
anchors.margins: 2

Text {
id: title
text: "Title"
color: "black"
}

ScrollView {
id: scrollView
Layout.fillHeight: true
Layout.fillWidth: true
clip: true
background: Rectangle {
color: "white"
}

Column {
id: buttonColumn
anchors.fill: parent
spacing: 1

Repeater {
id: buttonRepeater

delegate: Button {
id: buttonDelegate
flat: true
padding: 2

checkable: true
checked: highlightedIndex === index

text: {
let result = ""

if (modelData.id !== undefined) {
result = "ID: " + modelData.id + " "
}

if (modelData.name) {
result += "Name: " + modelData.name
} else {
result = modelData
}

return result
}

onClicked: {
root.clicked(modelData)
}
}
}
}
}
clip: true
}
}
179 changes: 82 additions & 97 deletions examples/SimpleViewer/RiveInspectorView.qml
Original file line number Diff line number Diff line change
@@ -1,176 +1,161 @@
// SPDX-FileCopyrightText: 2023 Jonas Kalinka <jonas.kalinka@basyskom.com>
// SPDX-FileCopyrightText: 2023 basysKom GmbH

//
// SPDX-License-Identifier: LGPL-3.0-or-later

import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15

import RiveQtQuickPlugin 1.0

Item {
id: root
id: container

property alias fileSource: riveItem.fileSource

RowLayout {
anchors.fill: parent

ControlPanel {
title: "Artboards"
Layout.fillHeight: true

title: "Artboards"
model: riveItem.artboards
highlightedIndex: riveItem.currentArtboardIndex
visible: model !== undefined ? model.length > 0 : false
onClicked: modelData => {
if (riveItem.currentArtboardIndex === modelData.id) {
riveItem.currentArtboardIndex = -1
} else {
riveItem.currentArtboardIndex = modelData.id
}
}
delegate: CheckDelegate {
width: ListView.view.width
autoExclusive: true
checked: riveItem.currentArtboardIndex === modelData.id
text: modelData.name

Layout.fillHeight: true
Layout.minimumWidth: 200
Layout.minimumHeight: 200
onClicked: riveItem.currentArtboardIndex = modelData.id
}
}

ControlPanel {
title: "Animations"
Layout.fillHeight: true

title: "Animations"
model: riveItem.animations
highlightedIndex: riveItem.currentAnimationIndex
visible: model !== undefined ? model.length > 0 : false
onClicked: modelData => {
if (riveItem.currentAnimationIndex === modelData.id) {
riveItem.currentAnimationIndex = -1
} else {
riveItem.currentAnimationIndex = modelData.id
}
}
delegate: CheckDelegate {
width: ListView.view.width
checked: riveItem.currentAnimationIndex === modelData.id
text: modelData.name

Layout.fillHeight: true
Layout.minimumWidth: 200
Layout.minimumHeight: 200
onClicked: riveItem.currentAnimationIndex = riveItem.currentAnimationIndex === modelData.id ? -1 : modelData.id
}
}

ControlPanel {
title: "State Machines"
Layout.fillHeight: true

title: "State Machines"
model: riveItem.stateMachines
highlightedIndex: riveItem.currentStateMachineIndex
visible: model !== undefined ? model.length > 0 : false
onClicked: modelData => {
if (riveItem.currentStateMachineIndex === modelData.id) {
riveItem.currentStateMachineIndex = -1
} else {
riveItem.currentStateMachineIndex = modelData.id
}
}
delegate: CheckDelegate {
width: ListView.view.width
checked: riveItem.currentStateMachineIndex === modelData.id
text: modelData.name

Layout.fillHeight: true
Layout.minimumWidth: 200
Layout.minimumHeight: 200
onClicked: riveItem.currentStateMachineIndex = riveItem.currentStateMachineIndex === modelData.id ? -1 : modelData.id
}
}

ControlPanel {
id: dynamicProperties
title: "Properties"

Layout.fillHeight: true

title: "Properties"
model: riveItem.stateMachineInterface.riveInputs
visible: riveItem.stateMachineInterface.riveInputs.length > 0

delegate: Button {
id: buttonDelegate
delegate: ColumnLayout {
width: ListView.view.width

width: dynamicProperties.width
ItemDelegate {
Layout.fillWidth: true

flat: true
padding: 2

checkable: false

text: {
if (modelData.type == RiveStateMachineInput.RiveTrigger) {
return modelData.text
visible: modelData.type != RiveStateMachineInput.RiveBoolean
text: {
if (modelData.type == RiveStateMachineInput.RiveTrigger) {
return modelData.text
} else if (modelData.type == RiveStateMachineInput.RiveNumber) {
return modelData.text + ": " + riveItem.stateMachineInterface.listenTo(modelData.text).value
} else {
return modelData.text + " " + modelData.type
}
}

if (modelData.type == RiveStateMachineInput.RiveBoolean
|| modelData.type == RiveStateMachineInput.RiveNumber) {
return modelData.text + ": "+riveItem.stateMachineInterface.listenTo(modelData.text).value
onClicked: {
if (modelData.type == RiveStateMachineInput.RiveTrigger) {
riveItem.stateMachineInterface.callTrigger(modelData.text)
}
}
return modelData.text + " " + modelData.type
}

onClicked: {
if (modelData.type == RiveStateMachineInput.RiveTrigger) {
riveItem.stateMachineInterface.callTrigger(modelData.text)
}
if (modelData.type == RiveStateMachineInput.RiveBoolean) {
riveItem.stateMachineInterface.setRiveProperty(modelData.text,
!riveItem.stateMachineInterface.listenTo(modelData.text).value)
}
SwitchDelegate {
Layout.fillWidth: true

text: modelData.text
visible: modelData.type == RiveStateMachineInput.RiveBoolean
checked: riveItem.stateMachineInterface.listenTo(modelData.text).value

onClicked: riveItem.stateMachineInterface.setRiveProperty(modelData.text,
!riveItem.stateMachineInterface.listenTo(modelData.text).value)
}

Slider {
id: slider

visible: modelData.type == RiveStateMachineInput.RiveNumber

anchors.fill: parent
Layout.fillWidth: true

from: 1
value: visible ? riveItem.stateMachineInterface.listenTo(modelData.text).value : 0
to: 100
stepSize: 1
visible: modelData.type == RiveStateMachineInput.RiveNumber

onValueChanged: riveItem.stateMachineInterface.setRiveProperty(modelData.text, value)
}
}

Layout.fillHeight: true
Layout.minimumWidth: 200
Layout.minimumHeight: 200
}

Rectangle {
color: "black"
Layout.fillHeight: true
Layout.fillWidth: true
Layout.fillHeight: true

Rectangle {
anchors.fill: parent
anchors.margins: 30
color: "grey"
border.color: "red"
color: "grey"
border.color: "red"

RiveQtQuickItem {
id: riveItem
RiveQtQuickItem {
id: riveItem

anchors.fill: parent
anchors.margins: 1
anchors.fill: parent
anchors.margins: parent.border.width

currentArtboardIndex: 0
currentStateMachineIndex: -1
currentArtboardIndex: 0
currentStateMachineIndex: -1

renderQuality: RiveQtQuickItem.Medium
postprocessingMode: RiveQtQuickItem.None
fillMode: RiveQtQuickItem.PreserveAspectFit
renderQuality: RiveQtQuickItem.Medium
postprocessingMode: RiveQtQuickItem.None
fillMode: RiveQtQuickItem.PreserveAspectFit

onStateMachineStringInterfaceChanged: {
dynamicProperties.model = riveItem.stateMachineInterface.riveInputs
Label {
anchors {
top: parent.top
right: parent.right
margins: 5
}
color: "red"
text: riveItem.frameRate
font.pixelSize: 30
}

Text {
anchors {
top: parent.top
right: parent.right
margins: 5
}
color: "red"
text: riveItem.frameRate
font.pixelSize: 30
}
onStateMachineStringInterfaceChanged: {
dynamicProperties.model = riveItem.stateMachineInterface.riveInputs
}
}
}
Expand Down
8 changes: 0 additions & 8 deletions examples/SimpleViewer/main.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@

// SPDX-FileCopyrightText: 2023 Jeremias Bosch <jeremias.bosch@basyskom.com>
// SPDX-FileCopyrightText: 2023 basysKom GmbH
//
// SPDX-License-Identifier: LGPL-3.0-or-later

#include <QDir>
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQuickWindow>

int main(int argc, char *argv[])
{

QSurfaceFormat f;
f.setSamples(4);
QSurfaceFormat::setDefaultFormat(f);
Expand All @@ -30,11 +27,6 @@ int main(int argc, char *argv[])

QQmlApplicationEngine engine;

const auto &pathList = engine.importPathList();
for (const QString &path : pathList) {
qDebug() << " " << path;
}

const QUrl url(QStringLiteral("qrc:/main.qml"));
QObject::connect(
&engine, &QQmlApplicationEngine::objectCreated, &app,
Expand Down
Loading
Loading