Skip to content

Commit

Permalink
Film controls (bindings + UI)
Browse files Browse the repository at this point in the history
  • Loading branch information
thp committed May 18, 2012
1 parent 95561be commit 1bf2e50
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 1 deletion.
42 changes: 42 additions & 0 deletions ClassicPrintDeclarative.h
Expand Up @@ -7,6 +7,7 @@

#include "ClassicPrint.h"
#include "ClassicPrintLens.h"
#include "ClassicPrintFilm.h"
#include "ClassicPrintProcessing.h"

class ClassicPrintDeclarative : public QObject {
Expand Down Expand Up @@ -37,6 +38,13 @@ class ClassicPrintDeclarative : public QObject {
QObject::connect(this, SIGNAL(defocusChanged()),
this, SLOT(contentUpdated()));

/* Film */
QObject::connect(this, SIGNAL(temperatureChanged()),
this, SLOT(contentUpdated()));

QObject::connect(this, SIGNAL(noiseChanged()),
this, SLOT(contentUpdated()));

/* Processing */
QObject::connect(this, SIGNAL(contrastChanged()),
this, SLOT(contentUpdated()));
Expand Down Expand Up @@ -125,6 +133,36 @@ class ClassicPrintDeclarative : public QObject {
NOTIFY defocusChanged)


/* Film */
qreal temperature() {
return getClassicPrint()->getCurrentFilm()->temperature()/100.;
}

void setTemperature(qreal temperature) {
getClassicPrint()->getCurrentFilm()->setTemperature(temperature*100.);
emit temperatureChanged();
}

Q_PROPERTY(qreal temperature
READ temperature
WRITE setTemperature
NOTIFY temperatureChanged)

qreal noise() {
return getClassicPrint()->getCurrentFilm()->noise()/100.;
}

void setNoise(qreal noise) {
getClassicPrint()->getCurrentFilm()->setNoise(noise*100.);
emit noiseChanged();
}

Q_PROPERTY(qreal noise
READ noise
WRITE setNoise
NOTIFY noiseChanged)


/* Processing */

qreal contrast() {
Expand Down Expand Up @@ -221,6 +259,10 @@ class ClassicPrintDeclarative : public QObject {
void dodgeChanged();
void defocusChanged();

/* Film */
void temperatureChanged();
void noiseChanged();

/* Processing */
void contrastChanged();
void colourisationChanged();
Expand Down
2 changes: 1 addition & 1 deletion classicprintqml.cpp
Expand Up @@ -6,7 +6,7 @@
#include "ClassicPrintProvider.h"
#include "ClassicPrintDeclarative.h"

//#define CLASSICPRINTQML_DESKTOP
#define CLASSICPRINTQML_DESKTOP

int main(int argc, char *argv[])
{
Expand Down
80 changes: 80 additions & 0 deletions classicprintqml.qml
Expand Up @@ -101,6 +101,7 @@ PageStackWindow {
anchors.fill: parent
onClicked: {
lensPane.state = 'down';
filmPane.state = 'down';
processingPane.state = 'down';
}
}
Expand Down Expand Up @@ -205,6 +206,70 @@ PageStackWindow {
}
}

Rectangle {
id: filmPane

state: 'down'

states: [
State {
name: 'up'
AnchorChanges { target: filmPane; anchors.bottom: imagePage.bottom }
},
State {
name: 'down'
AnchorChanges { target: filmPane; anchors.top: imagePage.bottom }
}
]

transitions: Transition {
AnchorAnimation { easing.type: Easing.OutCirc }
}

height: filmColumn.height + 2*20
color: '#a0000000'

anchors {
left: parent.left
right: parent.right
}

Column {
id: filmColumn
width: parent.width * .8

anchors {
horizontalCenter: parent.horizontalCenter
top: parent.top
topMargin: 20
}

Label { text: 'Temperature' }

Slider {
id: temperatureSlider
width: parent.width
onValueChanged: {
if (pressed) {
classicPrint.temperature = value;
}
}
}

Label { text: 'Noise' }

Slider {
id: noiseSlider
width: parent.width
onValueChanged: {
if (pressed) {
classicPrint.noise = value;
}
}
}
}
}

Rectangle {
id: processingPane

Expand Down Expand Up @@ -346,6 +411,7 @@ PageStackWindow {
dodgeSlider.value = classicPrint.dodge;
defocusSwitch.checked = classicPrint.defocus;

filmPane.state = 'down';
processingPane.state = 'down';
lensPane.state = 'up';
}
Expand All @@ -356,6 +422,19 @@ PageStackWindow {
visible: pageStack.currentPage == imagePage
iconId: 'icon-m-toolbar-all-content-white'
anchors.horizontalCenter: parent.horizontalCenter
onClicked: {
if (filmPane.state === 'up') {
filmPane.state = 'down';
return;
}

temperatureSlider.value = classicPrint.temperature;
noiseSlider.value = classicPrint.noise;

lensPane.state = 'down';
processingPane.state = 'down';
filmPane.state = 'up';
}
}

ToolIcon {
Expand All @@ -378,6 +457,7 @@ PageStackWindow {
lightLeakRow.checkedButton = lightLeakRow.children[classicPrint.lightLeak];

lensPane.state = 'down';
filmPane.state = 'down';
processingPane.state = 'up';
}
}
Expand Down

0 comments on commit 1bf2e50

Please sign in to comment.