Project

General

Profile

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

magiccube / src / main / java / org / distorted / config / ConfigScreenPane.java @ 14da3188

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.0f, 0.5f, 1.0f, 1.5f, 2.0f };
27
  public static final float[] CORNER_STEPS = { 0.0f, 0.5f, 1.0f, 1.5f, 2.0f };
28

    
29
  private static final float PADDING_RATIO = 0.016f;
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
    LinearLayout configLayout = act.findViewById(R.id.configLayout);
59
    configLayout.setPadding(padding,padding,padding,padding);
60

    
61
    LinearLayout.LayoutParams paramsLayout = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0, 1.00f);
62
    paramsLayout.bottomMargin = padding;
63
    paramsLayout.topMargin    = 0;
64
    paramsLayout.leftMargin   = padding;
65
    paramsLayout.rightMargin  = padding;
66

    
67
    configLayout.setLayoutParams(paramsLayout);
68

    
69
    TextView textStickers = configLayout.findViewById(R.id.configTextStickers);
70
    textStickers.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
71
    TextView textBorder   = configLayout.findViewById(R.id.configTextBorder);
72
    textBorder.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
73
    TextView textCorner   = configLayout.findViewById(R.id.configTextCorner);
74
    textCorner.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
75

    
76
    mSeekBarBorders = configLayout.findViewById(R.id.configSeekBarBorder);
77
    mCurrentBorders = mSeekBarBorders.getProgress();
78

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

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

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

    
97
    mSeekBarCorners = configLayout.findViewById(R.id.configSeekBarCorner);
98
    mCurrentCorners = mSeekBarCorners.getProgress();
99

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

    
108
      @Override
109
      public void onStartTrackingTouch(SeekBar seekBar) {}
110
      @Override
111
      public void onStopTrackingTouch(SeekBar seekBar)
112
        {
113
        act.recreateStickers(mCurrentBorders,mCurrentCorners);
114
        }
115
      });
116
    }
117
}
(5-5/6)