transparent shadow for non-transparent day skin, like we had it
This commit is contained in:
parent
5282d1bf67
commit
44069ab9d9
2 changed files with 78 additions and 77 deletions
|
@ -391,6 +391,9 @@ public class MapInfoLayer extends OsmandMapLayer {
|
||||||
int textColor = nightMode ? view.getResources().getColor(R.color.widgettext_night):Color.BLACK;
|
int textColor = nightMode ? view.getResources().getColor(R.color.widgettext_night):Color.BLACK;
|
||||||
// Night shadowColor always use widgettext_shadow_night, same as widget background color for non-transparent night skin (from box_night_free_simple.9.png)
|
// Night shadowColor always use widgettext_shadow_night, same as widget background color for non-transparent night skin (from box_night_free_simple.9.png)
|
||||||
int textShadowColor = nightMode? view.getResources().getColor(R.color.widgettext_shadow_night) : Color.WHITE;
|
int textShadowColor = nightMode? view.getResources().getColor(R.color.widgettext_shadow_night) : Color.WHITE;
|
||||||
|
if (transparent && !nighMode) then {
|
||||||
|
textShadowColor = Color.TRANSPARENT;
|
||||||
|
}
|
||||||
int boxTop;
|
int boxTop;
|
||||||
int boxTopStack;
|
int boxTopStack;
|
||||||
int boxTopR;
|
int boxTopR;
|
||||||
|
|
|
@ -21,87 +21,85 @@ public class RulerControl extends MapControls {
|
||||||
// Day view: color black, shadowColor white (transpparent skin or not)
|
// Day view: color black, shadowColor white (transpparent skin or not)
|
||||||
// Night view: color widgettext_night, shadowColor always use widgettext_shadow_night, same as widget background color for non-transparent night skin (from box_night_free_simple.9.png)
|
// Night view: color widgettext_night, shadowColor always use widgettext_shadow_night, same as widget background color for non-transparent night skin (from box_night_free_simple.9.png)
|
||||||
|
|
||||||
ShadowText cacheRulerText = null;
|
ShadowText cacheRulerText = null;
|
||||||
double cacheRulerZoom = 0;
|
double cacheRulerZoom = 0;
|
||||||
double cacheRulerTileX = 0;
|
double cacheRulerTileX = 0;
|
||||||
double cacheRulerTileY = 0;
|
double cacheRulerTileY = 0;
|
||||||
float cacheRulerTextLen = 0;
|
float cacheRulerTextLen = 0;
|
||||||
MapZoomControls zoomControls;
|
MapZoomControls zoomControls;
|
||||||
Drawable rulerDrawable;
|
Drawable rulerDrawable;
|
||||||
TextPaint rulerTextPaint;
|
TextPaint rulerTextPaint;
|
||||||
final static double screenRulerPercent = 0.25;
|
final static double screenRulerPercent = 0.25;
|
||||||
boolean isNightRemembered = false;
|
boolean isNightRemembered = false;
|
||||||
|
|
||||||
public RulerControl(MapZoomControls zoomControls, MapActivity mapActivity, Handler showUIHandler, float scaleCoefficient) {
|
public RulerControl(MapZoomControls zoomControls, MapActivity mapActivity, Handler showUIHandler, float scaleCoefficient) {
|
||||||
super(mapActivity, showUIHandler, scaleCoefficient);
|
super(mapActivity, showUIHandler, scaleCoefficient);
|
||||||
this.zoomControls = zoomControls;
|
this.zoomControls = zoomControls;
|
||||||
rulerTextPaint = new TextPaint();
|
rulerTextPaint = new TextPaint();
|
||||||
rulerTextPaint.setTextSize(20 * scaleCoefficient);
|
rulerTextPaint.setTextSize(20 * scaleCoefficient);
|
||||||
rulerTextPaint.setAntiAlias(true);
|
rulerTextPaint.setAntiAlias(true);
|
||||||
rulerDrawable = mapActivity.getResources().getDrawable(R.drawable.ruler);
|
rulerDrawable = mapActivity.getResources().getDrawable(R.drawable.ruler);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void hideControls(FrameLayout layout) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateTextColor(int textColor, int shadowColor) {
|
||||||
|
super.updateTextColor(textColor, shadowColor);
|
||||||
|
rulerTextPaint.setColor(textColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void showControls(FrameLayout layout) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDraw(Canvas canvas, RotatedTileBox tb, DrawSettings nightMode) {
|
||||||
|
if( (zoomControls.isVisible() && zoomControls.isShowZoomLevel()) || !mapActivity.getMyApplication().getSettings().SHOW_RULER.get()){
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
OsmandMapTileView view = mapActivity.getMapView();
|
||||||
@Override
|
boolean isNight = nightMode == null ? false : nightMode.isNightMode();
|
||||||
protected void hideControls(FrameLayout layout) {
|
// update cache
|
||||||
}
|
if (view.isZooming()) {
|
||||||
|
cacheRulerText = null;
|
||||||
@Override
|
} else if (((isNight != isNightRemembered) || (tb.getZoom() != cacheRulerZoom) ||
|
||||||
public void updateTextColor(int textColor, int shadowColor) {
|
Math.abs(tb.getCenterTileX() - cacheRulerTileX) + Math.abs(tb.getCenterTileY() - cacheRulerTileY) > 1) &&
|
||||||
super.updateTextColor(textColor, shadowColor);
|
tb.getPixWidth() > 0){
|
||||||
rulerTextPaint.setColor(textColor);
|
cacheRulerZoom = (tb.getZoom());
|
||||||
|
cacheRulerTileX = tb.getCenterTileX();
|
||||||
|
cacheRulerTileY = tb.getCenterTileY();
|
||||||
|
final double dist = tb.getDistance(0, tb.getPixHeight() / 2, tb.getPixWidth(), tb.getPixHeight() / 2);
|
||||||
|
double pixDensity = tb.getPixWidth() / dist;
|
||||||
|
double roundedDist = OsmAndFormatter.calculateRoundedDist(dist * screenRulerPercent, view.getApplication());
|
||||||
|
|
||||||
|
int cacheRulerDistPix = (int) (pixDensity * roundedDist);
|
||||||
|
cacheRulerText = ShadowText.create(OsmAndFormatter.getFormattedDistance((float) roundedDist, view.getApplication()));
|
||||||
|
cacheRulerTextLen = rulerTextPaint.measureText(cacheRulerText.getText());
|
||||||
|
rulerDrawable = (isNight ? mapActivity.getResources().getDrawable(R.drawable.ruler_night) : mapActivity.getResources().getDrawable(R.drawable.ruler));
|
||||||
|
Rect bounds = rulerDrawable.getBounds();
|
||||||
|
bounds.right = (int) (view.getWidth() - 7 * scaleCoefficient);
|
||||||
|
bounds.left = bounds.right - cacheRulerDistPix;
|
||||||
|
rulerDrawable.setBounds(bounds);
|
||||||
|
rulerDrawable.invalidateSelf();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
if (cacheRulerText != null) {
|
||||||
protected void showControls(FrameLayout layout) {
|
Rect bounds = rulerDrawable.getBounds();
|
||||||
}
|
int bottom = (int) (view.getHeight() - vmargin);
|
||||||
|
if(bounds.bottom != bottom) {
|
||||||
@Override
|
bounds.bottom = bottom;
|
||||||
public void onDraw(Canvas canvas, RotatedTileBox tb, DrawSettings nightMode) {
|
bounds.top = bounds.bottom - rulerDrawable.getMinimumHeight();
|
||||||
if( (zoomControls.isVisible() && zoomControls.isShowZoomLevel()) || !mapActivity.getMyApplication().getSettings().SHOW_RULER.get()){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
OsmandMapTileView view = mapActivity.getMapView();
|
|
||||||
boolean isNight = nightMode == null ? false : nightMode.isNightMode();
|
|
||||||
|
|
||||||
// update cache
|
|
||||||
if (view.isZooming()) {
|
|
||||||
cacheRulerText = null;
|
|
||||||
} else if(((isNight != isNightRemembered) || (tb.getZoom() != cacheRulerZoom) ||
|
|
||||||
Math.abs(tb.getCenterTileX() - cacheRulerTileX) + Math.abs(tb.getCenterTileY() - cacheRulerTileY) > 1) &&
|
|
||||||
tb.getPixWidth() > 0){
|
|
||||||
cacheRulerZoom = (tb.getZoom());
|
|
||||||
cacheRulerTileX = tb.getCenterTileX();
|
|
||||||
cacheRulerTileY = tb.getCenterTileY();
|
|
||||||
final double dist = tb.getDistance(0, tb.getPixHeight() / 2, tb.getPixWidth(), tb.getPixHeight() / 2);
|
|
||||||
double pixDensity = tb.getPixWidth() / dist;
|
|
||||||
double roundedDist = OsmAndFormatter.calculateRoundedDist(dist * screenRulerPercent, view.getApplication());
|
|
||||||
|
|
||||||
int cacheRulerDistPix = (int) (pixDensity * roundedDist);
|
|
||||||
cacheRulerText = ShadowText.create(OsmAndFormatter.getFormattedDistance((float) roundedDist, view.getApplication()));
|
|
||||||
cacheRulerTextLen = rulerTextPaint.measureText(cacheRulerText.getText());
|
|
||||||
rulerDrawable = (isNight ? mapActivity.getResources().getDrawable(R.drawable.ruler_night) : mapActivity.getResources().getDrawable(R.drawable.ruler));
|
|
||||||
Rect bounds = rulerDrawable.getBounds();
|
|
||||||
bounds.right = (int) (view.getWidth() - 7 * scaleCoefficient);
|
|
||||||
bounds.left = bounds.right - cacheRulerDistPix;
|
|
||||||
rulerDrawable.setBounds(bounds);
|
rulerDrawable.setBounds(bounds);
|
||||||
rulerDrawable.invalidateSelf();
|
rulerDrawable.invalidateSelf();
|
||||||
}
|
|
||||||
|
|
||||||
if (cacheRulerText != null) {
|
|
||||||
Rect bounds = rulerDrawable.getBounds();
|
|
||||||
int bottom = (int) (view.getHeight() - vmargin);
|
|
||||||
if(bounds.bottom != bottom) {
|
|
||||||
bounds.bottom = bottom;
|
|
||||||
bounds.top = bounds.bottom - rulerDrawable.getMinimumHeight();
|
|
||||||
rulerDrawable.setBounds(bounds);
|
|
||||||
rulerDrawable.invalidateSelf();
|
|
||||||
}
|
|
||||||
rulerDrawable.draw(canvas);
|
|
||||||
|
|
||||||
int shadowColor = isNight == true ? mapActivity.getResources().getColor(R.color.widgettext_shadow_night) : Color.WHITE;
|
|
||||||
cacheRulerText.draw(canvas, bounds.left + (bounds.width() - cacheRulerTextLen) / 2, bounds.bottom - 8 * scaleCoefficient,
|
|
||||||
rulerTextPaint, shadowColor);
|
|
||||||
}
|
}
|
||||||
isNightRemembered = isNight;
|
rulerDrawable.draw(canvas);
|
||||||
|
int shadowColor = isNight == true ? mapActivity.getResources().getColor(R.color.widgettext_shadow_night) : Color.WHITE;
|
||||||
|
cacheRulerText.draw(canvas, bounds.left + (bounds.width() - cacheRulerTextLen) / 2, bounds.bottom - 8 * scaleCoefficient,
|
||||||
|
rulerTextPaint, shadowColor);
|
||||||
}
|
}
|
||||||
}
|
isNightRemembered = isNight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue