-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed a Grid editor issue #1308
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -137,80 +137,48 @@ private void ExtendRangeToHaveEvenCellEdges() | |
// extend each edge of the [(_startCol, _startRow) - (_endCol, _endRow)] range based on merged cells until you have 4 straight edges with no "straddling cells" | ||
ivan100sic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
GridLayoutModel model = Model; | ||
|
||
while (_startRow > 0) | ||
// As long as there is an edge of the 2D range such that some zone crosses its boundary, extend that boundary. | ||
// A single pass is not enough, a while loop is needed. This results in the unique smallest rectangle containing | ||
// the initial range such that no zone is "broken". | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As code would be self-explaining now. Comments would be needless There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The whole code has been simplified, do you mind taking another look? |
||
bool possibly_broken = true; | ||
ivan100sic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
while (possibly_broken) | ||
{ | ||
bool dirty = false; | ||
possibly_broken = false; | ||
|
||
for (int col = _startCol; col <= _endCol; col++) | ||
{ | ||
if (model.CellChildMap[_startRow - 1, col] == model.CellChildMap[_startRow, col]) | ||
if (_startRow > 0 && model.CellChildMap[_startRow - 1, col] == model.CellChildMap[_startRow, col]) | ||
{ | ||
_startRow--; | ||
dirty = true; | ||
possibly_broken = true; | ||
break; | ||
} | ||
} | ||
|
||
if (!dirty) | ||
{ | ||
break; | ||
} | ||
} | ||
|
||
while (_endRow < model.Rows - 1) | ||
{ | ||
bool dirty = false; | ||
for (int col = _startCol; col <= _endCol; col++) | ||
{ | ||
if (model.CellChildMap[_endRow + 1, col] == model.CellChildMap[_endRow, col]) | ||
if (_endRow < model.Rows - 1 && model.CellChildMap[_endRow + 1, col] == model.CellChildMap[_endRow, col]) | ||
{ | ||
_endRow++; | ||
dirty = true; | ||
possibly_broken = true; | ||
break; | ||
} | ||
} | ||
|
||
if (!dirty) | ||
{ | ||
break; | ||
} | ||
} | ||
|
||
while (_startCol > 0) | ||
{ | ||
bool dirty = false; | ||
for (int row = _startRow; row <= _endRow; row++) | ||
{ | ||
if (model.CellChildMap[row, _startCol - 1] == model.CellChildMap[row, _startCol]) | ||
if (_startCol > 0 && model.CellChildMap[row, _startCol - 1] == model.CellChildMap[row, _startCol]) | ||
{ | ||
_startCol--; | ||
dirty = true; | ||
possibly_broken = true; | ||
break; | ||
} | ||
} | ||
|
||
if (!dirty) | ||
{ | ||
break; | ||
} | ||
} | ||
|
||
while (_endCol < model.Columns - 1) | ||
{ | ||
bool dirty = false; | ||
for (int row = _startRow; row <= _endRow; row++) | ||
{ | ||
if (model.CellChildMap[row, _endCol + 1] == model.CellChildMap[row, _endCol]) | ||
if (_endCol < model.Columns - 1 && model.CellChildMap[row, _endCol + 1] == model.CellChildMap[row, _endCol]) | ||
{ | ||
_endCol++; | ||
dirty = true; | ||
possibly_broken = true; | ||
break; | ||
} | ||
} | ||
|
||
if (!dirty) | ||
{ | ||
break; | ||
} | ||
} | ||
} | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function name ExtendOverhangingPartsToMinimalProperRectangle
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This name is arguable but let's just leave it as-is.