Project

General

Profile

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

magiccube / src / main / java / org / distorted / bandaged / BandagedCreatorObjectView.java @ 7cb8d4b0

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2022 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is free software: you can redistribute it and/or modify                            //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Magic Cube is distributed in the hope that it will be useful,                                 //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

    
20
package org.distorted.bandaged;
21

    
22
import android.view.LayoutInflater;
23
import android.view.View;
24
import android.widget.LinearLayout;
25

    
26
import org.distorted.helpers.TransparentButton;
27
import org.distorted.helpers.TransparentImageButton;
28
import org.distorted.main.R;
29
import org.distorted.main.RubikActivity;
30

    
31
///////////////////////////////////////////////////////////////////////////////////////////////////
32

    
33
public class BandagedCreatorObjectView
34
{
35
  private final LinearLayout mPane;
36
  private final String mName;
37

    
38
///////////////////////////////////////////////////////////////////////////////////////////////////
39

    
40
  private void playObject()
41
    {
42

    
43
    }
44

    
45
///////////////////////////////////////////////////////////////////////////////////////////////////
46

    
47
  private void deleteObject()
48
    {
49

    
50
    }
51

    
52
///////////////////////////////////////////////////////////////////////////////////////////////////
53

    
54
  public BandagedCreatorObjectView(BandagedCreatorActivity act, String name, boolean leftmost)
55
    {
56
    mName = name;
57
    LayoutInflater inflater = act.getLayoutInflater();
58
    mPane = (LinearLayout) inflater.inflate(R.layout.bandaged_pane, null);
59

    
60
    int width    = act.getScreenWidthInPixels();
61
    int lMargin  = (int)(width*RubikActivity.LARGE_MARGIN);
62
    int textSize = (int)(width*RubikActivity.BUTTON_TEXT_SIZE);
63

    
64
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( (int)(width*0.35f), LinearLayout.LayoutParams.MATCH_PARENT);
65
    params.bottomMargin = lMargin;
66
    params.topMargin    = lMargin;
67
    params.leftMargin   = leftmost ? lMargin : 0;
68
    params.rightMargin  = lMargin;
69

    
70
    mPane.setLayoutParams(params);
71

    
72
    LinearLayout bottom = mPane.findViewById(R.id.bandagedCreatorObjectLayout);
73

    
74
    TransparentButton plaButton = new TransparentButton(act, R.string.play, textSize);
75

    
76
    final int icon = RubikActivity.getDrawable(R.drawable.ui_small_trash,R.drawable.ui_medium_trash, R.drawable.ui_big_trash, R.drawable.ui_huge_trash);
77
    LinearLayout.LayoutParams paramsB = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,3.0f);
78
    TransparentImageButton delButton = new TransparentImageButton(act, icon, TransparentImageButton.GRAVITY_MIDDLE, paramsB);
79

    
80
    bottom.addView(plaButton);
81
    bottom.addView(delButton);
82

    
83
    plaButton.setOnClickListener( new View.OnClickListener()
84
      {
85
      @Override
86
      public void onClick(View v)
87
        {
88
        playObject();
89
        }
90
      });
91

    
92
    delButton.setOnClickListener( new View.OnClickListener()
93
      {
94
      @Override
95
      public void onClick(View v)
96
        {
97
        deleteObject();
98
        }
99
      });
100
    }
101

    
102
///////////////////////////////////////////////////////////////////////////////////////////////////
103

    
104
  public LinearLayout getPane()
105
    {
106
    return mPane;
107
    }
108
}
(2-2/13)