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.Distorted;
|
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
|
|
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 onResume()
|
74
|
{
|
75
|
super.onResume();
|
76
|
|
77
|
GLSurfaceView view = findViewById(R.id.movingeffectsSurfaceView);
|
78
|
view.onResume();
|
79
|
}
|
80
|
|
81
|
///////////////////////////////////////////////////////////////////
|
82
|
|
83
|
@Override
|
84
|
protected void onPause()
|
85
|
{
|
86
|
Abort(null);
|
87
|
|
88
|
GLSurfaceView view = findViewById(R.id.movingeffectsSurfaceView);
|
89
|
view.onPause();
|
90
|
|
91
|
Distorted.onPause();
|
92
|
super.onPause();
|
93
|
}
|
94
|
|
95
|
///////////////////////////////////////////////////////////////////
|
96
|
|
97
|
@Override
|
98
|
public void onStop()
|
99
|
{
|
100
|
super.onStop();
|
101
|
}
|
102
|
|
103
|
///////////////////////////////////////////////////////////////////
|
104
|
@Override
|
105
|
public void onDestroy()
|
106
|
{
|
107
|
Distorted.onDestroy();
|
108
|
super.onDestroy();
|
109
|
}
|
110
|
|
111
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
112
|
|
113
|
@Override
|
114
|
protected void onSaveInstanceState (Bundle outState)
|
115
|
{
|
116
|
outState.putBoolean(SHOWED_TOAST, true);
|
117
|
}
|
118
|
|
119
|
///////////////////////////////////////////////////////////////////
|
120
|
|
121
|
public void Bubble(View v)
|
122
|
{
|
123
|
MovingEffectsSurfaceView view = findViewById(R.id.movingeffectsSurfaceView);
|
124
|
view.Bubble();
|
125
|
|
126
|
mAbort.setBackgroundColor(COLOR_UNPRESSED);
|
127
|
mChroma.setBackgroundColor(COLOR_UNPRESSED);
|
128
|
mTrans.setBackgroundColor(COLOR_UNPRESSED);
|
129
|
mSink.setBackgroundColor(COLOR_UNPRESSED);
|
130
|
mBubble.setBackgroundColor(COLOR_PRESSED);
|
131
|
mSwirl.setBackgroundColor(COLOR_UNPRESSED);
|
132
|
}
|
133
|
|
134
|
///////////////////////////////////////////////////////////////////
|
135
|
|
136
|
public void Sink(View v)
|
137
|
{
|
138
|
MovingEffectsSurfaceView view = findViewById(R.id.movingeffectsSurfaceView);
|
139
|
view.Sink();
|
140
|
|
141
|
mAbort.setBackgroundColor(COLOR_UNPRESSED);
|
142
|
mChroma.setBackgroundColor(COLOR_UNPRESSED);
|
143
|
mTrans.setBackgroundColor(COLOR_UNPRESSED);
|
144
|
mSink.setBackgroundColor(COLOR_PRESSED);
|
145
|
mBubble.setBackgroundColor(COLOR_UNPRESSED);
|
146
|
mSwirl.setBackgroundColor(COLOR_UNPRESSED);
|
147
|
}
|
148
|
|
149
|
///////////////////////////////////////////////////////////////////
|
150
|
|
151
|
public void Transparency(View v)
|
152
|
{
|
153
|
MovingEffectsSurfaceView view = findViewById(R.id.movingeffectsSurfaceView);
|
154
|
view.Transparency();
|
155
|
|
156
|
mAbort.setBackgroundColor(COLOR_UNPRESSED);
|
157
|
mChroma.setBackgroundColor(COLOR_UNPRESSED);
|
158
|
mTrans.setBackgroundColor(COLOR_PRESSED);
|
159
|
mSink.setBackgroundColor(COLOR_UNPRESSED);
|
160
|
mBubble.setBackgroundColor(COLOR_UNPRESSED);
|
161
|
mSwirl.setBackgroundColor(COLOR_UNPRESSED);
|
162
|
}
|
163
|
|
164
|
///////////////////////////////////////////////////////////////////
|
165
|
|
166
|
public void Chroma(View v)
|
167
|
{
|
168
|
MovingEffectsSurfaceView view = findViewById(R.id.movingeffectsSurfaceView);
|
169
|
view.Chroma();
|
170
|
|
171
|
mAbort.setBackgroundColor(COLOR_UNPRESSED);
|
172
|
mChroma.setBackgroundColor(COLOR_PRESSED);
|
173
|
mTrans.setBackgroundColor(COLOR_UNPRESSED);
|
174
|
mSink.setBackgroundColor(COLOR_UNPRESSED);
|
175
|
mBubble.setBackgroundColor(COLOR_UNPRESSED);
|
176
|
mSwirl.setBackgroundColor(COLOR_UNPRESSED);
|
177
|
}
|
178
|
|
179
|
///////////////////////////////////////////////////////////////////
|
180
|
|
181
|
public void Swirl(View v)
|
182
|
{
|
183
|
MovingEffectsSurfaceView view = findViewById(R.id.movingeffectsSurfaceView);
|
184
|
view.Swirl();
|
185
|
|
186
|
mAbort.setBackgroundColor(COLOR_UNPRESSED);
|
187
|
mChroma.setBackgroundColor(COLOR_UNPRESSED);
|
188
|
mTrans.setBackgroundColor(COLOR_UNPRESSED);
|
189
|
mSink.setBackgroundColor(COLOR_UNPRESSED);
|
190
|
mBubble.setBackgroundColor(COLOR_UNPRESSED);
|
191
|
mSwirl.setBackgroundColor(COLOR_PRESSED);
|
192
|
}
|
193
|
|
194
|
///////////////////////////////////////////////////////////////////
|
195
|
|
196
|
public void Abort(View v)
|
197
|
{
|
198
|
MovingEffectsSurfaceView view = findViewById(R.id.movingeffectsSurfaceView);
|
199
|
view.Abort();
|
200
|
|
201
|
mAbort.setBackgroundColor(COLOR_PRESSED);
|
202
|
mChroma.setBackgroundColor(COLOR_UNPRESSED);
|
203
|
mTrans.setBackgroundColor(COLOR_UNPRESSED);
|
204
|
mSink.setBackgroundColor(COLOR_UNPRESSED);
|
205
|
mBubble.setBackgroundColor(COLOR_UNPRESSED);
|
206
|
mSwirl.setBackgroundColor(COLOR_UNPRESSED);
|
207
|
}
|
208
|
}
|