diff options
Diffstat (limited to 'source/ui/GlanceView.mc')
| -rw-r--r-- | source/ui/GlanceView.mc | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/source/ui/GlanceView.mc b/source/ui/GlanceView.mc index 4540f2a..6be18f3 100644 --- a/source/ui/GlanceView.mc +++ b/source/ui/GlanceView.mc @@ -89,8 +89,15 @@ class OtpGlanceView extends WatchUi.GlanceView { var h = dc.getHeight(); var top = h / 2 - dc.getFontHeight(Graphics.FONT_GLANCE); var x = inset(dc, top); + // In capitals the name reaches the round screen's edge on the + // Forerunner 70 and 965, which cuts the last letter; the narrower + // mixed case fits there. + var title = "OTP WALLET"; + if (x + dc.getTextWidthInPixels(title, Graphics.FONT_GLANCE) > dc.getWidth() - edgeCut(top)) { + title = "OTP Wallet"; + } dc.setColor(Graphics.COLOR_WHITE, Graphics.COLOR_TRANSPARENT); - dc.drawText(x, top, Graphics.FONT_GLANCE, "OTP WALLET", Graphics.TEXT_JUSTIFY_LEFT); + dc.drawText(x, top, Graphics.FONT_GLANCE, title, Graphics.TEXT_JUSTIFY_LEFT); dc.setColor(Graphics.COLOR_LT_GRAY, Graphics.COLOR_TRANSPARENT); dc.drawText(x, h / 2, Graphics.FONT_GLANCE, count == 1 ? "1 entry" : count + " entries", Graphics.TEXT_JUSTIFY_LEFT); @@ -103,15 +110,23 @@ class OtpGlanceView extends WatchUi.GlanceView { // screen's top-left curve; on most round watches this is 0 or a few // pixels). private function inset(dc as Graphics.Dc, y as Number) as Number { + var left = (System.getDeviceSettings().screenWidth - dc.getWidth()) / 2; + var edge = edgeCut(y); + return edge > left ? edge - left : 0; + } + + // How far a round screen's edge reaches in from each side at height y + // (0 on other shapes), with the same assumption: the glance starts at + // the top of the screen. The right end of a glance reaches the screen's + // edge, so this is also what the curve cuts off there. + private function edgeCut(y as Number) as Number { var screen = System.getDeviceSettings(); if (screen.screenShape != System.SCREEN_SHAPE_ROUND) { return 0; } var r = screen.screenWidth / 2; var dy = r - y; - var edge = r - Math.sqrt(r * r - dy * dy).toNumber(); - var left = (screen.screenWidth - dc.getWidth()) / 2; - return edge > left ? edge - left : 0; + return r - Math.sqrt(r * r - dy * dy).toNumber(); } // The label, the code and a bar for the seconds left in the period. |
