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