-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpaint_requests.go
107 lines (88 loc) · 2.38 KB
/
paint_requests.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package washeet
import "fmt"
func (sheet *Sheet) addPaintRequest(request *sheetPaintRequest) bool {
if sheet == nil || sheet.stopSignal {
return false
}
queued := false
select {
case sheet.paintQueue <- request:
queued = true
default:
// Queue is full, drop request
fmt.Printf("[D]")
}
return queued
}
// if col/row = -1 no changes are made before whole-redraw
// changeSheetStartCol/changeSheetStartRow is also used to set sheet.layoutFromStartCol/sheet.layoutFromStartRow
func (sheet *Sheet) paintWholeSheet(col, row int64, changeSheetStartCol, changeSheetStartRow bool) bool {
req := &sheetPaintRequest{
kind: sheetPaintWholeSheet,
col: col,
row: row,
changeSheetStartCol: changeSheetStartCol,
changeSheetStartRow: changeSheetStartRow,
}
if sheet.addPaintRequest(req) {
// Layout will be partly/fully computed in RAF thread, so independently compute that here too.
sheet.computeLayout(sheet.evtHndlrLayoutData, col, row, changeSheetStartCol, changeSheetStartRow)
return true
}
return false
}
func (sheet *Sheet) paintCell(col int64, row int64) bool {
if sheet == nil {
return false
}
layout := sheet.evtHndlrLayoutData
// optimization : don't fill the queue with these
// if we know they are not going to be painted.
if col < layout.startColumn || col > layout.endColumn ||
row < layout.startRow || row > layout.endRow {
return false
}
return sheet.addPaintRequest(&sheetPaintRequest{
kind: sheetPaintCell,
col: col,
row: row,
endCol: col,
endRow: row,
})
}
func (sheet *Sheet) paintCellRange(colStart int64, rowStart int64, colEnd int64, rowEnd int64) bool {
if sheet == nil {
return false
}
return sheet.addPaintRequest(&sheetPaintRequest{
kind: sheetPaintCellRange,
col: colStart,
row: rowStart,
endCol: colEnd,
endRow: rowEnd,
})
}
func (sheet *Sheet) paintCellSelection(col, row int64) bool {
if sheet == nil {
return false
}
return sheet.addPaintRequest(&sheetPaintRequest{
kind: sheetPaintSelection,
col: col,
row: row,
endCol: col,
endRow: row,
})
}
func (sheet *Sheet) paintCellRangeSelection(colStart, rowStart, colEnd, rowEnd int64) bool {
if sheet == nil {
return false
}
return sheet.addPaintRequest(&sheetPaintRequest{
kind: sheetPaintSelection,
col: colStart,
row: rowStart,
endCol: colEnd,
endRow: rowEnd,
})
}