1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2016 Leszek Koltunski //
|
3
|
// //
|
4
|
// This file is part of Distorted. //
|
5
|
// //
|
6
|
// Distorted is free software: you can redistribute it and/or modify //
|
7
|
// it under the terms of the GNU General Public License as published by //
|
8
|
// the Free Software Foundation, either version 2 of the License, or //
|
9
|
// (at your option) any later version. //
|
10
|
// //
|
11
|
// Distorted is distributed in the hope that it will be useful, //
|
12
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
13
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
14
|
// GNU General Public License for more details. //
|
15
|
// //
|
16
|
// You should have received a copy of the GNU General Public License //
|
17
|
// along with Distorted. If not, see <http://www.gnu.org/licenses/>. //
|
18
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
19
|
|
20
|
package org.distorted.examples.movingeffects;
|
21
|
|
22
|
import org.distorted.library.main.DistortedLibrary;
|
23
|
import org.distorted.examples.R;
|
24
|
|
25
|
import android.app.Activity;
|
26
|
import android.opengl.GLSurfaceView;
|
27
|
import android.os.Bundle;
|
28
|
import android.view.View;
|
29
|
import android.widget.Button;
|
30
|
import android.widget.Toast;
|
31
|
|
32
|
///////////////////////////////////////////////////////////////////
|
33
|
|
34
|
public class MovingEffectsActivity extends Activity
|
35
|
{
|
36
|
private static final int COLOR_PRESSED = 0xff0000ff;
|
37
|
private static final int COLOR_UNPRESSED = 0x888888ff;
|
38
|
private static final String SHOWED_TOAST = "showed_toast";
|
39
|
|
40
|
private Button mAbort, mChroma, mTrans, mSink, mBubble, mSwirl;
|
41
|
|
42
|
///////////////////////////////////////////////////////////////////
|
43
|
@Override
|
44
|
protected void onCreate(Bundle savedState)
|
45
|
{
|
46
|
super.onCreate(savedState);
|
47
|
DistortedLibrary.onCreate();
|
48
|
setContentView(R.layout.movingeffectslayout);
|
49
|
|
50
|
mAbort = findViewById(R.id.movingeffectsAbort);
|
51
|
mChroma= findViewById(R.id.movingeffectsChroma);
|
52
|
mTrans = findViewById(R.id.movingeffectsTrans);
|
53
|
mSink = findViewById(R.id.movingeffectsSink);
|
54
|
mBubble= findViewById(R.id.movingeffectsBubble);
|
55
|
mSwirl = findViewById(R.id.movingeffectsSwirl);
|
56
|
|
57
|
mAbort.setBackgroundColor(COLOR_PRESSED);
|
58
|
mChroma.setBackgroundColor(COLOR_UNPRESSED);
|
59
|
mTrans.setBackgroundColor(COLOR_UNPRESSED);
|
60
|
mSink.setBackgroundColor(COLOR_UNPRESSED);
|
61
|
mBubble.setBackgroundColor(COLOR_UNPRESSED);
|
62
|
mSwirl.setBackgroundColor(COLOR_UNPRESSED);
|
63
|
|
64
|
if ( savedState== null || !savedState.getBoolean(SHOWED_TOAST, false))
|
65
|
{
|
66
|
Toast.makeText(this, R.string.example_movingeffects_toast , Toast.LENGTH_LONG).show();
|
67
|
}
|
68
|
}
|
69
|
|
70
|
///////////////////////////////////////////////////////////////////
|
71
|
|
72
|
@Override
|
73
|
protected void onPause()
|
74
|
{
|
75
|
Abort(null);
|
76
|
|
77
|
super.onPause();
|
78
|
GLSurfaceView view = findViewById(R.id.movingeffectsSurfaceView);
|
79
|
view.onPause();
|
80
|
DistortedLibrary.onPause();
|
81
|
}
|
82
|
|
83
|
///////////////////////////////////////////////////////////////////
|
84
|
|
85
|
@Override
|
86
|
protected void onResume()
|
87
|
{
|
88
|
super.onResume();
|
89
|
GLSurfaceView view = findViewById(R.id.movingeffectsSurfaceView);
|
90
|
view.onResume();
|
91
|
}
|
92
|
|
93
|
///////////////////////////////////////////////////////////////////
|
94
|
|
95
|
@Override
|
96
|
public void onStop()
|
97
|
{
|
98
|
super.onStop();
|
99
|
}
|
100
|
|
101
|
///////////////////////////////////////////////////////////////////
|
102
|
@Override
|
103
|
public void onDestroy()
|
104
|
{
|
105
|
DistortedLibrary.onDestroy();
|
106
|
super.onDestroy();
|
107
|
}
|
108
|
|
109
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
110
|
|
111
|
@Override
|
112
|
protected void onSaveInstanceState (Bundle outState)
|
113
|
{
|
114
|
outState.putBoolean(SHOWED_TOAST, true);
|
115
|
}
|
116
|
|
117
|
///////////////////////////////////////////////////////////////////
|
118
|
|
119
|
public void Bubble(View v)
|
120
|
{
|
121
|
MovingEffectsSurfaceView view = findViewById(R.id.movingeffectsSurfaceView);
|
122
|
view.Bubble();
|
123
|
|
124
|
mAbort.setBackgroundColor(COLOR_UNPRESSED);
|
125
|
mChroma.setBackgroundColor(COLOR_UNPRESSED);
|
126
|
mTrans.setBackgroundColor(COLOR_UNPRESSED);
|
127
|
mSink.setBackgroundColor(COLOR_UNPRESSED);
|
128
|
mBubble.setBackgroundColor(COLOR_PRESSED);
|
129
|
mSwirl.setBackgroundColor(COLOR_UNPRESSED);
|
130
|
}
|
131
|
|
132
|
///////////////////////////////////////////////////////////////////
|
133
|
|
134
|
public void Sink(View v)
|
135
|
{
|
136
|
MovingEffectsSurfaceView view = findViewById(R.id.movingeffectsSurfaceView);
|
137
|
view.Sink();
|
138
|
|
139
|
mAbort.setBackgroundColor(COLOR_UNPRESSED);
|
140
|
mChroma.setBackgroundColor(COLOR_UNPRESSED);
|
141
|
mTrans.setBackgroundColor(COLOR_UNPRESSED);
|
142
|
mSink.setBackgroundColor(COLOR_PRESSED);
|
143
|
mBubble.setBackgroundColor(COLOR_UNPRESSED);
|
144
|
mSwirl.setBackgroundColor(COLOR_UNPRESSED);
|
145
|
}
|
146
|
|
147
|
///////////////////////////////////////////////////////////////////
|
148
|
|
149
|
public void Transparency(View v)
|
150
|
{
|
151
|
MovingEffectsSurfaceView view = findViewById(R.id.movingeffectsSurfaceView);
|
152
|
view.Transparency();
|
153
|
|
154
|
mAbort.setBackgroundColor(COLOR_UNPRESSED);
|
155
|
mChroma.setBackgroundColor(COLOR_UNPRESSED);
|
156
|
mTrans.setBackgroundColor(COLOR_PRESSED);
|
157
|
mSink.setBackgroundColor(COLOR_UNPRESSED);
|
158
|
mBubble.setBackgroundColor(COLOR_UNPRESSED);
|
159
|
mSwirl.setBackgroundColor(COLOR_UNPRESSED);
|
160
|
}
|
161
|
|
162
|
///////////////////////////////////////////////////////////////////
|
163
|
|
164
|
public void Chroma(View v)
|
165
|
{
|
166
|
MovingEffectsSurfaceView view = findViewById(R.id.movingeffectsSurfaceView);
|
167
|
view.Chroma();
|
168
|
|
169
|
mAbort.setBackgroundColor(COLOR_UNPRESSED);
|
170
|
mChroma.setBackgroundColor(COLOR_PRESSED);
|
171
|
mTrans.setBackgroundColor(COLOR_UNPRESSED);
|
172
|
mSink.setBackgroundColor(COLOR_UNPRESSED);
|
173
|
mBubble.setBackgroundColor(COLOR_UNPRESSED);
|
174
|
mSwirl.setBackgroundColor(COLOR_UNPRESSED);
|
175
|
}
|
176
|
|
177
|
///////////////////////////////////////////////////////////////////
|
178
|
|
179
|
public void Swirl(View v)
|
180
|
{
|
181
|
MovingEffectsSurfaceView view = findViewById(R.id.movingeffectsSurfaceView);
|
182
|
view.Swirl();
|
183
|
|
184
|
mAbort.setBackgroundColor(COLOR_UNPRESSED);
|
185
|
mChroma.setBackgroundColor(COLOR_UNPRESSED);
|
186
|
mTrans.setBackgroundColor(COLOR_UNPRESSED);
|
187
|
mSink.setBackgroundColor(COLOR_UNPRESSED);
|
188
|
mBubble.setBackgroundColor(COLOR_UNPRESSED);
|
189
|
mSwirl.setBackgroundColor(COLOR_PRESSED);
|
190
|
}
|
191
|
|
192
|
///////////////////////////////////////////////////////////////////
|
193
|
|
194
|
public void Abort(View v)
|
195
|
{
|
196
|
MovingEffectsSurfaceView view = findViewById(R.id.movingeffectsSurfaceView);
|
197
|
view.Abort();
|
198
|
|
199
|
mAbort.setBackgroundColor(COLOR_PRESSED);
|
200
|
mChroma.setBackgroundColor(COLOR_UNPRESSED);
|
201
|
mTrans.setBackgroundColor(COLOR_UNPRESSED);
|
202
|
mSink.setBackgroundColor(COLOR_UNPRESSED);
|
203
|
mBubble.setBackgroundColor(COLOR_UNPRESSED);
|
204
|
mSwirl.setBackgroundColor(COLOR_UNPRESSED);
|
205
|
}
|
206
|
}
|