Skip to content

Commit

Permalink
qmlui: preliminary implementation of Animation widget
Browse files Browse the repository at this point in the history
  • Loading branch information
mcallegari committed Aug 30, 2024
1 parent cb35bba commit d078e89
Show file tree
Hide file tree
Showing 6 changed files with 653 additions and 33 deletions.
145 changes: 133 additions & 12 deletions qmlui/qml/virtualconsole/VCAnimationItem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -36,31 +36,152 @@ VCWidgetItem
setCommonProperties(animationObj)
}

Row
GridLayout
{
id: itemsLayout
anchors.fill: parent

// value text box
columns: levelFader.visible ? 3 : 2

QLCPlusFader
{
id: levelFader
Layout.fillHeight: true
Layout.rowSpan: 3
from: 0
to: 255
visible: animationObj ? animationObj.visibilityMask & VCAnimation.Fader : true
value: animationObj ? animationObj.faderLevel : 0
onValueChanged: if (animationObj) animationObj.faderLevel = value
}

Text
{
width: parent.width
height: parent.height
color: "#bbb"
lineHeight: 0.8
horizontalAlignment: Text.AlignHCenter
Layout.columnSpan: 2
Layout.fillWidth: true
visible: animationObj ? animationObj.visibilityMask & VCAnimation.Label : true
font: animationObj ? animationObj.font : ""
text: animationObj ? animationObj.caption : ""
verticalAlignment: Text.AlignVCenter
textFormat: Text.RichText
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.Wrap
text: "VCAnimation not implemented yet.<br />See <a href=\"https://docs.google.com/spreadsheets/d/1J1BK0pYCsLVBfLpDZ-GqpNgUzbgTwmhf9zOjg4J_MWg\">QML Status</a>"
lineHeight: 0.8
color: animationObj ? animationObj.foregroundColor : "#111"
}

Rectangle
{
id: startColButton
width: UISettings.iconSizeDefault * 1.5
height: width
radius: 5
border.color: scMouseArea.containsMouse ? "white" : UISettings.bgLight
border.width: 2
color: animationObj ? animationObj.startColor : "transparent"
visible: animationObj ? animationObj.visibilityMask & VCAnimation.StartColor : true

MouseArea
{
id: scMouseArea
anchors.fill: parent
hoverEnabled: true
onClicked: startColTool.visible = !startColTool.visible
}

ColorTool
{
id: startColTool
parent: animationRoot.parent
x: animationRoot.x // -width - (UISettings.iconSizeDefault * 1.25)
y: animationRoot.y // UISettings.bigItemHeight
visible: false
closeOnSelect: true
currentRGB: animationObj ? animationObj.startColor : "black"

onLinkActivated: Qt.openUrlExternally(link)
onColorChanged:
{
startColButton.color = Qt.rgba(r, g, b, 1.0)
animationObj.startColor = startColButton.color
}
onClose: visible = false
}
}
Rectangle
{
id: endColButton
width: UISettings.iconSizeDefault * 1.5
height: width
radius: 5
border.color: ecMouseArea.containsMouse ? "white" : UISettings.bgLight
border.width: 2
color: animationObj ? animationObj.endColor : "transparent"
visible: animationObj ? animationObj.visibilityMask & VCAnimation.EndColor : true

MouseArea
{
id: ecMouseArea
anchors.fill: parent
acceptedButtons: Qt.NoButton
cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor
hoverEnabled: true
onClicked: endColTool.visible = !endColTool.visible
}

ColorTool
{
id: endColTool
parent: animationRoot.parent
x: animationRoot.x // -width - (UISettings.iconSizeDefault * 1.25)
y: animationRoot.y // UISettings.bigItemHeight
visible: false
closeOnSelect: true
currentRGB: animationObj ? animationObj.endColor : "black"

onColorChanged: animationObj.endColor = Qt.rgba(r, g, b, 1.0)
onClose: visible = false
}
}

CustomComboBox
{
id: algoCombo
Layout.columnSpan: 2
Layout.fillWidth: true
height: UISettings.listItemHeight
visible: animationObj ? animationObj.visibilityMask & VCAnimation.PresetCombo : true
textRole: ""
model: animationObj ? animationObj.algorithms : null
currentIndex: animationObj ? animationObj.algorithmIndex : 0
onCurrentIndexChanged:
{
if (animationObj)
animationObj.algorithmIndex = currentIndex
}
}
}

DropArea
{
id: dropArea
anchors.fill: parent
z: 2 // this area must be above the VCWidget resize controls
keys: [ "function" ]

onDropped:
{
// attach function here
if (drag.source.hasOwnProperty("fromFunctionManager"))
animationObj.functionID = drag.source.itemsList[0]
}

states: [
State
{
when: dropArea.containsDrag
PropertyChanges
{
target: animationRoot
color: UISettings.activeDropArea
}
}
]
}
}
185 changes: 181 additions & 4 deletions qmlui/qml/virtualconsole/VCAnimationProperties.qml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ Rectangle
property VCAnimation widgetRef: null

