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