Skip to content
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

Offset of marker behaves differently than offset of element in layer #2177

Closed
westnordost opened this issue Jul 9, 2020 · 1 comment · Fixed by #2186
Closed

Offset of marker behaves differently than offset of element in layer #2177

westnordost opened this issue Jul 9, 2020 · 1 comment · Fixed by #2186
Assignees

Comments

@westnordost
Copy link
Contributor

I have been reluctant to report this because there is already such a stack of open bugs here plus I couldn't pin-point the problem until today. However, the following screenshots might give (you) more insight.

Bug description

The offsets given in the draw block in YAML seem to not be adjusted (correctly) to screen DPI, unlike the sizes of the icons and other sizes.

The following screenshots are each made on Android each with screens set to different DPI.
Depending on the DPI of the device, the outcome is different. In Android, there is a developer setting ("smallest width") in which one can simulate different DPIs on the same device:


smallest width : large (320) - normal (360) - small (400) - smaller (??) - smallest (514)

Further information

There are three elements visible on the screen:

  • selected-quest-icons is the pin on which a house can be seen
  • quest-dots is the white dot that should be placed just so that it is obscured by the lower end of the pin
  • quest-selection is a marker consisting of a blue circle and should be placed so that it surrounds the icon part of the pin

This is the relevant stylesheet:

layers:
    streetcomplete_selected_quests:
        data: { source: streetcomplete_selected_quests }
        draw:
            selected-quest-icons:
                size: 66px
                sprite: function() { return feature.kind }
                sprite_default: quest
                collide: false
                offset: [-17px, -66px]
    streetcomplete_quests:
        dots_no_collide:
            filter: { $zoom: { min: 16 } }
            draw:
                quest-dots:
                    priority: 1
                    order: 1
                    size: 16px
                    collide: false
                    offset: [-2.5px, -22px]

and

val frame = ctx.resources.getBitmapDrawable(R.drawable.quest_selection_ring)
val w = frame.intrinsicWidth.toFloat().toDp(ctx)
val h = frame.intrinsicHeight.toFloat().toDp(ctx)

val marker = controller?.addMarker() ?: return null
marker.setStylingFromString("""{
    style: 'quest-selection',
    color: 'white',
    size: [${w}px, ${h}px],
    flat: false,
    collide: false,
    offset: ['1px', '-78px']
}""")

In case it matters, the styles for these elements are:

styles:
    quest-selection:
        base: points
        blend: overlay
        blend_order: 3
    selected-quest-icons:
        base: points
        texture: quests
        blend: overlay
        blend_order: 2
    quest-dots:
        base: points
        texture: quest_dot
        blend: overlay
        blend_order: 1

The bug was initially reported at streetcomplete/StreetComplete#1810

@matteblair
Copy link
Member

Thanks for the report, these details are super helpful! The error here looks proportional to DPI so it's possible we've just forgotten to multiply by display density somewhere - I'll check it out.

It's true that there's a backlog of bugs, but some are much easier to address than others so there's still good reasons to file issues :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants