Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
49432220
Commit
49432220
authored
Aug 17, 2018
by
Gus Grubba
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dealing with pixel density on Windows and iOS
parent
fd039529
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
17 deletions
+18
-17
ScreenTools.qml
src/QmlControls/ScreenTools.qml
+18
-17
No files found.
src/QmlControls/ScreenTools.qml
View file @
49432220
...
@@ -53,20 +53,24 @@ Item {
...
@@ -53,20 +53,24 @@ Item {
readonly
property
real
mediumFontPointRatio
:
1.25
readonly
property
real
mediumFontPointRatio
:
1.25
readonly
property
real
largeFontPointRatio
:
1.5
readonly
property
real
largeFontPointRatio
:
1.5
property
real
realPixelDensity
:
QGroundControl
.
corePlugin
.
options
.
devicePixelDensity
!=
0
?
QGroundControl
.
corePlugin
.
options
.
devicePixelDensity
:
Screen
.
pixelDensity
property
real
realPixelDensity
:
{
property
real
realPixelRatio
:
{
//-- If a plugin defines it, just use what it tells us
//-- If a plugin defines it, just use what it tells us
if
(
QGroundControl
.
corePlugin
.
options
.
devicePixelRatio
!=
0
)
if
(
QGroundControl
.
corePlugin
.
options
.
devicePixelDensity
!=
0
)
{
return
QGroundControl
.
corePlugin
.
options
.
devicePixelRatio
return
QGroundControl
.
corePlugin
.
options
.
devicePixelDensity
//-- Mobile is rather unreliable. They all return 1 for Screen.devicePixelRatio.
}
//-- Apple returns proper values
if
(
isiOS
||
isMac
)
{
return
Screen
.
pixelDensity
}
//-- Mobile is rather unreliable
if
(
isMobile
)
{
if
(
isMobile
)
{
// Lets assume it's unlikely you have a tablet over 300mm wide
// Lets assume it's unlikely you have a tablet over 300mm wide
if
((
Screen
.
width
/
Screen
.
pixelDensity
*
Screen
.
devicePixelRatio
)
>
300
)
if
((
Screen
.
width
/
Screen
.
pixelDensity
)
>
300
)
{
return
2
return
Screen
.
pixelDensity
*
2
}
}
}
//--
Use whatever the system tells u
s
//--
Still needs logical pixel density on Window
s
return
Screen
.
devicePixelRatio
return
Screen
.
pixelDensity
}
}
property
bool
isAndroid
:
ScreenToolsController
.
isAndroid
property
bool
isAndroid
:
ScreenToolsController
.
isAndroid
...
@@ -74,9 +78,10 @@ Item {
...
@@ -74,9 +78,10 @@ Item {
property
bool
isMobile
:
ScreenToolsController
.
isMobile
property
bool
isMobile
:
ScreenToolsController
.
isMobile
property
bool
isWindows
:
ScreenToolsController
.
isWindows
property
bool
isWindows
:
ScreenToolsController
.
isWindows
property
bool
isDebug
:
ScreenToolsController
.
isDebug
property
bool
isDebug
:
ScreenToolsController
.
isDebug
property
bool
isMac
:
ScreenToolsController
.
isMacOS
property
bool
isTinyScreen
:
(
Screen
.
width
/
realPixelDensity
)
<
120
// 120mm
property
bool
isTinyScreen
:
(
Screen
.
width
/
realPixelDensity
)
<
120
// 120mm
property
bool
isShortScreen
:
ScreenToolsController
.
isMobile
&&
((
Screen
.
height
/
Screen
.
width
)
<
0.6
)
// Nexus 7 for example
property
bool
isShortScreen
:
ScreenToolsController
.
isMobile
&&
((
Screen
.
height
/
Screen
.
width
)
<
0.6
)
// Nexus 7 for example
property
bool
isHugeScreen
:
Screen
.
width
>=
1920
*
2
property
bool
isHugeScreen
:
(
Screen
.
width
/
realPixelDensity
)
>=
(
23.5
*
25.4
)
// 27" monitor
readonly
property
real
minTouchMillimeters
:
10
///< Minimum touch size in millimeters
readonly
property
real
minTouchMillimeters
:
10
///< Minimum touch size in millimeters
property
real
minTouchPixels
:
0
///< Minimum touch size in pixels
property
real
minTouchPixels
:
0
///< Minimum touch size in pixels
...
@@ -111,10 +116,6 @@ Item {
...
@@ -111,10 +116,6 @@ Item {
_setBasePointSize
(
defaultFontPointSize
)
_setBasePointSize
(
defaultFontPointSize
)
}
}
onRealPixelRatioChanged
:
{
_setBasePointSize
(
defaultFontPointSize
)
}
function
printScreenStats
()
{
function
printScreenStats
()
{
console
.
log
(
'
ScreenTools: Screen.width:
'
+
Screen
.
width
+
'
Screen.height:
'
+
Screen
.
height
+
'
Screen.pixelDensity:
'
+
Screen
.
pixelDensity
)
console
.
log
(
'
ScreenTools: Screen.width:
'
+
Screen
.
width
+
'
Screen.height:
'
+
Screen
.
height
+
'
Screen.pixelDensity:
'
+
Screen
.
pixelDensity
)
}
}
...
@@ -138,7 +139,7 @@ Item {
...
@@ -138,7 +139,7 @@ Item {
smallFontPointSize
=
defaultFontPointSize
*
_screenTools
.
smallFontPointRatio
smallFontPointSize
=
defaultFontPointSize
*
_screenTools
.
smallFontPointRatio
mediumFontPointSize
=
defaultFontPointSize
*
_screenTools
.
mediumFontPointRatio
mediumFontPointSize
=
defaultFontPointSize
*
_screenTools
.
mediumFontPointRatio
largeFontPointSize
=
defaultFontPointSize
*
_screenTools
.
largeFontPointRatio
largeFontPointSize
=
defaultFontPointSize
*
_screenTools
.
largeFontPointRatio
minTouchPixels
=
Math
.
round
(
minTouchMillimeters
*
realPixelDensity
*
realPixelRatio
)
minTouchPixels
=
Math
.
round
(
minTouchMillimeters
*
realPixelDensity
)
if
(
minTouchPixels
/
Screen
.
height
>
0.15
)
{
if
(
minTouchPixels
/
Screen
.
height
>
0.15
)
{
// If using physical sizing takes up too much of the vertical real estate fall back to font based sizing
// If using physical sizing takes up too much of the vertical real estate fall back to font based sizing
minTouchPixels
=
defaultFontPixelHeight
*
3
minTouchPixels
=
defaultFontPixelHeight
*
3
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment