1 |
427ab7bf
|
Leszek Koltunski
|
package org.distortedandroid.examples.scratchpad;
|
2 |
|
|
|
3 |
|
|
import org.distortedandroid.library.Distorted;
|
4 |
|
|
import org.distortedandroid.examples.R;
|
5 |
|
|
|
6 |
|
|
import android.app.Activity;
|
7 |
|
|
import android.opengl.GLSurfaceView;
|
8 |
|
|
import android.os.Bundle;
|
9 |
|
|
import android.view.View;
|
10 |
|
|
import android.widget.SeekBar.OnSeekBarChangeListener;
|
11 |
|
|
import android.widget.SeekBar;
|
12 |
|
|
import android.widget.TextView;
|
13 |
|
|
|
14 |
|
|
///////////////////////////////////////////////////////////////////
|
15 |
|
|
|
16 |
|
|
public class ScratchpadActivity extends Activity implements OnSeekBarChangeListener
|
17 |
|
|
{
|
18 |
|
|
private static final float D_MULT=200.0f;
|
19 |
|
|
private static final float C_MULT= 0.1f;
|
20 |
|
|
|
21 |
|
|
private long effectID;
|
22 |
|
|
|
23 |
|
|
private SeekBar barD, barC, barI;
|
24 |
|
|
private TextView textD, textC, textI;
|
25 |
|
|
|
26 |
|
|
///////////////////////////////////////////////////////////////////
|
27 |
|
|
@Override
|
28 |
|
|
protected void onCreate(Bundle savedInstanceState)
|
29 |
|
|
{
|
30 |
|
|
super.onCreate(savedInstanceState);
|
31 |
|
|
|
32 |
|
|
setContentView(R.layout.scratchpadlayout);
|
33 |
|
|
|
34 |
|
|
barD = (SeekBar)findViewById(R.id.scratchpadSeekDuration);
|
35 |
|
|
barD.setOnSeekBarChangeListener(this);
|
36 |
|
|
barC = (SeekBar)findViewById(R.id.scratchpadSeekCount);
|
37 |
|
|
barC.setOnSeekBarChangeListener(this);
|
38 |
|
|
barI = (SeekBar)findViewById(R.id.scratchpadSeekID);
|
39 |
|
|
barI.setOnSeekBarChangeListener(this);
|
40 |
|
|
|
41 |
|
|
textD = (TextView)findViewById(R.id.scratchpadTextDuration);
|
42 |
|
|
textC = (TextView)findViewById(R.id.scratchpadTextCount);
|
43 |
|
|
textI = (TextView)findViewById(R.id.scratchpadTextID);
|
44 |
|
|
|
45 |
|
|
barD.setProgress(100);
|
46 |
|
|
barC.setProgress(10);
|
47 |
|
|
barI.setProgress(0);
|
48 |
|
|
|
49 |
|
|
textD.setText("Dur: 20 s");
|
50 |
|
|
textC.setText("Cou: 1.0");
|
51 |
|
|
textI.setText("ID: 0");
|
52 |
|
|
}
|
53 |
|
|
|
54 |
|
|
///////////////////////////////////////////////////////////////////
|
55 |
|
|
@Override
|
56 |
|
|
protected void onResume()
|
57 |
|
|
{
|
58 |
|
|
super.onResume();
|
59 |
|
|
|
60 |
|
|
GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.scratchpadSurfaceView);
|
61 |
|
|
mView.onResume();
|
62 |
|
|
}
|
63 |
|
|
|
64 |
|
|
///////////////////////////////////////////////////////////////////
|
65 |
|
|
@Override
|
66 |
|
|
protected void onPause()
|
67 |
|
|
{
|
68 |
|
|
GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.scratchpadSurfaceView);
|
69 |
|
|
mView.onPause();
|
70 |
|
|
|
71 |
|
|
super.onPause();
|
72 |
|
|
}
|
73 |
|
|
|
74 |
|
|
///////////////////////////////////////////////////////////////////
|
75 |
|
|
@Override
|
76 |
|
|
public void onStop()
|
77 |
|
|
{
|
78 |
|
|
super.onStop();
|
79 |
|
|
}
|
80 |
|
|
|
81 |
|
|
///////////////////////////////////////////////////////////////////
|
82 |
|
|
@Override
|
83 |
|
|
public void onDestroy()
|
84 |
|
|
{
|
85 |
|
|
Distorted.onDestroy();
|
86 |
|
|
super.onDestroy();
|
87 |
|
|
}
|
88 |
|
|
|
89 |
|
|
///////////////////////////////////////////////////////////////////
|
90 |
|
|
|
91 |
|
|
public void Distort(View v)
|
92 |
|
|
{
|
93 |
|
|
ScratchpadSurfaceView.setEffect(0);
|
94 |
|
|
}
|
95 |
|
|
|
96 |
|
|
///////////////////////////////////////////////////////////////////
|
97 |
|
|
|
98 |
|
|
public void Sink(View v)
|
99 |
|
|
{
|
100 |
|
|
ScratchpadSurfaceView.setEffect(1);
|
101 |
|
|
}
|
102 |
|
|
|
103 |
|
|
///////////////////////////////////////////////////////////////////
|
104 |
|
|
|
105 |
|
|
public void Transparency(View v)
|
106 |
|
|
{
|
107 |
|
|
ScratchpadSurfaceView.setEffect(2);
|
108 |
|
|
}
|
109 |
|
|
|
110 |
|
|
///////////////////////////////////////////////////////////////////
|
111 |
|
|
|
112 |
|
|
public void Macroblock(View v)
|
113 |
|
|
{
|
114 |
|
|
ScratchpadSurfaceView.setEffect(3);
|
115 |
|
|
}
|
116 |
|
|
|
117 |
|
|
///////////////////////////////////////////////////////////////////
|
118 |
|
|
|
119 |
|
|
public void Brightness(View v)
|
120 |
|
|
{
|
121 |
|
|
ScratchpadSurfaceView.setEffect(4);
|
122 |
|
|
}
|
123 |
|
|
|
124 |
|
|
///////////////////////////////////////////////////////////////////
|
125 |
|
|
|
126 |
|
|
public void Print(View v)
|
127 |
|
|
{
|
128 |
|
|
ScratchpadRenderer.mBackground.printEffect(effectID);
|
129 |
|
|
}
|
130 |
|
|
|
131 |
|
|
///////////////////////////////////////////////////////////////////
|
132 |
|
|
|
133 |
|
|
public void Abort(View v)
|
134 |
|
|
{
|
135 |
|
|
ScratchpadRenderer.mBackground.abortEffect(effectID);
|
136 |
|
|
}
|
137 |
|
|
|
138 |
|
|
///////////////////////////////////////////////////////////////////
|
139 |
|
|
|
140 |
|
|
public void onProgressChanged(SeekBar bar, int progress, boolean fromUser)
|
141 |
|
|
{
|
142 |
|
|
float v, t;
|
143 |
|
|
int i;
|
144 |
|
|
|
145 |
|
|
switch (bar.getId())
|
146 |
|
|
{
|
147 |
|
|
case R.id.scratchpadSeekDuration: v = progress*D_MULT;
|
148 |
|
|
i = (int)(v/100);
|
149 |
|
|
t = i/10.0f;
|
150 |
|
|
ScratchpadSurfaceView.setDuration((int)v);
|
151 |
|
|
textD.setText("Dur: "+(int)t+" s");
|
152 |
|
|
break;
|
153 |
|
|
case R.id.scratchpadSeekCount : v = progress*C_MULT;
|
154 |
|
|
i = (int)(v*10);
|
155 |
|
|
t = i/10.0f;
|
156 |
|
|
ScratchpadSurfaceView.setCount(v);
|
157 |
|
|
textC.setText("Cou: "+t);
|
158 |
|
|
break;
|
159 |
|
|
case R.id.scratchpadSeekID : effectID = progress;
|
160 |
|
|
textI.setText("ID: "+progress);
|
161 |
|
|
break;
|
162 |
|
|
}
|
163 |
|
|
}
|
164 |
|
|
|
165 |
|
|
///////////////////////////////////////////////////////////////////
|
166 |
|
|
|
167 |
|
|
public void onStartTrackingTouch(SeekBar bar) { }
|
168 |
|
|
|
169 |
|
|
///////////////////////////////////////////////////////////////////
|
170 |
|
|
|
171 |
|
|
public void onStopTrackingTouch(SeekBar bar) { }
|
172 |
|
|
|
173 |
|
|
///////////////////////////////////////////////////////////////////
|
174 |
|
|
// end of file
|
175 |
|
|
}
|