-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dims
statement considered harmful / asteroid apps break when windows resized
#44
Comments
I think this makes sense. As an experiment, I patched |
@beroset that's exactly the kind of changes I was looking at. Thank you! |
I too think that this make sense. Especially since we already are required to avoid It also seems that |
As a more complex exercise, I also converted |
The only hope i had with dims was that they would make it easier to adapt layouts to rectangular/irregular shaped screens using the Dims.l(XX). Since we have not yet adapted all of the OS for rectangular screens, could we define a method for that so i can implement it consistently? |
Right now
One obvious way to reimplement would be to simply require passing the height and width:
But then it's such a trivial function, it's not clear that it adds much. |
@eLtMosen Even simpler, I believe I've recommended this before: |
Preamble
QML element sizing is generally expected to either be explicitly set, or hierarchical. This means that QML item size is generally set in one of four ways:
anchors.fill: parent
,anchors.top: sibling.top
width: parent.width
,height: sibling.width*0.3
x: 3
,height: 20
anchors.margins: theme.itemSpacingNarrow
,height: iconSizeSmall
Dims
doesn't align with any of the above.The issue
Many asteroid apps use
Dims
as a means to ignore the QML hierarchy and directly get fractions of the size of the current window or the display. The window and display size are currently interchangeable because asteroid apps are always fullscreen, which allows this behaviour.Dims
breaks in this usecase as soon as the window is resized, as on desktop platforms.Solutions
The fantasy solution would be to have
Dims
give fractions of the current window, rather than the entire display size. This would easily fix all the current code.Unfortunately, QML doesn't want to work this way. The
Dims
singleton would have to somehow be mapped to the root window of the application, and any implementation of this would also affect howDims
is used in code.The distinction between
h
andw
is also not clear. Generally apps are designed correctly, but it is possible to have applications behave in very strange ways in unconventional display geometries whenh
orw
are incorrectly picked instead ofl
The actual solution involves stopping the use of
Dims
to ignore the QML hierarchy. In most places, this will just mean replacing, for example,Dims.h(10)
withwindowID.height*0.1
(windowID
being theid:
which was assigned to theApplication
at the root of the app).Flat tyres
Another current justification for
Dims
is that they provide a way to deal with flat tyres. I don't believe this should be used anywhere other thanasteroid-launcher
- and even there, it could be trivially replaced withScreen.desktopAvailableHeight+DeviceInfo.flatTireHeight
.I propose that a fractional value greater than one such as
flatTireHeightFractional
should be exposed throughdeviceInfo
- this should make it far easier to deal with the flat tyre, without having to go throughDims
or deal with the absolute display dimensions. This would be calculated as(Screen.desktopAvailableHeight+DeviceInfo.flatTireHeight)/Screen.desktopAvailableHeight
, and would return a value such as1.066667
on ayu.Dims.h(100)
would be replaced withwindowID.height*DeviceInfo.flatTireHeightFractional
. This should eliminate the flat tyre usecase forDims
as well.Perhaps some implementation details may differ for this, but the point is that
Dims
should not be used here either.Does
Dims
still have uses?The spirit of Dims does still have some value, as it provides an easy and consistent source of font and other element sizes. Asteroid is not currently DPI-aware, which makes the UI look very consistent across watches, but makes it weirdly massive on devices such as
minnow
and difficult to read on smaller devices such assawfish
. It may be desirable to add some interface for getting DPI-aware element sizes.In its current form,
Dims
probably should not have a future. On desktop, it will always continue to break things; the lack of DPI awareness and assumption of fullscreen will always cause elements to be inappropriately oversized.Dims will likely continue to be used internally in qml-asteroid to set the default element sizes. Provided that Dims is made DPI-aware, this should be fine on desktop as well.
The text was updated successfully, but these errors were encountered: