1 |
43bda3db
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
// Copyright 2016 Leszek Koltunski //
|
3 |
|
|
// //
|
4 |
71c8884f
|
Leszek Koltunski
|
// This file is part of Distorted. //
|
5 |
43bda3db
|
Leszek Koltunski
|
// //
|
6 |
71c8884f
|
Leszek Koltunski
|
// Distorted is free software: you can redistribute it and/or modify //
|
7 |
43bda3db
|
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 |
43bda3db
|
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 |
43bda3db
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
19 |
|
|
|
20 |
|
|
package org.distorted.examples.blur;
|
21 |
|
|
|
22 |
|
|
import android.app.Activity;
|
23 |
|
|
import android.opengl.GLSurfaceView;
|
24 |
|
|
import android.os.Bundle;
|
25 |
|
|
import android.widget.SeekBar;
|
26 |
|
|
import android.widget.SeekBar.OnSeekBarChangeListener;
|
27 |
|
|
import android.widget.TextView;
|
28 |
|
|
|
29 |
|
|
import org.distorted.examples.R;
|
30 |
e3900503
|
Leszek Koltunski
|
import org.distorted.library.main.DistortedLibrary;
|
31 |
43bda3db
|
Leszek Koltunski
|
|
32 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
33 |
|
|
|
34 |
|
|
public class BlurActivity extends Activity implements OnSeekBarChangeListener
|
35 |
|
|
{
|
36 |
bf2e8f97
|
Leszek Koltunski
|
private TextView textBlur, textHalo, textMove;
|
37 |
43bda3db
|
Leszek Koltunski
|
|
38 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
39 |
|
|
|
40 |
|
|
@Override
|
41 |
|
|
protected void onCreate(Bundle icicle)
|
42 |
|
|
{
|
43 |
|
|
super.onCreate(icicle);
|
44 |
a9df241d
|
Leszek Koltunski
|
DistortedLibrary.onCreate();
|
45 |
|
|
|
46 |
43bda3db
|
Leszek Koltunski
|
setContentView(R.layout.blurlayout);
|
47 |
bf2e8f97
|
Leszek Koltunski
|
|
48 |
a4d59c0b
|
Leszek Koltunski
|
textBlur = findViewById(R.id.blurText);
|
49 |
bf2e8f97
|
Leszek Koltunski
|
textHalo = findViewById(R.id.haloText);
|
50 |
|
|
textMove = findViewById(R.id.moveText);
|
51 |
|
|
|
52 |
|
|
SeekBar barB = findViewById(R.id.blurSeek);
|
53 |
|
|
barB.setOnSeekBarChangeListener(this);
|
54 |
|
|
barB.setProgress(50);
|
55 |
|
|
|
56 |
|
|
SeekBar barH = findViewById(R.id.haloSeek);
|
57 |
|
|
barH.setOnSeekBarChangeListener(this);
|
58 |
|
|
barH.setProgress(50);
|
59 |
|
|
|
60 |
|
|
SeekBar barM = findViewById(R.id.moveSeek);
|
61 |
|
|
barM.setOnSeekBarChangeListener(this);
|
62 |
|
|
barM.setProgress(50);
|
63 |
43bda3db
|
Leszek Koltunski
|
}
|
64 |
|
|
|
65 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
66 |
|
|
|
67 |
|
|
@Override
|
68 |
|
|
protected void onPause()
|
69 |
|
|
{
|
70 |
c0f27889
|
Leszek Koltunski
|
super.onPause();
|
71 |
a4d59c0b
|
Leszek Koltunski
|
GLSurfaceView view = findViewById(R.id.blurSurfaceView);
|
72 |
43bda3db
|
Leszek Koltunski
|
view.onPause();
|
73 |
e3900503
|
Leszek Koltunski
|
DistortedLibrary.onPause();
|
74 |
43bda3db
|
Leszek Koltunski
|
}
|
75 |
|
|
|
76 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
77 |
|
|
|
78 |
|
|
@Override
|
79 |
|
|
protected void onResume()
|
80 |
|
|
{
|
81 |
|
|
super.onResume();
|
82 |
a4d59c0b
|
Leszek Koltunski
|
GLSurfaceView view = findViewById(R.id.blurSurfaceView);
|
83 |
43bda3db
|
Leszek Koltunski
|
view.onResume();
|
84 |
|
|
}
|
85 |
|
|
|
86 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
87 |
|
|
|
88 |
|
|
@Override
|
89 |
|
|
protected void onDestroy()
|
90 |
|
|
{
|
91 |
e3900503
|
Leszek Koltunski
|
DistortedLibrary.onDestroy();
|
92 |
43bda3db
|
Leszek Koltunski
|
super.onDestroy();
|
93 |
|
|
}
|
94 |
efc280af
|
Leszek Koltunski
|
|
95 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
96 |
43bda3db
|
Leszek Koltunski
|
|
97 |
|
|
public void onProgressChanged(SeekBar bar, int progress, boolean fromUser)
|
98 |
|
|
{
|
99 |
a4d59c0b
|
Leszek Koltunski
|
BlurSurfaceView view = findViewById(R.id.blurSurfaceView);
|
100 |
43bda3db
|
Leszek Koltunski
|
|
101 |
bf2e8f97
|
Leszek Koltunski
|
switch( bar.getId() )
|
102 |
43bda3db
|
Leszek Koltunski
|
{
|
103 |
bf2e8f97
|
Leszek Koltunski
|
case R.id.blurSeek: int l1 = view.getRenderer().setBlur(progress);
|
104 |
|
|
textBlur.setText(getString(R.string.blur_placeholder,l1));
|
105 |
|
|
break;
|
106 |
|
|
case R.id.haloSeek: int l2 = view.getRenderer().setHalo(progress);
|
107 |
|
|
textHalo.setText(getString(R.string.halo_placeholder,l2));
|
108 |
|
|
break;
|
109 |
|
|
case R.id.moveSeek: int l3 = view.getRenderer().setMove(progress);
|
110 |
|
|
textMove.setText(getString(R.string.move_placeholder,l3));
|
111 |
|
|
break;
|
112 |
43bda3db
|
Leszek Koltunski
|
}
|
113 |
|
|
}
|
114 |
|
|
|
115 |
efc280af
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
116 |
43bda3db
|
Leszek Koltunski
|
|
117 |
|
|
public void onStartTrackingTouch(SeekBar bar) { }
|
118 |
efc280af
|
Leszek Koltunski
|
|
119 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
120 |
43bda3db
|
Leszek Koltunski
|
|
121 |
|
|
public void onStopTrackingTouch(SeekBar bar) { }
|
122 |
|
|
|
123 |
|
|
}
|