Skip to content
Snippets Groups Projects
Commit 31f0937d authored by Maxime Graulich's avatar Maxime Graulich
Browse files

Android: SeekBar can now control the animation

parent 1a068e7c
Branches
Tags
No related merge requests found
......@@ -35,6 +35,7 @@ public class Gmsh implements Parcelable {
public native int numberOfAnimation();
public native int animationNext();
public native int animationPrev();
public native void setAnimation(int animation);
/** Java CLASS **/
private long ptr;
......
......@@ -37,7 +37,7 @@ public class ModelFragment extends Fragment{
private GestureDetector _gestureDetector;
private Timer _animation;
private Handler _hideDelay;
private SeekBar _annimationStepper;
private SeekBar _animationStepper;
final Runnable hideControlsRunnable = new Runnable() {public void run() {hideControlBar();}};
......@@ -118,7 +118,19 @@ public class ModelFragment extends Fragment{
final ImageButton prevButton = (ImageButton)_controlBarLayout.findViewById(R.id.controlPrev);
final ImageButton playPauseButton = (ImageButton)_controlBarLayout.findViewById(R.id.controlPlay);
final ImageButton nextButton = (ImageButton)_controlBarLayout.findViewById(R.id.controlNext);
_annimationStepper = (SeekBar)_controlBarLayout.findViewById(R.id.controlStepper);
_animationStepper = (SeekBar)_controlBarLayout.findViewById(R.id.controlStepper);
_animationStepper.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
public void onStopTrackingTouch(SeekBar seekBar) {} // UNUSED Auto-generated method stub
public void onStartTrackingTouch(SeekBar seekBar) {} // UNUSED Auto-generated method stub
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
if(fromUser) {
postDelay();
_gmsh.setAnimation(progress);
requestRender();
}
}
});
_controlBarLayout.setEnabled(false);
playPauseButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
......@@ -126,11 +138,11 @@ public class ModelFragment extends Fragment{
if(((ImageButton)v).getContentDescription().equals("play")) {
((ImageButton)v).setContentDescription("pause");
((ImageButton)v).setImageResource(android.R.drawable.ic_media_pause);
_annimationStepper.setMax(_gmsh.numberOfAnimation());
_animationStepper.setMax(_gmsh.numberOfAnimation());
_animation = new Timer();
_animation.schedule(new TimerTask() {
public void run() {
_annimationStepper.setProgress(_gmsh.animationNext());
_animationStepper.setProgress(_gmsh.animationNext());
requestRender();
} }, 0, 500);
prevButton.setEnabled(false);
......@@ -148,14 +160,14 @@ public class ModelFragment extends Fragment{
nextButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
postDelay();
_annimationStepper.setProgress(_gmsh.animationNext());
_animationStepper.setProgress(_gmsh.animationNext());
requestRender();
}
});
prevButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
postDelay();
_annimationStepper.setProgress(_gmsh.animationPrev());
_animationStepper.setProgress(_gmsh.animationPrev());
requestRender();
}
});
......@@ -176,7 +188,7 @@ public class ModelFragment extends Fragment{
public void showControlBar() {
if(getActivity() == null || ((MainActivity)getActivity()).isComputing() || !_gmsh.haveAnimation()) return;
_controlBarLayout.setEnabled(true);
_annimationStepper.setMax(_gmsh.numberOfAnimation());
_animationStepper.setMax(_gmsh.numberOfAnimation()-1);
this.postDelay();
Animation bottomUp = AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_in);
_controlBarLayout.setVisibility(View.VISIBLE);
......
......@@ -320,4 +320,9 @@ JNIEXPORT jint JNICALL Java_org_geuz_onelab_Gmsh_animationPrev
{
return animation_prev();
}
JNIEXPORT void JNICALL Java_org_geuz_onelab_Gmsh_setAnimation
(JNIEnv *, jobject, jint animation)
{
set_animation(animation);
}
}
......@@ -161,6 +161,14 @@ JNIEXPORT jint JNICALL Java_org_geuz_onelab_Gmsh_animationNext
JNIEXPORT jint JNICALL Java_org_geuz_onelab_Gmsh_animationPrev
(JNIEnv *, jobject);
/*
* Class: org_geuz_onelab_Gmsh
* Method: setAnimation
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_org_geuz_onelab_Gmsh_setAnimation
(JNIEnv *, jobject, jint);
#ifdef __cplusplus
}
#endif
......
......@@ -694,6 +694,16 @@ int number_of_animation() {
return ret;
}
void set_animation(int step) {
for(unsigned int i = 0; i < PView::list.size(); i++){
PView * p = PView::list[i];
if(p->getOptions()->visible){
p->getOptions()->timeStep = step;
p->setChanged(true);
}
}
}
int animation_next() {
int ret = 0;
for(unsigned int i = 0; i < PView::list.size(); i++){
......
......@@ -24,6 +24,7 @@ int onelab_cb(std::string);
int animation_next();
int animation_prev();
int number_of_animation();
void set_animation(int step);
class drawContext{
private:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment