Wrote the code to actually scroll Areas on Windows.

This commit is contained in:
Pietro Gagliardi 2014-03-25 09:10:06 -04:00
parent 13370c22d3
commit 2b48f7cabf
3 changed files with 25 additions and 3 deletions

View File

@ -51,6 +51,7 @@ func paintArea(s *sysData) {
var xrect _RECT
var ps _PAINTSTRUCT
var si _SCROLLINFO
// TODO send _TRUE if we want to erase the clip area
r1, _, _ := _getUpdateRect.Call(
@ -61,15 +62,36 @@ func paintArea(s *sysData) {
return
}
si.cbSize = uint32(unsafe.Sizeof(si))
si.fMask = _SIF_POS | _SIF_TRACKPOS
r1, _, err := _getScrollInfo.Call(
uintptr(s.hwnd),
uintptr(_SB_HORZ),
uintptr(unsafe.Pointer(&si)))
if r1 == 0 { // failure
panic(fmt.Errorf("error getting horizontal scroll position for Area repaint: %v", err))
}
hscroll := int(si.nPos)
si.cbSize = uint32(unsafe.Sizeof(si)) // MSDN example code reinitializes this each time, so we'll do it too just to be safe
si.fMask = _SIF_POS | _SIF_TRACKPOS
r1, _, err = _getScrollInfo.Call(
uintptr(s.hwnd),
uintptr(_SB_VERT),
uintptr(unsafe.Pointer(&si)))
if r1 == 0 { // failure
panic(fmt.Errorf("error getting vertical scroll position for Area repaint: %v", err))
}
vscroll := int(si.nPos)
cliprect := image.Rect(int(xrect.Left), int(xrect.Top), int(xrect.Right), int(xrect.Bottom))
// TODO offset cliprect by scroll position
cliprect = cliprect.Add(image.Pt(hscroll, vscroll)) // adjust by scroll position
// make sure the cliprect doesn't fall outside the size of the Area
cliprect = cliprect.Intersect(image.Rect(0, 0, 320, 240)) // TODO change when adding resizing
if cliprect.Empty() { // still no update rect
return
}
r1, _, err := _beginPaint.Call(
r1, _, err = _beginPaint.Call(
uintptr(s.hwnd),
uintptr(unsafe.Pointer(&ps)))
if r1 == 0 { // failure

View File

@ -501,7 +501,6 @@ const (
var (
_getScrollInfo = user32.NewProc("GetScrollInfo")
_getScrollPos = user32.NewProc("GetScrollPos")
_setScrollInfo = user32.NewProc("SetScrollInfo")
_scrollWindowEx = user32.NewProc("ScrollWindowEx")
)

View File

@ -79,6 +79,7 @@ super ultra important things:
- see update 18 March 2014 in README
- resizing seems to be completely and totally broken in the Wayland backend
- scrolling Areas in wine by clicking in the page scroll area often causes the main thread to lock up; uitask does not
- make sure the first and last rows and columns of an Area are being drawn on Windows
important things:
- make specific wording in documentation consistent (make/create, etc.)