mirror of
https://github.com/house-of-abbey/GarminHomeAssistant.git
synced 2025-07-11 23:38:38 +00:00
Added correctly formatted code comments
The newer SDK support tooltips to show the function prototype and help text, so best to make good use of it.
This commit is contained in:
@ -11,35 +11,36 @@
|
||||
//
|
||||
// J D Abbey & P A Abbey, 28 December 2022
|
||||
//
|
||||
//
|
||||
// Description:
|
||||
//
|
||||
// A view with added methods to scale from percentages of scrren size to pixels.
|
||||
//
|
||||
//-----------------------------------------------------------------------------------
|
||||
|
||||
using Toybox.Lang;
|
||||
using Toybox.WatchUi;
|
||||
using Toybox.Math;
|
||||
|
||||
//! A view that provides a common method 'pixelsForScreen' to make Views easier to layout on different
|
||||
//! sized watch screens.
|
||||
//
|
||||
class ScalableView extends WatchUi.View {
|
||||
//! Retain the local screen width for efficiency
|
||||
private var mScreenWidth;
|
||||
|
||||
//! Class Constructor
|
||||
//
|
||||
function initialize() {
|
||||
View.initialize();
|
||||
mScreenWidth = System.getDeviceSettings().screenWidth;
|
||||
}
|
||||
|
||||
// Convert a fraction expressed as a percentage (%) to a number of pixels for the
|
||||
// screen's dimensions.
|
||||
//
|
||||
// Parameters:
|
||||
// * dc - Device context
|
||||
// * pc - Percentage (%) expressed as a number in the range 0.0..100.0
|
||||
//
|
||||
// Uses screen width rather than screen height as rectangular screens tend to have
|
||||
// height > width.
|
||||
//
|
||||
//! Convert a fraction expressed as a percentage (%) to a number of pixels for the
|
||||
//! screen's dimensions.
|
||||
//!
|
||||
//! Uses screen width rather than screen height as rectangular screens tend to have
|
||||
//! height > width.
|
||||
//!
|
||||
//! @param pc Percentage (%) expressed as a number in the range 0.0..100.0
|
||||
//!
|
||||
//! @return Number of pixels for the screen's dimensions for a fraction expressed as a percentage (%).
|
||||
//!
|
||||
function pixelsForScreen(pc as Lang.Float) as Lang.Number {
|
||||
return Math.round(pc * mScreenWidth) / 100;
|
||||
}
|
||||
|
Reference in New Issue
Block a user