commit f9afbbf360ad342b239e6fdc52b7751db559c809
Author: Leszek Koltunski <leszek@distoretedandroid.org>
Date:   Mon Jun 20 17:35:51 2016 +0100

    Upgrade what used to be the 'Scratchpad' app; step 2: reorganize layout

diff --git a/src/main/java/org/distorted/examples/TableOfContents.java b/src/main/java/org/distorted/examples/TableOfContents.java
index 1b0209c..1755e62 100644
--- a/src/main/java/org/distorted/examples/TableOfContents.java
+++ b/src/main/java/org/distorted/examples/TableOfContents.java
@@ -71,7 +71,6 @@ public class TableOfContents extends ListActivity
   public void onCreate(Bundle savedInstanceState) 
    {
    super.onCreate(savedInstanceState);
-   setTitle(R.string.toc);
    setContentView(R.layout.table_of_contents);
       
    final List<Map<String, Object>> data = new ArrayList<>();
diff --git a/src/main/java/org/distorted/examples/effects2d/Effects2DActivity.java b/src/main/java/org/distorted/examples/effects2d/Effects2DActivity.java
index 43972e5..277e577 100644
--- a/src/main/java/org/distorted/examples/effects2d/Effects2DActivity.java
+++ b/src/main/java/org/distorted/examples/effects2d/Effects2DActivity.java
@@ -26,22 +26,17 @@ import android.app.Activity;
 import android.opengl.GLSurfaceView;
 import android.os.Bundle;
 import android.view.View;
-import android.widget.SeekBar.OnSeekBarChangeListener;
-import android.widget.SeekBar;
-import android.widget.TextView;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.Spinner;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-public class Effects2DActivity extends Activity implements OnSeekBarChangeListener
+public class Effects2DActivity extends Activity implements AdapterView.OnItemSelectedListener
   {
-  private static final float D_MULT=200.0f;
-  private static final float C_MULT=  0.1f;
-   
-  private long effectID;
-   
-  private SeekBar barD, barC, barI;
-  private TextView textD, textC, textI;
-   
+  private Spinner mID, mName, mType;
+  private ArrayAdapter<String> mAdapterID, mAdapterName, mAdapterType;
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   @Override
@@ -49,26 +44,35 @@ public class Effects2DActivity extends Activity implements OnSeekBarChangeListen
     {
     super.onCreate(savedInstanceState);
  
-    setContentView(R.layout.scratchpadlayout);
-      
-    barD = (SeekBar)findViewById(R.id.scratchpadSeekDuration);
-    barD.setOnSeekBarChangeListener(this); 
-    barC = (SeekBar)findViewById(R.id.scratchpadSeekCount);
-    barC.setOnSeekBarChangeListener(this); 
-    barI = (SeekBar)findViewById(R.id.scratchpadSeekID);
-    barI.setOnSeekBarChangeListener(this); 
-        
-    textD = (TextView)findViewById(R.id.scratchpadTextDuration);
-    textC = (TextView)findViewById(R.id.scratchpadTextCount);
-    textI = (TextView)findViewById(R.id.scratchpadTextID);
-      
-    barD.setProgress(100);
-    barC.setProgress(10);
-    barI.setProgress(0);
-      
-    textD.setText("Dur: 20 s");
-    textC.setText("Cou: 1.0");
-    textI.setText("ID: 0");
+    setContentView(R.layout.effects2dlayout);
+
+    mID   = (Spinner)findViewById(R.id.effects2d_spinnerID  );
+    mName = (Spinner)findViewById(R.id.effects2d_spinnerName);
+    mType = (Spinner)findViewById(R.id.effects2d_spinnerType);
+
+    mID.setOnItemSelectedListener(this);
+    mName.setOnItemSelectedListener(this);
+    mType.setOnItemSelectedListener(this);
+
+    String[] itemsID   = new String[] {"1", "2", "3"};
+    String[] itemsName = new String[] { getText(R.string.distort     ).toString(),
+                                        getText(R.string.sink        ).toString(),
+                                        getText(R.string.transparency).toString(),
+                                        getText(R.string.macroblock  ).toString(),
+                                        getText(R.string.chroma      ).toString()};
+    String[] itemsType = new String[] {"VERTEX", "FRAGMENT"};
+
+    mAdapterID = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, itemsID);
+    mAdapterID.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+    mID.setAdapter(mAdapterID);
+
+    mAdapterName = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, itemsName);
+    mAdapterName.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+    mName.setAdapter(mAdapterName);
+
+    mAdapterType = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, itemsType);
+    mAdapterType.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+    mType.setAdapter(mAdapterType);
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -140,57 +144,35 @@ public class Effects2DActivity extends Activity implements OnSeekBarChangeListen
  
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  public void Brightness(View v)
+  public void Chroma(View v)
     {
     Effects2DSurfaceView.setEffect(4);
-    }       
-     
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  public void Print(View v)
-    {
-    Effects2DRenderer.mBackground.printEffect(effectID);
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  public void Abort(View v)
+  public void onItemSelected(AdapterView<?> parent, View view, int pos, long id)
     {
-    Effects2DRenderer.mBackground.abortEffect(effectID);
-    }
+    // An item was selected. You can retrieve the selected item using
+    // parent.getItemAtPosition(pos)
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-    
-  public void onProgressChanged(SeekBar bar, int progress, boolean fromUser) 
-    {
-    float v, t; 
-    int i;
-      
-    switch (bar.getId()) 
+    switch(parent.getId())
       {
-      case R.id.scratchpadSeekDuration: v = progress*D_MULT;
-                                        i = (int)(v/100);
-                                        t = i/10.0f;
-                                        Effects2DSurfaceView.setDuration((int)v);
-                                        textD.setText("Dur: "+(int)t+" s");
-                                        break;
-      case R.id.scratchpadSeekCount   : v = progress*C_MULT;
-                                        i = (int)(v*10);
-                                        t = i/10.0f;
-                                        Effects2DSurfaceView.setCount(v);
-                                        textC.setText("Cou: "+t);
-                                        break;
-      case R.id.scratchpadSeekID      : effectID = progress;
-                                        textI.setText("ID: "+progress);
-                                        break;                        
+      case R.id.effects2d_spinnerID  : android.util.Log.d("EFFECTS2D", "ID spinner!!"  ); break;
+      case R.id.effects2d_spinnerName: android.util.Log.d("EFFECTS2D", "Name spinner!!"); break;
+      case R.id.effects2d_spinnerType: android.util.Log.d("EFFECTS2D", "Type spinner!!"); break;
       }
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  public void onStartTrackingTouch(SeekBar bar) { }
-    
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  public void onStopTrackingTouch(SeekBar bar)  { }
+  public void onNothingSelected(AdapterView<?> parent)
+    {
+    switch(parent.getId())
+      {
+      case R.id.effects2d_spinnerID  : android.util.Log.d("EFFECTS2D", "(nothing) ID spinner!!"  ); break;
+      case R.id.effects2d_spinnerName: android.util.Log.d("EFFECTS2D", "(nothing) Name spinner!!"); break;
+      case R.id.effects2d_spinnerType: android.util.Log.d("EFFECTS2D", "(nothing) Type spinner!!"); break;
+      }
+    }
   }
diff --git a/src/main/java/org/distorted/examples/effects2d/Effects2DSurfaceView.java b/src/main/java/org/distorted/examples/effects2d/Effects2DSurfaceView.java
index 77f7932..da2922e 100644
--- a/src/main/java/org/distorted/examples/effects2d/Effects2DSurfaceView.java
+++ b/src/main/java/org/distorted/examples/effects2d/Effects2DSurfaceView.java
@@ -46,11 +46,13 @@ public class Effects2DSurfaceView extends GLSurfaceView
   private static Static2D point;
 
   private static Static4D mRegion;
-  private static Dynamic1D mInterA, mInterM, mInterB, mInterS;
+  private static Dynamic1D mInterA, mInterM, mInterC, mInterS;
 
   private static Dynamic3D mInterD;
   private static Static3D v0, v1, v2, v3;
-     
+
+  private final static Static3D mRED = new Static3D(1,0,0);
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
     
   public Effects2DSurfaceView(Context c, AttributeSet attrs)
@@ -83,9 +85,9 @@ public class Effects2DSurfaceView extends GLSurfaceView
     mInterS.add(new Static1D(1.0f));
     mInterS.add(new Static1D(0.3f));
 
-    mInterB = new Dynamic1D(mDuration,mCount);
-    mInterB.add(new Static1D(1));
-    mInterB.add(new Static1D(0));
+    mInterC = new Dynamic1D(mDuration,mCount);
+    mInterC.add(new Static1D(1));
+    mInterC.add(new Static1D(0));
 
     mInterM = new Dynamic1D(mDuration,mCount);
     mInterM.add(new Static1D(1));
@@ -122,13 +124,6 @@ public class Effects2DSurfaceView extends GLSurfaceView
     mScrH = height;
     }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  public static int getEffect()
