Revision 27401bea
Added by Leszek Koltunski almost 2 years ago
src/main/java/org/distorted/config/ConfigRenderer.java | ||
---|---|---|
22 | 22 |
import javax.microedition.khronos.egl.EGLConfig; |
23 | 23 |
import javax.microedition.khronos.opengles.GL10; |
24 | 24 |
|
25 |
import static org.distorted.config.ConfigScreenPane.PADDING_RATIO; |
|
26 |
|
|
27 | 25 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
28 | 26 |
|
29 | 27 |
public class ConfigRenderer implements GLSurfaceView.Renderer, DistortedLibrary.ExceptionListener |
src/main/java/org/distorted/config/ConfigScreen.java | ||
---|---|---|
35 | 35 |
|
36 | 36 |
public class ConfigScreen |
37 | 37 |
{ |
38 |
private static final float TEXT_SIZE = 0.0310f; |
|
39 |
private static final float PADDING = 0.0060f; |
|
40 |
private static final float MARGIN = 0.0024f; |
|
38 | 41 |
private static final int NUM_COLUMNS = 5; |
39 | 42 |
private static final int[] mLocation = new int[2]; |
40 | 43 |
|
... | ... | |
56 | 59 |
mRowCount = (numObjects + NUM_COLUMNS-1) / NUM_COLUMNS; |
57 | 60 |
mColCount = NUM_COLUMNS; |
58 | 61 |
|
59 |
int cubeSize = (int)(width/9);
|
|
60 |
int margin = (int)(width*RubikActivity.LARGE_MARGIN);
|
|
61 |
int padding = (int)(width*RubikActivity.POPUP_PADDING);
|
|
62 |
int cubeSize = (int)( (Math.min(width,(int)(height*0.7f))) / 9 );
|
|
63 |
int margin = (int)(height*RubikActivity.POPUP_MARGIN);
|
|
64 |
int padding = (int)(height*RubikActivity.POPUP_PADDING);
|
|
62 | 65 |
mObjectSize = (int)(cubeSize + 2*margin + 0.5f); |
63 | 66 |
mMaxRowCount = (int)((height-mBarHeight)/mObjectSize); |
64 | 67 |
|
... | ... | |
119 | 122 |
|
120 | 123 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
121 | 124 |
|
122 |
private void setupObjectButton(final ConfigActivity act, final int width) |
|
125 |
private void setupObjectButton(final ConfigActivity act, final int width, final int height)
|
|
123 | 126 |
{ |
124 |
final int margin= (int)(width*RubikActivity.SMALL_MARGIN);
|
|
127 |
final int margin= (int)(height*MARGIN);
|
|
125 | 128 |
final int icon = RubikActivity.getDrawable(R.drawable.ui_small_cube_menu,R.drawable.ui_medium_cube_menu, R.drawable.ui_big_cube_menu, R.drawable.ui_huge_cube_menu); |
126 | 129 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT); |
127 | 130 |
mObjectButton = new TransparentImageButton(act, icon, TransparentImageButton.GRAVITY_MIDDLE, params); |
... | ... | |
133 | 136 |
{ |
134 | 137 |
if( mObjectPopup==null ) |
135 | 138 |
{ |
136 |
float height= act.getScreenHeightInPixels(); |
|
137 | 139 |
setupObjectWindow(act,width,height); |
138 | 140 |
} |
139 | 141 |
|
... | ... | |
257 | 259 |
|
258 | 260 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
259 | 261 |
|
260 |
private void setupTextView(final ConfigActivity act, final float width, int numObjects)
|
|
262 |
private void setupTextView(final ConfigActivity act, final float height, int numObjects)
|
|
261 | 263 |
{ |
262 |
int padding = (int)(width*RubikActivity.PADDING);
|
|
263 |
int margin = (int)(width*RubikActivity.SMALL_MARGIN);
|
|
264 |
int padding = (int)(height*PADDING);
|
|
265 |
int margin = (int)(height*MARGIN);
|
|
264 | 266 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0,LinearLayout.LayoutParams.MATCH_PARENT,2.0f); |
265 | 267 |
params.topMargin = margin; |
266 | 268 |
params.bottomMargin = margin; |
... | ... | |
282 | 284 |
{ |
283 | 285 |
int numObjects = RubikObjectList.getNumObjects(); |
284 | 286 |
int width = act.getScreenWidthInPixels(); |
287 |
int height= act.getScreenHeightInPixels(); |
|
285 | 288 |
mBarHeight = act.getHeightBar(); |
286 |
mButtonSize = width*RubikActivity.BUTTON_TEXT_SIZE;
|
|
289 |
mButtonSize = height*TEXT_SIZE;
|
|
287 | 290 |
mObjectOrdinal = objectOrdinal; |
288 | 291 |
|
289 | 292 |
LinearLayout.LayoutParams paramsL = new LinearLayout.LayoutParams(width/4, LinearLayout.LayoutParams.MATCH_PARENT); |
... | ... | |
297 | 300 |
LinearLayout layoutRight= new LinearLayout(act); |
298 | 301 |
layoutRight.setLayoutParams(paramsR); |
299 | 302 |
|
300 |
setupObjectButton(act,width); |
|
303 |
setupObjectButton(act,width,height);
|
|
301 | 304 |
setupPrevButton(act); |
302 | 305 |
setupNextButton(act); |
303 |
setupTextView(act,width,numObjects);
|
|
306 |
setupTextView(act,height,numObjects);
|
|
304 | 307 |
setupBackButton(act); |
305 | 308 |
|
306 | 309 |
layoutLeft.addView(mObjectButton); |
src/main/java/org/distorted/config/ConfigScreenPane.java | ||
---|---|---|
50 | 50 |
}; |
51 | 51 |
|
52 | 52 |
private static final int NUM_IDS = IDS.length; |
53 |
public static final float PADDING_RATIO = 0.025f;
|
|
54 |
private static final float TEXT_RATIO = 0.042f;
|
|
53 |
private static final float PADDING_RATIO = 0.016f;
|
|
54 |
private static final float TEXT_RATIO = 0.027f;
|
|
55 | 55 |
private static final float RADIO_RATIO = 0.900f; |
56 | 56 |
|
57 | 57 |
private int mObjectOrdinal; |
... | ... | |
129 | 129 |
|
130 | 130 |
ConfigScreenPane(final ConfigActivity act, int objectOrdinal) |
131 | 131 |
{ |
132 |
int width = act.getScreenWidthInPixels();
|
|
133 |
float textSize = width*TEXT_RATIO;
|
|
134 |
int padding = (int)(width*PADDING_RATIO);
|
|
132 |
int height = act.getScreenHeightInPixels();
|
|
133 |
float textSize = height*TEXT_RATIO;
|
|
134 |
int padding = (int)(height*PADDING_RATIO);
|
|
135 | 135 |
|
136 | 136 |
LinearLayout configLayout = act.findViewById(R.id.configLayout); |
137 | 137 |
LinearLayout nameLayout = configLayout.findViewById(R.id.configLayoutName); |
src/main/java/org/distorted/main/RubikActivity.java | ||
---|---|---|
70 | 70 |
public static final float SMALL_MARGIN = 0.004f; |
71 | 71 |
public static final float MEDIUM_MARGIN = 0.015f; |
72 | 72 |
public static final float LARGE_MARGIN = 0.025f; |
73 |
public static final float POPUP_PADDING = 0.045f; |
|
74 | 73 |
public static final float BUTTON_TEXT_SIZE = 0.05f; |
75 | 74 |
public static final float TITLE_TEXT_SIZE = 0.06f; |
76 | 75 |
public static final float SOLVER_BMP_H_SIZE = 0.11f; |
... | ... | |
85 | 84 |
public static final float SMALL_TEXT_SIZE = 0.035f; |
86 | 85 |
public static final float TAB_WIDTH = 0.100f; |
87 | 86 |
public static final float TAB_HEIGHT = 0.100f; |
87 |
public static final float POPUP_PADDING = 0.028f; |
|
88 |
public static final float POPUP_MARGIN = 0.016f; |
|
88 | 89 |
|
89 | 90 |
public static final int FLAGS = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
90 | 91 |
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
src/main/java/org/distorted/screens/RubikScreenPlay.java | ||
---|---|---|
189 | 189 |
mRowCount = (numObjects + NUM_COLUMNS-1) / NUM_COLUMNS; |
190 | 190 |
mColCount = NUM_COLUMNS; |
191 | 191 |
|
192 |
int cubeSize = (int)(width/9);
|
|
193 |
int margin = (int)(width*RubikActivity.LARGE_MARGIN);
|
|
194 |
int padding = (int)(width*RubikActivity.POPUP_PADDING);
|
|
192 |
int cubeSize = (int)( (Math.min(width,(int)(height*0.7f))) / 9 );
|
|
193 |
int margin = (int)(height*RubikActivity.POPUP_MARGIN);
|
|
194 |
int padding = (int)(height*RubikActivity.POPUP_PADDING);
|
|
195 | 195 |
mObjectSize = (int)(cubeSize + 2*margin + 0.5f); |
196 | 196 |
mMaxRowCount = (int)((height-1.8f*mUpperBarHeight)/mObjectSize); |
197 | 197 |
|
Also available in: Unified diff
More fixes for UI in case of extreme screen (w/h) ratios ( from 1.0 to 2.0 ).