mirror of https://github.com/rivo/tview.git
Fixed multiple items in grid. Fixes #987
This commit is contained in:
parent
fc5680eecb
commit
a2885dd403
|
@ -28,7 +28,7 @@ I'm very picky about the code that goes into this repo. So if you violate any of
|
||||||
- Your code must follow the structure of the existing code. Don't just patch something on. Try to understand how `tview` is currently designed and follow that design. Your code needs to be consistent with existing code.
|
- Your code must follow the structure of the existing code. Don't just patch something on. Try to understand how `tview` is currently designed and follow that design. Your code needs to be consistent with existing code.
|
||||||
- If you're adding code that increases the work required to maintain the project, you must be willing to take responsibility for that extra work. I will ask you to maintain your part of the code in the long run.
|
- If you're adding code that increases the work required to maintain the project, you must be willing to take responsibility for that extra work. I will ask you to maintain your part of the code in the long run.
|
||||||
- Function/type/variable/constant names must be as descriptive as they are right now. Follow the conventions of the package.
|
- Function/type/variable/constant names must be as descriptive as they are right now. Follow the conventions of the package.
|
||||||
- All functions/types/variables/constants, even private ones, must have comments in good English. These comments must be elaborate enough so that new users of the package understand them and can follow them. Provide examples if you have to. Start all sentences upper-case, as is common in English, and end them with a period.
|
- All functions/types/variables/constants, even private ones, must have comments in good English. These comments must be elaborate enough so that new users of the package understand them and can follow them. Provide examples if you have to. Start all sentences upper-case, as is common in English, and end them with a period. Comments in their own lines must not exceed the 80 character border. Break over if necessary.
|
||||||
- A new function should be located close to related functions in the file. For example, `GetColor()` should come after (or before) `SetColor()`.
|
- A new function should be located close to related functions in the file. For example, `GetColor()` should come after (or before) `SetColor()`.
|
||||||
- Your changes must not decrease the project's [Go Report](https://goreportcard.com/report/github.com/rivo/tview) rating.
|
- Your changes must not decrease the project's [Go Report](https://goreportcard.com/report/github.com/rivo/tview) rating.
|
||||||
- No breaking changes unless there is absolutely no other way.
|
- No breaking changes unless there is absolutely no other way.
|
||||||
|
|
11
grid.go
11
grid.go
|
@ -281,11 +281,12 @@ ItemLoop:
|
||||||
continue // Disqualified.
|
continue // Disqualified.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for overlaps.
|
// Check for overlaps and multiple layouts of the same item.
|
||||||
for index, existing := range items {
|
for index, existing := range items {
|
||||||
// Do they overlap?
|
// Do they overlap or are identical?
|
||||||
if item.Row >= existing.Row+existing.Height || item.Row+item.Height <= existing.Row ||
|
if item.Item != existing.Item &&
|
||||||
item.Column >= existing.Column+existing.Width || item.Column+item.Width <= existing.Column {
|
(item.Row >= existing.Row+existing.Height || item.Row+item.Height <= existing.Row ||
|
||||||
|
item.Column >= existing.Column+existing.Width || item.Column+item.Width <= existing.Column) {
|
||||||
break // They don't.
|
break // They don't.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,7 +304,7 @@ ItemLoop:
|
||||||
if itemMin < existingMin {
|
if itemMin < existingMin {
|
||||||
continue ItemLoop // This one isn't. Drop it.
|
continue ItemLoop // This one isn't. Drop it.
|
||||||
}
|
}
|
||||||
items[index] = item
|
items[index] = item // This one is. Replace the other.
|
||||||
continue ItemLoop
|
continue ItemLoop
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue