1 |
bc0a685b
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
// Copyright 2016 Leszek Koltunski //
|
3 |
|
|
// //
|
4 |
71c8884f
|
Leszek Koltunski
|
// This file is part of Distorted. //
|
5 |
bc0a685b
|
Leszek Koltunski
|
// //
|
6 |
71c8884f
|
Leszek Koltunski
|
// Distorted is free software: you can redistribute it and/or modify //
|
7 |
bc0a685b
|
Leszek Koltunski
|
// 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 |
71c8884f
|
Leszek Koltunski
|
// Distorted is distributed in the hope that it will be useful, //
|
12 |
bc0a685b
|
Leszek Koltunski
|
// 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 |
71c8884f
|
Leszek Koltunski
|
// along with Distorted. If not, see <http://www.gnu.org/licenses/>. //
|
18 |
bc0a685b
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
19 |
|
|
|
20 |
5068fa06
|
Leszek Koltunski
|
package org.distorted.examples.movingeffects;
|
21 |
427ab7bf
|
Leszek Koltunski
|
|
22 |
e3900503
|
Leszek Koltunski
|
import org.distorted.library.main.DistortedLibrary;
|
23 |
5068fa06
|
Leszek Koltunski
|
import org.distorted.examples.R;
|
24 |
427ab7bf
|
Leszek Koltunski
|
|
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 |
f6d884d5
|
Leszek Koltunski
|
private Button mAbort, mChroma, mTrans, mSink, mBubble, mSwirl;
|
41 |
427ab7bf
|
Leszek Koltunski
|
|
42 |
|
|
///////////////////////////////////////////////////////////////////
|
43 |
|
|
@Override
|
44 |
|
|
protected void onCreate(Bundle savedState)
|
45 |
|
|
{
|
46 |
|
|
super.onCreate(savedState);
|
47 |
|
|
|
48 |
|
|
setContentView(R.layout.movingeffectslayout);
|
49 |
|
|
|
50 |
a4d59c0b
|
Leszek Koltunski
|
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 |
427ab7bf
|
Leszek Koltunski
|
|
57 |
|
|
mAbort.setBackgroundColor(COLOR_PRESSED);
|
58 |
4348b52e
|
Leszek Koltunski
|
mChroma.setBackgroundColor(COLOR_UNPRESSED);
|
59 |
427ab7bf
|
Leszek Koltunski
|
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 |
a4d59c0b
|
Leszek Koltunski
|
|
72 |
427ab7bf
|
Leszek Koltunski
|
@Override
|
73 |
|
|
protected void onResume()
|
74 |
|
|
{
|
75 |
|
|
super.onResume();
|
76 |
|
|
|
77 |
a4d59c0b
|
Leszek Koltunski
|
GLSurfaceView view = findViewById(R.id.movingeffectsSurfaceView);
|
78 |
4562f295
|
Leszek Koltunski
|
view.onResume();
|
79 |
427ab7bf
|
Leszek Koltunski
|
}
|
80 |
|
|
|
81 |
|
|
///////////////////////////////////////////////////////////////////
|
82 |
a4d59c0b
|
Leszek Koltunski
|
|
83 |
427ab7bf
|
Leszek Koltunski
|
@Override
|
84 |
|
|
protected void onPause()
|
85 |
|
|
{
|
86 |
|
|
Abort(null);
|
87 |
|
|
|
88 |
a4d59c0b
|
Leszek Koltunski
|
GLSurfaceView view = findViewById(R.id.movingeffectsSurfaceView);
|
89 |
4562f295
|
Leszek Koltunski
|
view.onPause();
|
90 |
b0ebdf5e
|
Leszek Koltunski
|
|
91 |
e3900503
|
Leszek Koltunski
|
DistortedLibrary.onPause();
|
92 |
427ab7bf
|
Leszek Koltunski
|
super.onPause();
|
93 |
|
|
}
|
94 |
|
|
|
95 |
|
|
///////////////////////////////////////////////////////////////////
|
96 |
a4d59c0b
|
Leszek Koltunski
|
|
97 |
427ab7bf
|
Leszek Koltunski
|
@Override
|
98 |
|
|
public void onStop()
|
99 |
|
|
{
|
100 |
|
|
super.onStop();
|
101 |
|
|
}
|
102 |
|
|
|
103 |
|
|
///////////////////////////////////////////////////////////////////
|
104 |
|
|
@Override
|
105 |
|
|
public void onDestroy()
|
106 |
|
|
{
|
107 |
e3900503
|
Leszek Koltunski
|
DistortedLibrary.onDestroy();
|
108 |
427ab7bf
|
Leszek Koltunski
|
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 |
a4d59c0b
|
Leszek Koltunski
|
MovingEffectsSurfaceView view = findViewById(R.id.movingeffectsSurfaceView);
|
124 |
4562f295
|
Leszek Koltunski
|
view.Bubble();
|
125 |
427ab7bf
|
Leszek Koltunski
|
|
126 |
|
|
mAbort.setBackgroundColor(COLOR_UNPRESSED);
|
127 |
4348b52e
|
Leszek Koltunski
|
mChroma.setBackgroundColor(COLOR_UNPRESSED);
|
128 |
427ab7bf
|
Leszek Koltunski
|
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 |
a4d59c0b
|
Leszek Koltunski
|
MovingEffectsSurfaceView view = findViewById(R.id.movingeffectsSurfaceView);
|
139 |
4562f295
|
Leszek Koltunski
|
view.Sink();
|
140 |
427ab7bf
|
Leszek Koltunski
|
|
141 |
|
|
mAbort.setBackgroundColor(COLOR_UNPRESSED);
|
142 |
4348b52e
|
Leszek Koltunski
|
mChroma.setBackgroundColor(COLOR_UNPRESSED);
|
143 |
427ab7bf
|
Leszek Koltunski
|
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 |
a4d59c0b
|
Leszek Koltunski
|
MovingEffectsSurfaceView view = findViewById(R.id.movingeffectsSurfaceView);
|
154 |
4562f295
|
Leszek Koltunski
|
view.Transparency();
|
155 |
427ab7bf
|
Leszek Koltunski
|
|
156 |
|
|
mAbort.setBackgroundColor(COLOR_UNPRESSED);
|
157 |
4348b52e
|
Leszek Koltunski
|
mChroma.setBackgroundColor(COLOR_UNPRESSED);
|
158 |
427ab7bf
|
Leszek Koltunski
|
mTrans.setBackgroundColor(COLOR_PRESSED);
|
159 |
|
|
mSink.setBackgroundColor(COLOR_UNPRESSED);
|
160 |
|
|
mBubble.setBackgroundColor(COLOR_UNPRESSED);
|
161 |
|
|
mSwirl.setBackgroundColor(COLOR_UNPRESSED);
|
162 |
|
|
}
|
163 |
|
|
|
164 |
|
|
///////////////////////////////////////////////////////////////////
|
165 |
|
|
|
166 |
4348b52e
|
Leszek Koltunski
|
public void Chroma(View v)
|
167 |
427ab7bf
|
Leszek Koltunski
|
{
|
168 |
a4d59c0b
|
Leszek Koltunski
|
MovingEffectsSurfaceView view = findViewById(R.id.movingeffectsSurfaceView);
|
169 |
4562f295
|
Leszek Koltunski
|
view.Chroma();
|
170 |
427ab7bf
|
Leszek Koltunski
|
|
171 |
|
|
mAbort.setBackgroundColor(COLOR_UNPRESSED);
|
172 |
4348b52e
|
Leszek Koltunski
|
mChroma.setBackgroundColor(COLOR_PRESSED);
|
173 |
427ab7bf
|
Leszek Koltunski
|
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 |
a4d59c0b
|
Leszek Koltunski
|
MovingEffectsSurfaceView view = findViewById(R.id.movingeffectsSurfaceView);
|
184 |
4562f295
|
Leszek Koltunski
|
view.Swirl();
|
185 |
427ab7bf
|
Leszek Koltunski
|
|
186 |
|
|
mAbort.setBackgroundColor(COLOR_UNPRESSED);
|
187 |
4348b52e
|
Leszek Koltunski
|
mChroma.setBackgroundColor(COLOR_UNPRESSED);
|
188 |
427ab7bf
|
Leszek Koltunski
|
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 |
a4d59c0b
|
Leszek Koltunski
|
MovingEffectsSurfaceView view = findViewById(R.id.movingeffectsSurfaceView);
|
199 |
4562f295
|
Leszek Koltunski
|
view.Abort();
|
200 |
427ab7bf
|
Leszek Koltunski
|
|
201 |
|
|
mAbort.setBackgroundColor(COLOR_PRESSED);
|
202 |
4348b52e
|
Leszek Koltunski
|
mChroma.setBackgroundColor(COLOR_UNPRESSED);
|
203 |
427ab7bf
|
Leszek Koltunski
|
mTrans.setBackgroundColor(COLOR_UNPRESSED);
|
204 |
|
|
mSink.setBackgroundColor(COLOR_UNPRESSED);
|
205 |
|
|
mBubble.setBackgroundColor(COLOR_UNPRESSED);
|
206 |
|
|
mSwirl.setBackgroundColor(COLOR_UNPRESSED);
|
207 |
|
|
}
|
208 |
|
|
}
|