{ "id": "91294", "key": "TIMOB-8978", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "13271", "description": "Release 2.1.0", "name": "Release 2.1.0", "archived": false, "released": true, "releaseDate": "2012-06-29" }, { "id": "13404", "description": "Sprint 2012-12 Core", "name": "Sprint 2012-12 Core", "archived": true, "released": true, "releaseDate": "2012-06-17" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2012-06-18T10:28:26.000+0000", "created": "2012-05-03T15:16:37.000+0000", "priority": { "name": "High", "id": "2" }, "labels": [ "core", "parity", "qe-port" ], "versions": [ { "id": "13272", "description": "Release 2.0.1", "name": "Release 2.0.1", "archived": true, "released": true, "releaseDate": "2012-04-16" } ], "issuelinks": [], "assignee": { "name": "ngupta", "key": "ngupta", "displayName": "Neeraj Gupta", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2012-08-09T15:13:18.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10224", "name": "TiAPI", "description": "This component is used for cross-platform API work. Specifications are most likely to use this component." } ], "description": "Currently, it appears that Ti.View.size and Ti.View.rect are reported in system default units, regardless of the setting of ti.ui.defaultunit. On Android, this means that these values are reported in pixels, even if you're specifying your entire UI in DIPs.\r\n\r\n(On iOS, they're reported in DIPs, which is usually what you want anyway; and in mobile web, px and DIP are the same thing.)\r\n\r\nIs there any reason that we couldn't report these values in defaultunit so that users can do simple math with them without having to convert them back into the unit of their choice?\r\n\r\n\r\n", "attachment": [], "flagged": false, "summary": "Ti API: View.size, View.rect should report values in defaultunit, not system unit", "creator": { "name": "aevans", "key": "aevans", "displayName": "Arthur Evans", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "aevans", "key": "aevans", "displayName": "Arthur Evans", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [ { "id": "197798", "author": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "body": "h4. Testing\r\n----\r\n\r\nTesting will need to be run on both iOS and Android, ideally with displays which have different densities (in order to ensure that the non-DIP values are treated correctly).\r\n\r\nCreate a new project, with the following app.js:\r\n\r\n{code:title=app.js}\r\nvar win = Ti.UI.createWindow();\r\n\r\nfunction onLayout(e) {\r\n\tvar view = e.source;\r\n\tvar rectObj = {\r\n\t\twidth:view.rect.width,\r\n\t\theight:view.rect.height\r\n\t};\r\n\tvar sizeObj = {\r\n\t\tx:view.size.x,\r\n\t\ty:view.size.y,\r\n\t\twidth:view.size.width,\r\n\t\theight:view.size.height\r\n\t};\r\n\tconsole.log(\"rect \",view.tag,\" in default: (\",view.rect.x,\",\",view.rect.y,\",\",view.rect.width,\",\",view.rect.height,\")\");\r\n\tconsole.log(\"size \",view.tag,\" in default: (\",view.size.x,\",\",view.size.y,\",\",view.size.width,\",\",view.size.height,\")\");\r\n}\r\n\r\nvar view = Ti.UI.createView({\r\n\twidth:\"100px\",\r\n\theight:\"100px\",\r\n\ttop:\"10px\",\r\n\ttag:1\r\n});\r\nwin.add(view);\r\nview.addEventListener('postlayout', onLayout);\r\n\r\nvar view2 = Ti.UI.createView({\r\n\twidth:\"1in\",\r\n\theight:\"1in\",\r\n\tbottom:\"10px\",\r\n\ttag:2\r\n});\r\nwin.add(view2);\r\nview2.addEventListener('postlayout', onLayout);\r\n\r\nvar view3 = Ti.UI.createView({\r\n\twidth:50,\r\n\theight:50,\r\n\tleft:10,\r\n\ttag:3\r\n});\r\nwin.add(view3);\r\nview3.addEventListener('postlayout', onLayout);\r\n\r\nwin.open();\r\n{code}\r\n\r\nReplace the {{ti.ui.defaultunit}} property in {{tiapp.xml}} with the following values:\r\n* unset (not present)\r\n** *iOS*: The units are displayed in DIP\r\n** *Android*: The units are displayed in px\r\n* {{px}}\r\n* {{in}}\r\n\r\nValues should be displayed for the appropriate unit type on various devices. Feel free to contact me for further information, but the most important thing to remember is that 1 dip = 2px on iOS, and 1 in = 160 dip.\r\n\r\n*NOTE:* Android has a bug where non-px values are always reported as rounded to the nearest integer. This needs to be fixed so that rect sizes can be reported accurately for in/cm/mm.", "updateAuthor": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-06-07T18:26:33.000+0000", "updated": "2012-06-07T18:46:29.000+0000" }, { "id": "213661", "author": { "name": "oromero", "key": "oromero", "displayName": "Olga Romero", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Verified fix with:\r\nTitanium Studio, build: 2.1.1.201207271312\r\nTitanium SDK: 2.1.1.v20120727140110", "updateAuthor": { "name": "oromero", "key": "oromero", "displayName": "Olga Romero", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-08-09T15:12:38.000+0000", "updated": "2012-08-09T15:12:38.000+0000" } ], "maxResults": 2, "total": 2, "startAt": 0 } } }