Project

General

Profile

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

magiccube / src / main / java / org / distorted / bandaged / BandagedCreatorObjectView.java @ 83e021c5

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.36f), 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
    plaButton.setSingleLine();
76

    
77
    final int icon = R.drawable.ui_trash;
78
    LinearLayout.LayoutParams paramsB = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,3.0f);
79
    TransparentImageButton delButton = new TransparentImageButton(act, icon, TransparentImageButton.GRAVITY_MIDDLE, paramsB);
80

    
81
    int height = act.getScreenHeightInPixels();
82
    int iconHeight = (int)(0.15f*(BandagedCreatorActivity.RATIO_SCROLL-2*RubikActivity.PADDING)*height);
83
    delButton.setIconSize(iconHeight);
84

    
85
    bottom.addView(plaButton);
86
    bottom.addView(delButton);
87

    
88
    plaButton.setOnClickListener( new View.OnClickListener()
89
      {
90
      @Override
91
      public void onClick(View v)
92
        {
93
        playObject();
94
        }
95
      });
96

    
97
    delButton.setOnClickListener( new View.OnClickListener()
98
      {
99
      @Override
100
      public void onClick(View v)
101
        {
102
        deleteObject();
103
        }
104
      });
105
    }
106

    
107
///////////////////////////////////////////////////////////////////////////////////////////////////
108

    
109
  public LinearLayout getPane()
110
    {
111
    return mPane;
112
    }
113
}
(2-2/13)