Project

General

Profile

Download (3.58 KB) Statistics
| Branch: | Tag: | Revision:

magiccube / src / main / java / org / distorted / config / ConfigScreen.java @ 58fd2ec0

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is proprietary software licensed under an EULA which you should have received      //
7
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html        //
8
///////////////////////////////////////////////////////////////////////////////////////////////////
9

    
10
package org.distorted.config;
11

    
12
import android.view.View;
13
import android.widget.LinearLayout;
14

    
15
import org.distorted.helpers.TransparentImageButton;
16
import org.distorted.main.R;
17

    
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

    
20
public class ConfigScreen
21
{
22
  private TransparentImageButton mBackButton, mResetButton;
23
  private ConfigScreenPane mPane;
24

    
25
///////////////////////////////////////////////////////////////////////////////////////////////////
26

    
27
  private void setupBackButton(final ConfigActivity act)
28
    {
29
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT);
30
    mBackButton = new TransparentImageButton(act,R.drawable.ui_smallback,params);
31

    
32
    mBackButton.setOnClickListener( new View.OnClickListener()
33
      {
34
      @Override
35
      public void onClick(View v)
36
        {
37
        act.finish();
38
        }
39
      });
40
    }
41

    
42
///////////////////////////////////////////////////////////////////////////////////////////////////
43

    
44
  private void setupResetButton(final ConfigActivity act)
45
    {
46
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT);
47
    mResetButton = new TransparentImageButton(act,R.drawable.ui_reset,params);
48

    
49
    mResetButton.setOnClickListener( new View.OnClickListener()
50
      {
51
      @Override
52
      public void onClick(View v)
53
        {
54
        ConfigRenderer renderer = act.getRenderer();
55
        renderer.setupReset();
56
        }
57
      });
58
    }
59

    
60
///////////////////////////////////////////////////////////////////////////////////////////////////
61

    
62
  void onAttachedToWindow(final ConfigActivity act, final int objectOrdinal)
63
    {
64
    int width = act.getScreenWidthInPixels();
65

    
66
    LinearLayout.LayoutParams paramsL = new LinearLayout.LayoutParams(width/4, LinearLayout.LayoutParams.MATCH_PARENT);
67
    LinearLayout.LayoutParams paramsM = new LinearLayout.LayoutParams(width/2, LinearLayout.LayoutParams.MATCH_PARENT);
68
    LinearLayout.LayoutParams paramsR = new LinearLayout.LayoutParams(width/4, LinearLayout.LayoutParams.MATCH_PARENT);
69

    
70
    LinearLayout layoutLeft = new LinearLayout(act);
71
    layoutLeft.setLayoutParams(paramsL);
72
    LinearLayout layoutMid  = new LinearLayout(act);
73
    layoutMid.setLayoutParams(paramsM);
74
    LinearLayout layoutRight= new LinearLayout(act);
75
    layoutRight.setLayoutParams(paramsR);
76

    
77
    setupBackButton(act);
78
    setupResetButton(act);
79
    layoutLeft.addView(mResetButton);
80
    layoutRight.addView(mBackButton);
81

    
82
    LinearLayout layout = act.findViewById(R.id.lowerBar);
83
    layout.removeAllViews();
84
    layout.addView(layoutLeft);
85
    layout.addView(layoutMid);
86
    layout.addView(layoutRight);
87

    
88
    mPane = new ConfigScreenPane(act,objectOrdinal);
89
    }
90
}
(4-4/6)