property int gridItemsHeight: UISettings.listItemHeight
property QLCFunction func
property int funcID: widgetRef ? widgetRef.functionID : -1

onFuncIDChanged: func = functionManager.getFunction(funcID)

Column
{
Expand All @@ -42,8 +46,8 @@ Rectangle

SectionBox
{
id: animationProp
sectionLabel: qsTr("Animation Properties")
id: btnFuncProps
sectionLabel: qsTr("Attached Function")

sectionContents:
GridLayout
Expand All @@ -54,11 +58,184 @@ Rectangle
rowSpacing: 4

// row 1
IconTextEntry
{
id: funcBox
Layout.columnSpan: 2
Layout.fillWidth: true

tFontSize: UISettings.textSizeDefault

tLabel: func ? func.name : ""
functionType: func ? func.type : -1

IconButton
{
anchors.top: parent.top
anchors.right: parent.right
faSource: FontAwesome.fa_remove
faColor: UISettings.bgControl
tooltip: qsTr("Detach the current function")
onClicked: widgetRef.functionID = -1
}
}

CustomCheckBox
{
implicitWidth: UISettings.iconSizeMedium
implicitHeight: implicitWidth
checked: widgetRef ? widgetRef.instantChanges : false
onClicked:
{
if (!widgetRef)
return

widgetRef.instantChanges = checked
}
}

RobotoText
{
height: UISettings.listItemHeight
Layout.fillWidth: true
label: qsTr("Apply color and preset changes immediately")
}
} // GridLayout
} // SectionBox

SectionBox
{
sectionLabel: qsTr("Appearance")

sectionContents:
GridLayout
{
width: parent.width
columns: 4
columnSpacing: 5
rowSpacing: 4

// row 1
CustomCheckBox
{
implicitWidth: UISettings.iconSizeMedium
implicitHeight: implicitWidth
checked: widgetRef ? widgetRef.visibilityMask & VCAnimation.Fader : false
onClicked:
{
if (!widgetRef)
return

if (checked)
widgetRef.visibilityMask |= VCAnimation.Fader
else
widgetRef.visibilityMask &= ~VCAnimation.Fader
}
}

RobotoText
{
height: UISettings.listItemHeight
Layout.fillWidth: true
label: qsTr("Level Fader")
}

CustomCheckBox
{
implicitWidth: UISettings.iconSizeMedium
implicitHeight: implicitWidth
checked: widgetRef ? widgetRef.visibilityMask & VCAnimation.Label : false
onClicked:
{
if (!widgetRef)
return

if (checked)
widgetRef.visibilityMask |= VCAnimation.Label
else
widgetRef.visibilityMask &= ~VCAnimation.Label
}
}

RobotoText
{
height: UISettings.listItemHeight
Layout.fillWidth: true
label: qsTr("Label")
}

// row 2
CustomCheckBox
{
implicitWidth: UISettings.iconSizeMedium
implicitHeight: implicitWidth
checked: widgetRef ? widgetRef.visibilityMask & VCAnimation.StartColor : false
onClicked:
{
if (!widgetRef)
return

if (checked)
widgetRef.visibilityMask |= VCAnimation.StartColor
else
widgetRef.visibilityMask &= ~VCAnimation.StartColor
}
}

RobotoText
{
height: UISettings.listItemHeight
Layout.fillWidth: true
label: qsTr("Start Color Button")
}

CustomCheckBox
{
implicitWidth: UISettings.iconSizeMedium
implicitHeight: implicitWidth
checked: widgetRef ? widgetRef.visibilityMask & VCAnimation.EndColor : false
onClicked:
{
if (!widgetRef)
return

if (checked)
widgetRef.visibilityMask |= VCAnimation.EndColor
else
widgetRef.visibilityMask &= ~VCAnimation.EndColor
}
}

RobotoText
{
height: UISettings.listItemHeight
Layout.fillWidth: true
label: qsTr("End Color Button")
}

// row 3
CustomCheckBox
{
implicitWidth: UISettings.iconSizeMedium
implicitHeight: implicitWidth
checked: widgetRef ? widgetRef.visibilityMask & VCAnimation.PresetCombo : false
onClicked:
{
if (!widgetRef)
return

if (checked)
widgetRef.visibilityMask |= VCAnimation.PresetCombo
else
widgetRef.visibilityMask &= ~VCAnimation.PresetCombo
}
}

RobotoText
{
height: gridItemsHeight
height: UISettings.listItemHeight
Layout.fillWidth: true
label: "Not implemented."
label: qsTr("Preset List")
}
} // GridLayout
} // SectionBox
Expand Down
Loading

0 comments on commit d078e89

Please sign in to comment.