-
Notifications
You must be signed in to change notification settings - Fork 700
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
Finally, really, fixed clipping #586
Conversation
Whoa! Great patch! Will review tonight! |
This has nothing to do with clipping either. I was able to change the |
It's not totally silly and of course it has nothing to do with clipping. In |
@tig this is really strange behavior because in |
Let us get this merged - Charlie, I am going to let you do the honors, given how large this patch is. Longer version - I truly appreciate the work that went into this, the clearing up of the naming and conventions is clearly a problem that was going to keep biting us down the line as both time takes a toll on memory and new contributors bring controls to the project. I love this patch. Regarding @BDisp comments on repainting - initially when Gui.cs was brought up, I did not really do much work to "queue" the damaged region on the parent view, and this might be just a side-effect of moving a window not sending the right setNeedDisplay to the container. |
Glad you like this. I've got a mondo PR coming that includes this one and the others; this will make merging easier and the history more clean. Note, I already merged #590 into that mondo and it'll be a pain to back out. So i'd appreciate it if @migueldeicaza would look at #590. It's another fairly big set of changes. |
@tig the issue is in
|
Good catch. However, As noted in above, people have confused ALWAYS CALL Redraw with Based on you identifying this call chain, I found that the REAL cause of this dragging bug is in ///<inheritdoc cref="Redraw"/>
public override void Redraw (Rect bounds)
{
Application.CurrentView = this;
if (IsCurrentTop || this == Application.Top) {
if (NeedDisplay != null && !NeedDisplay.IsEmpty) {
Driver.SetAttribute (Colors.TopLevel.Normal);
Clear (frame);
Driver.SetAttribute (Colors.Base.Normal);
}
foreach (var view in Subviews) {
if (view.Frame.IntersectsWith (bounds)) {
view.SetNeedsLayout ();
view.SetNeedsDisplay (view.Bounds);
}
}
ClearNeedsDisplay ();
}
base.Redraw (base.Bounds);
} Note /// <summary>
/// Clears the specified region with the current color.
/// </summary>
/// <remarks>
/// </remarks>
/// <param name="regionScreen">The screen-relative region to clear.</param>
public void Clear (Rect regionScreen)
{
var h = regionScreen.Height;
var w = regionScreen.Width;
for (int line = regionScreen.Y; line < regionScreen.Y + h; line++) {
Driver.Move (regionScreen.X, line);
for (int col = 0; col < w; col++)
Driver.AddRune (' ');
}
}
I'll fix this before I submit again. |
This PR includes: #586 - Fixed Clipping #587 - LayoutComplete #591 - Sys Console Scenario #590 - Significantly improves MessageBox, Dialog, Frame drawning and more See the PRs above for all the details. Here are the issues this closes: Closes #299 - MessageBox now auto sizes Closes #557 - MessageBoxes on small screens Closes #432 - MessageBox does not deal with long text; width/height params are goofy Closes #521 - MessageBox should take ustrings (BREAKING CHANGE) Closes #35 - Dialog should have 1 char padding around edges Closes #570 - Dialog should use computed layout for buttons Closes #470 - UI Catalog: Add Dialogs Scenario Closes #569 - LayoutComplete event Plus probably more.
@tig please see my comment here #601 (comment) |
This was incorporated in #600. Closing. |
@BDisp and @migueldeicaza - Please do a code review of all this...
I started over by first reading every line (and comment) in
View
andWindow
. I re-wrote all the documentation to ensure I actually understood the intent. I found that either originally, or over time, the code had gotten confused onFrame
vs.Bounds
and view-relative, screen-relative, and superview-relative coordinates. I fixed all of that, renaming internals to be consistent and updating all XML documentation.One of the most confusing parts was the internal API
RectToScreen
which is used extensively across the project. This API was mis-named (and the comment was not clear) and it was obvious people didn't know whether it took view-relative or super-view-relative coordinates. Some usages wereRectToScreen (Bounds)
and others wereRectToScreen (Frame)
. I decided to rename this API toViewToScreen
and change the parameter name fromrect
toregion
. I also updated the comment:I fixed all usages across the project (sorry; touches lots of stuff and might make merging hard) to correctly call this using superview-relative coordinates (
Frame
). This fixed several visual bugs (and exposed others...seeFileDialog
).Similarly, I noted that implementations of
Redraw
were confused on what coordinates were passed in theregion
parameter. I made it clear by changing the parameter name tobounds
and fixing the docs:Of course, almost every file in the project references
Draw
so that's why 21 files have changed with this PR.I was confused by what the internal
RelativeLayout
API did. After studying the code I noted it SETS THE FRAME. So I renamed it toSetRelativeLayout
and added better comments so future contributors aren't as confused as I was.The key to fixing clipping was to utilize
Rect.Intersects()
to ensure theDriver.Clip
that gets set is never larger than the previous clip. I did this in theSetClilp
API to keep the code centralized:Typical
Redraw
code now does this when callingRedraw
on subviews (orcontentView
s):I expanded several
Scenarios
in UICatalog to help me test. And I added a clipping specific test scenario named Clipping.