Revision 3b1e9c7e
Added by Leszek Koltunski over 7 years ago
| src/main/java/org/distorted/examples/effects3d/Effects3DEffect.java | ||
|---|---|---|
| 63 | 63 |
|
| 64 | 64 |
class Effects3DEffect implements SeekBar.OnSeekBarChangeListener |
| 65 | 65 |
{
|
| 66 |
private static final int BACKGROUND_ODD = 0xff555555; |
|
| 67 |
private static final int BACKGROUND_EVEN= 0xff333333; |
|
| 68 |
|
|
| 66 | 69 |
private WeakReference<Effects3DActivity2> mAct; |
| 67 | 70 |
|
| 68 | 71 |
private EffectName mName; |
| ... | ... | |
| 385 | 388 |
mTextRegion.setText("region ("+f0+","+f1+","+f2+","+f3+")");
|
| 386 | 389 |
} |
| 387 | 390 |
|
| 391 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 392 |
|
|
| 393 |
void setBackground(int pos) |
|
| 394 |
{
|
|
| 395 |
int color = (pos%2==1 ? BACKGROUND_ODD:BACKGROUND_EVEN); |
|
| 396 |
|
|
| 397 |
if( mEffect!=null ) mEffect.setBackgroundColor(color); |
|
| 398 |
if( mCenter!=null ) mCenter.setBackgroundColor(color); |
|
| 399 |
if( mRegion!=null ) mRegion.setBackgroundColor(color); |
|
| 400 |
} |
|
| 401 |
|
|
| 388 | 402 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 389 | 403 |
|
| 390 | 404 |
Effects3DEffect(EffectName name, Effects3DActivity2 act) |
| ... | ... | |
| 477 | 491 |
|
| 478 | 492 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 479 | 493 |
|
| 480 |
View createView() |
|
| 494 |
View createView(int num)
|
|
| 481 | 495 |
{
|
| 482 | 496 |
SeekBar[] seek = new SeekBar[mDimension]; |
| 483 | 497 |
|
| ... | ... | |
| 535 | 549 |
mSeekID[4] = seek[4].getId(); |
| 536 | 550 |
mButton = mEffect.findViewById(R.id.button5dRemove); |
| 537 | 551 |
break; |
| 538 |
default: android.util.Log.e("Matrix3DEffect", "dimension "+mDimension+" not supported!");
|
|
| 552 |
default: android.util.Log.e("Effects3DEffect", "dimension "+mDimension+" not supported!");
|
|
| 539 | 553 |
return null; |
| 540 | 554 |
} |
| 541 | 555 |
|
| 556 |
mEffect.setBackgroundColor( num%2==1 ? BACKGROUND_EVEN: BACKGROUND_ODD ); |
|
| 557 |
|
|
| 542 | 558 |
setDefaultInter(); |
| 543 | 559 |
|
| 544 | 560 |
for(int i=0; i<mDimension; i++) |
| ... | ... | |
| 552 | 568 |
|
| 553 | 569 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 554 | 570 |
|
| 555 |
View createRegion() |
|
| 571 |
View createRegion(int num)
|
|
| 556 | 572 |
{
|
| 557 | 573 |
Effects3DActivity2 act = mAct.get(); |
| 558 | 574 |
|
| 559 | 575 |
mRegion = act.getLayoutInflater().inflate(R.layout.effectregion, null); |
| 576 |
mRegion.setBackgroundColor( num%2==1 ? BACKGROUND_EVEN: BACKGROUND_ODD ); |
|
| 560 | 577 |
|
| 561 | 578 |
SeekBar[] seek = new SeekBar[4]; |
| 562 | 579 |
|
| ... | ... | |
| 587 | 604 |
|
| 588 | 605 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 589 | 606 |
|
| 590 |
View createCenter() |
|
| 607 |
View createCenter(int num)
|
|
| 591 | 608 |
{
|
| 592 | 609 |
Effects3DActivity2 act = mAct.get(); |
| 593 | 610 |
|
| 594 | 611 |
mCenter = act.getLayoutInflater().inflate(R.layout.effectcenter, null); |
| 612 |
mCenter.setBackgroundColor( num%2==1 ? BACKGROUND_EVEN: BACKGROUND_ODD ); |
|
| 595 | 613 |
|
| 596 | 614 |
SeekBar[] seek = new SeekBar[3]; |
| 597 | 615 |
|
| src/main/java/org/distorted/examples/effects3d/Effects3DTab.java | ||
|---|---|---|
| 47 | 47 |
private DistortedEffects mEffects; |
| 48 | 48 |
private String[] mEffectStrings; |
| 49 | 49 |
private int mTab, mLayout, mSpinner; |
| 50 |
private int mChildren; |
|
| 50 | 51 |
|
| 51 | 52 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 52 | 53 |
|
| ... | ... | |
| 54 | 55 |
{
|
| 55 | 56 |
mList = new ArrayList<>(); |
| 56 | 57 |
mEffectAdd = 0; |
| 58 |
mChildren = 0; |
|
| 57 | 59 |
} |
| 58 | 60 |
|
| 59 | 61 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 154 | 156 |
Effects3DEffect eff = new Effects3DEffect(mEffectNames[mEffectAdd], act ); |
| 155 | 157 |
mList.add(eff); |
| 156 | 158 |
|
| 159 |
mChildren++; |
|
| 160 |
|
|
| 157 | 161 |
LinearLayout layout = act.findViewById(mLayout); |
| 158 |
View view = eff.createView(); |
|
| 162 |
View view = eff.createView(mChildren);
|
|
| 159 | 163 |
layout.addView(view); |
| 160 | 164 |
|
| 161 | 165 |
if( mEffectNames[mEffectAdd].supportsCenter() ) |
| 162 | 166 |
{
|
| 163 |
View center = eff.createCenter(); |
|
| 167 |
View center = eff.createCenter(mChildren);
|
|
| 164 | 168 |
layout.addView(center); |
| 165 | 169 |
} |
| 166 | 170 |
|
| 167 | 171 |
if( mEffectNames[mEffectAdd].supportsRegion() ) |
| 168 | 172 |
{
|
| 169 |
View region = eff.createRegion(); |
|
| 173 |
View region = eff.createRegion(mChildren);
|
|
| 170 | 174 |
layout.addView(region); |
| 171 | 175 |
} |
| 172 | 176 |
|
| ... | ... | |
| 208 | 212 |
{
|
| 209 | 213 |
Effects3DActivity2 act = (Effects3DActivity2)getActivity(); |
| 210 | 214 |
|
| 215 |
mChildren = 0; |
|
| 216 |
|
|
| 211 | 217 |
mList.clear(); |
| 212 | 218 |
LinearLayout layout = act.findViewById(mLayout); |
| 213 | 219 |
layout.removeAllViews(); |
| ... | ... | |
| 237 | 243 |
if( view!=null ) layout.removeView(view); |
| 238 | 244 |
|
| 239 | 245 |
mEffects.abortById(effect.getId()); |
| 246 |
|
|
| 247 |
int index = mList.indexOf(effect); |
|
| 248 |
int capac = mList.size(); |
|
| 249 |
|
|
| 250 |
for(int i=index+1; i<capac; i++) |
|
| 251 |
{
|
|
| 252 |
mList.get(i).setBackground(i-1); |
|
| 253 |
} |
|
| 254 |
|
|
| 240 | 255 |
mList.remove(effect); |
| 256 |
mChildren--; |
|
| 241 | 257 |
|
| 242 | 258 |
resetData(); |
| 243 | 259 |
|
| src/main/res/layout/effectregion.xml | ||
|---|---|---|
| 63 | 63 |
android:layout_weight="0.5"/> |
| 64 | 64 |
|
| 65 | 65 |
</LinearLayout> |
| 66 |
|
|
| 67 |
<View |
|
| 68 |
android:layout_height="3dip" |
|
| 69 |
android:background="#777777" |
|
| 70 |
android:layout_width="match_parent" |
|
| 71 |
/> |
|
| 72 |
|
|
| 73 | 66 |
</LinearLayout> |
Also available in: Unified diff
Progress with Effects3D app.