Project

General

Profile

« Previous | Next » 

Revision fed00329

Added by Leszek Koltunski about 8 years ago

Effects3D: can remove arbitrary effect

View differences:

src/main/java/org/distorted/examples/effects3d/Effects3DActivity.java
552 552
      if( effect.thisView(v) )
553 553
        {
554 554
        android.util.Log.e("effects3D", "effect: "+i);
555

  
556
        LinearLayout layout = (LinearLayout)findViewById(R.id.effects3dlayout);
557
        View view;
558

  
559
        view = effect.getEffect();
560
        if( view!=null ) layout.removeView(view);
561
        view = effect.getCenter();
562
        if( view!=null ) layout.removeView(view);
563
        view = effect.getRegion();
564
        if( view!=null ) layout.removeView(view);
565

  
566
        long id = effect.getId();
567
        mObject.abortEffect(id);
568
        mEffects.remove(i);
569

  
570
        break;
555 571
        }
556 572
      }
557 573
    }
src/main/java/org/distorted/examples/effects3d/Effects3DEffect.java
67 67
  private Dynamic2D mCenterDyn;
68 68
  private Static2D  mCenterSta;
69 69

  
70
  private View mButton;
70
  private View mButton, mEffect, mCenter, mRegion;
71 71
  private long mId;
72 72

  
73 73
///////////////////////////////////////////////////////////////////////////////////////////////////
......
369 369
    mCenterDyn   = new Dynamic2D();
370 370
    mCenterSta   = new Static2D(0,0);
371 371
    mCenterDyn.add(mCenterSta);
372

  
373
    mButton = null;
374
    mEffect = null;
375
    mCenter = null;
376
    mRegion = null;
372 377
    }
373 378

  
374 379
///////////////////////////////////////////////////////////////////////////////////////////////////
375 380

  
376 381
  View createView()
