-
Notifications
You must be signed in to change notification settings - Fork 696
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
Finish Adornments (master Issue) #2994
Comments
@BDisp which part of this do you feel like tackling first? If it were me, I'd do it in this order (each as a separate PR):
But I'm happy to let you approach it how you see fit. |
Margin
, Border
, Padding
) to be overridden
My doubt is if you add views or adornments on the |
I think your thinking is spot on. We have to figure out how to enable auto-join of lines and ALSO let arbitrary views in Frames (adornments) render appropriately. This will be tricky and will require deep thought and experimentation. I was going down this path with the Personally, i'm excited about the challenge of working on this with you ;-) |
deleted |
I think that the 3 adornments should be primitive on
If a user want more adornments he can create new // TODO: Make this cancelable
/// <summary>
/// Prepares <see cref="View.LineCanvas"/>. If <see cref="SuperViewRendersLineCanvas"/> is true, only the <see cref="LineCanvas"/> of
/// this view's subviews will be rendered. If <see cref="SuperViewRendersLineCanvas"/> is false (the default), this
/// method will cause the <see cref="LineCanvas"/> be prepared to be rendered.
/// </summary>
/// <returns></returns>
public virtual bool OnDrawFrames ()
{
if (!IsInitialized) {
return false;
}
// Each of these renders lines to either this View's LineCanvas
// Those lines will be finally rendered in OnRenderLineCanvas
Margin?.OnDrawContent (Margin.Bounds);
Border?.OnDrawContent (Border.Bounds);
Padding?.OnDrawContent (Padding.Bounds);
// Each of these renders lines to either this View's LineCanvas
// Those lines will be finally rendered in OnRenderLineCanvas
foreach (var frame in Frames) {
frame.OnDrawContent (frame.Bounds);
}
return true;
} |
Thinking about this more, I may be overcomplicating things. If we support replaceability of the 3 built-ins, the need for adding additional is mitigated. In addition, I'm now worried about ordering. There is a clear ordering for "Margin->Border->Padding" that can be seen in the current (hacky) code in /// <summary>
/// Overriden by <see cref="Frame"/> to do nothing, as the <see cref="Frame"/> does not have frames.
/// </summary>
internal virtual void LayoutFrames ()
{
if (Margin == null) return; // CreateFrames() has not been called yet
if (Margin.Frame.Size != Frame.Size) {
Margin._frame = new Rect (Point.Empty, Frame.Size);
Margin.X = 0;
Margin.Y = 0;
Margin.Width = Frame.Size.Width;
Margin.Height = Frame.Size.Height;
Margin.SetNeedsLayout ();
Margin.LayoutSubviews ();
Margin.SetNeedsDisplay ();
}
var border = Margin.Thickness.GetInside (Margin.Frame);
if (border != Border.Frame) {
Border._frame = new Rect (new Point (border.Location.X, border.Location.Y), border.Size);
Border.X = border.Location.X;
Border.Y = border.Location.Y;
Border.Width = border.Size.Width;
Border.Height = border.Size.Height;
Border.SetNeedsLayout ();
Border.LayoutSubviews ();
Border.SetNeedsDisplay ();
}
var padding = Border.Thickness.GetInside (Border.Frame);
if (padding != Padding.Frame) {
Padding._frame = new Rect (new Point (padding.Location.X, padding.Location.Y), padding.Size);
Padding.X = padding.Location.X;
Padding.Y = padding.Location.Y;
Padding.Width = padding.Size.Width;
Padding.Height = padding.Size.Height;
Padding.SetNeedsLayout ();
Padding.LayoutSubviews ();
Padding.SetNeedsDisplay ();
}
} Therefore, I retract my previous assertion that we should have a |
Unless you can remove the virtual keyword and thus you make the current sort order first. But I think this will complicate much more. |
@BDisp I'm wondering if you've made progress on: I'm working on some stuff that needs that done. I'd be happy to jump on it if you're on other things.. |
Do you already have any idea about this? I'm thinking that instead of using the In this case we refer to them as if |
See #2563. I considered (and wrote about) 3 sub-classes above. However, I now think just having To get there, the first step is to move the OnDrawContent code out of Where |
In, otherwords:
|
@tig how you type ? |
Use a font that supports ligatures and it just does it automatically. e.g |
Thanks. |
After sleeping on it, I'm back on the "have Border be a subclass of Frame" bandwagon. Just We want helpers for common things like @BDisp if you're ok with this I'm going to start a PR that just refactors |
Because of the difference between them I proposed the sub-class. I'm glad you accept my opinion. |
Todo
Adornments
- In progress: Partially Adresses #2491. Refactors howFocus
works #3627Border
is not always working #2995ScrollBar
based on a newScroll
and removeScrollBarView/ScrollView
#2489Border
to use subviews for title, lines, and close button #3407Toplevel
- IntroduceRunnable
andOverlapped
instead #2491Line
and removeLineView
#3014Arrangement
enumViews
by taking advantage ofAdornment
Border
- Use subviews instead of bespokeOnDrawContent
for lines and title.Dialog
(andMessageBox
) - Put buttons in bottomPadding
Wizard
- Put nav buttons in bottomPadding
. PutHelp
in rightPadding
Toplevel - Put
MenuBarin top
Paddingand
StatusBarin bottom
Padding` - See RefactorMenuBar
andStatusBar
to be adornments #2488ScrollBarView
- Update any view that uses it (orScrollView
to use newScrollBar
s inPadding
and built-in content scrolling.Related Todos
Margin
,Border
, andPadding
#2563ScrollBar
based on a newScroll
and removeScrollBarView/ScrollView
#2489EnsureVisibleBounds
is complex & confusing #2407Background
When I was designing
Frames
I had the idea thatView
'sMargin
,Border
, andPadding
could be replaced by a View. I didn't complete the implementation of this, but did makeView.CreateFrames
virtual
:In addition, I left unfinished how the Frames are drawn. I used a hack of setting
Frame.Id
to"Border"
etc...:If we were to complete this idea ("Adornments"), we would have 3 built-in derivations of
Frame
:MarginView
BorderView
PaddingView
Then, a view like
TabView
could replace any of these. In TabView's caseTabRowView
would derive fromFrame
(and be namedTabFrame
).I have an open Issue for this already: #2563
Note that in it, I call out that the problem of how Mouse/Keyboard events are handled correctly. In the current v2_develop,
Frame
can never get focus. But for all this to work, we have to change that.Note that by doing this it we also can remove
TabView.ContentView
which is a hack that was required in v1... and one of the motivations I had for implementingFrames
.This same solution, BTW, will also simplify
Dialog
andWizard
(the button/nav bar just becomes a set of controls in a customBorder
.@BDisp, what would you think of attacking solving all of this such that
TabView
is a great example of how to replaceView.Border
with an advanced implementation that provides all of the Tab navigation etc...?Related (you'd be taking on enabling all of these Issues to be addressed):
Margin
,Border
, andPadding
#2563MenuBar
andStatusBar
to be adornments #2488ScrollBar
based on a newScroll
and removeScrollBarView/ScrollView
#2489EnsureVisibleBounds
is complex & confusing #2407Border
#2814Toplevel
- IntroduceRunnable
andOverlapped
instead #2491Line
and removeLineView
#3014Extra Credit:
Figure out the best way to satisfy this requirement:
Border
(orMargin
orPadding
) has been overridden, can still have a "standard" border with a Title, frame, and (eventually standard things like close buttons (Adornments: Enable SubViews inMargin
,Border
, andPadding
#2563).There are two potential solutions I can think of:
View
I'm not sure of the best approach, but I suspect 1) is simpler and more obvious.
What do you think???
Originally posted by @tig in #2980 (comment)
The text was updated successfully, but these errors were encountered: