Project

General

Profile

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

magiccube / src / main / java / org / distorted / config / ConfigScreenPane.java @ 94ff5962

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2024 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.util.TypedValue;
13
import android.widget.LinearLayout;
14
import android.widget.SeekBar;
15
import android.widget.TextView;
16

    
17
import org.distorted.main.R;
18

    
19
///////////////////////////////////////////////////////////////////////////////////////////////////
20

    
21
public class ConfigScreenPane
22
{
23
  public static final int DEFAULT_BORDERS = 2;
24
  public static final int DEFAULT_CORNERS = 2;
25

    
26
  public static final float[] BORDER_STEPS = { 0.50f, 0.75f, 1.00f, 1.50f, 2.00f };
27
  public static final float[] CORNER_STEPS = { 0.00f, 0.50f, 1.00f, 1.50f, 2.00f };
28

    
29
  private static final float PADDING_RATIO = 0.010f;
30
  private static final float TEXT_RATIO    = 0.025f;
31

    
32
  private final SeekBar mSeekBarBorders, mSeekBarCorners;
33
  private int mCurrentBorders, mCurrentCorners;
34

    
35
///////////////////////////////////////////////////////////////////////////////////////////////////
36

    
37
  void updatePane(ConfigActivity act, int objectOrdinal)
38
    {
39

    
40
    }
41

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

    
44
  void resetUI()
45
    {
46
    mSeekBarBorders.setProgress(DEFAULT_BORDERS);
47
    mSeekBarCorners.setProgress(DEFAULT_CORNERS);
48
    }
49

    
50
///////////////////////////////////////////////////////////////////////////////////////////////////
51

    
52
  ConfigScreenPane(final ConfigActivity act, int objectOrdinal)
53
    {
54
    int height = act.getScreenHeightInPixels();
55
    float textSize = height*TEXT_RATIO;
56
    int padding = (int)(height*PADDING_RATIO);
57

    
58
    ///// UPPER LAYOUT /////////////////////////////////
59
    LinearLayout configLayoutU = act.findViewById(R.id.configLayoutUpper);
60
    configLayoutU.setPadding(padding,padding,padding,padding);
61

    
62
    LinearLayout.LayoutParams paramsLayoutU = (LinearLayout.LayoutParams)configLayoutU.getLayoutParams();
63
    paramsLayoutU.bottomMargin = padding;
64
    paramsLayoutU.topMargin    = 0;
65
    paramsLayoutU.leftMargin   = padding;
66
    paramsLayoutU.rightMargin  = padding;
67

    
68
    configLayoutU.setLayoutParams(paramsLayoutU);
69

    
70
    TextView textBorder   = configLayoutU.findViewById(R.id.configTextBorder);
71
    textBorder.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
72
    TextView textCorner   = configLayoutU.findViewById(R.id.configTextCorner);
73
    textCorner.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
74

    
75
    mSeekBarBorders = configLayoutU.findViewById(R.id.configSeekBarBorder);
76
    mCurrentBorders = mSeekBarBorders.getProgress();
77

    
78
    mSeekBarBorders.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener()
79
      {
80
      @Override
81
      public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser)
82
        {
83
        mCurrentBorders = progress;
84
        }
85

    
86
      @Override
87
      public void onStartTrackingTouch(SeekBar seekBar) {}
88

    
89
      @Override
90
      public void onStopTrackingTouch(SeekBar seekBar)
91
        {
92
        act.recreateStickers(mCurrentBorders,mCurrentCorners);
93
        }
94
      });
95

    
96
    mSeekBarCorners = configLayoutU.findViewById(R.id.configSeekBarCorner);
97
    mCurrentCorners = mSeekBarCorners.getProgress();
98

    
99
    mSeekBarCorners.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener()
100
      {
101
      @Override
102
      public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser)
103
        {
104
        mCurrentCorners = progress;
105
        }
106

    
107
      @Override
108
      public void onStartTrackingTouch(SeekBar seekBar) {}
109
      @Override
110
      public void onStopTrackingTouch(SeekBar seekBar)
111
        {
112
        act.recreateStickers(mCurrentBorders,mCurrentCorners);
113
        }
114
      });
115

    
116
    ///// LOWER LAYOUT /////////////////////////////////
117
    LinearLayout configLayoutL = act.findViewById(R.id.configLayoutLower);
118
    configLayoutL.setPadding(padding,padding,padding,padding);
119

    
120
    LinearLayout.LayoutParams paramsLayoutL = (LinearLayout.LayoutParams)configLayoutL.getLayoutParams();
121
    paramsLayoutL.bottomMargin = padding;
122
    paramsLayoutL.topMargin    = 0;
123
    paramsLayoutL.leftMargin   = padding;
124
    paramsLayoutL.rightMargin  = padding;
125

    
126
    configLayoutL.setLayoutParams(paramsLayoutL);
127
    }
128
}
(5-5/6)