ViewController: refactor 'setScreenSize' to 'setViewSize', 'setMapScreenCenter' to 'setMapViewCenter' (#523)
This commit is contained in:
parent
d036bb0bac
commit
d7aad27ed8
@ -149,7 +149,7 @@ public class MapView extends GLSurfaceView {
|
||||
|
||||
if (!isInEditMode()) {
|
||||
if (width > 0 && height > 0)
|
||||
mMap.viewport().setScreenSize(width, height);
|
||||
mMap.viewport().setViewSize(width, height);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ public abstract class GdxMap implements ApplicationListener {
|
||||
int w = Gdx.graphics.getWidth();
|
||||
int h = Gdx.graphics.getHeight();
|
||||
|
||||
mMap.viewport().setScreenSize(w, h);
|
||||
mMap.viewport().setViewSize(w, h);
|
||||
mMapRenderer.onSurfaceCreated();
|
||||
mMapRenderer.onSurfaceChanged(w, h);
|
||||
|
||||
@ -116,7 +116,7 @@ public abstract class GdxMap implements ApplicationListener {
|
||||
|
||||
@Override
|
||||
public void resize(int w, int h) {
|
||||
mMap.viewport().setScreenSize(w, h);
|
||||
mMap.viewport().setViewSize(w, h);
|
||||
mMapRenderer.onSurfaceChanged(w, h);
|
||||
mMap.render();
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ public class GdxSpriteBatchTest extends GdxMapApp {
|
||||
mMapRenderer = new MapRenderer(mMap);
|
||||
mMapRenderer.onSurfaceCreated();
|
||||
mMapRenderer.onSurfaceChanged(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||
mMap.viewport().setScreenSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||
mMap.viewport().setViewSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||
|
||||
// Generate a simple texture for testing
|
||||
Pixmap pixmap = new Pixmap(64, 64, Pixmap.Format.RGB565);
|
||||
@ -115,7 +115,7 @@ public class GdxSpriteBatchTest extends GdxMapApp {
|
||||
@Override
|
||||
public void resize(int w, int h) {
|
||||
mMapRenderer.onSurfaceChanged(w, h);
|
||||
mMap.viewport().setScreenSize(w, h);
|
||||
mMap.viewport().setViewSize(w, h);
|
||||
viewport.update(w, h);
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ public class MapApplicationAdapter extends ApplicationAdapter {
|
||||
Gdx.app.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
map.viewport().setScreenSize(MapApplicationAdapter.this.width, MapApplicationAdapter.this.height);
|
||||
map.viewport().setViewSize(MapApplicationAdapter.this.width, MapApplicationAdapter.this.height);
|
||||
mapRenderer.onSurfaceChanged(MapApplicationAdapter.this.width, MapApplicationAdapter.this.height);
|
||||
}
|
||||
});
|
||||
@ -129,7 +129,7 @@ public class MapApplicationAdapter extends ApplicationAdapter {
|
||||
int w = Gdx.graphics.getWidth();
|
||||
int h = Gdx.graphics.getHeight();
|
||||
|
||||
map.viewport().setScreenSize(w, h);
|
||||
map.viewport().setViewSize(w, h);
|
||||
mapRenderer.onSurfaceCreated();
|
||||
mapRenderer.onSurfaceChanged(w, h);
|
||||
|
||||
|
@ -33,7 +33,7 @@ public class ViewController extends Viewport {
|
||||
|
||||
private final float[] mat = new float[16];
|
||||
|
||||
public void setScreenSize(int width, int height) {
|
||||
public void setViewSize(int width, int height) {
|
||||
ThreadUtils.assertMainThread();
|
||||
|
||||
mHeight = height;
|
||||
@ -72,11 +72,11 @@ public class ViewController extends Viewport {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set pivot height relative to screen center. E.g. 0.5 is usually preferred
|
||||
* for navigation, moving the center to 25% of the screen height.
|
||||
* Set pivot height relative to view center. E.g. 0.5 is usually preferred
|
||||
* for navigation, moving the center to 25% of the view height.
|
||||
* Range is [-1, 1].
|
||||
*/
|
||||
public void setMapScreenCenter(float pivotY) {
|
||||
public void setMapViewCenter(float pivotY) {
|
||||
mPivotY = FastMath.clamp(pivotY, -1, 1) * 0.5f;
|
||||
}
|
||||
|
||||
@ -144,7 +144,7 @@ public class ViewController extends Viewport {
|
||||
|
||||
/**
|
||||
* Scale map by scale width center at pivot in pixel relative to
|
||||
* screen center. Map scale is clamp to MIN_SCALE and MAX_SCALE.
|
||||
* view center. Map scale is clamp to MIN_SCALE and MAX_SCALE.
|
||||
*
|
||||
* @return true if scale was changed
|
||||
*/
|
||||
@ -178,7 +178,7 @@ public class ViewController extends Viewport {
|
||||
|
||||
/**
|
||||
* Rotate map by radians around pivot. Pivot is in pixel relative
|
||||
* to screen center.
|
||||
* to view center.
|
||||
*/
|
||||
public void rotateMap(double radians, float pivotX, float pivotY) {
|
||||
ThreadUtils.assertMainThread();
|
||||
|
Loading…
x
Reference in New Issue
Block a user