-
Notifications
You must be signed in to change notification settings - Fork 131
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
Fix scale bar text being cut #1716
Conversation
015e5c4
to
9a457fb
Compare
Fix looks good, but wondering about the alignment of the start/end labels, at least the "100m" seems to be differently aligned than in the original screenshot. Should we try to centrally align the labels above the start/end of the scalebar? In this case, the "0" should be more slightly to the left (does not look correctly aligned even in the original) and the "100m" should be more to the right. The "50m" label seems to be correctly centred. |
plugin-scalebar/src/main/java/com/mapbox/maps/plugin/scalebar/ScaleBarImpl.kt
Show resolved
Hide resolved
The alignment has not changed, but in order for the text to fix we need to "move" it away from the margins. See this video of the behaviour: scale_bar.mp4The scale bar layout has a defined width that we should honour. Therefore, the only way I could think to easily fix it is to move the label. If we want a more advanced solution we could try to figure out if the labels fit and if not then reduce the amount of unit bars we show. We will probably need to do that to fix the issue where the labels overlap each other. But that I'd say is for another PR.
The "0" is left aligned but given the horizontal bearing it renders it a bit to the right. (See https://stackoverflow.com/a/7579469) |
plugin-scalebar/src/main/java/com/mapbox/maps/plugin/scalebar/ScaleBarImpl.kt
Show resolved
Hide resolved
plugin-scalebar/src/main/java/com/mapbox/maps/plugin/scalebar/ScaleBarImpl.kt
Outdated
Show resolved
Hide resolved
plugin-scalebar/src/main/java/com/mapbox/maps/plugin/scalebar/ScaleBarImpl.kt
Outdated
Show resolved
Hide resolved
Co-authored-by: Kiryl Dzehtsiarenka <kiryl.dzehtsiarenka@mapbox.com>
} | ||
|
||
// Check if it goes beyond the left margin of the view | ||
if (x - strokePaint.strokeWidth / 2 < 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it ok that we check x
here but operate with safeX
below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. It's better to use safeX
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and also for better readability I'd use if (x < trokePaint.strokeWidth / 2)
similar to L316
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm I personally think that:
if (x < trokePaint.strokeWidth / 2)
it's a bit obscure.
I need to think more to figure out why we're comparing a position (x
or safeX
) with a width (strokeWidth
). Somehow, to me, mine reads easier: to position safeX
I remove a width and then check if it goes beyond the left minimum position (0
).
But happy to change it to your proposal if others also prefer it.
/** | ||
* Activity to showcase scale bar custom configuration using xml attributes. | ||
*/ | ||
class ScaleBarActivity : AppCompatActivity() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we create similar activity on iOS for parity and making sure that our scalebar customizations are aligned? @mapbox/maps-ios
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to have dedicated pixel match as the tailwork, otherwise LGTM
plugin-scalebar/src/main/java/com/mapbox/maps/plugin/scalebar/ScaleBarImpl.kt
Outdated
Show resolved
Hide resolved
plugin-scalebar/src/main/java/com/mapbox/maps/plugin/scalebar/ScaleBarImpl.kt
Show resolved
Hide resolved
5e38872
to
f97571a
Compare
7c69dc9
to
d0adea0
Compare
* Improve performance of setting puck style properties * fix test * fix more tests
Summary of changes
Fixes rendering issues where the scale bar text was being cut on the sides:
Before:
After:
Also added a new example activity to showcase scale bar customization.
User impact (optional)
Pull request checklist:
@JvmOverloads
,@file:JvmName
, etc).make update-api
to update generated api files, if there's public API changes, otherwise theverify-api-*
CI steps might fail.check changelog
CI step will fail.v10.[version]
release branch fix / enhancement, merge it tomain
firstly and then port tov10.[version]
release branch.Fixes: < Link to related issues that will be fixed by this pull request, if they exist >
PRs must be submitted under the terms of our Contributor License Agreement CLA.