Reordered screen zoom settings, so the smallest display comes on top

This commit is contained in:
pelya
2011-11-24 17:22:34 +02:00
parent 15099fa668
commit c1e5111158
5 changed files with 58 additions and 39 deletions

View File

@@ -1185,34 +1185,61 @@ class Settings
} }
void run (final MainActivity p) void run (final MainActivity p)
{ {
CharSequence[] items = { p.getResources().getString(R.string.display_size_large), CharSequence[] items = {
p.getResources().getString(R.string.display_size_tiny_touchpad),
p.getResources().getString(R.string.display_size_tiny),
p.getResources().getString(R.string.display_size_small), p.getResources().getString(R.string.display_size_small),
p.getResources().getString(R.string.display_size_small_touchpad), p.getResources().getString(R.string.display_size_small_touchpad),
p.getResources().getString(R.string.display_size_tiny), p.getResources().getString(R.string.display_size_large),
p.getResources().getString(R.string.display_size_tiny_touchpad), }; };
int _size_tiny_touchpad = 0;
int _size_tiny = 1;
int _size_small = 2;
int _size_small_touchpad = 3;
int _size_large = 4;
int _more_options = 5;
if( ! Globals.SwVideoMode ) if( ! Globals.SwVideoMode )
{ {
CharSequence[] items2 = { p.getResources().getString(R.string.display_size_large), CharSequence[] items2 = {
p.getResources().getString(R.string.display_size_small_touchpad), }; p.getResources().getString(R.string.display_size_small_touchpad),
p.getResources().getString(R.string.display_size_large),
};
items = items2; items = items2;
_size_small_touchpad = 0;
_size_large = 1;
_size_tiny_touchpad = _size_tiny = _size_small = 1000;
} }
if( firstStart ) if( firstStart )
{ {
CharSequence[] items2 = { p.getResources().getString(R.string.display_size_large), CharSequence[] items2 = {
p.getResources().getString(R.string.display_size_tiny_touchpad),
p.getResources().getString(R.string.display_size_tiny),
p.getResources().getString(R.string.display_size_small), p.getResources().getString(R.string.display_size_small),
p.getResources().getString(R.string.display_size_small_touchpad), p.getResources().getString(R.string.display_size_small_touchpad),
p.getResources().getString(R.string.display_size_tiny), p.getResources().getString(R.string.display_size_large),
p.getResources().getString(R.string.display_size_tiny_touchpad), p.getResources().getString(R.string.show_more_options),
p.getResources().getString(R.string.show_more_options), }; };
items = items2; items = items2;
if( ! Globals.SwVideoMode ) if( ! Globals.SwVideoMode )
{ {
CharSequence[] items3 = { p.getResources().getString(R.string.display_size_large), CharSequence[] items3 = {
p.getResources().getString(R.string.display_size_small_touchpad), p.getResources().getString(R.string.display_size_small_touchpad),
p.getResources().getString(R.string.show_more_options), }; p.getResources().getString(R.string.display_size_large),
p.getResources().getString(R.string.show_more_options),
};
items = items3; items = items3;
_more_options = 3;
} }
} }
// Java is so damn worse than C++11
final int size_tiny_touchpad = _size_tiny_touchpad;
final int size_tiny = _size_tiny;
final int size_small = _size_small;
final int size_small_touchpad = _size_small_touchpad;
final int size_large = _size_large;
final int more_options = _more_options;
AlertDialog.Builder builder = new AlertDialog.Builder(p); AlertDialog.Builder builder = new AlertDialog.Builder(p);
builder.setTitle(R.string.display_size); builder.setTitle(R.string.display_size);
@@ -1221,47 +1248,37 @@ class Settings
public void onClick(DialogInterface dialog, int item) public void onClick(DialogInterface dialog, int item)
{ {
dialog.dismiss(); dialog.dismiss();
if( item == 0 ) if( item == size_large )
{ {
Globals.LeftClickMethod = Mouse.LEFT_CLICK_WITH_TAP_OR_TIMEOUT; Globals.LeftClickMethod = Mouse.LEFT_CLICK_WITH_TAP_OR_TIMEOUT;
Globals.RelativeMouseMovement = false; Globals.RelativeMouseMovement = false;
Globals.ShowScreenUnderFinger = Mouse.ZOOM_NONE; Globals.ShowScreenUnderFinger = Mouse.ZOOM_NONE;
} }
if( item == 1 ) if( item == size_small )
{ {
if( Globals.SwVideoMode ) Globals.LeftClickMethod = Mouse.LEFT_CLICK_NEAR_CURSOR;
{ Globals.RelativeMouseMovement = false;
Globals.LeftClickMethod = Mouse.LEFT_CLICK_NEAR_CURSOR; Globals.ShowScreenUnderFinger = Mouse.ZOOM_MAGNIFIER;
Globals.RelativeMouseMovement = false;
Globals.ShowScreenUnderFinger = Mouse.ZOOM_MAGNIFIER;
}
else
{
// OpenGL does not support magnifying glass
Globals.LeftClickMethod = Mouse.LEFT_CLICK_WITH_TAP_OR_TIMEOUT;
Globals.RelativeMouseMovement = true;
Globals.ShowScreenUnderFinger = Mouse.ZOOM_NONE;
}
} }
if( item == 2 && Globals.SwVideoMode ) if( item == size_small_touchpad )
{ {
Globals.LeftClickMethod = Mouse.LEFT_CLICK_WITH_TAP_OR_TIMEOUT; Globals.LeftClickMethod = Mouse.LEFT_CLICK_WITH_TAP_OR_TIMEOUT;
Globals.RelativeMouseMovement = true; Globals.RelativeMouseMovement = true;
Globals.ShowScreenUnderFinger = Mouse.ZOOM_NONE; Globals.ShowScreenUnderFinger = Mouse.ZOOM_NONE;
} }
if( item == 3 ) if( item == size_tiny )
{ {
Globals.LeftClickMethod = Mouse.LEFT_CLICK_NEAR_CURSOR; Globals.LeftClickMethod = Mouse.LEFT_CLICK_NEAR_CURSOR;
Globals.RelativeMouseMovement = false; Globals.RelativeMouseMovement = false;
Globals.ShowScreenUnderFinger = Mouse.ZOOM_WHOLE_SCREEN; Globals.ShowScreenUnderFinger = Mouse.ZOOM_SCREEN_TRANSFORM;
} }
if( item == 4 ) if( item == size_tiny_touchpad )
{ {
Globals.LeftClickMethod = Mouse.LEFT_CLICK_WITH_TAP_OR_TIMEOUT; Globals.LeftClickMethod = Mouse.LEFT_CLICK_WITH_TAP_OR_TIMEOUT;
Globals.RelativeMouseMovement = true; Globals.RelativeMouseMovement = true;
Globals.ShowScreenUnderFinger = Mouse.ZOOM_FULLSCREEN_MAGNIFIER; Globals.ShowScreenUnderFinger = Mouse.ZOOM_FULLSCREEN_MAGNIFIER;
} }
if( firstStart && ( item == 5 || ( ! Globals.SwVideoMode && item == 2 ) ) ) if( item == more_options )
{ {
menuStack.clear(); menuStack.clear();
new MainMenu().run(p); new MainMenu().run(p);
@@ -1270,8 +1287,8 @@ class Settings
goBack(p); goBack(p);
} }
} }
if( firstStart ) builder.setItems(items, new ClickListener());
builder.setItems(items, new ClickListener()); /*
else else
builder.setSingleChoiceItems(items, builder.setSingleChoiceItems(items,
Globals.ShowScreenUnderFinger == Mouse.ZOOM_NONE ? Globals.ShowScreenUnderFinger == Mouse.ZOOM_NONE ?
@@ -1279,6 +1296,7 @@ class Settings
( Globals.ShowScreenUnderFinger == Mouse.ZOOM_MAGNIFIER && Globals.SwVideoMode ) ? 1 : ( Globals.ShowScreenUnderFinger == Mouse.ZOOM_MAGNIFIER && Globals.SwVideoMode ) ? 1 :
Globals.ShowScreenUnderFinger + 1, Globals.ShowScreenUnderFinger + 1,
new ClickListener()); new ClickListener());
*/
builder.setOnCancelListener(new DialogInterface.OnCancelListener() builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{ {
public void onCancel(DialogInterface dialog) public void onCancel(DialogInterface dialog)

View File

@@ -81,7 +81,7 @@ class Mouse
public static final int ZOOM_NONE = 0; public static final int ZOOM_NONE = 0;
public static final int ZOOM_MAGNIFIER = 1; public static final int ZOOM_MAGNIFIER = 1;
public static final int ZOOM_WHOLE_SCREEN = 2; public static final int ZOOM_SCREEN_TRANSFORM = 2;
public static final int ZOOM_FULLSCREEN_MAGNIFIER = 3; public static final int ZOOM_FULLSCREEN_MAGNIFIER = 3;
} }
@@ -468,6 +468,7 @@ class DemoGLSurfaceView extends GLSurfaceView_SDL {
{ {
touchInput.process(event); touchInput.process(event);
// Wait a bit, and try to synchronize to app framerate, or event thread will eat all CPU and we'll lose FPS // Wait a bit, and try to synchronize to app framerate, or event thread will eat all CPU and we'll lose FPS
// With Froyo the rate of touch events is limited, but they are arriving faster then we're redrawing anyway
if(( event.getAction() == MotionEvent.ACTION_MOVE || if(( event.getAction() == MotionEvent.ACTION_MOVE ||
event.getAction() == MotionEvent.ACTION_HOVER_MOVE)) event.getAction() == MotionEvent.ACTION_HOVER_MOVE))
{ {
@@ -475,7 +476,7 @@ class DemoGLSurfaceView extends GLSurfaceView_SDL {
{ {
try try
{ {
mRenderer.wait(300L); mRenderer.wait(300L); // And sometimes the app decides not to render at all, so this timeout should not be big.
} catch (InterruptedException e) { } } catch (InterruptedException e) { }
} }
} }

View File

@@ -897,7 +897,7 @@ static void ANDROID_FlipHWSurfaceInternal(int numrects, SDL_Rect *rects)
glPopMatrix(); glPopMatrix();
//glFlush(); //glFlush();
} }
if( SDL_ANDROID_ShowScreenUnderFinger == ZOOM_WHOLE_SCREEN ) if( SDL_ANDROID_ShowScreenUnderFinger == ZOOM_SCREEN_TRANSFORM )
{ {
SDL_RenderCopy((struct SDL_Texture *)SDL_CurrentVideoSurface->hwdata, &SDL_ANDROID_ShowScreenUnderFingerRectSrc, &SDL_ANDROID_ShowScreenUnderFingerRect); SDL_RenderCopy((struct SDL_Texture *)SDL_CurrentVideoSurface->hwdata, &SDL_ANDROID_ShowScreenUnderFingerRectSrc, &SDL_ANDROID_ShowScreenUnderFingerRect);
SDL_Rect edge, edgeSrc; SDL_Rect edge, edgeSrc;

View File

@@ -195,7 +195,7 @@ void UpdateScreenUnderFingerRect(int x, int y)
if( InsideRect(&SDL_ANDROID_ShowScreenUnderFingerRect, x, y) ) if( InsideRect(&SDL_ANDROID_ShowScreenUnderFingerRect, x, y) )
SDL_ANDROID_ShowScreenUnderFingerRect.x = x - SDL_ANDROID_ShowScreenUnderFingerRect.w*11/10 - 1; SDL_ANDROID_ShowScreenUnderFingerRect.x = x - SDL_ANDROID_ShowScreenUnderFingerRect.w*11/10 - 1;
} }
if( SDL_ANDROID_ShowScreenUnderFinger == ZOOM_WHOLE_SCREEN ) if( SDL_ANDROID_ShowScreenUnderFinger == ZOOM_SCREEN_TRANSFORM )
{ {
SDL_ANDROID_ShowScreenUnderFingerRectSrc.w = screenX / 3; SDL_ANDROID_ShowScreenUnderFingerRectSrc.w = screenX / 3;
SDL_ANDROID_ShowScreenUnderFingerRectSrc.h = screenY / 3; SDL_ANDROID_ShowScreenUnderFingerRectSrc.h = screenY / 3;
@@ -648,7 +648,7 @@ JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeMouse) ( JNIEnv* env, jobject thiz, j
if( SDL_ANDROID_ShowScreenUnderFinger == ZOOM_MAGNIFIER ) if( SDL_ANDROID_ShowScreenUnderFinger == ZOOM_MAGNIFIER )
UpdateScreenUnderFingerRect(x, y); UpdateScreenUnderFingerRect(x, y);
} }
if( SDL_ANDROID_ShowScreenUnderFinger == ZOOM_WHOLE_SCREEN || if( SDL_ANDROID_ShowScreenUnderFinger == ZOOM_SCREEN_TRANSFORM ||
SDL_ANDROID_ShowScreenUnderFinger == ZOOM_FULLSCREEN_MAGNIFIER ) SDL_ANDROID_ShowScreenUnderFinger == ZOOM_FULLSCREEN_MAGNIFIER )
UpdateScreenUnderFingerRect(x, y); UpdateScreenUnderFingerRect(x, y);
} }

View File

@@ -28,7 +28,7 @@
#include "SDL_joystick.h" #include "SDL_joystick.h"
#include "SDL_events.h" #include "SDL_events.h"
enum ScreenZoom { ZOOM_NONE = 0, ZOOM_MAGNIFIER = 1, ZOOM_WHOLE_SCREEN = 2, ZOOM_FULLSCREEN_MAGNIFIER = 3 }; enum ScreenZoom { ZOOM_NONE = 0, ZOOM_MAGNIFIER = 1, ZOOM_SCREEN_TRANSFORM = 2, ZOOM_FULLSCREEN_MAGNIFIER = 3 };
extern int SDL_ANDROID_sWindowWidth; extern int SDL_ANDROID_sWindowWidth;
extern int SDL_ANDROID_sWindowHeight; extern int SDL_ANDROID_sWindowHeight;