Skip to content

Commit 2c405de

Browse files
committed
fix a bug in TransitionLoop
1 parent 3380ee5 commit 2c405de

File tree

3 files changed

+33
-8
lines changed

3 files changed

+33
-8
lines changed

styles/tests.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,11 @@ Monitoring monitor;
124124
#include "edit_mode.h"
125125
#include "remap.h"
126126
#include "stripes.h"
127+
#include "transition_loop.h"
128+
#include "sequence.h"
127129
#include "../transitions/base.h"
128130
#include "../transitions/join.h"
131+
#include "../transitions/boing.h"
129132
#include "../transitions/wipe.h"
130133
#include "../transitions/delay.h"
131134
#include "../transitions/concat.h"
@@ -563,6 +566,25 @@ void TestCompileStyle() {
563566
InOutTrL<TrWipe<300>, TrWipeIn<500>>>> t1;
564567
}
565568

569+
570+
void test_style5() {
571+
TestStyle<Layers<
572+
Blue,
573+
AlphaL<
574+
PulsingL<
575+
TransitionLoop<
576+
AlphaL<ColorSequence<3500,Cyan,Black,Rgb<25,10,255>,Black>,Int<8000>>,
577+
TrRandom<
578+
TrConcat<TrBoing<500,2>,Black,TrInstant>,
579+
TrJoinR<
580+
TrJoin<TrWipeInX<Int<300>>,TrWaveX<White,Int<400>,Int<600>,Int<300>,Int<32768>>>,
581+
TrJoin<TrWipeX< Int<300>>,TrWaveX<White,Int<400>,Int<600>,Int<300>,Int<0>>>>>>,
582+
Int<1500>>,
583+
Int<16000>>
584+
>> t1;
585+
Color16 c = get_color_when_on(&t1);
586+
}
587+
566588
void testGetArg(const char* str, int arg, const char* expected) {
567589
char tmp[1024];
568590
fprintf(stderr, "testGetArg(%s, %d)\n", str, arg);
@@ -694,6 +716,7 @@ void test_argument_parsing() {
694716
}
695717

696718
int main() {
719+
test_style5();
697720
test_style4();
698721
test_cylon();
699722
test_inouthelper();

styles/transition_effect.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,15 @@ class MultiTransitionEffectL {
5858
public:
5959
MultiTransitionEffectL() { for (size_t i = 0; i < N; i++) run_[i] = false; }
6060

61-
void run(BladeBase* blade) {
62-
for (size_t i = 0; i < N; i++)
63-
if (effect_.DetectScoped(blade)) {
64-
transitions_[pos_].begin();
65-
run_[pos_] = true;
66-
effects_[pos_] = last_detected_blade_effect;
67-
pos_++;
68-
if (pos_ >= N) pos_ = 0;
61+
void run(BladeBase* blade) {
62+
for (size_t i = 0; i < N; i++) {
63+
if (effect_.DetectScoped(blade)) {
64+
transitions_[pos_].begin();
65+
run_[pos_] = true;
66+
effects_[pos_] = last_detected_blade_effect;
67+
pos_++;
68+
if (pos_ >= N) pos_ = 0;
69+
}
6970
}
7071
for (size_t i = 0; i < N; i++) {
7172
if (run_[i]) {

styles/transition_loop.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
template<class TRANSITION>
1515
class TransitionLoopL {
1616
public:
17+
TransitionLoopL() { transition_.begin(); }
1718
void run(BladeBase* blade) {
1819
if (transition_.done()) transition_.begin();
1920
transition_.run(blade);

0 commit comments

Comments
 (0)