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