fix runchart resize issue, caused by superfluous math.abs for coordinate delta

This commit is contained in:
sqshq 2019-04-15 21:55:05 -04:00
parent 646fd4f67d
commit 3c88c56fa2
2 changed files with 4 additions and 3 deletions

View File

@ -67,7 +67,6 @@ func (l *Layout) changeMode(m Mode) {
} }
func (l *Layout) HandleMouseClick(x int, y int) { func (l *Layout) HandleMouseClick(x int, y int) {
l.getSelection().CommandChannel <- &data.Command{Type: runchart.CommandMoveSelection, Value: 0}
l.menu.Idle() l.menu.Idle()
selected, i := l.findComponentAtPoint(image.Point{X: x, Y: y}) selected, i := l.findComponentAtPoint(image.Point{X: x, Y: y})
if selected == nil { if selected == nil {
@ -302,6 +301,7 @@ func (l *Layout) Draw(buffer *ui.Buffer) {
l.menu.Draw(buffer) l.menu.Draw(buffer)
} }
// TODO extract x/y calculation to a separate method
func (l *Layout) findComponentAtPoint(point image.Point) (*component.Component, int) { func (l *Layout) findComponentAtPoint(point image.Point) (*component.Component, int) {
columnWidth := float64(l.GetRect().Dx()) / float64(columnsCount) columnWidth := float64(l.GetRect().Dx()) / float64(columnsCount)

View File

@ -21,7 +21,7 @@ const (
xAxisLabelsIndent = 2 xAxisLabelsIndent = 2
yAxisLabelsHeight = 1 yAxisLabelsHeight = 1
yAxisLabelsIndent = 1 yAxisLabelsIndent = 1
historyReserveMin = 20 historyReserveMin = 2
xBrailleMultiplier = 2 xBrailleMultiplier = 2
yBrailleMultiplier = 4 yBrailleMultiplier = 4
) )
@ -208,7 +208,8 @@ func (c *RunChart) renderLines(buffer *ui.Buffer, drawArea image.Rectangle) {
selectionPoints := make(map[int]image.Point) selectionPoints := make(map[int]image.Point)
probe := c.lines[0].points[0] probe := c.lines[0].points[0]
delta := ui.AbsInt(c.calculateTimeCoordinate(probe.time) - probe.coordinate) probeCalculatedCoordinate := c.calculateTimeCoordinate(probe.time)
delta := probe.coordinate - probeCalculatedCoordinate
for i, line := range c.lines { for i, line := range c.lines {