377 382
    {
378
    View effect;
379 383
    SeekBar[] seek = new SeekBar[mDimension];
380 384

  
381 385
    Effects3DActivity act = mAct.get();
382 386

  
383 387
    switch(mDimension)
384 388
      {
385
      case 1 : effect     = act.getLayoutInflater().inflate(R.layout.effect1d, null);
386
               mText      = (TextView)effect.findViewById(R.id.effect1dText);
387
               seek[0]    = (SeekBar)effect.findViewById(R.id.effect1dbar1);
389
      case 1 : mEffect    = act.getLayoutInflater().inflate(R.layout.effect1d, null);
390
               mText      = (TextView)mEffect.findViewById(R.id.effect1dText);
391
               seek[0]    = (SeekBar)mEffect.findViewById(R.id.effect1dbar1);
388 392
               mSeekID[0] = seek[0].getId();
389
               mButton    = effect.findViewById(R.id.button1dRemove);
393
               mButton    = mEffect.findViewById(R.id.button1dRemove);
390 394
               break;
391
      case 2 : effect     = act.getLayoutInflater().inflate(R.layout.effect2d, null);
392
               mText      = (TextView)effect.findViewById(R.id.effect2dText);
393
               seek[0]    = (SeekBar)effect.findViewById(R.id.effect2dbar1);
394
               seek[1]    = (SeekBar)effect.findViewById(R.id.effect2dbar2);
395
      case 2 : mEffect    = act.getLayoutInflater().inflate(R.layout.effect2d, null);
396
               mText      = (TextView)mEffect.findViewById(R.id.effect2dText);
397
               seek[0]    = (SeekBar)mEffect.findViewById(R.id.effect2dbar1);
398
               seek[1]    = (SeekBar)mEffect.findViewById(R.id.effect2dbar2);
395 399
               mSeekID[0] = seek[0].getId();
396 400
               mSeekID[1] = seek[1].getId();
397
               mButton    = effect.findViewById(R.id.button2dRemove);
401
               mButton    = mEffect.findViewById(R.id.button2dRemove);
398 402
               break;
399
      case 3 : effect     = act.getLayoutInflater().inflate(R.layout.effect3d, null);
400
               mText      = (TextView)effect.findViewById(R.id.effect3dText);
401
               seek[0]    = (SeekBar)effect.findViewById(R.id.effect3dbar1);
402
               seek[1]    = (SeekBar)effect.findViewById(R.id.effect3dbar2);
403
               seek[2]    = (SeekBar)effect.findViewById(R.id.effect3dbar3);
403
      case 3 : mEffect    = act.getLayoutInflater().inflate(R.layout.effect3d, null);
404
               mText      = (TextView)mEffect.findViewById(R.id.effect3dText);
405
               seek[0]    = (SeekBar)mEffect.findViewById(R.id.effect3dbar1);
406
               seek[1]    = (SeekBar)mEffect.findViewById(R.id.effect3dbar2);
407
               seek[2]    = (SeekBar)mEffect.findViewById(R.id.effect3dbar3);
404 408
               mSeekID[0] = seek[0].getId();
405 409
               mSeekID[1] = seek[1].getId();
406 410
               mSeekID[2] = seek[2].getId();
407
               mButton    = effect.findViewById(R.id.button3dRemove);
411
               mButton    = mEffect.findViewById(R.id.button3dRemove);
408 412
               break;
409
      case 4 : effect     = act.getLayoutInflater().inflate(R.layout.effect4d, null);
410
               mText      = (TextView)effect.findViewById(R.id.effect4dText);
411
               seek[0]    = (SeekBar)effect.findViewById(R.id.effect4dbar1);
412
               seek[1]    = (SeekBar)effect.findViewById(R.id.effect4dbar2);
413
               seek[2]    = (SeekBar)effect.findViewById(R.id.effect4dbar3);
414
               seek[3]    = (SeekBar)effect.findViewById(R.id.effect4dbar4);
413
      case 4 : mEffect    = act.getLayoutInflater().inflate(R.layout.effect4d, null);
414
               mText      = (TextView)mEffect.findViewById(R.id.effect4dText);
415
               seek[0]    = (SeekBar)mEffect.findViewById(R.id.effect4dbar1);
416
               seek[1]    = (SeekBar)mEffect.findViewById(R.id.effect4dbar2);
417
               seek[2]    = (SeekBar)mEffect.findViewById(R.id.effect4dbar3);
418
               seek[3]    = (SeekBar)mEffect.findViewById(R.id.effect4dbar4);
415 419
               mSeekID[0] = seek[0].getId();
416 420
               mSeekID[1] = seek[1].getId();
417 421
               mSeekID[2] = seek[2].getId();
418 422
               mSeekID[3] = seek[3].getId();
419
               mButton    = effect.findViewById(R.id.button4dRemove);
423
               mButton    = mEffect.findViewById(R.id.button4dRemove);
420 424
               break;
421
      case 5 : effect     = act.getLayoutInflater().inflate(R.layout.effect5d, null);
422
               mText      = (TextView)effect.findViewById(R.id.effect5dText);
423
               seek[0]    = (SeekBar)effect.findViewById(R.id.effect5dbar1);
424
               seek[1]    = (SeekBar)effect.findViewById(R.id.effect5dbar2);
425
               seek[2]    = (SeekBar)effect.findViewById(R.id.effect5dbar3);
426
               seek[3]    = (SeekBar)effect.findViewById(R.id.effect5dbar4);
427
               seek[4]    = (SeekBar)effect.findViewById(R.id.effect5dbar5);
425
      case 5 : mEffect    = act.getLayoutInflater().inflate(R.layout.effect5d, null);
426
               mText      = (TextView)mEffect.findViewById(R.id.effect5dText);
427
               seek[0]    = (SeekBar)mEffect.findViewById(R.id.effect5dbar1);
428
               seek[1]    = (SeekBar)mEffect.findViewById(R.id.effect5dbar2);
429
               seek[2]    = (SeekBar)mEffect.findViewById(R.id.effect5dbar3);
430
               seek[3]    = (SeekBar)mEffect.findViewById(R.id.effect5dbar4);
431
               seek[4]    = (SeekBar)mEffect.findViewById(R.id.effect5dbar5);
428 432
               mSeekID[0] = seek[0].getId();
429 433
               mSeekID[1] = seek[1].getId();
430 434
               mSeekID[2] = seek[2].getId();
431 435
               mSeekID[3] = seek[3].getId();
432 436
               mSeekID[4] = seek[4].getId();
433
               mButton    = effect.findViewById(R.id.button5dRemove);
437
               mButton    = mEffect.findViewById(R.id.button5dRemove);
434 438
               break;
435 439
      default: android.util.Log.e("Effects3DEffect", "dimension "+mDimension+" not supported!");
436 440
               return null;
......
447 451
    Effects3DActivity.setSupportsRegion(supportsRegion());
448 452
    Effects3DActivity.setTypeVertex(mName.getType() == EffectTypes.VERTEX);
449 453

  
450
    return effect;
454
    return mEffect;
451 455
    }
452 456

  
453 457
///////////////////////////////////////////////////////////////////////////////////////////////////
......
456 460
    {
457 461
    Effects3DActivity act = mAct.get();
458 462

  
459
    View region = act.getLayoutInflater().inflate(R.layout.effectregion, null);
463
    mRegion = act.getLayoutInflater().inflate(R.layout.effectregion, null);
460 464

  
461 465
    SeekBar[] seek = new SeekBar[4];
462 466

  
463
    seek[0] = (SeekBar)region.findViewById(R.id.effectRegionBarX );
464
    seek[1] = (SeekBar)region.findViewById(R.id.effectRegionBarY );
465
    seek[2] = (SeekBar)region.findViewById(R.id.effectRegionBarRX);
466
    seek[3] = (SeekBar)region.findViewById(R.id.effectRegionBarRY);
467
    seek[0] = (SeekBar)mRegion.findViewById(R.id.effectRegionBarX );
468
    seek[1] = (SeekBar)mRegion.findViewById(R.id.effectRegionBarY );
469
    seek[2] = (SeekBar)mRegion.findViewById(R.id.effectRegionBarRX);
470
    seek[3] = (SeekBar)mRegion.findViewById(R.id.effectRegionBarRY);
467 471

  
468 472
    mSeekRegionID[0] = seek[0].getId();
469 473
    mSeekRegionID[1] = seek[1].getId();
470 474
    mSeekRegionID[2] = seek[2].getId();
471 475
    mSeekRegionID[3] = seek[3].getId();
472 476

  
473
    mTextRegion = (TextView)region.findViewById(R.id.effectRegionText);
477
    mTextRegion = (TextView)mRegion.findViewById(R.id.effectRegionText);
474 478

  
475 479
    setDefaultRegionInter();
476 480

  
......
482 486

  
483 487
    act.setRegion(mRegionSta.getX(),mRegionSta.getY(),mRegionSta.getZ());
484 488

  
485
    return region;
489
    return mRegion;
486 490
    }
487 491

  
488 492
///////////////////////////////////////////////////////////////////////////////////////////////////
......
491 495
    {
492 496
    Effects3DActivity act = mAct.get();
493 497

  
494
    View center = act.getLayoutInflater().inflate(R.layout.effectcenter, null);
498
    mCenter = act.getLayoutInflater().inflate(R.layout.effectcenter, null);
495 499

  
496 500
    SeekBar[] seek = new SeekBar[2];
497 501

  
498
    seek[0] = (SeekBar)center.findViewById(R.id.effectCenterBarX );
499
    seek[1] = (SeekBar)center.findViewById(R.id.effectCenterBarY );
502
    seek[0] = (SeekBar)mCenter.findViewById(R.id.effectCenterBarX );
503
    seek[1] = (SeekBar)mCenter.findViewById(R.id.effectCenterBarY );
500 504

  
501 505
    mSeekCenterID[0] = seek[0].getId();
502 506
    mSeekCenterID[1] = seek[1].getId();
503 507

  
504
    mTextCenter = (TextView)center.findViewById(R.id.effectCenterText);
508
    mTextCenter = (TextView)mCenter.findViewById(R.id.effectCenterText);
505 509

  
506 510
    setDefaultCenterInter();
507 511

  
......
513 517

  
514 518
    act.setCenter(mCenterSta.getX(),mCenterSta.getY());
515 519

  
516
    return center;
520
    return mCenter;
517 521
    }
518 522

  
519 523
///////////////////////////////////////////////////////////////////////////////////////////////////
......
608 612
    return v==mButton;
609 613
    }
610 614

  
615
///////////////////////////////////////////////////////////////////////////////////////////////////
616

  
617
  public long getId()
618
    {
619
    return mId;
620
    }
621

  
622
///////////////////////////////////////////////////////////////////////////////////////////////////
623

  
624
  public View getEffect()
625
    {
626
    return mEffect;
627
    }
628

  
629
///////////////////////////////////////////////////////////////////////////////////////////////////
630

  
631
  public View getRegion()
632
    {
633
    return mRegion;
634
    }
635

  
636
///////////////////////////////////////////////////////////////////////////////////////////////////
637

  
638
  public View getCenter()
639
    {
640
    return mCenter;
641
    }
642

  
611 643
///////////////////////////////////////////////////////////////////////////////////////////////////
612 644

  
613 645
  public void onStartTrackingTouch(SeekBar bar) { }

Also available in: Unified diff