More go fmt. That completes the main package go fmt. Won't bother with test or tools.
This commit is contained in:
parent
a210775287
commit
5fa1bd22e2
24
area.go
24
area.go
|
@ -4,10 +4,10 @@ package ui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"sync"
|
|
||||||
"image"
|
"image"
|
||||||
"unsafe"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"sync"
|
||||||
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Area represents a blank canvas upon which programs may draw anything and receive arbitrary events from the user.
|
// Area represents a blank canvas upon which programs may draw anything and receive arbitrary events from the user.
|
||||||
|
@ -186,6 +186,7 @@ type KeyEvent struct {
|
||||||
|
|
||||||
// ExtKey represents keys that are not in the typewriter section of the keyboard.
|
// ExtKey represents keys that are not in the typewriter section of the keyboard.
|
||||||
type ExtKey uintptr
|
type ExtKey uintptr
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Escape ExtKey = iota + 1
|
Escape ExtKey = iota + 1
|
||||||
Insert // equivalent to "Help" on Apple keyboards
|
Insert // equivalent to "Help" on Apple keyboards
|
||||||
|
@ -241,7 +242,7 @@ func (e KeyEvent) EffectiveKey() byte {
|
||||||
k := e.ExtKey
|
k := e.ExtKey
|
||||||
switch {
|
switch {
|
||||||
case k >= N0 && k <= N9:
|
case k >= N0 && k <= N9:
|
||||||
return byte(k - N0) + '0'
|
return byte(k-N0) + '0'
|
||||||
case k == NDot:
|
case k == NDot:
|
||||||
return '.'
|
return '.'
|
||||||
case k == NEnter:
|
case k == NEnter:
|
||||||
|
@ -262,6 +263,7 @@ func (e KeyEvent) EffectiveKey() byte {
|
||||||
// There is no way to differentiate between left and right modifier keys.
|
// There is no way to differentiate between left and right modifier keys.
|
||||||
// As such, what KeyEvents get sent if the user does something unusual with both of a certain modifier key at once is undefined.
|
// As such, what KeyEvents get sent if the user does something unusual with both of a certain modifier key at once is undefined.
|
||||||
type Modifiers uintptr
|
type Modifiers uintptr
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Ctrl Modifiers = 1 << iota // the keys labelled Ctrl or Control on all platforms
|
Ctrl Modifiers = 1 << iota // the keys labelled Ctrl or Control on all platforms
|
||||||
Alt // the keys labelled Alt or Option or Meta on all platforms
|
Alt // the keys labelled Alt or Option or Meta on all platforms
|
||||||
|
@ -373,16 +375,16 @@ func toARGB(i *image.RGBA, memory uintptr, memstride int) {
|
||||||
nextp := p + i.Stride
|
nextp := p + i.Stride
|
||||||
nextq := q + memstride
|
nextq := q + memstride
|
||||||
for x := i.Rect.Min.X; x < i.Rect.Max.X; x++ {
|
for x := i.Rect.Min.X; x < i.Rect.Max.X; x++ {
|
||||||
argb := uint32(i.Pix[p + 3]) << 24 // A
|
argb := uint32(i.Pix[p+3]) << 24 // A
|
||||||
argb |= uint32(i.Pix[p + 0]) << 16 // R
|
argb |= uint32(i.Pix[p+0]) << 16 // R
|
||||||
argb |= uint32(i.Pix[p + 1]) << 8 // G
|
argb |= uint32(i.Pix[p+1]) << 8 // G
|
||||||
argb |= uint32(i.Pix[p + 2]) // B
|
argb |= uint32(i.Pix[p+2]) // B
|
||||||
// the magic of conversion
|
// the magic of conversion
|
||||||
native := (*[4]byte)(unsafe.Pointer(&argb))
|
native := (*[4]byte)(unsafe.Pointer(&argb))
|
||||||
realbits[q + 0] = native[0]
|
realbits[q+0] = native[0]
|
||||||
realbits[q + 1] = native[1]
|
realbits[q+1] = native[1]
|
||||||
realbits[q + 2] = native[2]
|
realbits[q+2] = native[2]
|
||||||
realbits[q + 3] = native[3]
|
realbits[q+3] = native[3]
|
||||||
p += 4
|
p += 4
|
||||||
q += 4
|
q += 4
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
package ui
|
package ui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
|
||||||
"image"
|
"image"
|
||||||
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
// #include <stdlib.h>
|
// #include <stdlib.h>
|
||||||
|
@ -28,7 +28,7 @@ func areaView_drawRect(self C.id, rect C.struct_xrect) {
|
||||||
s := getSysData(self)
|
s := getSysData(self)
|
||||||
// no need to clear the clip rect; the NSScrollView does that for us (see the setDrawsBackground: call in objc_darwin.m)
|
// no need to clear the clip rect; the NSScrollView does that for us (see the setDrawsBackground: call in objc_darwin.m)
|
||||||
// rectangles in Cocoa are origin/size, not point0/point1; if we don't watch for this, weird things will happen when scrolling
|
// rectangles in Cocoa are origin/size, not point0/point1; if we don't watch for this, weird things will happen when scrolling
|
||||||
cliprect := image.Rect(int(rect.x), int(rect.y), int(rect.x + rect.width), int(rect.y + rect.height))
|
cliprect := image.Rect(int(rect.x), int(rect.y), int(rect.x+rect.width), int(rect.y+rect.height))
|
||||||
max := C.frame(self)
|
max := C.frame(self)
|
||||||
cliprect = image.Rect(0, 0, int(max.width), int(max.height)).Intersect(cliprect)
|
cliprect = image.Rect(0, 0, int(max.width), int(max.height)).Intersect(cliprect)
|
||||||
if cliprect.Empty() { // no intersection; nothing to paint
|
if cliprect.Empty() { // no intersection; nothing to paint
|
||||||
|
@ -93,18 +93,18 @@ func areaMouseEvent(self C.id, e C.id, click bool, up bool) {
|
||||||
}
|
}
|
||||||
// the docs do say don't use this for tracking (mouseMoved:) since it returns the state now, and mouse move events work by tracking, but as far as I can tell dragging the mouse over the inactive window does not generate an event on Mac OS X, so :/ (tracking doesn't touch dragging anyway except during mouseEntered: and mouseExited:, which we don't handle, and the only other tracking message, cursorChanged:, we also don't handle (yet...? need to figure out if this is how to set custom cursors or not), so)
|
// the docs do say don't use this for tracking (mouseMoved:) since it returns the state now, and mouse move events work by tracking, but as far as I can tell dragging the mouse over the inactive window does not generate an event on Mac OS X, so :/ (tracking doesn't touch dragging anyway except during mouseEntered: and mouseExited:, which we don't handle, and the only other tracking message, cursorChanged:, we also don't handle (yet...? need to figure out if this is how to set custom cursors or not), so)
|
||||||
held := C.pressedMouseButtons()
|
held := C.pressedMouseButtons()
|
||||||
if which != 1 && (held & 1) != 0 { // button 1
|
if which != 1 && (held&1) != 0 { // button 1
|
||||||
me.Held = append(me.Held, 1)
|
me.Held = append(me.Held, 1)
|
||||||
}
|
}
|
||||||
if which != 2 && (held & 4) != 0 { // button 2; mind the swap
|
if which != 2 && (held&4) != 0 { // button 2; mind the swap
|
||||||
me.Held = append(me.Held, 2)
|
me.Held = append(me.Held, 2)
|
||||||
}
|
}
|
||||||
if which != 3 && (held & 2) != 0 { // button 3
|
if which != 3 && (held&2) != 0 { // button 3
|
||||||
me.Held = append(me.Held, 3)
|
me.Held = append(me.Held, 3)
|
||||||
}
|
}
|
||||||
held >>= 3
|
held >>= 3
|
||||||
for i := uint(4); held != 0; i++ {
|
for i := uint(4); held != 0; i++ {
|
||||||
if which != i && (held & 1) != 0 {
|
if which != i && (held&1) != 0 {
|
||||||
me.Held = append(me.Held, i)
|
me.Held = append(me.Held, i)
|
||||||
}
|
}
|
||||||
held >>= 1
|
held >>= 1
|
||||||
|
|
Loading…
Reference in New Issue