Project

General

Profile

« Previous | Next » 

Revision 8aece7f2

Added by Leszek Koltunski over 4 years ago

Progress with the MeshFile app.

View differences:

src/main/java/org/distorted/examples/meshfile/MeshFileActivity.java
25 25
import android.view.View;
26 26
import android.widget.AdapterView;
27 27
import android.widget.ArrayAdapter;
28
import android.widget.Button;
28
import android.widget.CompoundButton;
29 29
import android.widget.LinearLayout;
30 30
import android.widget.SeekBar;
31 31
import android.widget.Spinner;
32 32
import android.widget.TextView;
33
import android.widget.ToggleButton;
33 34

  
34 35
import org.distorted.examples.R;
35 36
import org.distorted.library.main.DistortedLibrary;
......
38 39
///////////////////////////////////////////////////////////////////////////////////////////////////
39 40

  
40 41
public class MeshFileActivity extends Activity implements AdapterView.OnItemSelectedListener,
41
                                                          SeekBar.OnSeekBarChangeListener,
42
                                                          View.OnClickListener
42
                                                          SeekBar.OnSeekBarChangeListener
43 43
{
44
    private static final int OFFSET = 100000;
45

  
46 44
    private LinearLayout mLayout;
47 45
    private int mResource;
48 46
    private String[] mNames = new String[] { "deferredjob",
......
145 143

  
146 144
///////////////////////////////////////////////////////////////////////////////////////////////////
147 145

  
148
    private View createComponentView(MeshFileRenderer renderer, int component)
146
    private View createComponentView(MeshFileRenderer renderer, final int component)
149 147
      {
150 148
      View view = getLayoutInflater().inflate(R.layout.meshfilecomponent, null);
151 149

  
......
156 154
      TextView index = view.findViewById(R.id.meshfileComponentText);
157 155
      index.setText(String.valueOf(endIndex));
158 156

  
159
      Button disappear = view.findViewById(R.id.meshfileComponentDisappear);
160
      disappear.setId(component);
161
      disappear.setOnClickListener(this);
157
      final ToggleButton toggle = view.findViewById(R.id.meshfileComponentToggle);
162 158

  
163
      Button appear = view.findViewById(R.id.meshfileComponentAppear);
164
      appear.setId(component+OFFSET);
165
      appear.setOnClickListener(this);
159
      toggle.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener()
160
        {
161
        @Override
162
        public void onCheckedChanged(CompoundButton toggleButton, boolean isChecked)
163
          {
164
          MeshFileSurfaceView view = findViewById(R.id.meshfileSurfaceView);
165
          MeshFileRenderer renderer = view.getRenderer();
166
          MeshFile mesh = renderer.getMesh();
167
          mesh.setEffectAssociation(component,isChecked ? 1:0,component);
168
          }
169
        }) ;
166 170

  
167 171
      return view;
168 172
      }
......
195 199
      {
196 200
      }
197 201

  
198
///////////////////////////////////////////////////////////////////////////////////////////////////
199

  
200
    @Override
201
    public void onClick(View v)
202
      {
203
      int id = v.getId();
204

  
205
      MeshFileSurfaceView view = findViewById(R.id.meshfileSurfaceView);
206
      MeshFileRenderer renderer = view.getRenderer();
207

  
208
      MeshFile mesh = renderer.getMesh();
209

  
210
      if( id>=OFFSET )
211
        {
212
        id -= OFFSET;
213
        mesh.setEffectAssociation(id,0,id);
214
        }
215
      else
216
        {
217
        mesh.setEffectAssociation(id,1,id);
218
        }
219
      }
220

  
221 202
///////////////////////////////////////////////////////////////////////////////////////////////////
222 203

  
223 204
    public void onProgressChanged(SeekBar bar, int progress, boolean fromUser)
src/main/res/layout/meshfilecomponent.xml
22 22
          android:layout_marginTop="5dp"
23 23
          android:layout_weight="1"/>
24 24

  
25
     <Button
26
          android:id="@+id/meshfileComponentAppear"
27
          android:text="@string/appear"
25
     <ToggleButton
26
          android:id="@+id/meshfileComponentToggle"
27
          android:textOn="@string/off"
28
          android:textOff="@string/on"
28 29
          android:layout_width="wrap_content"
29 30
          android:layout_height="wrap_content"
30 31
          android:layout_weight="0.2"
31 32
          android:layout_marginEnd="5dp"
32 33
          android:layout_marginStart="5dp"
33
          android:layout_marginTop="5dp"/>
34
          android:layout_marginTop="2dp"/>
34 35

  
35
     <Button
36
          android:id="@+id/meshfileComponentDisappear"
37
          android:text="@string/disappear"
38
          android:layout_width="wrap_content"
39
          android:layout_height="wrap_content"
40
          android:layout_weight="0.2"
41
          android:layout_marginEnd="5dp"
42
          android:layout_marginStart="5dp"
43
          android:layout_marginTop="5dp"/>
44 36
</LinearLayout>
src/main/res/layout/meshfilelayout.xml
4 4
    android:layout_height="fill_parent"
5 5
    android:orientation="vertical" >
6 6

  
7
    <SeekBar
8
        android:id="@+id/meshfileScale"
9
        android:layout_width="match_parent"
10
        android:layout_height="wrap_content"
11
        android:paddingLeft="10dp"
12
        android:paddingRight="10dp"
13
        android:paddingTop="10dp"
14
        android:paddingBottom="10dp" />
15

  
7 16
    <org.distorted.examples.meshfile.MeshFileSurfaceView
8 17
        android:id="@+id/meshfileSurfaceView"
9 18
        android:layout_width="fill_parent"
......
33 42

  
34 43
    </LinearLayout>
35 44

  
36
    <SeekBar
37
            android:id="@+id/meshfileScale"
38
            android:layout_width="match_parent"
39
            android:layout_height="wrap_content"
40
            android:paddingLeft="20dp"
41
            android:paddingRight="20dp" />
42

  
43 45
    <LinearLayout
44 46
        android:orientation="horizontal"
45 47
        android:layout_width="match_parent"
src/main/res/values/strings.xml
90 90
    <string name="open">Open</string>
91 91
    <string name="vertices">Vert</string>
92 92
    <string name="time">Time</string>
93
    <string name="disappear">Disappear</string>
94
    <string name="appear">Appear</string>
93
    <string name="on">On</string>
94
    <string name="off">Off</string>
95 95
    <string name="effComponents">Effect Components</string>
96 96

  
97 97
    <string name="quality0">Highest</string>

Also available in: Unified diff