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