Skip to content

Commit

Permalink
Merge pull request #413 from ywwg/not-transformer
Browse files Browse the repository at this point in the history
Add a BindProperty transformation for boolean Not
  • Loading branch information
ywwg committed Nov 30, 2014
2 parents ba293d2 + 691f03c commit a28e19b
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 15 deletions.
3 changes: 1 addition & 2 deletions res/skins/Deere/effect_rack.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@
<ConfigKey persist="true">[Master],show_library</ConfigKey>
<BindProperty>visible</BindProperty>
<Transform>
<Invert/>
<Add>1</Add>
<Not/>
</Transform>
</Connection>
</WidgetGroup>
Expand Down
3 changes: 1 addition & 2 deletions res/skins/Deere/left_deck_mixer_controls.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
<ConfigKey>[Master],show_4decks</ConfigKey>
<BindProperty>visible</BindProperty>
<Transform>
<Invert/>
<Add>1</Add>
<Not/>
</Transform>
</Connection>
</WidgetGroup>
Expand Down
3 changes: 1 addition & 2 deletions res/skins/Deere/main_decks.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
<ConfigKey persist="true">[Master],show_library</ConfigKey>
<BindProperty>visible</BindProperty>
<Transform>
<Invert/>
<Add>1</Add>
<Not/>
</Transform>
</Connection>
</WidgetGroup>
Expand Down
3 changes: 1 addition & 2 deletions res/skins/Deere/microphone_rack.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@
<ConfigKey persist="true">[Master],show_library</ConfigKey>
<BindProperty>visible</BindProperty>
<Transform>
<Invert/>
<Add>1</Add>
<Not/>
</Transform>
</Connection>
</WidgetGroup>
Expand Down
3 changes: 1 addition & 2 deletions res/skins/Deere/mixer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@
<ConfigKey>[Master],hide_mixer</ConfigKey>
<BindProperty>visible</BindProperty>
<Transform>
<Invert/>
<Add>1</Add>
<Not/>
</Transform>
</Connection>
</WidgetGroup>
Expand Down
3 changes: 1 addition & 2 deletions res/skins/Deere/right_deck_mixer_controls.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
<ConfigKey>[Master],show_4decks</ConfigKey>
<BindProperty>visible</BindProperty>
<Transform>
<Invert/>
<Add>1</Add>
<Not/>
</Transform>
</Connection>
</WidgetGroup>
Expand Down
3 changes: 1 addition & 2 deletions res/skins/Deere/sample_decks.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@
<ConfigKey persist="true">[Master],show_library</ConfigKey>
<BindProperty>visible</BindProperty>
<Transform>
<Invert/>
<Add>1</Add>
<Not/>
</Transform>
</Connection>
</WidgetGroup>
Expand Down
27 changes: 26 additions & 1 deletion res/skins/LateNight/waveform_and_mixer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,32 @@
<ConfigKey>[Master],show_mixer</ConfigKey>
<BindProperty>visible</BindProperty>
</Connection>
</WidgetGroup>
</WidgetGroup>
<WidgetGroup>
<ObjectName>AlignRightBottom</ObjectName>
<Layout>horizontal</Layout>
<SizePolicy>min,f</SizePolicy>
<Children>
<WidgetGroup> <!-- spacer to push logo to the right -->
<Layout>horizontal</Layout>
<SizePolicy>e,min</SizePolicy>
<Children/>
</WidgetGroup>
<WidgetGroup>
<Layout>horizontal</Layout>
<SizePolicy>f,f</SizePolicy>
<Size>103,40</Size>
<BackPath>style/mixxx_logo.png</BackPath>
</WidgetGroup>
</Children>
<Connection>
<ConfigKey>[Master],show_mixer</ConfigKey>
<BindProperty>visible</BindProperty>
<Transform>
<Not/>
</Transform>
</Connection>
</WidgetGroup>
</Children>
</WidgetGroup>
</Template>
2 changes: 2 additions & 0 deletions src/util/valuetransformer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ ValueTransformer* ValueTransformer::parseFromXml(QDomElement transformElement,
if (ok) {
pTransformer->addTransformer(new TransformAdd(addend));
}
} else if (element.nodeName() == "Not") {
pTransformer->addTransformer(new TransformNot());
}
}

Expand Down
13 changes: 13 additions & 0 deletions src/util/valuetransformer.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,19 @@ class TransformInvert : public TransformNode {
}
};

class TransformNot : public TransformNode {
public:
TransformNot() {}

double transform(double argument) const {
return !static_cast<bool>(argument);
}

double transformInverse(double argument) const {
return !static_cast<bool>(argument);
}
};

class ValueTransformer {
public:
double transform(double argument) const;
Expand Down

0 comments on commit a28e19b

Please sign in to comment.