Skip to content

Commit

Permalink
qmlui: color fanning too
Browse files Browse the repository at this point in the history
  • Loading branch information
mcallegari committed Nov 25, 2019
1 parent 2de5bdc commit c968382
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 37 deletions.
26 changes: 18 additions & 8 deletions engine/src/qlcpalette.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ QList<SceneValue> QLCPalette::valuesFromFixtures(Doc *doc, QList<quint32> fixtur
// nomralized progress in [ 0.0, 1.0 ] range
qreal progress = 0.0;
int intFanValue = fanningValue().toInt();
FanningType fType = fanningType();

foreach (quint32 id, fixtures)
{
Expand All @@ -193,21 +194,30 @@ QList<SceneValue> QLCPalette::valuesFromFixtures(Doc *doc, QList<quint32> fixtur
int dValue = value().toInt();
quint32 intCh = fixture->masterIntensityChannel();

qDebug() << "dvalue" << dValue;

if (intCh != QLCChannel::invalid())
{
if (fanningType() != Flat)
if (fType != Flat)
dValue = int((qreal(intFanValue - dValue) * factor) + dValue);

qDebug() << "progress" << progress << "factor" << factor << "value" << dValue;
list << SceneValue(id, intCh, uchar(dValue));
}
}
break;
case Color:
{
QColor col = value().value<QColor>();
QColor startColor = value().value<QColor>();
QColor col = startColor;

if (fType != Flat)
{
QColor endColor = fanningValue().value<QColor>();
qreal rDelta = endColor.red() - startColor.red();
qreal gDelta = endColor.green() - startColor.green();
qreal bDelta = endColor.blue() - startColor.blue();
col.setRed(startColor.red() + qRound(rDelta * factor));
col.setGreen(startColor.green() + qRound(gDelta * factor));
col.setBlue(startColor.blue() + qRound(bDelta * factor));
}

for (int i = 0; i < fixture->heads(); i++)
{
Expand All @@ -232,7 +242,7 @@ QList<SceneValue> QLCPalette::valuesFromFixtures(Doc *doc, QList<quint32> fixtur
{
int degrees = value().toInt();

if (fanningType() != Flat)
if (fType != Flat)
degrees = int((qreal(degrees) + qreal(intFanValue) * factor));

list << fixture->positionToValues(QLCChannel::Pan, degrees);
Expand All @@ -242,7 +252,7 @@ QList<SceneValue> QLCPalette::valuesFromFixtures(Doc *doc, QList<quint32> fixtur
{
int degrees = m_values.count() == 2 ? m_values.at(1).toInt() : value().toInt();

if (fanningType() != Flat)
if (fType != Flat)
degrees = int((qreal(degrees) + qreal(intFanValue) * factor));

list << fixture->positionToValues(QLCChannel::Tilt, degrees);
Expand All @@ -255,7 +265,7 @@ QList<SceneValue> QLCPalette::valuesFromFixtures(Doc *doc, QList<quint32> fixtur
int panDegrees = m_values.at(0).toInt();
int tiltDegrees = m_values.at(1).toInt();

if (fanningType() != Flat)
if (fType != Flat)
{
panDegrees = int((qreal(panDegrees) + qreal(intFanValue) * factor));
tiltDegrees = int((qreal(tiltDegrees) + qreal(intFanValue) * factor));
Expand Down
47 changes: 35 additions & 12 deletions qmlui/qml/ColorTool.qml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import QtQuick 2.3
import QtQuick.Controls 2.1
import QtQuick.Layouts 1.1

import org.qlcplus.classes 1.0
import "."

Rectangle
Expand Down Expand Up @@ -128,30 +130,51 @@ Rectangle
//objectName: "editorLoader"
anchors.top: colorToolBar.bottom
width: colorToolBox.width
height: parent.height - colorToolBar.height
height: colorToolBox.height - colorToolBar.height - paletteBox.height - 4
source: colorToolQML

onLoaded:
{
item.width = width
item.colorsMask = Qt.binding(function() { return colorToolBox.colorsMask })
if (item.hasOwnProperty("currentRGB"))
item.currentRGB = colorToolBox.currentRGB
item.currentRGB = Qt.binding(function() { return colorToolBox.currentRGB })
if (item.hasOwnProperty("currentWAUV"))
item.currentWAUV = colorToolBox.currentWAUV
item.currentWAUV = Qt.binding(function() { return colorToolBox.currentWAUV })
}

Connections
{
target: toolLoader.item
ignoreUnknownSignals: true
onColorChanged:
{
currentRGB = Qt.rgba(r, g, b, 1.0)
currentWAUV = Qt.rgba(w, a, uv, 1.0)
colorToolBox.colorChanged(r, g, b, w, a, uv)
}
onReleased: if (closeOnSelect) colorToolBox.visible = false
target: toolLoader.item
ignoreUnknownSignals: true
onColorChanged:
{
if (paletteBox.checked && paletteBox.isPicking)
{
var rgb = Qt.rgba(r, g, b, 1.0)
paletteBox.setColor(rgb)
}
else
{
currentRGB = Qt.rgba(r, g, b, 1.0)
currentWAUV = Qt.rgba(w, a, uv, 1.0)
colorToolBox.colorChanged(r, g, b, w, a, uv)
}

if (paletteBox.checked)
paletteBox.updatePreview()
}
onReleased: if (closeOnSelect) colorToolBox.visible = false
}
}

PaletteFanningBox
{
id: paletteBox
x: 5
y: colorToolBox.height - height - 2
width: colorToolBox.width - 10
paletteType: QLCPalette.Color
value1: colorToolBox.currentRGB
}
}
23 changes: 9 additions & 14 deletions qmlui/qml/ColorToolBasic.qml
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,23 @@ Rectangle
signal colorChanged(real r, real g, real b, real w, real a, real uv)
signal released()

onCurrentRGBChanged:
{
colorChanged(currentRGB.r, currentRGB.g, currentRGB.b, 0, 0, 0)
}

property var baseColors: [ 0xFF0000, 0xFF9900, 0xFFFF00, 0x00FF00, 0x00FFFF, 0x0000FF, 0x9900FF, 0xFF00FF ]

function getHTMLColor(r, g, b)
{
return "#" + r.toString(16) + g.toString(16) + b.toString(16);
return "#" + r.toString(16) + g.toString(16) + b.toString(16)
}

function getBaseHTMLColor(index)
{
var bcStr = baseColors[index].toString(16);
return "#" + "000000".substr(0, 6 - bcStr.length) + bcStr;
var bcStr = baseColors[index].toString(16)
return "#" + "000000".substr(0, 6 - bcStr.length) + bcStr
}

function getShadedColor(colIndex, index)
{
var bcStr = baseColors[colIndex].toString(16);
var htmlColor = "#" + "000000".substr(0, 6 - bcStr.length) + bcStr;
var bcStr = baseColors[colIndex].toString(16)
var htmlColor = "#" + "000000".substr(0, 6 - bcStr.length) + bcStr
if (index < 3)
return Qt.lighter(htmlColor, 1 + (0.20 * (3 - index)))
else
Expand Down Expand Up @@ -89,7 +84,7 @@ Rectangle
anchors.fill: parent
onClicked:
{
currentRGB = color
rootBox.colorChanged(color.r, color.g, color.b, 0, 0, 0)
rootBox.released()
}
}
Expand Down Expand Up @@ -124,7 +119,7 @@ Rectangle
anchors.fill: parent
onClicked:
{
currentRGB = color
rootBox.colorChanged(color.r, color.g, color.b, 0, 0, 0)
rootBox.released()
}
}
Expand Down Expand Up @@ -168,7 +163,7 @@ Rectangle
anchors.fill: parent
onClicked:
{
currentRGB = color
rootBox.colorChanged(color.r, color.g, color.b, 0, 0, 0)
rootBox.released()
}
}
Expand All @@ -189,7 +184,7 @@ Rectangle
RobotoText
{
height: UISettings.listItemHeight
label: qsTr("Selected color");
label: qsTr("Selected color")
}
Rectangle
{
Expand Down
3 changes: 2 additions & 1 deletion qmlui/qml/ColorToolFull.qml
Original file line number Diff line number Diff line change
Expand Up @@ -324,11 +324,12 @@ Rectangle
RobotoText
{
height: UISettings.listItemHeight
label: qsTr("Selected color");
label: qsTr("Selected color")
}

MultiColorBox
{
id: previewBox
width: UISettings.mediumItemHeight
height: UISettings.listItemHeight
primary: currentRGB
Expand Down
32 changes: 30 additions & 2 deletions qmlui/qml/PaletteFanningBox.qml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ Rectangle
color: "transparent"

property alias checked: fanningButton.checked
property alias isPicking: colorPicker.checked
property QLCPalette palette
property int paletteType: QLCPalette.Undefined
property int value1: 0
property int value2: 0
property var value1: 0
property var value2: 0

onVisibleChanged: palette = paletteManager.getEditingPalette(paletteType)

Expand All @@ -53,6 +54,12 @@ Rectangle
palettePopup.focusEditItem()
}

function setColor(color)
{
colorPreview.color = color
palette.fanningValue = color
}

function stringFromType()
{
switch(typeButton.currentValue)
Expand Down Expand Up @@ -355,6 +362,27 @@ Rectangle
}
}
}
RowLayout
{
visible: boxRoot.paletteType == QLCPalette.Color

Rectangle
{
id: colorPreview
height: UISettings.iconSizeDefault
Layout.fillWidth: true
color: "black"
}
IconButton
{
id: colorPicker
faSource: FontAwesome.fa_eyedropper
faColor: "white"
imgMargins: UISettings.iconSizeDefault / 4
checkable: true
tooltip: qsTr("Pick the selected color")
}
}
} // GridLayout
} // Rectangle
}

0 comments on commit c968382

Please sign in to comment.