Skip to content

Commit

Permalink
Reordered screen zoom settings, so the smallest display comes on top
Browse files Browse the repository at this point in the history
  • Loading branch information
pelya committed Nov 24, 2011
1 parent 15099fa commit c1e5111
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 39 deletions.
84 changes: 51 additions & 33 deletions project/java/Settings.java
Expand Up @@ -1185,34 +1185,61 @@ String title(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_touchpad),
p.getResources().getString(R.string.display_size_tiny),
p.getResources().getString(R.string.display_size_tiny_touchpad), };
p.getResources().getString(R.string.display_size_large),
};
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 )
{
CharSequence[] items2 = { p.getResources().getString(R.string.display_size_large),
p.getResources().getString(R.string.display_size_small_touchpad), };
CharSequence[] items2 = {
p.getResources().getString(R.string.display_size_small_touchpad),
p.getResources().getString(R.string.display_size_large),
};
items = items2;
_size_small_touchpad = 0;
_size_large = 1;
_size_tiny_touchpad = _size_tiny = _size_small = 1000;

}
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_touchpad),
p.getResources().getString(R.string.display_size_tiny),
p.getResources().getString(R.string.display_size_tiny_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 = items2;
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.show_more_options), };
p.getResources().getString(R.string.display_size_large),
p.getResources().getString(R.string.show_more_options),
};
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);
builder.setTitle(R.string.display_size);
Expand All @@ -1221,47 +1248,37 @@ class ClickListener implements DialogInterface.OnClickListener
public void onClick(DialogInterface dialog, int item)
{
dialog.dismiss();
if( item == 0 )
if( item == size_large )
{
Globals.LeftClickMethod = Mouse.LEFT_CLICK_WITH_TAP_OR_TIMEOUT;
Globals.RelativeMouseMovement = false;
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.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;
}
Globals.LeftClickMethod = Mouse.LEFT_CLICK_NEAR_CURSOR;
Globals.RelativeMouseMovement = false;
Globals.ShowScreenUnderFinger = Mouse.ZOOM_MAGNIFIER;
}
if( item == 2 && Globals.SwVideoMode )
if( item == size_small_touchpad )
{
Globals.LeftClickMethod = Mouse.LEFT_CLICK_WITH_TAP_OR_TIMEOUT;
Globals.RelativeMouseMovement = true;
Globals.ShowScreenUnderFinger = Mouse.ZOOM_NONE;
}
if( item == 3 )
if( item == size_tiny )
{
Globals.LeftClickMethod = Mouse.LEFT_CLICK_NEAR_CURSOR;
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.RelativeMouseMovement = true;
Globals.ShowScreenUnderFinger = Mouse.ZOOM_FULLSCREEN_MAGNIFIER;
}
if( firstStart && ( item == 5 || ( ! Globals.SwVideoMode && item == 2 ) ) )
if( item == more_options )
{
menuStack.clear();
new MainMenu().run(p);
Expand All @@ -1270,15 +1287,16 @@ public void onClick(DialogInterface dialog, int item)
goBack(p);
}
}
if( firstStart )
builder.setItems(items, new ClickListener());
builder.setItems(items, new ClickListener());
/*
else
builder.setSingleChoiceItems(items,
Globals.ShowScreenUnderFinger == Mouse.ZOOM_NONE ?
( Globals.RelativeMouseMovement ? Globals.SwVideoMode ? 2 : 1 : 0 ) :
( Globals.ShowScreenUnderFinger == Mouse.ZOOM_MAGNIFIER && Globals.SwVideoMode ) ? 1 :
Globals.ShowScreenUnderFinger + 1,
new ClickListener());
*/
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
Expand Down
5 changes: 3 additions & 2 deletions project/java/Video.java
Expand Up @@ -81,7 +81,7 @@ class Mouse

public static final int ZOOM_NONE = 0;
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;
}

Expand Down Expand Up @@ -468,14 +468,15 @@ public boolean onTouchEvent(final MotionEvent 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
// 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 ||
event.getAction() == MotionEvent.ACTION_HOVER_MOVE))
{
synchronized(mRenderer)
{
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) { }
}
}
Expand Down
Expand Up @@ -897,7 +897,7 @@ static void ANDROID_FlipHWSurfaceInternal(int numrects, SDL_Rect *rects)
glPopMatrix();
//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_Rect edge, edgeSrc;
Expand Down
4 changes: 2 additions & 2 deletions project/jni/sdl-1.3/src/video/android/SDL_androidinput.c
Expand Up @@ -195,7 +195,7 @@ void UpdateScreenUnderFingerRect(int x, int y)
if( InsideRect(&SDL_ANDROID_ShowScreenUnderFingerRect, x, y) )
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.h = screenY / 3;
Expand Down Expand Up @@ -648,7 +648,7 @@ JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeMouse) ( JNIEnv* env, jobject thiz, j
if( SDL_ANDROID_ShowScreenUnderFinger == ZOOM_MAGNIFIER )
UpdateScreenUnderFingerRect(x, y);
}
if( SDL_ANDROID_ShowScreenUnderFinger == ZOOM_WHOLE_SCREEN ||
if( SDL_ANDROID_ShowScreenUnderFinger == ZOOM_SCREEN_TRANSFORM ||
SDL_ANDROID_ShowScreenUnderFinger == ZOOM_FULLSCREEN_MAGNIFIER )
UpdateScreenUnderFingerRect(x, y);
}
Expand Down
2 changes: 1 addition & 1 deletion project/jni/sdl-1.3/src/video/android/SDL_androidvideo.h
Expand Up @@ -28,7 +28,7 @@
#include "SDL_joystick.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_sWindowHeight;
Expand Down

0 comments on commit c1e5111

Please sign in to comment.