io/pointer: rename button names to reflect their meaning, not placement

For example, ButtonLeft may be the right-most button for a left-handed user.
Rename the button names to match their intended use.

This is an API change. Use the following commands to update your
projects:

    $ gofmt -r 'pointer.ButtonLeft -> pointer.ButtonPrimary' -w .
    $ gofmt -r 'pointer.ButtonRight -> pointer.ButtonSecondary' -w .
    $ gofmt -r 'pointer.ButtonMiddle -> pointer.ButtonTertiary' -w .

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2021-03-03 11:03:38 +01:00
parent f36ed04380
commit ffb26b0e17
13 changed files with 48 additions and 43 deletions
+14 -9
View File
@@ -148,9 +148,14 @@ const (
)
const (
ButtonLeft Buttons = 1 << iota
ButtonRight
ButtonMiddle
// ButtonPrimary is the primary button, usually the left button for a
// right-handed user.
ButtonPrimary Buttons = 1 << iota
// ButtonSecondary is the secondary button, usually the right button for a
// right-handed user.
ButtonSecondary
// ButtonTertiary is the tertiary button, usually the middle button.
ButtonTertiary
)
const (
@@ -265,14 +270,14 @@ func (b Buttons) Contain(buttons Buttons) bool {
func (b Buttons) String() string {
var strs []string
if b.Contain(ButtonLeft) {
strs = append(strs, "ButtonLeft")
if b.Contain(ButtonPrimary) {
strs = append(strs, "ButtonPrimary")
}
if b.Contain(ButtonRight) {
strs = append(strs, "ButtonRight")
if b.Contain(ButtonSecondary) {
strs = append(strs, "ButtonSecondary")
}
if b.Contain(ButtonMiddle) {
strs = append(strs, "ButtonMiddle")
if b.Contain(ButtonTertiary) {
strs = append(strs, "ButtonTertiary")
}
return strings.Join(strs, "|")
}