-    {
-    return mCurrentEffect;
-    }
-   
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   public static void setEffect(int effect)
@@ -136,30 +131,6 @@ public class Effects2DSurfaceView extends GLSurfaceView
     mCurrentEffect = effect;
     }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  public static void setDuration(int duration)
-    {
-    mDuration = duration;
-    mInterD.setDuration(duration);
-    mInterA.setDuration(duration);
-    mInterB.setDuration(duration);
-    mInterM.setDuration(duration);
-    mInterS.setDuration(duration);
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  public static void setCount(float count)
-    {
-    mCount = count;
-    mInterD.setCount(count);
-    mInterA.setCount(count);
-    mInterB.setCount(count);
-    mInterM.setCount(count);
-    mInterS.setCount(count);
-    }
-  
 ///////////////////////////////////////////////////////////////////////////////////////////////////
     
   @Override public boolean onTouchEvent(MotionEvent event) 
@@ -184,7 +155,7 @@ public class Effects2DSurfaceView extends GLSurfaceView
                                            break;  
                                       case 3: Effects2DRenderer.mBackground.macroblock(mInterM, mRegion);
                                            break;
-                                      case 4: Effects2DRenderer.mBackground.brightness(mInterB, mRegion, false);
+                                      case 4: Effects2DRenderer.mBackground.chroma(mInterC, mRED, mRegion, false);
                                            break;      
                                       }
                                     break;
diff --git a/src/main/res/layout/effects2dlayout.xml b/src/main/res/layout/effects2dlayout.xml
new file mode 100644
index 0000000..3e6427f
--- /dev/null
+++ b/src/main/res/layout/effects2dlayout.xml
@@ -0,0 +1,178 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    android:orientation="vertical" >
+
+    <org.distorted.examples.effects2d.Effects2DSurfaceView
+        android:id="@+id/scratchpadSurfaceView"
+        android:layout_width="fill_parent"
+        android:layout_height="0dp"
+        android:layout_weight="1" />
+
+    <LinearLayout
+        android:id="@+id/linearLayout1"
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:layout_weight="0.3"
+        android:gravity="fill_horizontal|top"
+        android:orientation="vertical"
+        android:weightSum="1">
+
+        <View
+            android:layout_height="2dip"
+            android:background="#FF0000"
+            android:layout_width="match_parent"
+            />
+
+        <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="@string/add"
+            android:id="@+id/textView"
+            android:layout_gravity="center_horizontal"/>
+
+        <RadioGroup
+            android:id="@+id/radioGroup1"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:paddingLeft="5dp"
+            android:paddingRight="10dp"
+            android:orientation="horizontal"
+            android:layout_gravity="center_horizontal">
+
+            <RadioButton
+                android:id="@+id/scratchpadDistort"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:checked="true"
+                android:onClick="Distort"
+                android:text="@string/distort"
+                android:textSize="12dp"/>
+
+            <RadioButton
+                android:id="@+id/scratchpadSink"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:onClick="Sink"
+                android:text="@string/sink"
+                android:textSize="12dp"/>
+
+            <RadioButton
+                android:id="@+id/scratchpadTransparency"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:onClick="Transparency"
+                android:text="@string/transparency"
+                android:textSize="12dp"/>
+
+            <RadioButton
+                android:id="@+id/scratchpadMacroblock"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:onClick="Macroblock"
+                android:text="@string/macroblock"
+                android:textSize="12dp"/>
+
+            <RadioButton
+                android:id="@+id/scratchpadBrightness"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:onClick="Chroma"
+                android:text="@string/chroma"
+                android:textSize="12dp"/>
+
+        </RadioGroup>
+
+        <View
+            android:layout_height="2dip"
+            android:background="#FF0000"
+            android:layout_width="match_parent"/>
+
+        <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="@string/remove"
+            android:id="@+id/textView2"
+            android:layout_gravity="center_horizontal"/>
+
+        <TableLayout
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:paddingTop="10dp"
+            android:paddingBottom="10dp"
+            android:stretchColumns="0,1"
+            android:paddingLeft="10dp"
+            android:paddingRight="10dp">
+
+            <TableRow
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_gravity="center"
+                android:orientation="vertical">
+
+                <TextView
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:text="@string/id"
+                    android:id="@+id/textView3"
+                    android:layout_gravity="center"/>
+
+                <Spinner
+                    android:layout_width="fill_parent"
+                    android:layout_height="40dp"
+                    android:id="@+id/effects2d_spinnerID"/>
+            </TableRow>
+
+            <TableRow
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_gravity="center">
+
+                <TextView
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:text="@string/name"
+                    android:id="@+id/textView4"
+                    android:layout_gravity="center"/>
+
+                <Spinner
+                    android:layout_width="fill_parent"
+                    android:layout_height="40dp"
+                    android:id="@+id/effects2d_spinnerName"/>
+            </TableRow>
+
+            <TableRow
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_gravity="center">
+
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="@string/type"
+                    android:id="@+id/textView5"
+                    android:layout_gravity="center"/>
+
+                <Spinner
+                    android:layout_width="fill_parent"
+                    android:layout_height="40dp"
+                    android:id="@+id/effects2d_spinnerType"/>
+            </TableRow>
+
+        </TableLayout>
+        <View
+            android:layout_height="2dip"
+            android:background="#FF0000"
+            android:layout_width="match_parent"
+            />
+
+        <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="@string/list"
+            android:id="@+id/textView6"
+            android:layout_gravity="center_horizontal"/>
+    </LinearLayout>
+
+</LinearLayout>
diff --git a/src/main/res/layout/scratchpadlayout.xml b/src/main/res/layout/scratchpadlayout.xml
deleted file mode 100644
index c6343c3..0000000
--- a/src/main/res/layout/scratchpadlayout.xml
+++ /dev/null
@@ -1,167 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="fill_parent"
-    android:layout_height="fill_parent"
-    android:onClick="Brightness"
-    android:orientation="vertical" >
-
-    <org.distorted.examples.effects2d.Effects2DSurfaceView
-        android:id="@+id/scratchpadSurfaceView"
-        android:layout_width="fill_parent"
-        android:layout_height="0dp"
-        android:layout_weight="1" />
-
-    <LinearLayout
-        android:id="@+id/linearLayout1"
-        android:layout_width="fill_parent"
-        android:layout_height="wrap_content"
-        android:layout_weight="0.07"
-        android:gravity="center|fill_horizontal" >
-
-        <RadioGroup
-            android:id="@+id/radioGroup1"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:paddingLeft="5dp"
-            android:paddingRight="10dp" >
-			
-            <RadioButton
-                android:id="@+id/scratchpadDistort"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:checked="true"
-                android:onClick="Distort"
-                android:text="@string/distort" />
-
-            <RadioButton
-                android:id="@+id/scratchpadSink"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:onClick="Sink"
-                android:text="@string/sink" />
-
-            <RadioButton
-                android:id="@+id/scratchpadTransparency"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:onClick="Transparency"
-                android:text="@string/transparency" />
-
-            <RadioButton
-                android:id="@+id/scratchpadMacroblock"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:onClick="Macroblock"
-                android:text="@string/macroblock" />
-
-            <RadioButton
-                android:id="@+id/scratchpadBrightness"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:onClick="Brightness"
-                android:text="@string/brightness" />
-
-        </RadioGroup>
-
-        <LinearLayout
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"
-            android:gravity="center_vertical|right"
-            android:orientation="vertical"
-            android:paddingLeft="10dp"
-            android:paddingRight="5dp" >
-
-            <LinearLayout
-                android:layout_width="match_parent"
-                android:layout_height="45dp"
-                android:gravity="center_vertical"
-                android:orientation="horizontal" >
-
-                <TextView
-                    android:id="@+id/scratchpadTextCount"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:layout_weight="1"
-                    android:text="@string/count"
-                    android:textAppearance="?android:attr/textAppearanceMedium" />
-
-                <SeekBar
-                    android:id="@+id/scratchpadSeekCount"
-                    android:layout_width="105dp"
-                    android:layout_height="wrap_content"
-                    android:layout_weight="1"
-                    android:paddingLeft="0dp"
-                    android:paddingRight="3dp" />
-            </LinearLayout>
-
-            <LinearLayout
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:gravity="center_vertical"
-                android:orientation="horizontal" >
-
-                <TextView
-                    android:id="@+id/scratchpadTextDuration"
-                    android:layout_width="0dp"
-                    android:layout_height="wrap_content"
-                    android:layout_weight="1"
-                    android:text="@string/duration"
-                    android:textAppearance="?android:attr/textAppearanceMedium" />
-
-                <SeekBar
-                    android:id="@+id/scratchpadSeekDuration"
-                    android:layout_width="106dp"
-                    android:layout_height="wrap_content"
-                    android:paddingLeft="0dp"
-                    android:paddingRight="3dp" />
-
-            </LinearLayout>
-
-            <LinearLayout
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:orientation="horizontal" >
-
-                <Button
-                    android:id="@+id/scratchpadButtonPrint"
-                    android:layout_width="24dp"
-                    android:layout_height="match_parent"
-                    android:layout_weight="0.77"
-                    android:onClick="Print"
-                    android:text="@string/print" />
-
-                <Button
-                    android:id="@+id/scratchpadButtonAbort"
-                    android:layout_width="wrap_content"
-                    android:layout_height="match_parent"
-                    android:layout_weight="0.39"
-                    android:onClick="Abort"
-                    android:text="@string/abort" />
-            </LinearLayout>
-
-            <LinearLayout
-                android:layout_width="match_parent"
-                android:layout_height="45dp"
-                android:gravity="center_vertical"
-                android:orientation="horizontal" >
-
-                <TextView
-                    android:id="@+id/scratchpadTextID"
-                    android:layout_width="0dp"
-                    android:layout_height="wrap_content"
-                    android:layout_weight="1"
-                    android:text="@string/id"
-                    android:textAppearance="?android:attr/textAppearanceMedium" />
-
-                <SeekBar
-                    android:id="@+id/scratchpadSeekID"
-                    android:layout_width="110dp"
-                    android:layout_height="wrap_content" />
-
-            </LinearLayout>
-
-        </LinearLayout>
-
-    </LinearLayout>
-
-</LinearLayout>
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index ca9d0c5..a279fb1 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -1,7 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <resources>    
     <string name="app_name">Distorted Examples</string>
-    <string name="toc">Table of Contents</string>
     <string name="tocHeader">Welcome to the Distorted Examples!\nCode, Tutorials, Wiki: http://distorted.org/</string>
     
     <string name="continu">Continue</string>
@@ -19,12 +18,17 @@
     <string name="sink">Sink</string>
     <string name="transparency">Trans</string>
     <string name="macroblock">Macro</string>
-    <string name="brightness">Bright</string>
+    <string name="chroma">Chroma</string>
+    <string name="add">Touch screen to add new</string>
+    <string name="remove">Remove existing effect(s) by</string>
+    <string name="name">Name</string>
+    <string name="type">Type</string>
+    <string name="id">ID</string>
+    <string name="list">List of all existing effects</string>
     <string name="swirl">Swirl</string>
     <string name="print">Print</string>
     <string name="abort">Abort</string>
     <string name="count">Count</string>
-    <string name="id">ID</string>
     <string name="maxv">vertex:</string>
     <string name="maxf">fragment:</string>
     <string name="introduction">Set maximum number of vertex and fragment effects and press \'Check\' to see if shaders compile:</string>
