|
|
DescriptionBoxLayout now suports per-view margins.
Call BoxLayout::SetViewMargins(view, margins) to set the amount of space for each side of the control.
Review-Url: https://codereview.chromium.org/2836313002
Cr-Commit-Position: refs/heads/master@{#477955}
Committed: https://chromium.googlesource.com/chromium/src/+/3c489a82647c5e33a6e4fae55bc1a30d87c87d91
Patch Set 1 #
Total comments: 11
Patch Set 2 : Clarifications, comments, and logic changes #Patch Set 3 : BoxLayout now uses Margins property on the view #
Total comments: 1
Patch Set 4 : Added margin collapsing and a BoxLayout example #
Total comments: 45
Patch Set 5 : Refactor Combobox and Textfield creation into common functions #Patch Set 6 : BoxLayoutExample complete #Patch Set 7 : Comments, constant identifiers, removed ViewListener and ExampleModel #Patch Set 8 : Adjust cross-axis margin to be the max of all margins or insets #Patch Set 9 : Added unit tests. Fixed GetPreferredSize() calculations. Refactored some code. #
Total comments: 11
Patch Set 10 : Added example comment. Addressed other feedback. #Patch Set 11 : Moved view properties to separate file. #Patch Set 12 : Fixed crash in example and added ability to control size of child panels. #Patch Set 13 : Uncollapsed margins in the cross-axis now align the views #Patch Set 14 : Fixed BoxLayout for unit tests #Patch Set 15 : Adjusted cross-axis calculations to better account for existing margins from other, larger peer vie… #Patch Set 16 : Fix for BoxLayout unittests #
Total comments: 22
Patch Set 17 : Refactoring, style and formatting changes #
Total comments: 26
Patch Set 18 : More cleanup. #Patch Set 19 : Better preferred size calculations and corrected layout for the cross axis. #
Total comments: 2
Patch Set 20 : Cross axis wasn't collapsing and didn't handle the leading/trailing edges correctly. Clarify what h… #Patch Set 21 : When cross axis alignment is START or END, only collapse the anchoring edge when collapse_margins_s… #Patch Set 22 : Remove unused local variable. #Patch Set 23 : Don't collapse cross axis margins with adjacent margins in STRETCH or CENTER. #
Total comments: 4
Patch Set 24 : Fixed comment describing the BoxLayout behavior. #
Total comments: 28
Patch Set 25 : Merged with master. Removed cached orientation_ from ViewWrapper. #
Messages
Total messages: 187 (88 generated)
Description was changed from ========== BoxLayout now suports per-view margins. Call BoxLayout::SetViewMargins(view, margins) to set the amount of space for each side of the control. ========== to ========== BoxLayout now suports per-view margins. Call BoxLayout::SetViewMargins(view, margins) to set the amount of space for each side of the control. ==========
kylixrd@chromium.org changed reviewers: + pkasting@chromium.org, sky@chromium.org
Here's the initial cut at adding per-view margins to BoxLayout. If this passes muster, I'll add some unit-tests as well. Ultimately, this and FillLayout will be retired as the functionality is merged into AlignLayout.
https://codereview.chromium.org/2836313002/diff/1/ui/views/layout/box_layout.cc File ui/views/layout/box_layout.cc (right): https://codereview.chromium.org/2836313002/diff/1/ui/views/layout/box_layout.... ui/views/layout/box_layout.cc:15: : view_(nullptr), layout_(nullptr), margins_(0, 0, 0, 0){}; (0,0,0,0) is the default, so need to specify margins_ here. https://codereview.chromium.org/2836313002/diff/1/ui/views/layout/box_layout.... ui/views/layout/box_layout.cc:20: BoxLayout::ViewWrapper::ViewWrapper(const ViewWrapper& wrapper) = default? https://codereview.chromium.org/2836313002/diff/1/ui/views/layout/box_layout.... ui/views/layout/box_layout.cc:34: const_cast<View*>(view_)->SetBounds( Why the const_cast here? https://codereview.chromium.org/2836313002/diff/1/ui/views/layout/box_layout.h File ui/views/layout/box_layout.h (right): https://codereview.chromium.org/2836313002/diff/1/ui/views/layout/box_layout.... ui/views/layout/box_layout.h:106: void SetViewMargins(const View* view, const gfx::Insets& margins); Is there a reason you aren't using a UI property for the insets? I think a UI property is better given we want to support margins on multiple layout managers. This means you can get rid of both SetViewMargins and ClearMarginsForView. Please also document the expectations of views placed right next to each other. e.g. is the margin the total of the two sides? I could also see wanting to have no margins along the edges, or possibly options as to which edges should have margins. I started reviewing this, but given you are doing this for Peter I would rather make sure you are addressing his needs. Peter, what specific behavior do you need? https://codereview.chromium.org/2836313002/diff/1/ui/views/layout/box_layout.... ui/views/layout/box_layout.h:116: struct ViewWrapper { Please add a description of this.
My needs are minimal -- I won't have cases with adjacent margins, so collapsing behavior is immaterial. robliao brought up margin collapsing in a f2f discussion with Allen, expressing concern about adding something called "margins" if it wasn't going to behave like CSS margins. I think it would be nice to call this "margins", and nice to collapse-by-default (with a bit for "don't collapse"), but I don't have enough needs to drive that one direction or the other.
https://codereview.chromium.org/2836313002/diff/1/ui/views/layout/box_layout.cc File ui/views/layout/box_layout.cc (right): https://codereview.chromium.org/2836313002/diff/1/ui/views/layout/box_layout.... ui/views/layout/box_layout.cc:306: gfx::Size BoxLayout::GetPreferredSizeForChildWidth(const View* host, It seems like what you're doing here is getting the max of the heights, which includes the margins. Shouldn't you calculate the max of the margins and then add that to that the max of the views? For example, if the alignment is horizontal and you have two views, A and B then I believe you're calculating the pref height as: Max(a_wrapper.preferred_size().height(), b_wrapper.preferred_size().height()); where _wrapper.preferred_size() includes the margin. Don't you want: Max(A.margin.top, B.margin.top) + Max(a.preferred_size.height(), b.preferred_size().height()) + Max(A.margin.bottom, B.margin.bottom); ? Similarly when you are positioning views I would assume you position them relative to the max of the margins along the opposite axis.
The CQ bit was checked by kylixrd@chromium.org to run a CQ dry run
https://codereview.chromium.org/2836313002/diff/1/ui/views/layout/box_layout.cc File ui/views/layout/box_layout.cc (right): https://codereview.chromium.org/2836313002/diff/1/ui/views/layout/box_layout.... ui/views/layout/box_layout.cc:15: : view_(nullptr), layout_(nullptr), margins_(0, 0, 0, 0){}; On 2017/04/25 17:28:58, sky wrote: > (0,0,0,0) is the default, so need to specify margins_ here. Done. https://codereview.chromium.org/2836313002/diff/1/ui/views/layout/box_layout.... ui/views/layout/box_layout.cc:20: BoxLayout::ViewWrapper::ViewWrapper(const ViewWrapper& wrapper) On 2017/04/25 17:28:58, sky wrote: > = default? Done. https://codereview.chromium.org/2836313002/diff/1/ui/views/layout/box_layout.... ui/views/layout/box_layout.cc:34: const_cast<View*>(view_)->SetBounds( On 2017/04/25 17:28:58, sky wrote: > Why the const_cast here? The view_ field is declared as "const View* view_;" Most references to the view are const. So I elected to cast the "const" away only at the one point that modifies the view. https://codereview.chromium.org/2836313002/diff/1/ui/views/layout/box_layout.... ui/views/layout/box_layout.cc:306: gfx::Size BoxLayout::GetPreferredSizeForChildWidth(const View* host, On 2017/04/25 22:46:07, sky wrote: > It seems like what you're doing here is getting the max of the heights, which > includes the margins. Shouldn't you calculate the max of the margins and then > add that to that the max of the views? For example, if the alignment is > horizontal and you have two views, A and B then I believe you're calculating the > pref height as: > > Max(a_wrapper.preferred_size().height(), b_wrapper.preferred_size().height()); > > where _wrapper.preferred_size() includes the margin. > > Don't you want: > Max(A.margin.top, B.margin.top) + > Max(a.preferred_size.height(), b.preferred_size().height()) + > Max(A.margin.bottom, B.margin.bottom); > ? > Similarly when you are positioning views I would assume you position them > relative to the max of the margins along the opposite axis. The next patch should resolve this confusion. The short answer is that the width/height of each view always includes its margins. No collapsing is done at this time.
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
https://codereview.chromium.org/2836313002/diff/1/ui/views/layout/box_layout.cc File ui/views/layout/box_layout.cc (right): https://codereview.chromium.org/2836313002/diff/1/ui/views/layout/box_layout.... ui/views/layout/box_layout.cc:34: const_cast<View*>(view_)->SetBounds( On 2017/04/26 17:41:33, kylix_rd wrote: > On 2017/04/25 17:28:58, sky wrote: > > Why the const_cast here? > > The view_ field is declared as "const View* view_;" Most references to the view > are const. So I elected to cast the "const" away only at the one point that > modifies the view. If you're going to const_cast, why make the member const? Otherwise, what's the point?
The CQ bit was checked by kylixrd@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
This patch addresses more feedback and also moves to using a class property on View for the Margins.
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
Could you please clarify what 'more feedback'? Specifically are you still working on the patch or is it ready to review? On Thu, Apr 27, 2017 at 11:58 AM, <kylixrd@chromium.org> wrote: > This patch addresses more feedback and also moves to using a class > property on > View for the Margins. > > https://codereview.chromium.org/2836313002/ > -- You received this message because you are subscribed to the Google Groups "Chromium-reviews" group. To unsubscribe from this group and stop receiving emails from it, send an email to chromium-reviews+unsubscribe@chromium.org.
On 2017/04/27 22:21:45, sky wrote: > Could you please clarify what 'more feedback'? Specifically are you still > working on the patch or is it ready to review? It addressed some of the comments which were not addressed by other patches. Yes, it should be ready for further review.
On 2017/04/26 17:41:33, kylix_rd wrote: > https://codereview.chromium.org/2836313002/diff/1/ui/views/layout/box_layout.cc > File ui/views/layout/box_layout.cc (right): > > https://codereview.chromium.org/2836313002/diff/1/ui/views/layout/box_layout.... > ui/views/layout/box_layout.cc:15: : view_(nullptr), layout_(nullptr), > margins_(0, 0, 0, 0){}; > On 2017/04/25 17:28:58, sky wrote: > > (0,0,0,0) is the default, so need to specify margins_ here. > > Done. > > https://codereview.chromium.org/2836313002/diff/1/ui/views/layout/box_layout.... > ui/views/layout/box_layout.cc:20: BoxLayout::ViewWrapper::ViewWrapper(const > ViewWrapper& wrapper) > On 2017/04/25 17:28:58, sky wrote: > > = default? > > Done. > > https://codereview.chromium.org/2836313002/diff/1/ui/views/layout/box_layout.... > ui/views/layout/box_layout.cc:34: const_cast<View*>(view_)->SetBounds( > On 2017/04/25 17:28:58, sky wrote: > > Why the const_cast here? > > The view_ field is declared as "const View* view_;" Most references to the view > are const. So I elected to cast the "const" away only at the one point that > modifies the view. > > https://codereview.chromium.org/2836313002/diff/1/ui/views/layout/box_layout.... > ui/views/layout/box_layout.cc:306: gfx::Size > BoxLayout::GetPreferredSizeForChildWidth(const View* host, > On 2017/04/25 22:46:07, sky wrote: > > It seems like what you're doing here is getting the max of the heights, which > > includes the margins. Shouldn't you calculate the max of the margins and then > > add that to that the max of the views? For example, if the alignment is > > horizontal and you have two views, A and B then I believe you're calculating > the > > pref height as: > > > > Max(a_wrapper.preferred_size().height(), b_wrapper.preferred_size().height()); > > > > where _wrapper.preferred_size() includes the margin. > > > > Don't you want: > > Max(A.margin.top, B.margin.top) + > > Max(a.preferred_size.height(), b.preferred_size().height()) + > > Max(A.margin.bottom, B.margin.bottom); > > ? > > Similarly when you are positioning views I would assume you position them > > relative to the max of the margins along the opposite axis. > > The next patch should resolve this confusion. The short answer is that the > width/height of each view always includes its margins. No collapsing is done at > this time. So again, I think this is wrong. I think the margin along the cross axis should be the max of the margins for each view as I outlined above.
On 2017/04/28 19:20:59, sky wrote: > On 2017/04/26 17:41:33, kylix_rd wrote: > > > https://codereview.chromium.org/2836313002/diff/1/ui/views/layout/box_layout.cc > > File ui/views/layout/box_layout.cc (right): > > > > > https://codereview.chromium.org/2836313002/diff/1/ui/views/layout/box_layout.... > > ui/views/layout/box_layout.cc:15: : view_(nullptr), layout_(nullptr), > > margins_(0, 0, 0, 0){}; > > On 2017/04/25 17:28:58, sky wrote: > > > (0,0,0,0) is the default, so need to specify margins_ here. > > > > Done. > > > > > https://codereview.chromium.org/2836313002/diff/1/ui/views/layout/box_layout.... > > ui/views/layout/box_layout.cc:20: BoxLayout::ViewWrapper::ViewWrapper(const > > ViewWrapper& wrapper) > > On 2017/04/25 17:28:58, sky wrote: > > > = default? > > > > Done. > > > > > https://codereview.chromium.org/2836313002/diff/1/ui/views/layout/box_layout.... > > ui/views/layout/box_layout.cc:34: const_cast<View*>(view_)->SetBounds( > > On 2017/04/25 17:28:58, sky wrote: > > > Why the const_cast here? > > > > The view_ field is declared as "const View* view_;" Most references to the > view > > are const. So I elected to cast the "const" away only at the one point that > > modifies the view. > > > > > https://codereview.chromium.org/2836313002/diff/1/ui/views/layout/box_layout.... > > ui/views/layout/box_layout.cc:306: gfx::Size > > BoxLayout::GetPreferredSizeForChildWidth(const View* host, > > On 2017/04/25 22:46:07, sky wrote: > > > It seems like what you're doing here is getting the max of the heights, > which > > > includes the margins. Shouldn't you calculate the max of the margins and > then > > > add that to that the max of the views? For example, if the alignment is > > > horizontal and you have two views, A and B then I believe you're calculating > > the > > > pref height as: > > > > > > Max(a_wrapper.preferred_size().height(), > b_wrapper.preferred_size().height()); > > > > > > where _wrapper.preferred_size() includes the margin. > > > > > > Don't you want: > > > Max(A.margin.top, B.margin.top) + > > > Max(a.preferred_size.height(), b.preferred_size().height()) + > > > Max(A.margin.bottom, B.margin.bottom); > > > ? > > > Similarly when you are positioning views I would assume you position them > > > relative to the max of the margins along the opposite axis. > > > > The next patch should resolve this confusion. The short answer is that the > > width/height of each view always includes its margins. No collapsing is done > at > > this time. > > So again, I think this is wrong. I think the margin along the cross axis should > be the max of the margins for each view as I outlined above. I think I understand what you're getting at here. I consider this part of the work to collapse the margins. That includes collapsing each view's margins with the surrounding insets as well as the max of the margins along the cross axis. I'm working on doing the margin collapse along all axes. I think I'll have a fairly simple solution in the next day or so.
Glad to hear it! Don't hesitate to ask questions if I wasn't clear in my feedback. -Scott On Tue, May 2, 2017 at 1:37 PM, <kylixrd@chromium.org> wrote: > On 2017/04/28 19:20:59, sky wrote: > > On 2017/04/26 17:41:33, kylix_rd wrote: > > > > > > https://codereview.chromium.org/2836313002/diff/1/ui/ > views/layout/box_layout.cc > > > File ui/views/layout/box_layout.cc (right): > > > > > > > > > https://codereview.chromium.org/2836313002/diff/1/ui/ > views/layout/box_layout.cc#newcode15 > > > ui/views/layout/box_layout.cc:15: : view_(nullptr), layout_(nullptr), > > > margins_(0, 0, 0, 0){}; > > > On 2017/04/25 17:28:58, sky wrote: > > > > (0,0,0,0) is the default, so need to specify margins_ here. > > > > > > Done. > > > > > > > > > https://codereview.chromium.org/2836313002/diff/1/ui/ > views/layout/box_layout.cc#newcode20 > > > ui/views/layout/box_layout.cc:20: BoxLayout::ViewWrapper:: > ViewWrapper(const > > > ViewWrapper& wrapper) > > > On 2017/04/25 17:28:58, sky wrote: > > > > = default? > > > > > > Done. > > > > > > > > > https://codereview.chromium.org/2836313002/diff/1/ui/ > views/layout/box_layout.cc#newcode34 > > > ui/views/layout/box_layout.cc:34: const_cast<View*>(view_)->SetBounds( > > > On 2017/04/25 17:28:58, sky wrote: > > > > Why the const_cast here? > > > > > > The view_ field is declared as "const View* view_;" Most references to > the > > view > > > are const. So I elected to cast the "const" away only at the one point > that > > > modifies the view. > > > > > > > > > https://codereview.chromium.org/2836313002/diff/1/ui/ > views/layout/box_layout.cc#newcode306 > > > ui/views/layout/box_layout.cc:306: gfx::Size > > > BoxLayout::GetPreferredSizeForChildWidth(const View* host, > > > On 2017/04/25 22:46:07, sky wrote: > > > > It seems like what you're doing here is getting the max of the > heights, > > which > > > > includes the margins. Shouldn't you calculate the max of the margins > and > > then > > > > add that to that the max of the views? For example, if the alignment > is > > > > horizontal and you have two views, A and B then I believe you're > calculating > > > the > > > > pref height as: > > > > > > > > Max(a_wrapper.preferred_size().height(), > > b_wrapper.preferred_size().height()); > > > > > > > > where _wrapper.preferred_size() includes the margin. > > > > > > > > Don't you want: > > > > Max(A.margin.top, B.margin.top) + > > > > Max(a.preferred_size.height(), b.preferred_size().height()) + > > > > Max(A.margin.bottom, B.margin.bottom); > > > > ? > > > > Similarly when you are positioning views I would assume you position > them > > > > relative to the max of the margins along the opposite axis. > > > > > > The next patch should resolve this confusion. The short answer is that > the > > > width/height of each view always includes its margins. No collapsing > is done > > at > > > this time. > > > > So again, I think this is wrong. I think the margin along the cross axis > should > > be the max of the margins for each view as I outlined above. > > I think I understand what you're getting at here. I consider this part of > the > work to collapse the margins. That includes collapsing each view's margins > with > the surrounding insets as well as the max of the margins along the cross > axis. > > I'm working on doing the margin collapse along all axes. I think I'll have > a > fairly simple solution in the next day or so. > > https://codereview.chromium.org/2836313002/ > -- You received this message because you are subscribed to the Google Groups "Chromium-reviews" group. To unsubscribe from this group and stop receiving emails from it, send an email to chromium-reviews+unsubscribe@chromium.org.
On 2017/05/03 00:03:09, sky wrote: > Glad to hear it! > > Don't hesitate to ask questions if I wasn't clear in my feedback. > > -Scott If the current patch can get Peter unblocked, might we go ahead and land it while I work on the margin collapsing? I will probably take at least the rest of the week and into next to work through the reviews, write the unit-tests and get the margin collapsing landed. I'd also like to look at merging/replacing the functionality of BoxLayout with AlignLayout. I have an idea to minimize the impact (other than the class/module/header names) on the existing code. > On Tue, May 2, 2017 at 1:37 PM, <mailto:kylixrd@chromium.org> wrote: > > > On 2017/04/28 19:20:59, sky wrote: > > > On 2017/04/26 17:41:33, kylix_rd wrote: > > > > > > > > > https://codereview.chromium.org/2836313002/diff/1/ui/ > > views/layout/box_layout.cc > > > > File ui/views/layout/box_layout.cc (right): > > > > > > > > > > > > > https://codereview.chromium.org/2836313002/diff/1/ui/ > > views/layout/box_layout.cc#newcode15 > > > > ui/views/layout/box_layout.cc:15: : view_(nullptr), layout_(nullptr), > > > > margins_(0, 0, 0, 0){}; > > > > On 2017/04/25 17:28:58, sky wrote: > > > > > (0,0,0,0) is the default, so need to specify margins_ here. > > > > > > > > Done. > > > > > > > > > > > > > https://codereview.chromium.org/2836313002/diff/1/ui/ > > views/layout/box_layout.cc#newcode20 > > > > ui/views/layout/box_layout.cc:20: BoxLayout::ViewWrapper:: > > ViewWrapper(const > > > > ViewWrapper& wrapper) > > > > On 2017/04/25 17:28:58, sky wrote: > > > > > = default? > > > > > > > > Done. > > > > > > > > > > > > > https://codereview.chromium.org/2836313002/diff/1/ui/ > > views/layout/box_layout.cc#newcode34 > > > > ui/views/layout/box_layout.cc:34: const_cast<View*>(view_)->SetBounds( > > > > On 2017/04/25 17:28:58, sky wrote: > > > > > Why the const_cast here? > > > > > > > > The view_ field is declared as "const View* view_;" Most references to > > the > > > view > > > > are const. So I elected to cast the "const" away only at the one point > > that > > > > modifies the view. > > > > > > > > > > > > > https://codereview.chromium.org/2836313002/diff/1/ui/ > > views/layout/box_layout.cc#newcode306 > > > > ui/views/layout/box_layout.cc:306: gfx::Size > > > > BoxLayout::GetPreferredSizeForChildWidth(const View* host, > > > > On 2017/04/25 22:46:07, sky wrote: > > > > > It seems like what you're doing here is getting the max of the > > heights, > > > which > > > > > includes the margins. Shouldn't you calculate the max of the margins > > and > > > then > > > > > add that to that the max of the views? For example, if the alignment > > is > > > > > horizontal and you have two views, A and B then I believe you're > > calculating > > > > the > > > > > pref height as: > > > > > > > > > > Max(a_wrapper.preferred_size().height(), > > > b_wrapper.preferred_size().height()); > > > > > > > > > > where _wrapper.preferred_size() includes the margin. > > > > > > > > > > Don't you want: > > > > > Max(A.margin.top, B.margin.top) + > > > > > Max(a.preferred_size.height(), b.preferred_size().height()) + > > > > > Max(A.margin.bottom, B.margin.bottom); > > > > > ? > > > > > Similarly when you are positioning views I would assume you position > > them > > > > > relative to the max of the margins along the opposite axis. > > > > > > > > The next patch should resolve this confusion. The short answer is that > > the > > > > width/height of each view always includes its margins. No collapsing > > is done > > > at > > > > this time. > > > > > > So again, I think this is wrong. I think the margin along the cross axis > > should > > > be the max of the margins for each view as I outlined above. > > > > I think I understand what you're getting at here. I consider this part of > > the > > work to collapse the margins. That includes collapsing each view's margins > > with > > the surrounding insets as well as the max of the margins along the cross > > axis. > > > > I'm working on doing the margin collapse along all axes. I think I'll have > > a > > fairly simple solution in the next day or so. > > > > https://codereview.chromium.org/2836313002/ > > > > -- > You received this message because you are subscribed to the Google Groups > "Chromium-reviews" group. > To unsubscribe from this group and stop receiving emails from it, send an email > to mailto:chromium-reviews+unsubscribe@chromium.org.
I believe Peter is out of the office right now, so I'm not sure he is blocked. Am I wrong there? I would also prefer to land this the right way rather than land something we know needs a lot of changes. -Scott On Wed, May 3, 2017 at 11:29 AM, <kylixrd@chromium.org> wrote: > On 2017/05/03 00:03:09, sky wrote: > > Glad to hear it! > > > > Don't hesitate to ask questions if I wasn't clear in my feedback. > > > > -Scott > > If the current patch can get Peter unblocked, might we go ahead and land it > while I work on the margin collapsing? I will probably take at least the > rest of > the week and into next to work through the reviews, write the unit-tests > and get > the margin collapsing landed. > > I'd also like to look at merging/replacing the functionality of BoxLayout > with > AlignLayout. I have an idea to minimize the impact (other than the > class/module/header names) on the existing code. > > > > On Tue, May 2, 2017 at 1:37 PM, <mailto:kylixrd@chromium.org> wrote: > > > > > On 2017/04/28 19:20:59, sky wrote: > > > > On 2017/04/26 17:41:33, kylix_rd wrote: > > > > > > > > > > > > https://codereview.chromium.org/2836313002/diff/1/ui/ > > > views/layout/box_layout.cc > > > > > File ui/views/layout/box_layout.cc (right): > > > > > > > > > > > > > > > > > https://codereview.chromium.org/2836313002/diff/1/ui/ > > > views/layout/box_layout.cc#newcode15 > > > > > ui/views/layout/box_layout.cc:15: : view_(nullptr), > layout_(nullptr), > > > > > margins_(0, 0, 0, 0){}; > > > > > On 2017/04/25 17:28:58, sky wrote: > > > > > > (0,0,0,0) is the default, so need to specify margins_ here. > > > > > > > > > > Done. > > > > > > > > > > > > > > > > > https://codereview.chromium.org/2836313002/diff/1/ui/ > > > views/layout/box_layout.cc#newcode20 > > > > > ui/views/layout/box_layout.cc:20: BoxLayout::ViewWrapper:: > > > ViewWrapper(const > > > > > ViewWrapper& wrapper) > > > > > On 2017/04/25 17:28:58, sky wrote: > > > > > > = default? > > > > > > > > > > Done. > > > > > > > > > > > > > > > > > https://codereview.chromium.org/2836313002/diff/1/ui/ > > > views/layout/box_layout.cc#newcode34 > > > > > ui/views/layout/box_layout.cc:34: const_cast<View*>(view_)-> > SetBounds( > > > > > On 2017/04/25 17:28:58, sky wrote: > > > > > > Why the const_cast here? > > > > > > > > > > The view_ field is declared as "const View* view_;" Most > references to > > > the > > > > view > > > > > are const. So I elected to cast the "const" away only at the one > point > > > that > > > > > modifies the view. > > > > > > > > > > > > > > > > > https://codereview.chromium.org/2836313002/diff/1/ui/ > > > views/layout/box_layout.cc#newcode306 > > > > > ui/views/layout/box_layout.cc:306: gfx::Size > > > > > BoxLayout::GetPreferredSizeForChildWidth(const View* host, > > > > > On 2017/04/25 22:46:07, sky wrote: > > > > > > It seems like what you're doing here is getting the max of the > > > heights, > > > > which > > > > > > includes the margins. Shouldn't you calculate the max of the > margins > > > and > > > > then > > > > > > add that to that the max of the views? For example, if the > alignment > > > is > > > > > > horizontal and you have two views, A and B then I believe you're > > > calculating > > > > > the > > > > > > pref height as: > > > > > > > > > > > > Max(a_wrapper.preferred_size().height(), > > > > b_wrapper.preferred_size().height()); > > > > > > > > > > > > where _wrapper.preferred_size() includes the margin. > > > > > > > > > > > > Don't you want: > > > > > > Max(A.margin.top, B.margin.top) + > > > > > > Max(a.preferred_size.height(), b.preferred_size().height()) + > > > > > > Max(A.margin.bottom, B.margin.bottom); > > > > > > ? > > > > > > Similarly when you are positioning views I would assume you > position > > > them > > > > > > relative to the max of the margins along the opposite axis. > > > > > > > > > > The next patch should resolve this confusion. The short answer is > that > > > the > > > > > width/height of each view always includes its margins. No > collapsing > > > is done > > > > at > > > > > this time. > > > > > > > > So again, I think this is wrong. I think the margin along the cross > axis > > > should > > > > be the max of the margins for each view as I outlined above. > > > > > > I think I understand what you're getting at here. I consider this part > of > > > the > > > work to collapse the margins. That includes collapsing each view's > margins > > > with > > > the surrounding insets as well as the max of the margins along the > cross > > > axis. > > > > > > I'm working on doing the margin collapse along all axes. I think I'll > have > > > a > > > fairly simple solution in the next day or so. > > > > > > https://codereview.chromium.org/2836313002/ > > > > > > > -- > > You received this message because you are subscribed to the Google Groups > > "Chromium-reviews" group. > > To unsubscribe from this group and stop receiving emails from it, send an > email > > to mailto:chromium-reviews+unsubscribe@chromium.org. > > > > https://codereview.chromium.org/2836313002/ > -- You received this message because you are subscribed to the Google Groups "Chromium-reviews" group. To unsubscribe from this group and stop receiving emails from it, send an email to chromium-reviews+unsubscribe@chromium.org.
Patchset #4 (id:60001) has been deleted
Here's BoxLayout with full margin collapsing. I've also got most of the work done on the BoxLayoutExample, which I also used to verify BoxLayout's function. I still need to augment the suite of unit tests for BoxLayout. BoxLayout itself should now be cleared for review. While that's happening I'll work on completing the BoxLayoutExample and the suite of unit tests. Feel free to comment on what is present in the BoxLayoutExample as well.
The CQ bit was checked by kylixrd@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
https://codereview.chromium.org/2836313002/diff/40001/ui/views/view.h File ui/views/view.h (right): https://codereview.chromium.org/2836313002/diff/40001/ui/views/view.h#newcode... ui/views/view.h:1705: VIEWS_EXPORT extern const ui::ClassProperty<gfx::Insets*>* const kMarginsKey; Please move this into it's own file, perhaps view_properties.h/.cc. https://codereview.chromium.org/2836313002/diff/80001/ui/views/examples/box_l... File ui/views/examples/box_layout_example.cc (right): https://codereview.chromium.org/2836313002/diff/80001/ui/views/examples/box_l... ui/views/examples/box_layout_example.cc:1: // Copyright (c) 2017 The Chromium Authors. All rights reserved. no (c) https://codereview.chromium.org/2836313002/diff/80001/ui/views/examples/box_l... ui/views/examples/box_layout_example.cc:31: class FullPanel : public View { Please add comments for classes. This name is confusing as I would naively expect the children to be given the full bounds, which isn't the case. Also, more often than not we use View in the name rather than panel. https://codereview.chromium.org/2836313002/diff/80001/ui/views/examples/box_l... ui/views/examples/box_layout_example.cc:36: void Layout() override; Prefix with where override comes from. https://codereview.chromium.org/2836313002/diff/80001/ui/views/examples/box_l... ui/views/examples/box_layout_example.cc:44: ChildPanel(BoxLayoutExample* example); explicit. https://codereview.chromium.org/2836313002/diff/80001/ui/views/examples/box_l... ui/views/examples/box_layout_example.cc:74: class ExampleModel : public ui::ComboboxModel { Can you use ui/views/examples/example_combobox_model.h ? https://codereview.chromium.org/2836313002/diff/80001/ui/views/examples/box_l... ui/views/examples/box_layout_example.cc:79: // ComboboxModel newline between 78/79. https://codereview.chromium.org/2836313002/diff/80001/ui/views/examples/box_l... ui/views/examples/box_layout_example.cc:393: base::StringToInt(between_child_spacing_->text(), &child_spacing); Remember that conversion may fail and return false, in which case the field isn't updated. https://codereview.chromium.org/2836313002/diff/80001/ui/views/examples/box_l... File ui/views/examples/box_layout_example.h (right): https://codereview.chromium.org/2836313002/diff/80001/ui/views/examples/box_l... ui/views/examples/box_layout_example.h:1: // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2017, and we don't use (c) in chromium. https://codereview.chromium.org/2836313002/diff/80001/ui/views/examples/box_l... ui/views/examples/box_layout_example.h:25: class ViewListener { This name is overly generic. How about a more specific name such as BoxLayoutExampleListener? https://codereview.chromium.org/2836313002/diff/80001/ui/views/examples/box_l... ui/views/examples/box_layout_example.h:63: void RefreshLayoutPanel(); moooaaarrrr comments please! https://codereview.chromium.org/2836313002/diff/80001/ui/views/examples/box_l... ui/views/examples/box_layout_example.h:85: #endif // UI_VIEWS_EXAMPLES_BOX_LAYOUT_EXAMPLE_H_ newline between 84/85 https://codereview.chromium.org/2836313002/diff/80001/ui/views/layout/box_lay... File ui/views/layout/box_layout.cc (right): https://codereview.chromium.org/2836313002/diff/80001/ui/views/layout/box_lay... ui/views/layout/box_layout.cc:28: : view_->GetHeightForWidth(width - margins_.width()) + Make sure you don't go negative here. https://codereview.chromium.org/2836313002/diff/80001/ui/views/layout/box_lay... ui/views/layout/box_layout.cc:43: view_->SetBounds(bounds.x() + margins_.left(), bounds.y() + margins_.top(), optional: use {} around this if given the body spans multiple lines. https://codereview.chromium.org/2836313002/diff/80001/ui/views/layout/box_lay... ui/views/layout/box_layout.cc:44: bounds.width() - margins_.width(), Do you need to protect against going negative? https://codereview.chromium.org/2836313002/diff/80001/ui/views/layout/box_lay... ui/views/layout/box_layout.cc:328: if (collapse_margins_spacing_) { Generally we prefer early return than lots of nesting. https://codereview.chromium.org/2836313002/diff/80001/ui/views/layout/box_lay... ui/views/layout/box_layout.cc:336: rect->set_width((rect->right() - std::max(inside_border_insets_.right(), Make sure you don't end up with a negative width (or height below). https://codereview.chromium.org/2836313002/diff/80001/ui/views/layout/box_lay... ui/views/layout/box_layout.cc:350: void BoxLayout::AdjustCrossAxisForMargin(const ViewWrapper& child, I don't think this implements what I outlined in comment #6: https://codereview.chromium.org/2836313002/#msg6 . My suggestion there is I think the cross axis margins should be the max of across all children. I say this as to do otherwise means the views aren't going to be aligned nicely on the cross axis, they'll be staggered. https://codereview.chromium.org/2836313002/diff/80001/ui/views/layout/box_lay... ui/views/layout/box_layout.cc:449: DCHECK_EQ(host_, host); Why bother with passing in host when host_ is already a member? Same comment for the other functions. https://codereview.chromium.org/2836313002/diff/80001/ui/views/layout/box_lay... File ui/views/layout/box_layout.h (right): https://codereview.chromium.org/2836313002/diff/80001/ui/views/layout/box_lay... ui/views/layout/box_layout.h:29: class VIEWS_EXPORT BoxLayout : public LayoutManager { You should make this class a ViewObserver on the views so that if the margins change you trigger a layout. You can do this in a separate patch as you'll need to change ViewObserver. https://codereview.chromium.org/2836313002/diff/80001/ui/views/layout/box_lay... ui/views/layout/box_layout.h:73: bool collapse_margins_spacing); Merge this with other constructor and make collapse_margins_spacing have a default value. https://codereview.chromium.org/2836313002/diff/80001/ui/views/layout/box_lay... ui/views/layout/box_layout.h:116: // This struct is used internally to "wrap" a child view in order to obviate Thanks for the detailed comments! https://codereview.chromium.org/2836313002/diff/80001/ui/views/layout/box_lay... ui/views/layout/box_layout.h:127: struct ViewWrapper { Style guide says, "Use a struct only for passive objects that carry data; everything else is a class." Given you have a bunch of functions use a class here. https://codereview.chromium.org/2836313002/diff/80001/ui/views/layout/box_lay... ui/views/layout/box_layout.h:235: bool collapse_margins_spacing_; const
Some things were already addressed in a subsequent patch prior to the comments. Others are in process. https://codereview.chromium.org/2836313002/diff/80001/ui/views/examples/box_l... File ui/views/examples/box_layout_example.cc (right): https://codereview.chromium.org/2836313002/diff/80001/ui/views/examples/box_l... ui/views/examples/box_layout_example.cc:393: base::StringToInt(between_child_spacing_->text(), &child_spacing); On 2017/05/09 19:26:03, sky wrote: > Remember that conversion may fail and return false, in which case the field > isn't updated. According to the doc, errors will set |*output| to 0, which is fine in this instance. https://codereview.chromium.org/2836313002/diff/80001/ui/views/examples/box_l... File ui/views/examples/box_layout_example.h (right): https://codereview.chromium.org/2836313002/diff/80001/ui/views/examples/box_l... ui/views/examples/box_layout_example.h:1: // Copyright (c) 2012 The Chromium Authors. All rights reserved. On 2017/05/09 19:26:03, sky wrote: > 2017, and we don't use (c) in chromium. Thanks. Copy-pasta error. Copied block from another file and didn't update. https://codereview.chromium.org/2836313002/diff/80001/ui/views/layout/box_lay... File ui/views/layout/box_layout.cc (right): https://codereview.chromium.org/2836313002/diff/80001/ui/views/layout/box_lay... ui/views/layout/box_layout.cc:328: if (collapse_margins_spacing_) { On 2017/05/09 19:26:03, sky wrote: > Generally we prefer early return than lots of nesting. "if" block gone in subsequent patch. https://codereview.chromium.org/2836313002/diff/80001/ui/views/layout/box_lay... ui/views/layout/box_layout.cc:350: void BoxLayout::AdjustCrossAxisForMargin(const ViewWrapper& child, On 2017/05/09 19:26:03, sky wrote: > I don't think this implements what I outlined in comment #6: > https://codereview.chromium.org/2836313002/#msg6 . My suggestion there is I > think the cross axis margins should be the max of across all children. I say > this as to do otherwise means the views aren't going to be aligned nicely on the > cross axis, they'll be staggered. In all modes other than stretch, they'll be staggered anyway. If alignment is wanted, cross-axis margins should be set consistently. I was just maintaining that "feature" of the layout. https://codereview.chromium.org/2836313002/diff/80001/ui/views/layout/box_lay... ui/views/layout/box_layout.cc:449: DCHECK_EQ(host_, host); On 2017/05/09 19:26:03, sky wrote: > Why bother with passing in host when host_ is already a member? Same comment for > the other functions. I was keeping the established pattern... odd that it may be. I'll go ahead and fix it. (remove all the redundant "host" parameters). https://codereview.chromium.org/2836313002/diff/80001/ui/views/layout/box_lay... File ui/views/layout/box_layout.h (right): https://codereview.chromium.org/2836313002/diff/80001/ui/views/layout/box_lay... ui/views/layout/box_layout.h:73: bool collapse_margins_spacing); On 2017/05/09 19:26:03, sky wrote: > Merge this with other constructor and make collapse_margins_spacing have a > default value. I'm wondering if the default should be "true". It has a zero net-effect if there are no margins set on the individual views. https://codereview.chromium.org/2836313002/diff/80001/ui/views/layout/box_lay... ui/views/layout/box_layout.h:127: struct ViewWrapper { On 2017/05/09 19:26:03, sky wrote: > Style guide says, "Use a struct only for passive objects that carry data; > everything else is a class." Given you have a bunch of functions use a class > here. Sure thing. This comes from my notion that "class" is for dynamically allocated objects (ie. new & delete) and "struct" (or "record" in Delphi) is for stack-based or inplace-allocated instances. Old habits and all :).
https://codereview.chromium.org/2836313002/diff/80001/ui/views/layout/box_lay... File ui/views/layout/box_layout.cc (right): https://codereview.chromium.org/2836313002/diff/80001/ui/views/layout/box_lay... ui/views/layout/box_layout.cc:350: void BoxLayout::AdjustCrossAxisForMargin(const ViewWrapper& child, On 2017/05/09 20:07:06, kylix_rd wrote: > On 2017/05/09 19:26:03, sky wrote: > > I don't think this implements what I outlined in comment #6: > > https://codereview.chromium.org/2836313002/#msg6 . My suggestion there is I > > think the cross axis margins should be the max of across all children. I say > > this as to do otherwise means the views aren't going to be aligned nicely on > the > > cross axis, they'll be staggered. > > In all modes other than stretch, they'll be staggered anyway. If alignment is > wanted, cross-axis margins should be set consistently. I was just maintaining > that "feature" of the layout. That makes it rather painful to set margins, in so far as you have to be sure to set them consistently. In an ideal world it seems harmony would set default margins based on the type (which I thought Peter mentioned the harmony specs called for) and they would just work. By work I mean you would end up with nice results, without having to iterate over children and reset the values to be consistent. Can you think of a reason why you would not want cross axis margins to effectively be the same? From what I could see of earlier screenshots it seems they wanted to use the max as I am asking for here. https://codereview.chromium.org/2836313002/diff/80001/ui/views/layout/box_lay... File ui/views/layout/box_layout.h (right): https://codereview.chromium.org/2836313002/diff/80001/ui/views/layout/box_lay... ui/views/layout/box_layout.h:73: bool collapse_margins_spacing); On 2017/05/09 20:07:06, kylix_rd wrote: > On 2017/05/09 19:26:03, sky wrote: > > Merge this with other constructor and make collapse_margins_spacing have a > > default value. > > I'm wondering if the default should be "true". It has a zero net-effect if there > are no margins set on the individual views. I think existing consumers should have to opt into the new behavior. I say that based on a feeling that harmony would want to set default margins at view creation time, but I could certainly be wrong there.
As for the unification of the cross-axis margins, I'll think about that some more. My first thought is that if the cross-axis margins need to be consistent, then the user can keep the margins on that axis as 0 and then set the appropriate inside_border_xxxx_spacing. There is no reason that each side of margins must be the same. IMO, because the user can do something wrong with something in some instances, doesn't mean it shouldn't be allowed in other instances. https://codereview.chromium.org/2836313002/diff/80001/ui/views/examples/box_l... File ui/views/examples/box_layout_example.cc (right): https://codereview.chromium.org/2836313002/diff/80001/ui/views/examples/box_l... ui/views/examples/box_layout_example.cc:31: class FullPanel : public View { On 2017/05/09 19:26:02, sky wrote: > Please add comments for classes. This name is confusing as I would naively > expect the children to be given the full bounds, which isn't the case. Also, > more often than not we use View in the name rather than panel. Done. https://codereview.chromium.org/2836313002/diff/80001/ui/views/examples/box_l... ui/views/examples/box_layout_example.cc:36: void Layout() override; On 2017/05/09 19:26:03, sky wrote: > Prefix with where override comes from. Done. https://codereview.chromium.org/2836313002/diff/80001/ui/views/examples/box_l... ui/views/examples/box_layout_example.cc:44: ChildPanel(BoxLayoutExample* example); On 2017/05/09 19:26:02, sky wrote: > explicit. Done. https://codereview.chromium.org/2836313002/diff/80001/ui/views/examples/box_l... ui/views/examples/box_layout_example.cc:74: class ExampleModel : public ui::ComboboxModel { On 2017/05/09 19:26:03, sky wrote: > Can you use ui/views/examples/example_combobox_model.h ? Yep. I didn't notice it was there. Done. https://codereview.chromium.org/2836313002/diff/80001/ui/views/examples/box_l... File ui/views/examples/box_layout_example.h (right): https://codereview.chromium.org/2836313002/diff/80001/ui/views/examples/box_l... ui/views/examples/box_layout_example.h:25: class ViewListener { On 2017/05/09 19:26:03, sky wrote: > This name is overly generic. How about a more specific name such as > BoxLayoutExampleListener? Upon further review, this isn't necessary at this time. https://codereview.chromium.org/2836313002/diff/80001/ui/views/examples/box_l... ui/views/examples/box_layout_example.h:63: void RefreshLayoutPanel(); On 2017/05/09 19:26:03, sky wrote: > moooaaarrrr comments please! Done. https://codereview.chromium.org/2836313002/diff/80001/ui/views/layout/box_lay... File ui/views/layout/box_layout.h (right): https://codereview.chromium.org/2836313002/diff/80001/ui/views/layout/box_lay... ui/views/layout/box_layout.h:73: bool collapse_margins_spacing); On 2017/05/09 19:26:03, sky wrote: > Merge this with other constructor and make collapse_margins_spacing have a > default value. Done. https://codereview.chromium.org/2836313002/diff/80001/ui/views/layout/box_lay... ui/views/layout/box_layout.h:127: struct ViewWrapper { On 2017/05/09 19:26:03, sky wrote: > Style guide says, "Use a struct only for passive objects that carry data; > everything else is a class." Given you have a bunch of functions use a class > here. Done. https://codereview.chromium.org/2836313002/diff/80001/ui/views/layout/box_lay... ui/views/layout/box_layout.h:235: bool collapse_margins_spacing_; On 2017/05/09 19:26:03, sky wrote: > const Done.
The CQ bit was checked by kylixrd@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: linux_chromium_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...)
Peter should weigh in on this, but again my thinking is that we will end up in a place where margins are injected based on type and perhaps context. As the margins are injected they may have different sizes (the mocks Peter pointed out in the thread that lead to this patch had different cross axis margins). In this scenario I think the expectation is you use the biggest cross axis margin, otherwise the layout is not going to look good. -Scott On Wed, May 10, 2017 at 8:30 AM, <kylixrd@chromium.org> wrote: > As for the unification of the cross-axis margins, I'll think about that > some > more. My first thought is that if the cross-axis margins need to be > consistent, > then the user can keep the margins on that axis as 0 and then set the > appropriate inside_border_xxxx_spacing. There is no reason that each side > of > margins must be the same. > > IMO, because the user can do something wrong with something in some > instances, > doesn't mean it shouldn't be allowed in other instances. > > > https://codereview.chromium.org/2836313002/diff/80001/ui/ > views/examples/box_layout_example.cc > File ui/views/examples/box_layout_example.cc (right): > > https://codereview.chromium.org/2836313002/diff/80001/ui/ > views/examples/box_layout_example.cc#newcode31 > ui/views/examples/box_layout_example.cc:31: class FullPanel : public > View { > On 2017/05/09 19:26:02, sky wrote: > > Please add comments for classes. This name is confusing as I would > naively > > expect the children to be given the full bounds, which isn't the case. > Also, > > more often than not we use View in the name rather than panel. > > Done. > > https://codereview.chromium.org/2836313002/diff/80001/ui/ > views/examples/box_layout_example.cc#newcode36 > ui/views/examples/box_layout_example.cc:36: void Layout() override; > On 2017/05/09 19:26:03, sky wrote: > > Prefix with where override comes from. > > Done. > > https://codereview.chromium.org/2836313002/diff/80001/ui/ > views/examples/box_layout_example.cc#newcode44 > ui/views/examples/box_layout_example.cc:44: ChildPanel(BoxLayoutExample* > example); > On 2017/05/09 19:26:02, sky wrote: > > explicit. > > Done. > > https://codereview.chromium.org/2836313002/diff/80001/ui/ > views/examples/box_layout_example.cc#newcode74 > ui/views/examples/box_layout_example.cc:74: class ExampleModel : public > ui::ComboboxModel { > On 2017/05/09 19:26:03, sky wrote: > > Can you use ui/views/examples/example_combobox_model.h ? > > Yep. I didn't notice it was there. > > Done. > > https://codereview.chromium.org/2836313002/diff/80001/ui/ > views/examples/box_layout_example.h > File ui/views/examples/box_layout_example.h (right): > > https://codereview.chromium.org/2836313002/diff/80001/ui/ > views/examples/box_layout_example.h#newcode25 > ui/views/examples/box_layout_example.h:25: class ViewListener { > On 2017/05/09 19:26:03, sky wrote: > > This name is overly generic. How about a more specific name such as > > BoxLayoutExampleListener? > > Upon further review, this isn't necessary at this time. > > https://codereview.chromium.org/2836313002/diff/80001/ui/ > views/examples/box_layout_example.h#newcode63 > ui/views/examples/box_layout_example.h:63: void RefreshLayoutPanel(); > On 2017/05/09 19:26:03, sky wrote: > > moooaaarrrr comments please! > > Done. > > https://codereview.chromium.org/2836313002/diff/80001/ui/ > views/layout/box_layout.h > File ui/views/layout/box_layout.h (right): > > https://codereview.chromium.org/2836313002/diff/80001/ui/ > views/layout/box_layout.h#newcode73 > ui/views/layout/box_layout.h:73: bool collapse_margins_spacing); > On 2017/05/09 19:26:03, sky wrote: > > Merge this with other constructor and make collapse_margins_spacing > have a > > default value. > > Done. > > https://codereview.chromium.org/2836313002/diff/80001/ui/ > views/layout/box_layout.h#newcode127 > ui/views/layout/box_layout.h:127: struct ViewWrapper { > On 2017/05/09 19:26:03, sky wrote: > > Style guide says, "Use a struct only for passive objects that carry > data; > > everything else is a class." Given you have a bunch of functions use a > class > > here. > > Done. > > https://codereview.chromium.org/2836313002/diff/80001/ui/ > views/layout/box_layout.h#newcode235 > ui/views/layout/box_layout.h:235: bool collapse_margins_spacing_; > On 2017/05/09 19:26:03, sky wrote: > > const > > Done. > > https://codereview.chromium.org/2836313002/ > -- You received this message because you are subscribed to the Google Groups "Chromium-reviews" group. To unsubscribe from this group and stop receiving emails from it, send an email to chromium-reviews+unsubscribe@chromium.org.
Patchset #7 (id:140001) has been deleted
The CQ bit was checked by kylixrd@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
It seems like there are generally two routes to go with most of the cross-axis alignment values: (1) Position/size the views against each other ignoring their margins; then tack on the margins and fit the container around the result. (2) Size the container based on overall view + margin sizes, then position/size each view against the container. For example, assume you have views like: MMMM VVVV MMMM VVVV MMMM VVVV VVVV VVVV MMMM (Here we have three horizontally-laid-out views VVVV, with vertical margins MMMM.) Here are the alignments that result from these different methods: STRETCH (1): STRETCH (2): -------------- -------------- MMMM MMMM VVVV MMMM MMMM MMMM VVVV VVVV MMMM VVVV VVVV VVVV VVVV VVVV VVVV VVVV VVVV VVVV VVVV VVVV VVVV VVVV VVVV VVVV MMMM VVVV VVVV MMMM -------------- -------------- START (1): START (2): -------------- -------------- MMMM MMMM VVVV MMMM MMMM MMMM VVVV MMMM VVVV VVVV VVVV VVVV VVVV VVVV VVVV VVVV MMMM MMMM -------------- -------------- CENTER (1) or (2):* -------------- MMMM MMMM VVVV MMMM VVVV VVVV VVVV VVVV MMMM -------------- END (1): END (2): -------------- -------------- MMMM MMMM VVVV MMMM VVVV VVVV MMMM VVVV MMMM VVVV VVVV VVVV VVVV MMMM MMMM MMMM VVVV VVVV -------------- -------------- *I think methods (1) and (2) always produce the same results for CENTER. However, there's a separate question: when top and bottom margins are unequal, do we fit the container tightly around the views + margins, or do we potentially expand its height as needed so the view centerline can be on the container centerline? Consider a simple two-view case for example: Fit tightly: Expand height: --------- --------- MMMM MMMM VVVV VVVV VVVV VVVV --------- --------- Looking at all these, I think there are cases where one might want each; but overall I think route (1) makes more sense. Does that answer the question?
Based on Peter's highly detailed and epic ASCII art illustration, this patch implements (1). It also addresses some more of the feedback from previous patches. The example is now very illustrative when exercised interactively. Proper unit-tests are the next step now that (I think) the functionality has been nailed down. https://codereview.chromium.org/2836313002/diff/80001/ui/views/layout/box_lay... File ui/views/layout/box_layout.cc (right): https://codereview.chromium.org/2836313002/diff/80001/ui/views/layout/box_lay... ui/views/layout/box_layout.cc:28: : view_->GetHeightForWidth(width - margins_.width()) + On 2017/05/09 19:26:03, sky wrote: > Make sure you don't go negative here. Done. https://codereview.chromium.org/2836313002/diff/80001/ui/views/layout/box_lay... ui/views/layout/box_layout.cc:43: view_->SetBounds(bounds.x() + margins_.left(), bounds.y() + margins_.top(), On 2017/05/09 19:26:03, sky wrote: > optional: use {} around this if given the body spans multiple lines. Done. https://codereview.chromium.org/2836313002/diff/80001/ui/views/layout/box_lay... ui/views/layout/box_layout.cc:44: bounds.width() - margins_.width(), On 2017/05/09 19:26:03, sky wrote: > Do you need to protect against going negative? Done. https://codereview.chromium.org/2836313002/diff/80001/ui/views/layout/box_lay... ui/views/layout/box_layout.cc:336: rect->set_width((rect->right() - std::max(inside_border_insets_.right(), On 2017/05/09 19:26:03, sky wrote: > Make sure you don't end up with a negative width (or height below). Done.
The CQ bit was checked by kylixrd@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: linux_android_rel_ng on master.tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/linux_androi...)
The CQ bit was checked by kylixrd@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
This includes some unit tests which will ensure margins are taken into account and/or collapsed when collapse_margins_spacing is true. The unit tests also demonstrated (go unit tests!) that BoxLayout::GetPreferredSize() wasn't being calculated correctly, so that is also fixed in this patch. Because of that I broke out the logic from the AdjustxxxAxisForMargin() methods into xxxAxisOuterMargin() methods, respectively. For the record, it's silly that gfx::Rect and gfx::Insets take the integer parameters in a different order :).
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: android_n5x_swarming_rel on master.tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/android_n5x_...)
Peter, I stared at your ASCII art for a good ten minutes and couldn't make heads or tails of it. Specifically you said there are three horizontally laid out views (VVVV), yet I see more: MMMM VVVV MMMM VVVV MMMM VVVV VVVV VVVV MMMM I don't understand what this means. If the views are laid out horizontally how can you have two views in column two? No doubt I'm reading this wrong. I feel like this would be a lot easier to resolve in front of a whiteboard. I'm in Waterloo until Tuesday and back in the MTV office Wednesday. Could this wait until then? -Scott On Wed, May 10, 2017 at 11:07 AM, <pkasting@chromium.org> wrote: > It seems like there are generally two routes to go with most of the > cross-axis > alignment values: > > (1) Position/size the views against each other ignoring their margins; > then tack > on the margins and fit the container around the result. > (2) Size the container based on overall view + margin sizes, then > position/size > each view against the container. > > For example, assume you have views like: > > MMMM VVVV MMMM > VVVV MMMM > VVVV VVVV > VVVV > MMMM > > (Here we have three horizontally-laid-out views VVVV, with vertical margins > MMMM.) > > Here are the alignments that result from these different methods: > > STRETCH (1): STRETCH (2): > -------------- -------------- > MMMM MMMM VVVV MMMM > MMMM MMMM VVVV VVVV MMMM > VVVV VVVV VVVV VVVV VVVV VVVV > VVVV VVVV VVVV VVVV VVVV VVVV > VVVV VVVV VVVV MMMM VVVV VVVV > MMMM -------------- > -------------- > > > START (1): START (2): > -------------- -------------- > MMMM MMMM VVVV MMMM > MMMM MMMM VVVV MMMM > VVVV VVVV VVVV VVVV VVVV > VVVV VVVV > VVVV MMMM > MMMM -------------- > -------------- > > > CENTER (1) or (2):* > -------------- > MMMM MMMM > VVVV MMMM > VVVV VVVV VVVV > VVVV > MMMM > -------------- > > > END (1): END (2): > -------------- -------------- > MMMM MMMM > VVVV MMMM VVVV > VVVV MMMM VVVV MMMM > VVVV VVVV VVVV VVVV MMMM > MMMM MMMM VVVV VVVV > -------------- -------------- > > > *I think methods (1) and (2) always produce the same results for CENTER. > However, there's a separate question: when top and bottom margins are > unequal, > do we fit the container tightly around the views + margins, or do we > potentially > expand its height as needed so the view centerline can be on the container > centerline? Consider a simple two-view case for example: > > Fit tightly: Expand height: > --------- --------- > MMMM MMMM > VVVV VVVV VVVV VVVV > --------- > --------- > > > Looking at all these, I think there are cases where one might want each; > but > overall I think route (1) makes more sense. > > Does that answer the question? > > https://codereview.chromium.org/2836313002/ > -- You received this message because you are subscribed to the Google Groups "Chromium-reviews" group. To unsubscribe from this group and stop receiving emails from it, send an email to chromium-reviews+unsubscribe@chromium.org.
On 2017/05/12 14:03:10, sky wrote: > Peter, > > I stared at your ASCII art for a good ten minutes and couldn't make heads > or tails of it. Specifically you said there are three horizontally laid out > views (VVVV), yet I see more: > > MMMM VVVV MMMM > VVVV MMMM > VVVV VVVV > VVVV > MMMM > > I don't understand what this means. If the views are laid out horizontally > how can you have two views in column two? No doubt I'm reading this wrong. > > I feel like this would be a lot easier to resolve in front of a whiteboard. > I'm in Waterloo until Tuesday and back in the MTV office Wednesday. Could > this wait until then? > > -Scott If you view it on the review page itself it looks fine. His post relied on the fixed pitch font used for the review app.
On 2017/05/12 15:25:53, kylix_rd wrote: > On 2017/05/12 14:03:10, sky wrote: > > Peter, > > > > I stared at your ASCII art for a good ten minutes and couldn't make heads > > or tails of it. Specifically you said there are three horizontally laid out > > views (VVVV), yet I see more: > > > > MMMM VVVV MMMM > > VVVV MMMM > > VVVV VVVV > > VVVV > > MMMM > > > > I don't understand what this means. If the views are laid out horizontally > > how can you have two views in column two? No doubt I'm reading this wrong. > > > > I feel like this would be a lot easier to resolve in front of a whiteboard. > > I'm in Waterloo until Tuesday and back in the MTV office Wednesday. Could > > this wait until then? > > > > -Scott > > If you view it on the review page itself it looks fine. His post relied on the > fixed pitch font used for the review app. I'm advocating for something like 1, but not quite. In words the margins are *always* fixed to the max of the margins of each view (along the cross axis). START (1 and 3): START (2): -------------- -------------- MMMM MMMM VVVV MMMM MMMM MMMM VVVV MMMM VVVV VVVV VVVV VVVV VVVV VVVV VVVV VVVV MMMM MMMM -------------- -------------- CENTER (1) or (2):* CENTER (3): -------------- -------------- MMMM MMMM MMMM VVVV MMMM MMMM MMMM VVVV VVVV VVVV VVVV VVVV VVVV VVVV VVVV MMMM VVVV -------------- MMMM -------------- END (1): END (2): END (3): -------------- -------------- -------------- MMMM MMMM MMMM VVVV MMMM VVVV MMMM MMMM VVVV MMMM VVVV MMMM VVVV VVVV VVVV VVVV VVVV MMMM VVVV MMMM MMMM VVVV VVVV VVVV VVVV VVVV -------------- -------------- MMMM -------------- Why do this? I believe it produces the result best matching what a designer would want and the most visually pleasing.
On 2017/05/12 19:41:43, sky wrote: > I'm advocating for something like 1, but not quite. In words the margins are > *always* fixed to the max of the margins of each view (along the cross axis). > > START (1 and 3): START (2): > -------------- -------------- > MMMM MMMM VVVV MMMM > MMMM MMMM VVVV MMMM > VVVV VVVV VVVV VVVV VVVV > VVVV VVVV > VVVV MMMM > MMMM -------------- > -------------- > > > CENTER (1) or (2):* CENTER (3): > -------------- -------------- > MMMM MMMM MMMM > VVVV MMMM MMMM MMMM > VVVV VVVV VVVV VVVV > VVVV VVVV VVVV VVVV > MMMM VVVV > -------------- MMMM > -------------- > > END (1): END (2): END (3): > -------------- -------------- -------------- > MMMM MMMM MMMM > VVVV MMMM VVVV MMMM MMMM > VVVV MMMM VVVV MMMM VVVV > VVVV VVVV VVVV VVVV MMMM VVVV > MMMM MMMM VVVV VVVV VVVV VVVV VVVV > -------------- -------------- MMMM > -------------- > > Why do this? I believe it produces the result best matching what a designer > would want and the most visually pleasing. Hmm. I understand what you're asking for, but to me this would make less sense and be less practically useful. Basically, I think of a "margin" as saying "my view needs at least X space on this side". Route (1) alone already guarantees this. Route (3) is basically saying, let's create a "margin row" above and below the views, sized to the max margin heights. Effectively, this is a way of saying that view 3's margin dictates how much space is above view 1 _even when view 3 doesn't need that space_. That seems strange. And practically, this sort of thing can be accomplished with gridlayout/nested layouts today much more easily (I think) than route (1) can be accomplished today, so it adds less value to do this. I don't know if there are examples of margins in CSS or something that would suggest how other developers might expect margins to behave; if so that'd be another data point here.
In earlier email threads I thought we wanted to head toward a place where views automatically get margins at some point in their lifetime. The margin is determined based on type and perhaps context. This comes from the email thread "Adding a margin to a view." If you agree with this, then the place creating the views (infobar code in your case), isn't explicitly setting the margins. In such a scenario it's all too easy to end up with different cross axis margins. Using different cross axis margins will result in a bad layout. All of the examples I see at https://folio.googleplex.com/chrome-ux-specs-and-sources/Chrome%20browser%20(... have the same cross axis margin. This is why I think the cross axis margins should be the max. Do you disagree with the path I've outlined? Can you think of places where you would actually want different cross axis margins? I've outlined my reasoning for the route I think this code should go, but at the end of the day you guys are actually using it. So, if my latest comments aren't enough to convince you, then we go with route 1. I'll wait for a response and then we'll take it from there. -Scott On Fri, May 12, 2017 at 12:59 PM, <pkasting@chromium.org> wrote: > On 2017/05/12 19:41:43, sky wrote: > > I'm advocating for something like 1, but not quite. In words the margins > are > > *always* fixed to the max of the margins of each view (along the cross > axis). > > > > START (1 and 3): START (2): > > -------------- -------------- > > MMMM MMMM VVVV MMMM > > MMMM MMMM VVVV MMMM > > VVVV VVVV VVVV VVVV VVVV > > VVVV VVVV > > VVVV MMMM > > MMMM -------------- > > -------------- > > > > > > CENTER (1) or (2):* CENTER (3): > > -------------- -------------- > > MMMM MMMM MMMM > > VVVV MMMM MMMM MMMM > > VVVV VVVV VVVV VVVV > > VVVV VVVV VVVV VVVV > > MMMM VVVV > > -------------- MMMM > > -------------- > > > > END (1): END (2): END (3): > > -------------- -------------- -------------- > > MMMM MMMM MMMM > > VVVV MMMM VVVV MMMM MMMM > > VVVV MMMM VVVV MMMM VVVV > > VVVV VVVV VVVV VVVV MMMM VVVV > > MMMM MMMM VVVV VVVV VVVV VVVV VVVV > > -------------- -------------- MMMM > > -------------- > > > > Why do this? I believe it produces the result best matching what a > designer > > would want and the most visually pleasing. > > Hmm. I understand what you're asking for, but to me this would make less > sense > and be less practically useful. > > Basically, I think of a "margin" as saying "my view needs at least X space > on > this side". Route (1) alone already guarantees this. > > Route (3) is basically saying, let's create a "margin row" above and below > the > views, sized to the max margin heights. Effectively, this is a way of > saying > that view 3's margin dictates how much space is above view 1 _even when > view 3 > doesn't need that space_. That seems strange. And practically, this sort of > thing can be accomplished with gridlayout/nested layouts today much more > easily > (I think) than route (1) can be accomplished today, so it adds less value > to do > this. > > I don't know if there are examples of margins in CSS or something that > would > suggest how other developers might expect margins to behave; if so that'd > be > another data point here. > > https://codereview.chromium.org/2836313002/ > -- You received this message because you are subscribed to the Google Groups "Chromium-reviews" group. To unsubscribe from this group and stop receiving emails from it, send an email to chromium-reviews+unsubscribe@chromium.org.
On 2017/05/14 14:04:25, sky wrote: > In earlier email threads I thought we wanted to head toward a place where > views automatically get margins at some point in their lifetime. The margin > is determined based on type and perhaps context. This comes from the email > thread "Adding a margin to a view." If you agree with this, then the place > creating the views (infobar code in your case), isn't explicitly setting > the margins. In such a scenario it's all too easy to end up with different > cross axis margins. Using different cross axis margins will result in a bad > layout. All of the examples I see at > https://folio.googleplex.com/chrome-ux-specs-and-sources/Chrome%20browser%20(... > have the same cross axis margin. This is why I think the cross axis margins > should be the max. > > Do you disagree with the path I've outlined? Can you think of places where > you would actually want different cross axis margins? I actually hope to implement the spec using different cross-axis margins with centered layout, and if I do so, then route (3) will break things. Consider the zoom bubble case in the "toasts with buttons" mock: if I stick a 12 pt top and bottom margin on the label and 8 pt top and bottom margins on the buttons, and then center, then route (1) and (2) give me what I want, but route (3) gives me 12 pt margins outside the buttons. I could choose to implement differently, but the goal of this implementation path was that the zoom bubble not need to care what the child margins are, and the children not need to know which kinds of siblings they have.
(3) it is. Will review shortly. On Mon, May 15, 2017 at 10:06 AM, <pkasting@chromium.org> wrote: > On 2017/05/14 14:04:25, sky wrote: > > In earlier email threads I thought we wanted to head toward a place where > > views automatically get margins at some point in their lifetime. The > margin > > is determined based on type and perhaps context. This comes from the > email > > thread "Adding a margin to a view." If you agree with this, then the > place > > creating the views (infobar code in your case), isn't explicitly setting > > the margins. In such a scenario it's all too easy to end up with > different > > cross axis margins. Using different cross axis margins will result in a > bad > > layout. All of the examples I see at > > > https://folio.googleplex.com/chrome-ux-specs-and-sources/ > Chrome%20browser%20(MD)/Secondary%20UI%20Previews% > 20and%20specs%20(exports)/Spec#%2FSPEC-secondary-UI-07a- > layout.png%3Ff=hidden > > have the same cross axis margin. This is why I think the cross axis > margins > > should be the max. > > > > Do you disagree with the path I've outlined? Can you think of places > where > > you would actually want different cross axis margins? > > I actually hope to implement the spec using different cross-axis margins > with > centered layout, and if I do so, then route (3) will break things. > Consider the > zoom bubble case in the "toasts with buttons" mock: if I stick a 12 pt top > and > bottom margin on the label and 8 pt top and bottom margins on the buttons, > and > then center, then route (1) and (2) give me what I want, but route (3) > gives me > 12 pt margins outside the buttons. > > I could choose to implement differently, but the goal of this > implementation > path was that the zoom bubble not need to care what the child margins are, > and > the children not need to know which kinds of siblings they have. > > https://codereview.chromium.org/2836313002/ > -- You received this message because you are subscribed to the Google Groups "Chromium-reviews" group. To unsubscribe from this group and stop receiving emails from it, send an email to chromium-reviews+unsubscribe@chromium.org.
GAH! Sorry, that should be (1) it is. Will review shortly. On Mon, May 15, 2017 at 11:18 AM, Scott Violet <sky@chromium.org> wrote: > (3) it is. Will review shortly. > > On Mon, May 15, 2017 at 10:06 AM, <pkasting@chromium.org> wrote: > >> On 2017/05/14 14:04:25, sky wrote: >> > In earlier email threads I thought we wanted to head toward a place >> where >> > views automatically get margins at some point in their lifetime. The >> margin >> > is determined based on type and perhaps context. This comes from the >> email >> > thread "Adding a margin to a view." If you agree with this, then the >> place >> > creating the views (infobar code in your case), isn't explicitly setting >> > the margins. In such a scenario it's all too easy to end up with >> different >> > cross axis margins. Using different cross axis margins will result in a >> bad >> > layout. All of the examples I see at >> > >> https://folio.googleplex.com/chrome-ux-specs-and-sources/Chr >> ome%20browser%20(MD)/Secondary%20UI%20Previews%20and% >> 20specs%20(exports)/Spec#%2FSPEC-secondary-UI-07a-layout.png%3Ff=hidden >> > have the same cross axis margin. This is why I think the cross axis >> margins >> > should be the max. >> > >> > Do you disagree with the path I've outlined? Can you think of places >> where >> > you would actually want different cross axis margins? >> >> I actually hope to implement the spec using different cross-axis margins >> with >> centered layout, and if I do so, then route (3) will break things. >> Consider the >> zoom bubble case in the "toasts with buttons" mock: if I stick a 12 pt >> top and >> bottom margin on the label and 8 pt top and bottom margins on the >> buttons, and >> then center, then route (1) and (2) give me what I want, but route (3) >> gives me >> 12 pt margins outside the buttons. >> >> I could choose to implement differently, but the goal of this >> implementation >> path was that the zoom bubble not need to care what the child margins >> are, and >> the children not need to know which kinds of siblings they have. >> >> https://codereview.chromium.org/2836313002/ >> > > -- You received this message because you are subscribed to the Google Groups "Chromium-reviews" group. To unsubscribe from this group and stop receiving emails from it, send an email to chromium-reviews+unsubscribe@chromium.org.
On 2017/05/15 18:18:34, sky wrote: > GAH! Sorry, that should be (1) it is. Will review shortly. > > On Mon, May 15, 2017 at 11:18 AM, Scott Violet <mailto:sky@chromium.org> wrote: > > > (3) it is. Will review shortly. > > > > On Mon, May 15, 2017 at 10:06 AM, <mailto:pkasting@chromium.org> wrote: > > > >> On 2017/05/14 14:04:25, sky wrote: > >> > In earlier email threads I thought we wanted to head toward a place > >> where > >> > views automatically get margins at some point in their lifetime. The > >> margin > >> > is determined based on type and perhaps context. This comes from the > >> email > >> > thread "Adding a margin to a view." If you agree with this, then the > >> place > >> > creating the views (infobar code in your case), isn't explicitly setting > >> > the margins. In such a scenario it's all too easy to end up with > >> different > >> > cross axis margins. Using different cross axis margins will result in a > >> bad > >> > layout. All of the examples I see at > >> > > >> https://folio.googleplex.com/chrome-ux-specs-and-sources/Chr > >> ome%20browser%20(MD)/Secondary%20UI%20Previews%20and% > >> 20specs%20(exports)/Spec#%2FSPEC-secondary-UI-07a-layout.png%3Ff=hidden > >> > have the same cross axis margin. This is why I think the cross axis > >> margins > >> > should be the max. > >> > > >> > Do you disagree with the path I've outlined? Can you think of places > >> where > >> > you would actually want different cross axis margins? > >> > >> I actually hope to implement the spec using different cross-axis margins > >> with > >> centered layout, and if I do so, then route (3) will break things. > >> Consider the > >> zoom bubble case in the "toasts with buttons" mock: if I stick a 12 pt > >> top and > >> bottom margin on the label and 8 pt top and bottom margins on the > >> buttons, and > >> then center, then route (1) and (2) give me what I want, but route (3) > >> gives me > >> 12 pt margins outside the buttons. > >> > >> I could choose to implement differently, but the goal of this > >> implementation > >> path was that the zoom bubble not need to care what the child margins > >> are, and > >> the children not need to know which kinds of siblings they have. > >> > >> https://codereview.chromium.org/2836313002/ > >> > > > > > > -- > You received this message because you are subscribed to the Google Groups > "Chromium-reviews" group. > To unsubscribe from this group and stop receiving emails from it, send an email > to mailto:chromium-reviews+unsubscribe@chromium.org. I started reviewing again, and realized I'm confused. I think Allen implemented (3), which for the reasons I outlined SGTM, but it doesn't match what you want. Looking back at your ascii art I realized something: Notice the following have different heights: START (1): -------------- MMMM MMMM MMMM VVVV VVVV VVVV VVVV VVVV MMMM -------------- CENTER (1) -------------- MMMM MMMM VVVV MMMM VVVV VVVV VVVV VVVV MMMM -------------- In start the height is 6, but in center the height is 5. If use an algorithm like the following to get the preferred height (which is something like Allen has in the patch, although his is in two passes): for (view in views) { margin_height = max(margin_height, view->margin->height()); pref_height = max(pref_height, view->GetPreferredSize().height()); } return margin_height + pref_height; Then the height of what the 3 views you list is going to be 6. Why would center be different? But maybe you want an algorithm like: for (view in views) { pref_height = max(pref_height, view->GetPreferredSize().height() + view->margin().height()); } return pref_height; But if you do that, then the start case becomes: MMMM VVVV MMMM VVVV MMMM VVVV VVVV VVVV MMMM
I got part way through this before realizing what you implemented isn't what Peter wants. Here's the comments though. https://codereview.chromium.org/2836313002/diff/200001/ui/views/layout/box_la... File ui/views/layout/box_layout.cc (right): https://codereview.chromium.org/2836313002/diff/200001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:41: view_->SetBounds(bounds.x(), bounds.y(), bounds.width(), bounds.height()); view_->SetBoundsRect(bounds) https://codereview.chromium.org/2836313002/diff/200001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:310: ? std::max(between_child_spacing_, optional: this code is nigh unreadable because of the excessive ternary operators. Peter may disagree as he uses the ternary operator a lot, so I'm leaving this optional. Specifically I would rather you use multiple 'ifs.' I'm ok with one ternary operator, but 3 ternary operators is not particularly readable. Maybe checking if either view is null or !collapse_margins_spacing_ first would help, e.g. if (!collapse_margins_spacing_ || !left.view() || !right.right()) return between_child_spacing_; https://codereview.chromium.org/2836313002/diff/200001/ui/views/layout/box_la... File ui/views/layout/box_layout.h (right): https://codereview.chromium.org/2836313002/diff/200001/ui/views/layout/box_la... ui/views/layout/box_layout.h:61: // space in between child views. |collapse_margins_spacing| paramter controls parameter https://codereview.chromium.org/2836313002/diff/200001/ui/views/layout/box_la... ui/views/layout/box_layout.h:62: // whether or not spacing adjacent to view margins are collapsed base on the How about: 'spacing between views along the main axis are collapsed to the max of the margins of the two adjacent views.' Please also add an example to help drive it home. https://codereview.chromium.org/2836313002/diff/200001/ui/views/layout/box_la... ui/views/layout/box_layout.h:126: ViewWrapper(const ViewWrapper& wrapper) = delete; Is there a reason to delete this constructor and not use DISALLOW that deletes more? https://codereview.chromium.org/2836313002/diff/200001/ui/views/view.h File ui/views/view.h (right): https://codereview.chromium.org/2836313002/diff/200001/ui/views/view.h#newcod... ui/views/view.h:1705: VIEWS_EXPORT extern const ui::ClassProperty<gfx::Insets*>* const kMarginsKey; Please move this into a separate file (I commented on this in an earlier patch with recommendations as to where to put it).
On 2017/05/15 20:28:24, sky wrote: > On 2017/05/15 18:18:34, sky wrote: > > GAH! Sorry, that should be (1) it is. Will review shortly. > > > > On Mon, May 15, 2017 at 11:18 AM, Scott Violet <mailto:sky@chromium.org> > wrote: > > > > > (3) it is. Will review shortly. > > > > > > On Mon, May 15, 2017 at 10:06 AM, <mailto:pkasting@chromium.org> wrote: > > > > > >> On 2017/05/14 14:04:25, sky wrote: > > >> > In earlier email threads I thought we wanted to head toward a place > > >> where > > >> > views automatically get margins at some point in their lifetime. The > > >> margin > > >> > is determined based on type and perhaps context. This comes from the > > >> email > > >> > thread "Adding a margin to a view." If you agree with this, then the > > >> place > > >> > creating the views (infobar code in your case), isn't explicitly setting > > >> > the margins. In such a scenario it's all too easy to end up with > > >> different > > >> > cross axis margins. Using different cross axis margins will result in a > > >> bad > > >> > layout. All of the examples I see at > > >> > > > >> https://folio.googleplex.com/chrome-ux-specs-and-sources/Chr > > >> ome%20browser%20(MD)/Secondary%20UI%20Previews%20and% > > >> 20specs%20(exports)/Spec#%2FSPEC-secondary-UI-07a-layout.png%3Ff=hidden > > >> > have the same cross axis margin. This is why I think the cross axis > > >> margins > > >> > should be the max. > > >> > > > >> > Do you disagree with the path I've outlined? Can you think of places > > >> where > > >> > you would actually want different cross axis margins? > > >> > > >> I actually hope to implement the spec using different cross-axis margins > > >> with > > >> centered layout, and if I do so, then route (3) will break things. > > >> Consider the > > >> zoom bubble case in the "toasts with buttons" mock: if I stick a 12 pt > > >> top and > > >> bottom margin on the label and 8 pt top and bottom margins on the > > >> buttons, and > > >> then center, then route (1) and (2) give me what I want, but route (3) > > >> gives me > > >> 12 pt margins outside the buttons. > > >> > > >> I could choose to implement differently, but the goal of this > > >> implementation > > >> path was that the zoom bubble not need to care what the child margins > > >> are, and > > >> the children not need to know which kinds of siblings they have. > > >> > > >> https://codereview.chromium.org/2836313002/ > > >> > > > > > > > > > > -- > > You received this message because you are subscribed to the Google Groups > > "Chromium-reviews" group. > > To unsubscribe from this group and stop receiving emails from it, send an > email > > to mailto:chromium-reviews+unsubscribe@chromium.org. > > I started reviewing again, and realized I'm confused. I think Allen implemented > (3), which for the reasons I outlined SGTM, but it doesn't match what you want. > > Looking back at your ascii art I realized something: Notice the following have > different heights: > > START (1): > -------------- > MMMM > MMMM MMMM > VVVV VVVV VVVV > VVVV > VVVV > MMMM > -------------- > > CENTER (1) > -------------- > MMMM MMMM > VVVV MMMM > VVVV VVVV VVVV > VVVV > MMMM > -------------- > > In start the height is 6, but in center the height is 5. Correct. > If use an algorithm > like the following to get the preferred height (which is something like Allen > has in the patch, although his is in two passes): > > for (view in views) { > margin_height = max(margin_height, view->margin->height()); > pref_height = max(pref_height, view->GetPreferredSize().height()); > } > return margin_height + pref_height; > > Then the height of what the 3 views you list is going to be 6. I believe that's closest to what you'd want for (3), not (1) or (2). > But maybe you want an algorithm like: > for (view in views) { > pref_height = max(pref_height, view->GetPreferredSize().height() + > view->margin().height()); > } > return pref_height; I believe that's more what you want for (2). > But if you do that, then the start case becomes: > > MMMM VVVV MMMM > VVVV MMMM > VVVV VVVV > VVVV > MMMM Right, that was indeed my drawing for (2). The way to compute height for (1) would be to compute it after both sizing and positioning all the views relative to each other. You can't easily compute the container height without doing full layout. The flow for (1) is basically: * Size/position views against each other ignoring margins * Attach margins to cross axis of views * Draw a box around the outside of everything. That's your preferred size So for the center case, we would start with our three views: VVVV VVVV VVVV VVVV VVVV And we would center them against each other: VVVV VVVV VVVV VVVV VVVV (At this point, we've basically executed the pre-margin-support layout routine.) Then we would attach the margins to each view: MMMM MMMM VVVV MMMM VVVV VVVV VVVV VVVV MMMM And then we would draw the container around them: -------------- MMMM MMMM VVVV MMMM VVVV VVVV VVVV VVVV MMMM -------------- And now we would know where the local 0 coordinate is (the top of the container) and what the height is.
On 2017/05/15 21:15:33, Peter Kasting wrote: > On 2017/05/15 20:28:24, sky wrote: > > On 2017/05/15 18:18:34, sky wrote: > > > GAH! Sorry, that should be (1) it is. Will review shortly. > > > > > > On Mon, May 15, 2017 at 11:18 AM, Scott Violet <mailto:sky@chromium.org> > > wrote: > > > > > > > (3) it is. Will review shortly. > > > > > > > > On Mon, May 15, 2017 at 10:06 AM, <mailto:pkasting@chromium.org> wrote: > > > > > > > >> On 2017/05/14 14:04:25, sky wrote: > > > >> > In earlier email threads I thought we wanted to head toward a place > > > >> where > > > >> > views automatically get margins at some point in their lifetime. The > > > >> margin > > > >> > is determined based on type and perhaps context. This comes from the > > > >> email > > > >> > thread "Adding a margin to a view." If you agree with this, then the > > > >> place > > > >> > creating the views (infobar code in your case), isn't explicitly > setting > > > >> > the margins. In such a scenario it's all too easy to end up with > > > >> different > > > >> > cross axis margins. Using different cross axis margins will result in a > > > >> bad > > > >> > layout. All of the examples I see at > > > >> > > > > >> https://folio.googleplex.com/chrome-ux-specs-and-sources/Chr > > > >> ome%20browser%20(MD)/Secondary%20UI%20Previews%20and% > > > >> 20specs%20(exports)/Spec#%2FSPEC-secondary-UI-07a-layout.png%3Ff=hidden > > > >> > have the same cross axis margin. This is why I think the cross axis > > > >> margins > > > >> > should be the max. > > > >> > > > > >> > Do you disagree with the path I've outlined? Can you think of places > > > >> where > > > >> > you would actually want different cross axis margins? > > > >> > > > >> I actually hope to implement the spec using different cross-axis margins > > > >> with > > > >> centered layout, and if I do so, then route (3) will break things. > > > >> Consider the > > > >> zoom bubble case in the "toasts with buttons" mock: if I stick a 12 pt > > > >> top and > > > >> bottom margin on the label and 8 pt top and bottom margins on the > > > >> buttons, and > > > >> then center, then route (1) and (2) give me what I want, but route (3) > > > >> gives me > > > >> 12 pt margins outside the buttons. > > > >> > > > >> I could choose to implement differently, but the goal of this > > > >> implementation > > > >> path was that the zoom bubble not need to care what the child margins > > > >> are, and > > > >> the children not need to know which kinds of siblings they have. > > > >> > > > >> https://codereview.chromium.org/2836313002/ > > > >> > > > > > > > > > > > > > > -- > > > You received this message because you are subscribed to the Google Groups > > > "Chromium-reviews" group. > > > To unsubscribe from this group and stop receiving emails from it, send an > > email > > > to mailto:chromium-reviews+unsubscribe@chromium.org. > > > > I started reviewing again, and realized I'm confused. I think Allen > implemented > > (3), which for the reasons I outlined SGTM, but it doesn't match what you > want. > > > > Looking back at your ascii art I realized something: Notice the following have > > different heights: > > > > START (1): > > -------------- > > MMMM > > MMMM MMMM > > VVVV VVVV VVVV > > VVVV > > VVVV > > MMMM > > -------------- > > > > CENTER (1) > > -------------- > > MMMM MMMM > > VVVV MMMM > > VVVV VVVV VVVV > > VVVV > > MMMM > > -------------- > > > > In start the height is 6, but in center the height is 5. > > Correct. > > > If use an algorithm > > like the following to get the preferred height (which is something like Allen > > has in the patch, although his is in two passes): > > > > for (view in views) { > > margin_height = max(margin_height, view->margin->height()); > > pref_height = max(pref_height, view->GetPreferredSize().height()); > > } > > return margin_height + pref_height; > > > > Then the height of what the 3 views you list is going to be 6. > > I believe that's closest to what you'd want for (3), not (1) or (2). > > > But maybe you want an algorithm like: > > for (view in views) { > > pref_height = max(pref_height, view->GetPreferredSize().height() + > > view->margin().height()); > > } > > return pref_height; > > I believe that's more what you want for (2). > > > But if you do that, then the start case becomes: > > > > MMMM VVVV MMMM > > VVVV MMMM > > VVVV VVVV > > VVVV > > MMMM > > Right, that was indeed my drawing for (2). > > The way to compute height for (1) would be to compute it after both sizing and > positioning all the views relative to each other. You can't easily compute the > container height without doing full layout. > > The flow for (1) is basically: > > * Size/position views against each other ignoring margins > * Attach margins to cross axis of views > * Draw a box around the outside of everything. That's your preferred size > > So for the center case, we would start with our three views: > > VVVV VVVV VVVV > VVVV > VVVV > > And we would center them against each other: > > VVVV > VVVV VVVV VVVV > VVVV > > (At this point, we've basically executed the pre-margin-support layout routine.) > > Then we would attach the margins to each view: By attach margin is it something like you're subtracting the top-margin from the y-coordinate in the last pass, accumulating the max margin, and then loop over the views again offseting the max? max_top = 0; for (view in views) { max_top = max(max_top, view->margin().top()); view->SetBounds(... view->bounds().y() - view->margin().top() ...); } And then you make a pass offsetting by max_top? for (view in views) { view->SetBounds(... view->bounds().y() + max_top ...); } I'm not suggesting the actual code set the bounds multiple times, it's just easiest illustrate. > MMMM MMMM > VVVV MMMM > VVVV VVVV VVVV > VVVV > MMMM > > And then we would draw the container around them: > > -------------- > MMMM MMMM > VVVV MMMM > VVVV VVVV VVVV > VVVV > MMMM > -------------- > > And now we would know where the local 0 coordinate is (the top of the container) > and what the height is.
On 2017/05/15 21:44:53, sky wrote: > On 2017/05/15 21:15:33, Peter Kasting wrote: > > Then we would attach the margins to each view: > > By attach margin is it something like you're subtracting the top-margin from the > y-coordinate in the last pass, accumulating the max margin, and then loop over > the views again offseting the max? > > max_top = 0; > for (view in views) { > max_top = max(max_top, view->margin().top()); > view->SetBounds(... view->bounds().y() - view->margin().top() ...); > } > > And then you make a pass offsetting by max_top? > for (view in views) { > view->SetBounds(... view->bounds().y() + max_top ...); > } > > I'm not suggesting the actual code set the bounds multiple times, it's just > easiest illustrate. Yes, I believe that would achieve what I'm describing.
On 2017/05/15 21:53:03, Peter Kasting wrote: > On 2017/05/15 21:44:53, sky wrote: > > On 2017/05/15 21:15:33, Peter Kasting wrote: > > > Then we would attach the margins to each view: > > > > By attach margin is it something like you're subtracting the top-margin from > the > > y-coordinate in the last pass, accumulating the max margin, and then loop over > > the views again offseting the max? > > > > max_top = 0; > > for (view in views) { > > max_top = max(max_top, view->margin().top()); > > view->SetBounds(... view->bounds().y() - view->margin().top() ...); > > } > > > > And then you make a pass offsetting by max_top? > > for (view in views) { > > view->SetBounds(... view->bounds().y() + max_top ...); > > } > > > > I'm not suggesting the actual code set the bounds multiple times, it's just > > easiest illustrate. > > Yes, I believe that would achieve what I'm describing. Would it be helpful for you both to play with the BoxLayoutExample to get a feel for how it works right now. I think once you actually see the behavior in practice, it will make much more sense both visually and operationally. If anything, it will give both of you a clearer picture of where tweaks and adjustments need to be made. For the most part, I think the code is doing exactly what is being described here. I can even make changes to the example in order to better represent real-world scenarios. IMO, an interactive and operational test rig is more valuable than an in-person or virtual whiteboard discussion. If this would expedite things, I even can provide a link to the views_examples_with_content_exe.exe executable file and the required DLLs so you don't have to apply the patch and build locally.
On 2017/05/16 13:34:01, kylix_rd wrote: > On 2017/05/15 21:53:03, Peter Kasting wrote: > > On 2017/05/15 21:44:53, sky wrote: > > > On 2017/05/15 21:15:33, Peter Kasting wrote: > > > > Then we would attach the margins to each view: > > > > > > By attach margin is it something like you're subtracting the top-margin from > > the > > > y-coordinate in the last pass, accumulating the max margin, and then loop > over > > > the views again offseting the max? > > > > > > max_top = 0; > > > for (view in views) { > > > max_top = max(max_top, view->margin().top()); > > > view->SetBounds(... view->bounds().y() - view->margin().top() ...); > > > } > > > > > > And then you make a pass offsetting by max_top? > > > for (view in views) { > > > view->SetBounds(... view->bounds().y() + max_top ...); > > > } > > > > > > I'm not suggesting the actual code set the bounds multiple times, it's just > > > easiest illustrate. > > > > Yes, I believe that would achieve what I'm describing. > > Would it be helpful for you both to play with the BoxLayoutExample to get a feel > for how it works right now. I think once you actually see the behavior in > practice, it will make much more sense both visually and operationally. If > anything, it will give both of you a clearer picture of where tweaks and > adjustments need to be made. For the most part, I think the code is doing > exactly what is being described here. I can even make changes to the example in > order to better represent real-world scenarios. IMO, an interactive and > operational test rig is more valuable than an in-person or virtual whiteboard > discussion. > > If this would expedite things, I even can provide a link to the > views_examples_with_content_exe.exe executable file and the required DLLs so you > don't have to apply the patch and build locally. I tried to get views_examples_with_content_exe.exe pulled out with it's required libraries, but it crashes on startup.. I guess it needs more than merely the dlls. Again, if this might be helpful, I'll continue to put this together by doing a slimmed down non-component build into a separate output folder.
On 2017/05/16 16:21:35, kylix_rd wrote: > On 2017/05/16 13:34:01, kylix_rd wrote: > > On 2017/05/15 21:53:03, Peter Kasting wrote: > > > On 2017/05/15 21:44:53, sky wrote: > > > > On 2017/05/15 21:15:33, Peter Kasting wrote: > > > > > Then we would attach the margins to each view: > > > > > > > > By attach margin is it something like you're subtracting the top-margin > from > > > the > > > > y-coordinate in the last pass, accumulating the max margin, and then loop > > over > > > > the views again offseting the max? > > > > > > > > max_top = 0; > > > > for (view in views) { > > > > max_top = max(max_top, view->margin().top()); > > > > view->SetBounds(... view->bounds().y() - view->margin().top() ...); > > > > } > > > > > > > > And then you make a pass offsetting by max_top? > > > > for (view in views) { > > > > view->SetBounds(... view->bounds().y() + max_top ...); > > > > } > > > > > > > > I'm not suggesting the actual code set the bounds multiple times, it's > just > > > > easiest illustrate. > > > > > > Yes, I believe that would achieve what I'm describing. > > > > Would it be helpful for you both to play with the BoxLayoutExample to get a > feel > > for how it works right now. I think once you actually see the behavior in > > practice, it will make much more sense both visually and operationally. If > > anything, it will give both of you a clearer picture of where tweaks and > > adjustments need to be made. For the most part, I think the code is doing > > exactly what is being described here. I can even make changes to the example > in > > order to better represent real-world scenarios. IMO, an interactive and > > operational test rig is more valuable than an in-person or virtual whiteboard > > discussion. > > > > If this would expedite things, I even can provide a link to the > > views_examples_with_content_exe.exe executable file and the required DLLs so > you > > don't have to apply the patch and build locally. > > > I tried to get views_examples_with_content_exe.exe pulled out with it's required > libraries, but it crashes on startup.. I guess it needs more than merely the > dlls. Again, if this might be helpful, I'll continue to put this together by > doing a slimmed down non-component build into a separate output folder. https://drive.google.com/open?id=0B6LQg8CWo5bNX080Q19LYUJaUzg This should be views_examples.zip. You should be able to unzip to a local folder and run views_examples_with_content_exe. The first "example" is BoxLayout so it should be ready to go right off.
Still need to separate the view property into a separate file, and maybe add more ASCII-art examples to the .h file. https://codereview.chromium.org/2836313002/diff/200001/ui/views/layout/box_la... File ui/views/layout/box_layout.cc (right): https://codereview.chromium.org/2836313002/diff/200001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:41: view_->SetBounds(bounds.x(), bounds.y(), bounds.width(), bounds.height()); On 2017/05/15 20:29:09, sky wrote: > view_->SetBoundsRect(bounds) Done. https://codereview.chromium.org/2836313002/diff/200001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:310: ? std::max(between_child_spacing_, On 2017/05/15 20:29:09, sky wrote: > optional: this code is nigh unreadable because of the excessive ternary > operators. Peter may disagree as he uses the ternary operator a lot, so I'm > leaving this optional. Specifically I would rather you use multiple 'ifs.' I'm > ok with one ternary operator, but 3 ternary operators is not particularly > readable. > > Maybe checking if either view is null or !collapse_margins_spacing_ first would > help, e.g. > if (!collapse_margins_spacing_ || !left.view() || !right.right()) > return between_child_spacing_; What? You don't appreciate my "mad ternary operator skillz" :)? Yes, a little rework would make this more readable... Done. https://codereview.chromium.org/2836313002/diff/200001/ui/views/layout/box_la... File ui/views/layout/box_layout.h (right): https://codereview.chromium.org/2836313002/diff/200001/ui/views/layout/box_la... ui/views/layout/box_layout.h:62: // whether or not spacing adjacent to view margins are collapsed base on the On 2017/05/15 20:29:09, sky wrote: > How about: 'spacing between views along the main axis are collapsed to the max > of the margins of the two adjacent views.' Please also add an example to help > drive it home. It's more than merely "adjacent views". The collapsing also happens with the inside border spacing (aka. the internal padding). So it is the adjacent "spacing", regardless of where that spacing is specified, that is collapsed. I can certainly add an example... based on the ASCII art you and pkasting@ are bantering about :). https://codereview.chromium.org/2836313002/diff/200001/ui/views/layout/box_la... ui/views/layout/box_layout.h:126: ViewWrapper(const ViewWrapper& wrapper) = delete; On 2017/05/15 20:29:09, sky wrote: > Is there a reason to delete this constructor and not use DISALLOW that deletes > more? No, not really. Done. https://codereview.chromium.org/2836313002/diff/200001/ui/views/view.h File ui/views/view.h (right): https://codereview.chromium.org/2836313002/diff/200001/ui/views/view.h#newcod... ui/views/view.h:1705: VIEWS_EXPORT extern const ui::ClassProperty<gfx::Insets*>* const kMarginsKey; On 2017/05/15 20:29:10, sky wrote: > Please move this into a separate file (I commented on this in an earlier patch > with recommendations as to where to put it). Oops. My bad. I completely missed that comment.
The CQ bit was checked by kylixrd@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: linux_chromium_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...)
The CQ bit was checked by kylixrd@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
New patches. Moved view properties to separate files. Fixed crash reported by pkasting@ in the example and added ability to control the size of new child panels.
The CQ bit was checked by kylixrd@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: win_chromium_x64_rel_ng on master.tryserver.chromium.win (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_x64_...)
OK, this patch *should* get the functionality nailed down. In the non-collapsed margin mode, the margin along the cross-axis is the inside border spacing + the maximum margin between all views along the cross-axis sides. For example, the inside border spacing is 2 and view 1 has margins of 3 and view 2 has margins of 4, all along the cross-axis. The overall margin will be 6 (inside border spacing 2 + max margin 4). This will ensure that the actual view boundaries will align when the boundaries of the view encroach into that space. To accomplish this, I changed the ViewWrapper to never add/subtract the margins for the cross-axis. The layout code then always calculates the max margins along the cross-axis and adjusts the client area accordingly. The comment example and the description of the ViewWrapper are also updated to reflect these changes.
The CQ bit was checked by kylixrd@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
On 2017/05/18 17:06:14, kylix_rd wrote: > OK, this patch *should* get the functionality nailed down. In the non-collapsed > margin mode, the margin along the cross-axis is the inside border spacing + the > maximum margin between all views along the cross-axis sides. For example, the > inside border spacing is 2 and view 1 has margins of 3 and view 2 has margins of > 4, all along the cross-axis. The overall margin will be 6 (inside border spacing > 2 + max margin 4). This will ensure that the actual view boundaries will align > when the boundaries of the view encroach into that space. Offhand, that sounds like Scott's route (3), which oversizes the margin. Consider laying out these two views in centered mode: MMMM MMMM VVVV MMMM VVVV VVVV VVVV Here the total margin above the taller view should only be 1, despite the margin of the second view being 2, because that's sufficient to guarantee both views their desired margin.
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: linux_chromium_chromeos_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...)
On 2017/05/18 17:10:46, Peter Kasting wrote: > On 2017/05/18 17:06:14, kylix_rd wrote: > > OK, this patch *should* get the functionality nailed down. In the > non-collapsed > > margin mode, the margin along the cross-axis is the inside border spacing + > the > > maximum margin between all views along the cross-axis sides. For example, the > > inside border spacing is 2 and view 1 has margins of 3 and view 2 has margins > of > > 4, all along the cross-axis. The overall margin will be 6 (inside border > spacing > > 2 + max margin 4). This will ensure that the actual view boundaries will align > > when the boundaries of the view encroach into that space. > > Offhand, that sounds like Scott's route (3), which oversizes the margin. > Consider laying out these two views in centered mode: > > MMMM MMMM > VVVV MMMM > VVVV VVVV > VVVV > > Here the total margin above the taller view should only be 1, despite the margin > of the second view being 2, because that's sufficient to guarantee both views > their desired margin. Hmmm... You're right. To get it to do this will take a little more work. It will affect GetPreferredSize() which has never taken into account centering along the cross axis.
The CQ bit was checked by kylixrd@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: win_chromium_rel_ng on master.tryserver.chromium.win (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_rel_...)
On 2017/05/18 19:16:16, kylix_rd wrote: > On 2017/05/18 17:10:46, Peter Kasting wrote: > > On 2017/05/18 17:06:14, kylix_rd wrote: > > > OK, this patch *should* get the functionality nailed down. In the > > non-collapsed > > > margin mode, the margin along the cross-axis is the inside border spacing + > > the > > > maximum margin between all views along the cross-axis sides. For example, > the > > > inside border spacing is 2 and view 1 has margins of 3 and view 2 has > margins > > of > > > 4, all along the cross-axis. The overall margin will be 6 (inside border > > spacing > > > 2 + max margin 4). This will ensure that the actual view boundaries will > align > > > when the boundaries of the view encroach into that space. > > > > Offhand, that sounds like Scott's route (3), which oversizes the margin. > > Consider laying out these two views in centered mode: > > > > MMMM MMMM > > VVVV MMMM > > VVVV VVVV > > VVVV > > > > Here the total margin above the taller view should only be 1, despite the > margin > > of the second view being 2, because that's sufficient to guarantee both views > > their desired margin. > > Hmmm... You're right. To get it to do this will take a little more work. It will > affect GetPreferredSize() which has never taken into account centering along the > cross axis. I looked at this some more and it's going to take more work than I thought. Is this critical at this point? Can we finalize this patch and acknowledge the current behavior either in a TODO or merely document it? IMO, if margins are added to views, collapse_margins_spacing would most likely be set to true.
On 2017/05/19 18:53:17, kylix_rd wrote: > On 2017/05/18 19:16:16, kylix_rd wrote: > > On 2017/05/18 17:10:46, Peter Kasting wrote: > > > On 2017/05/18 17:06:14, kylix_rd wrote: > > > > OK, this patch *should* get the functionality nailed down. In the > > > non-collapsed > > > > margin mode, the margin along the cross-axis is the inside border spacing > + > > > the > > > > maximum margin between all views along the cross-axis sides. For example, > > the > > > > inside border spacing is 2 and view 1 has margins of 3 and view 2 has > > margins > > > of > > > > 4, all along the cross-axis. The overall margin will be 6 (inside border > > > spacing > > > > 2 + max margin 4). This will ensure that the actual view boundaries will > > align > > > > when the boundaries of the view encroach into that space. > > > > > > Offhand, that sounds like Scott's route (3), which oversizes the margin. > > > Consider laying out these two views in centered mode: > > > > > > MMMM MMMM > > > VVVV MMMM > > > VVVV VVVV > > > VVVV > > > > > > Here the total margin above the taller view should only be 1, despite the > > margin > > > of the second view being 2, because that's sufficient to guarantee both > views > > > their desired margin. > > > > Hmmm... You're right. To get it to do this will take a little more work. It > will > > affect GetPreferredSize() which has never taken into account centering along > the > > cross axis. > > I looked at this some more and it's going to take more work than I thought. Is > this critical at this point? Can we finalize this patch and acknowledge the > current behavior either in a TODO or merely document it? The behavior I think you're saying would take more work is the behavior I need for infobars, that's presumably why you're adding this to begin with. So uh... if you want your one consumer to use this, yes, it's critical? :)
On 2017/05/19 19:02:21, Peter Kasting wrote: > On 2017/05/19 18:53:17, kylix_rd wrote: > > On 2017/05/18 19:16:16, kylix_rd wrote: > > > On 2017/05/18 17:10:46, Peter Kasting wrote: > > > > On 2017/05/18 17:06:14, kylix_rd wrote: > > > > > OK, this patch *should* get the functionality nailed down. In the > > > > non-collapsed > > > > > margin mode, the margin along the cross-axis is the inside border > spacing > > + > > > > the > > > > > maximum margin between all views along the cross-axis sides. For > example, > > > the > > > > > inside border spacing is 2 and view 1 has margins of 3 and view 2 has > > > margins > > > > of > > > > > 4, all along the cross-axis. The overall margin will be 6 (inside border > > > > spacing > > > > > 2 + max margin 4). This will ensure that the actual view boundaries will > > > align > > > > > when the boundaries of the view encroach into that space. > > > > > > > > Offhand, that sounds like Scott's route (3), which oversizes the margin. > > > > Consider laying out these two views in centered mode: > > > > > > > > MMMM MMMM > > > > VVVV MMMM > > > > VVVV VVVV > > > > VVVV > > > > > > > > Here the total margin above the taller view should only be 1, despite the > > > margin > > > > of the second view being 2, because that's sufficient to guarantee both > > views > > > > their desired margin. > > > > > > Hmmm... You're right. To get it to do this will take a little more work. It > > will > > > affect GetPreferredSize() which has never taken into account centering along > > the > > > cross axis. > > > > I looked at this some more and it's going to take more work than I thought. Is > > this critical at this point? Can we finalize this patch and acknowledge the > > current behavior either in a TODO or merely document it? > > The behavior I think you're saying would take more work is the behavior I need > for infobars, that's presumably why you're adding this to begin with. So uh... > if you want your one consumer to use this, yes, it's critical? :) OK, I'll look into this a little deeper. I should be able come up with a solution in the next day or so (early next week).
On 2017/05/19 19:02:21, Peter Kasting wrote: > On 2017/05/19 18:53:17, kylix_rd wrote: > > On 2017/05/18 19:16:16, kylix_rd wrote: > > > On 2017/05/18 17:10:46, Peter Kasting wrote: > > > > On 2017/05/18 17:06:14, kylix_rd wrote: > > > > > OK, this patch *should* get the functionality nailed down. In the > > > > non-collapsed > > > > > margin mode, the margin along the cross-axis is the inside border > spacing > > + > > > > the > > > > > maximum margin between all views along the cross-axis sides. For > example, > > > the > > > > > inside border spacing is 2 and view 1 has margins of 3 and view 2 has > > > margins > > > > of > > > > > 4, all along the cross-axis. The overall margin will be 6 (inside border > > > > spacing > > > > > 2 + max margin 4). This will ensure that the actual view boundaries will > > > align > > > > > when the boundaries of the view encroach into that space. > > > > > > > > Offhand, that sounds like Scott's route (3), which oversizes the margin. > > > > Consider laying out these two views in centered mode: > > > > > > > > MMMM MMMM > > > > VVVV MMMM > > > > VVVV VVVV > > > > VVVV > > > > > > > > Here the total margin above the taller view should only be 1, despite the > > > margin > > > > of the second view being 2, because that's sufficient to guarantee both > > views > > > > their desired margin. > > > > > > Hmmm... You're right. To get it to do this will take a little more work. It > > will > > > affect GetPreferredSize() which has never taken into account centering along > > the > > > cross axis. > > > > I looked at this some more and it's going to take more work than I thought. Is > > this critical at this point? Can we finalize this patch and acknowledge the > > current behavior either in a TODO or merely document it? > > The behavior I think you're saying would take more work is the behavior I need > for infobars, that's presumably why you're adding this to begin with. So uh... > if you want your one consumer to use this, yes, it's critical? :) Peter, I encourage you to put up a patch for converting InfoBars to using BoxLayout. I would hate for Allen to do all this work and then you realize there is some reason InfoBars can't actually use BoxLayout... I think the chances of that happening are slim, but it would be good to know sooner rather than later. -Scott
On 2017/05/19 22:06:48, sky wrote: > Peter, I encourage you to put up a patch for converting InfoBars to using > BoxLayout. I would hate for Allen to do all this work and then you realize there > is some reason InfoBars can't actually use BoxLayout... I think the chances of > that happening are slim, but it would be good to know sooner rather than later. That's a good idea.
Patchset #15 (id:320001) has been deleted
Ok, I will freely admit this was one of the most challenging patches I've done so far. I think I've satisfied the outlined requirements. While there are still some unit test adjustments that need to be made since the assumption have changed regarding how margins are handled, the "meat" of the overall logic should be in place.
The CQ bit was checked by kylixrd@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
https://codereview.chromium.org/2836313002/diff/360001/ui/views/layout/box_la... File ui/views/layout/box_layout.cc (right): https://codereview.chromium.org/2836313002/diff/360001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:30: } else if (orientation_ == Orientation::kHorizontal) { style guide says no if after return. https://codereview.chromium.org/2836313002/diff/360001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:335: std::max(left.margins().right(), right.margins().left())); I think this code would be easier to read if you isolate the conditionals based on orientation to helper functions. e.g. return std::max(between_child_spacing_, std::max(MainAxisLeadingInset(left.margins()), MainAxisTrailingOffset(right.margins()))); MainAxisLeadingInset could also be used on 348, and I suspect other places. Easier to ensure the conditionals are right in one places vs a bunch of functions. You should extract similar functions for CrossAxisMargin calculation. https://codereview.chromium.org/2836313002/diff/360001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:336: } else { no else https://codereview.chromium.org/2836313002/diff/360001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:350: } else { no else https://codereview.chromium.org/2836313002/diff/360001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:355: } else { no else https://codereview.chromium.org/2836313002/diff/360001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:359: } else { no else https://codereview.chromium.org/2836313002/diff/360001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:382: else no else. https://codereview.chromium.org/2836313002/diff/360001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:501: } else { no else https://codereview.chromium.org/2836313002/diff/360001/ui/views/layout/box_la... File ui/views/layout/box_layout.h (right): https://codereview.chromium.org/2836313002/diff/360001/ui/views/layout/box_la... ui/views/layout/box_layout.h:64: // adjacent to view margins are collapsed base on the max of the two values. adjacent -> main axis? https://codereview.chromium.org/2836313002/diff/360001/ui/views/layout/box_la... ui/views/layout/box_layout.h:220: // Return the outer margin along the main axis as insets. Return -> Returns (same on 223, and 226). https://codereview.chromium.org/2836313002/diff/360001/ui/views/view_properti... File ui/views/view_properties.h (right): https://codereview.chromium.org/2836313002/diff/360001/ui/views/view_properti... ui/views/view_properties.h:9: #include "ui/gfx/geometry/insets.h" forward declare insets.
The CQ bit was checked by kylixrd@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
https://codereview.chromium.org/2836313002/diff/360001/ui/views/layout/box_la... File ui/views/layout/box_layout.cc (right): https://codereview.chromium.org/2836313002/diff/360001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:30: } else if (orientation_ == Orientation::kHorizontal) { On 2017/05/24 21:28:51, sky wrote: > style guide says no if after return. Done. https://codereview.chromium.org/2836313002/diff/360001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:335: std::max(left.margins().right(), right.margins().left())); On 2017/05/24 21:28:51, sky wrote: > I think this code would be easier to read if you isolate the conditionals based > on orientation to helper functions. e.g. > > return std::max(between_child_spacing_, > std::max(MainAxisLeadingInset(left.margins()), > MainAxisTrailingOffset(right.margins()))); > > MainAxisLeadingInset could also be used on 348, and I suspect other places. > Easier to ensure the conditionals are right in one places vs a bunch of > functions. > > You should extract similar functions for CrossAxisMargin calculation. Done. https://codereview.chromium.org/2836313002/diff/360001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:336: } else { On 2017/05/24 21:28:51, sky wrote: > no else Done. https://codereview.chromium.org/2836313002/diff/360001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:350: } else { On 2017/05/24 21:28:51, sky wrote: > no else Done. https://codereview.chromium.org/2836313002/diff/360001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:355: } else { On 2017/05/24 21:28:51, sky wrote: > no else Done. https://codereview.chromium.org/2836313002/diff/360001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:359: } else { On 2017/05/24 21:28:51, sky wrote: > no else Done. https://codereview.chromium.org/2836313002/diff/360001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:382: else On 2017/05/24 21:28:51, sky wrote: > no else. Done. https://codereview.chromium.org/2836313002/diff/360001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:501: } else { On 2017/05/24 21:28:51, sky wrote: > no else Done. https://codereview.chromium.org/2836313002/diff/360001/ui/views/layout/box_la... File ui/views/layout/box_layout.h (right): https://codereview.chromium.org/2836313002/diff/360001/ui/views/layout/box_la... ui/views/layout/box_layout.h:64: // adjacent to view margins are collapsed base on the max of the two values. On 2017/05/24 21:28:51, sky wrote: > adjacent -> main axis? Done. https://codereview.chromium.org/2836313002/diff/360001/ui/views/layout/box_la... ui/views/layout/box_layout.h:220: // Return the outer margin along the main axis as insets. On 2017/05/24 21:28:51, sky wrote: > Return -> Returns (same on 223, and 226). Done. https://codereview.chromium.org/2836313002/diff/360001/ui/views/view_properti... File ui/views/view_properties.h (right): https://codereview.chromium.org/2836313002/diff/360001/ui/views/view_properti... ui/views/view_properties.h:9: #include "ui/gfx/geometry/insets.h" On 2017/05/24 21:28:51, sky wrote: > forward declare insets. Done.
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
https://codereview.chromium.org/2836313002/diff/380001/ui/views/layout/box_la... File ui/views/layout/box_layout.cc (right): https://codereview.chromium.org/2836313002/diff/380001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:117: ViewWrapper next(this, NextVisibleView(i)); move after visible check. https://codereview.chromium.org/2836313002/diff/380001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:167: ViewWrapper next(this, NextVisibleView(i)); move after visible check. https://codereview.chromium.org/2836313002/diff/380001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:342: return orientation_ == kHorizontal ? insets.left() : insets.top(); Much easier to read, thank you! https://codereview.chromium.org/2836313002/diff/380001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:357: int BoxLayout::MainAxisMarginBetweenViews(const ViewWrapper& left, leading/trailing https://codereview.chromium.org/2836313002/diff/380001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:382: int top_or_left = 0; leading https://codereview.chromium.org/2836313002/diff/380001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:383: int bottom_or_right = 0; trailing https://codereview.chromium.org/2836313002/diff/380001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:401: int top_or_left = CrossAxisLeadingInset(inside_border_insets_); leading https://codereview.chromium.org/2836313002/diff/380001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:402: int bottom_or_right = CrossAxisTrailingInset(inside_border_insets_); trailing https://codereview.chromium.org/2836313002/diff/380001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:404: return MaxAxisInsets(is_vertical ? HORIZONTAL_AXIS : VERTICAL_AXIS, optional: is_vertical is *super* confusing here. Look at he conditional you have, it's basically: if (is_vertical) return HORIZONTAL_AXIS; ... Ugh. https://codereview.chromium.org/2836313002/diff/380001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:458: const ViewWrapper next(this, NextVisibleView(i)); Move after visible and preferred size checks? Same comment in next branch. https://codereview.chromium.org/2836313002/diff/380001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:493: gfx::Size non_child_size = NonChildSize(host_); Won't this result in a layout like option (3). Aren't you effectively adding the max of the cross axis margins to the max of the preferred size? https://codereview.chromium.org/2836313002/diff/380001/ui/views/layout/box_la... File ui/views/layout/box_layout.h (right): https://codereview.chromium.org/2836313002/diff/380001/ui/views/layout/box_la... ui/views/layout/box_layout.h:216: gfx::Insets MaxAxisInsets(Axis axis, This doesn't need any state from BoxLayout; move into anonymous namespace in .cc (and put Axis there too). https://codereview.chromium.org/2836313002/diff/380001/ui/views/layout/box_la... ui/views/layout/box_layout.h:217: const gfx::Insets& left1, left and right imply horizontal, which isn't always the case. How about leading and trailing? Leading/trailing better match how you've named the other functions too.
The CQ bit was checked by kylixrd@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
leading/trailing is a *much* better name. Thanks. https://codereview.chromium.org/2836313002/diff/380001/ui/views/layout/box_la... File ui/views/layout/box_layout.cc (right): https://codereview.chromium.org/2836313002/diff/380001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:117: ViewWrapper next(this, NextVisibleView(i)); On 2017/05/25 19:16:51, sky wrote: > move after visible check. Done. https://codereview.chromium.org/2836313002/diff/380001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:167: ViewWrapper next(this, NextVisibleView(i)); On 2017/05/25 19:16:51, sky wrote: > move after visible check. Done. https://codereview.chromium.org/2836313002/diff/380001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:357: int BoxLayout::MainAxisMarginBetweenViews(const ViewWrapper& left, On 2017/05/25 19:16:51, sky wrote: > leading/trailing Done. https://codereview.chromium.org/2836313002/diff/380001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:382: int top_or_left = 0; On 2017/05/25 19:16:51, sky wrote: > leading Done. https://codereview.chromium.org/2836313002/diff/380001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:383: int bottom_or_right = 0; On 2017/05/25 19:16:51, sky wrote: > trailing Done. https://codereview.chromium.org/2836313002/diff/380001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:401: int top_or_left = CrossAxisLeadingInset(inside_border_insets_); On 2017/05/25 19:16:51, sky wrote: > leading Done. https://codereview.chromium.org/2836313002/diff/380001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:402: int bottom_or_right = CrossAxisTrailingInset(inside_border_insets_); On 2017/05/25 19:16:51, sky wrote: > trailing Done. https://codereview.chromium.org/2836313002/diff/380001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:404: return MaxAxisInsets(is_vertical ? HORIZONTAL_AXIS : VERTICAL_AXIS, On 2017/05/25 19:16:51, sky wrote: > optional: is_vertical is *super* confusing here. Look at he conditional you > have, it's basically: > if (is_vertical) > return HORIZONTAL_AXIS; > ... > Ugh. Understandable. It's certainly a little more confusing than most of the other similar conditionals throughout the file where you're dealing with the cross axis. In those instances, whatever the current orientation is, you return the *other* axis. How about this? Axis cross_axis = orientation_ == kVertical ? HORIZONTAL_AXIS : VERTICAL_AXIS; then use cross_axis directly in the MaxAxisInsets() call and explicitly test (cross_axis == HORIZONTAL_AXIS) in the "if" further down? Next patch will reflect that. https://codereview.chromium.org/2836313002/diff/380001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:458: const ViewWrapper next(this, NextVisibleView(i)); On 2017/05/25 19:16:51, sky wrote: > Move after visible and preferred size checks? Same comment in next branch. Done. https://codereview.chromium.org/2836313002/diff/380001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:493: gfx::Size non_child_size = NonChildSize(host_); On 2017/05/25 19:16:51, sky wrote: > Won't this result in a layout like option (3). Aren't you effectively adding the > max of the cross axis margins to the max of the preferred size? If the margins aren't collapsed, this will only be the host view's current insets plus the inside border insets. All the previous calculations have already taken the margins for each view into account. For collapsed margins, the views' margins aren't additive and are accounted for independently by calculating the max for each margin/spacing butting against each other. https://codereview.chromium.org/2836313002/diff/380001/ui/views/layout/box_la... File ui/views/layout/box_layout.h (right): https://codereview.chromium.org/2836313002/diff/380001/ui/views/layout/box_la... ui/views/layout/box_layout.h:216: gfx::Insets MaxAxisInsets(Axis axis, On 2017/05/25 19:16:52, sky wrote: > This doesn't need any state from BoxLayout; move into anonymous namespace in .cc > (and put Axis there too). Done. https://codereview.chromium.org/2836313002/diff/380001/ui/views/layout/box_la... ui/views/layout/box_layout.h:217: const gfx::Insets& left1, On 2017/05/25 19:16:52, sky wrote: > left and right imply horizontal, which isn't always the case. How about leading > and trailing? Leading/trailing better match how you've named the other functions > too. Done.
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
https://codereview.chromium.org/2836313002/diff/380001/ui/views/layout/box_la... File ui/views/layout/box_layout.cc (right): https://codereview.chromium.org/2836313002/diff/380001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:493: gfx::Size non_child_size = NonChildSize(host_); On 2017/05/25 20:11:19, kylix_rd wrote: > On 2017/05/25 19:16:51, sky wrote: > > Won't this result in a layout like option (3). Aren't you effectively adding > the > > max of the cross axis margins to the max of the preferred size? > > If the margins aren't collapsed, this will only be the host view's current > insets plus the inside border insets. All the previous calculations have already > taken the margins for each view into account. > > For collapsed margins, the views' margins aren't additive and are accounted for > independently by calculating the max for each margin/spacing butting against > each other. I think I'm still confused. I left a diagram on the board in your office. I'll stop by tomorrow to talk about it.
In the immortal words of Bullwinkle Moose, "This time for sure!"... After correcting an issue with how GetPreferredSize() was calculating the size, I also had to adjust how the layout works when the cross axis is centered. The upshot of this is that regardless of whether or not the margins are collapsed, the behavior of the cross-axis remains the same. Another point is that the views are centered based on the full cross-axis size (sans the insets). This can cause the view to be positioned off-center when the available bounds are sufficiently small and the margins are unbalanced across that axis. Clear as mud?
On 2017/05/30 20:43:43, kylix_rd wrote: > In the immortal words of Bullwinkle Moose, "This time for sure!"... > > After correcting an issue with how GetPreferredSize() was calculating the size, > I also had to adjust how the layout works when the cross axis is centered. > > The upshot of this is that regardless of whether or not the margins are > collapsed, the behavior of the cross-axis remains the same. Another point is > that the views are centered based on the full cross-axis size (sans the insets). > This can cause the view to be positioned off-center when the available bounds > are sufficiently small and the margins are unbalanced across that axis. Clear as > mud? Here's a unit test for the test case we talked about: TEST_F(BoxLayoutTest, OverlappingCrossMargins) { { BoxLayout* layout = new BoxLayout(BoxLayout::kHorizontal, 0, 0, 0, false); host_->SetLayoutManager(layout); layout->set_cross_axis_alignment(BoxLayout::CROSS_AXIS_ALIGNMENT_END); View* v1 = new StaticSizedView(gfx::Size(20, 4)); v1->SetProperty(kMarginsKey, new gfx::Insets(3, 0, 0, 0)); host_->AddChildView(v1); View* v2 = new StaticSizedView(gfx::Size(20, 5)); v2->SetProperty(kMarginsKey, new gfx::Insets(0, 0, 2, 0)); host_->AddChildView(v2); EXPECT_EQ(9, layout->GetPreferredSize(host_.get()).height()); } { BoxLayout* layout = new BoxLayout(BoxLayout::kHorizontal, 0, 0, 0, true); host_->SetLayoutManager(layout); layout->set_cross_axis_alignment(BoxLayout::CROSS_AXIS_ALIGNMENT_END); View* v1 = new StaticSizedView(gfx::Size(20, 4)); v1->SetProperty(kMarginsKey, new gfx::Insets(3, 0, 0, 0)); host_->AddChildView(v1); View* v2 = new StaticSizedView(gfx::Size(20, 5)); v2->SetProperty(kMarginsKey, new gfx::Insets(0, 0, 2, 0)); host_->AddChildView(v2); EXPECT_EQ(9, layout->GetPreferredSize(host_.get()).height()); } } Unless I'm missing something the height with this patch is 10, not 9 as I would expect. Am I missing something?
Also, I did have one comment on the name below. Please correct me if I'm wrong on what collapse_margins_spacing means. https://codereview.chromium.org/2836313002/diff/420001/ui/views/layout/box_la... File ui/views/layout/box_layout.h (right): https://codereview.chromium.org/2836313002/diff/420001/ui/views/layout/box_la... ui/views/layout/box_layout.h:63: // |collapse_margins_spacing| parameter controls whether or not adjacent adjacent -> margins along the main axis, right? In fact how about naming it as such, e.g. collapse_main_axis_margins?
https://codereview.chromium.org/2836313002/diff/420001/ui/views/layout/box_la... File ui/views/layout/box_layout.h (right): https://codereview.chromium.org/2836313002/diff/420001/ui/views/layout/box_la... ui/views/layout/box_layout.h:63: // |collapse_margins_spacing| parameter controls whether or not adjacent On 2017/05/31 15:25:15, sky wrote: > adjacent -> margins along the main axis, right? In fact how about naming it as > such, e.g. collapse_main_axis_margins? It will also collapse the cross-axis margins with the insets. It will use the greatest of that edge's inset or view margins.
Fair enough. Please make this clear in the description. Thanks! On Wed, May 31, 2017 at 8:44 AM, <kylixrd@chromium.org> wrote: > > https://codereview.chromium.org/2836313002/diff/420001/ui/ > views/layout/box_layout.h > File ui/views/layout/box_layout.h (right): > > https://codereview.chromium.org/2836313002/diff/420001/ui/ > views/layout/box_layout.h#newcode63 > ui/views/layout/box_layout.h:63: // |collapse_margins_spacing| parameter > controls whether or not adjacent > On 2017/05/31 15:25:15, sky wrote: > > adjacent -> margins along the main axis, right? In fact how about > naming it as > > such, e.g. collapse_main_axis_margins? > > It will also collapse the cross-axis margins with the insets. It will > use the greatest of that edge's inset or view margins. > > https://codereview.chromium.org/2836313002/ > -- You received this message because you are subscribed to the Google Groups "Chromium-reviews" group. To unsubscribe from this group and stop receiving emails from it, send an email to chromium-reviews+unsubscribe@chromium.org.
On 2017/05/31 14:53:54, sky wrote: > On 2017/05/30 20:43:43, kylix_rd wrote: > > In the immortal words of Bullwinkle Moose, "This time for sure!"... > > > > After correcting an issue with how GetPreferredSize() was calculating the > size, > > I also had to adjust how the layout works when the cross axis is centered. > > > > The upshot of this is that regardless of whether or not the margins are > > collapsed, the behavior of the cross-axis remains the same. Another point is > > that the views are centered based on the full cross-axis size (sans the > insets). > > This can cause the view to be positioned off-center when the available bounds > > are sufficiently small and the margins are unbalanced across that axis. Clear > as > > mud? > > Here's a unit test for the test case we talked about: > > TEST_F(BoxLayoutTest, OverlappingCrossMargins) { > { > BoxLayout* layout = new BoxLayout(BoxLayout::kHorizontal, 0, 0, 0, false); > host_->SetLayoutManager(layout); > layout->set_cross_axis_alignment(BoxLayout::CROSS_AXIS_ALIGNMENT_END); > View* v1 = new StaticSizedView(gfx::Size(20, 4)); > v1->SetProperty(kMarginsKey, new gfx::Insets(3, 0, 0, 0)); > host_->AddChildView(v1); > View* v2 = new StaticSizedView(gfx::Size(20, 5)); > v2->SetProperty(kMarginsKey, new gfx::Insets(0, 0, 2, 0)); > host_->AddChildView(v2); > > EXPECT_EQ(9, layout->GetPreferredSize(host_.get()).height()); > } > { > BoxLayout* layout = new BoxLayout(BoxLayout::kHorizontal, 0, 0, 0, true); > host_->SetLayoutManager(layout); > layout->set_cross_axis_alignment(BoxLayout::CROSS_AXIS_ALIGNMENT_END); > View* v1 = new StaticSizedView(gfx::Size(20, 4)); > v1->SetProperty(kMarginsKey, new gfx::Insets(3, 0, 0, 0)); > host_->AddChildView(v1); > View* v2 = new StaticSizedView(gfx::Size(20, 5)); > v2->SetProperty(kMarginsKey, new gfx::Insets(0, 0, 2, 0)); > host_->AddChildView(v2); > > EXPECT_EQ(9, layout->GetPreferredSize(host_.get()).height()); > } > } > > Unless I'm missing something the height with this patch is 10, not 9 as I would > expect. Am I missing something? What happens to view(20,5) as the vertical height shrinks? Does it remain 2 from the upper edge and shrink along with view(20,4)? If sized down to 8, then view(20,5) becomes (20,4) and view(20,4) becomes (20,3) and they would never align their top edges. I thought that the margin along the cross axis edges should be the max of all the views. That would keep (20,5) from violating that constraint. That is why it is 10 instead of 9. pkasting@? Am I understanding this correctly?
The CQ bit was checked by kylixrd@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
On Wed, May 31, 2017 at 10:02 AM, <kylixrd@chromium.org> wrote: > On 2017/05/31 14:53:54, sky wrote: > > On 2017/05/30 20:43:43, kylix_rd wrote: > > > In the immortal words of Bullwinkle Moose, "This time for sure!"... > > > > > > After correcting an issue with how GetPreferredSize() was calculating > the > > size, > > > I also had to adjust how the layout works when the cross axis is > centered. > > > > > > The upshot of this is that regardless of whether or not the margins are > > > collapsed, the behavior of the cross-axis remains the same. Another > point is > > > that the views are centered based on the full cross-axis size (sans the > > insets). > > > This can cause the view to be positioned off-center when the available > bounds > > > are sufficiently small and the margins are unbalanced across that axis. > Clear > > as > > > mud? > > > > Here's a unit test for the test case we talked about: > > > > TEST_F(BoxLayoutTest, OverlappingCrossMargins) { > > { > > BoxLayout* layout = new BoxLayout(BoxLayout::kHorizontal, 0, 0, 0, > false); > > host_->SetLayoutManager(layout); > > layout->set_cross_axis_alignment(BoxLayout::CROSS_AXIS_ALIGNMENT_END); > > View* v1 = new StaticSizedView(gfx::Size(20, 4)); > > v1->SetProperty(kMarginsKey, new gfx::Insets(3, 0, 0, 0)); > > host_->AddChildView(v1); > > View* v2 = new StaticSizedView(gfx::Size(20, 5)); > > v2->SetProperty(kMarginsKey, new gfx::Insets(0, 0, 2, 0)); > > host_->AddChildView(v2); > > > > EXPECT_EQ(9, layout->GetPreferredSize(host_.get()).height()); > > } > > { > > BoxLayout* layout = new BoxLayout(BoxLayout::kHorizontal, 0, 0, 0, > true); > > host_->SetLayoutManager(layout); > > layout->set_cross_axis_alignment(BoxLayout::CROSS_AXIS_ALIGNMENT_END); > > View* v1 = new StaticSizedView(gfx::Size(20, 4)); > > v1->SetProperty(kMarginsKey, new gfx::Insets(3, 0, 0, 0)); > > host_->AddChildView(v1); > > View* v2 = new StaticSizedView(gfx::Size(20, 5)); > > v2->SetProperty(kMarginsKey, new gfx::Insets(0, 0, 2, 0)); > > host_->AddChildView(v2); > > > > EXPECT_EQ(9, layout->GetPreferredSize(host_.get()).height()); > > } > > } > > > > Unless I'm missing something the height with this patch is 10, not 9 as I > would > > expect. Am I missing something? > > What happens to view(20,5) as the vertical height shrinks? Does it remain > 2 from > the upper edge and shrink along with view(20,4)? If sized down to 8, then > view(20,5) becomes (20,4) and view(20,4) becomes (20,3) and they would > never > align their top edges. I thought that the margin along the cross axis edges > should be the max of all the views. > If the margin along the cross axis is the max, then that's option (3), which isn't what Peter wants. What happens during resize depends upon the minimize size. I would treat the margins as inflexible. Behavior when resized smaller than the minimum is generally views extend outside the bounds of their parent, which most often leads to clipping. > That would keep (20,5) from violating that > constraint. That is why it is 10 instead of 9. > > pkasting@? Am I understanding this correctly? > > https://codereview.chromium.org/2836313002/ > -- You received this message because you are subscribed to the Google Groups "Chromium-reviews" group. To unsubscribe from this group and stop receiving emails from it, send an email to chromium-reviews+unsubscribe@chromium.org.
On 2017/05/31 19:53:11, sky wrote: > On Wed, May 31, 2017 at 10:02 AM, <mailto:kylixrd@chromium.org> wrote: > > > On 2017/05/31 14:53:54, sky wrote: > > > On 2017/05/30 20:43:43, kylix_rd wrote: > > > > In the immortal words of Bullwinkle Moose, "This time for sure!"... > > > > > > > > After correcting an issue with how GetPreferredSize() was calculating > > the > > > size, > > > > I also had to adjust how the layout works when the cross axis is > > centered. > > > > > > > > The upshot of this is that regardless of whether or not the margins are > > > > collapsed, the behavior of the cross-axis remains the same. Another > > point is > > > > that the views are centered based on the full cross-axis size (sans the > > > insets). > > > > This can cause the view to be positioned off-center when the available > > bounds > > > > are sufficiently small and the margins are unbalanced across that axis. > > Clear > > > as > > > > mud? > > > > > > Here's a unit test for the test case we talked about: > > > > > > TEST_F(BoxLayoutTest, OverlappingCrossMargins) { > > > { > > > BoxLayout* layout = new BoxLayout(BoxLayout::kHorizontal, 0, 0, 0, > > false); > > > host_->SetLayoutManager(layout); > > > layout->set_cross_axis_alignment(BoxLayout::CROSS_AXIS_ALIGNMENT_END); > > > View* v1 = new StaticSizedView(gfx::Size(20, 4)); > > > v1->SetProperty(kMarginsKey, new gfx::Insets(3, 0, 0, 0)); > > > host_->AddChildView(v1); > > > View* v2 = new StaticSizedView(gfx::Size(20, 5)); > > > v2->SetProperty(kMarginsKey, new gfx::Insets(0, 0, 2, 0)); > > > host_->AddChildView(v2); > > > > > > EXPECT_EQ(9, layout->GetPreferredSize(host_.get()).height()); > > > } > > > { > > > BoxLayout* layout = new BoxLayout(BoxLayout::kHorizontal, 0, 0, 0, > > true); > > > host_->SetLayoutManager(layout); > > > layout->set_cross_axis_alignment(BoxLayout::CROSS_AXIS_ALIGNMENT_END); > > > View* v1 = new StaticSizedView(gfx::Size(20, 4)); > > > v1->SetProperty(kMarginsKey, new gfx::Insets(3, 0, 0, 0)); > > > host_->AddChildView(v1); > > > View* v2 = new StaticSizedView(gfx::Size(20, 5)); > > > v2->SetProperty(kMarginsKey, new gfx::Insets(0, 0, 2, 0)); > > > host_->AddChildView(v2); > > > > > > EXPECT_EQ(9, layout->GetPreferredSize(host_.get()).height()); > > > } > > > } > > > > > > Unless I'm missing something the height with this patch is 10, not 9 as I > > would > > > expect. Am I missing something? > > > > What happens to view(20,5) as the vertical height shrinks? Does it remain > > 2 from > > the upper edge and shrink along with view(20,4)? If sized down to 8, then > > view(20,5) becomes (20,4) and view(20,4) becomes (20,3) and they would > > never > > align their top edges. I thought that the margin along the cross axis edges > > should be the max of all the views. > > > > If the margin along the cross axis is the max, then that's option (3), > which isn't what Peter wants. > > What happens during resize depends upon the minimize size. I would treat > the margins as inflexible. Behavior when resized smaller than the minimum > is generally views extend outside the bounds of their parent, which most > often leads to clipping. > > > > That would keep (20,5) from violating that > > constraint. That is why it is 10 instead of 9. > > > > pkasting@? Am I understanding this correctly? > > > > https://codereview.chromium.org/2836313002/ > > > > -- > You received this message because you are subscribed to the Google Groups > "Chromium-reviews" group. > To unsubscribe from this group and stop receiving emails from it, send an email > to mailto:chromium-reviews+unsubscribe@chromium.org. Pardon me while I wipe the egg off my face... I went back over the ASCII diagrams again. I think I see where I missed it. In non-collapsed margin more, the preferred size calculation *does* need to take into account the cross axis alignment, especially for START and END. The margins will "collapse" to the max of all the views along the common START or END edge... the margin on the opposite edge will only affect that specific view. Currently GetPreferredSize() collapses both margins along the cross axis regardless of the alignment.
On 2017/05/31 20:49:38, kylix_rd wrote: > Pardon me while I wipe the egg off my face... I went back over the ASCII > diagrams again. I think I see where I missed it. In non-collapsed margin more, > the preferred size calculation *does* need to take into account the cross axis > alignment, especially for START and END. The margins will "collapse" to the max > of all the views along the common START or END edge... the margin on the > opposite edge will only affect that specific view. Currently GetPreferredSize() > collapses both margins along the cross axis regardless of the alignment. I think you are coming to the same place I am, but below is the response to your earlier question I just finished writing, in case it adds clarity. On 2017/05/31 17:02:22, kylix_rd wrote: > On 2017/05/31 14:53:54, sky wrote: > > On 2017/05/30 20:43:43, kylix_rd wrote: > > > In the immortal words of Bullwinkle Moose, "This time for sure!"... > > > > > > After correcting an issue with how GetPreferredSize() was calculating the > > size, > > > I also had to adjust how the layout works when the cross axis is centered. > > > > > > The upshot of this is that regardless of whether or not the margins are > > > collapsed, the behavior of the cross-axis remains the same. Another point is > > > that the views are centered based on the full cross-axis size (sans the > > insets). > > > This can cause the view to be positioned off-center when the available > bounds > > > are sufficiently small and the margins are unbalanced across that axis. > Clear > > as > > > mud? > > > > Here's a unit test for the test case we talked about: > > > > TEST_F(BoxLayoutTest, OverlappingCrossMargins) { > > { > > BoxLayout* layout = new BoxLayout(BoxLayout::kHorizontal, 0, 0, 0, false); > > host_->SetLayoutManager(layout); > > layout->set_cross_axis_alignment(BoxLayout::CROSS_AXIS_ALIGNMENT_END); > > View* v1 = new StaticSizedView(gfx::Size(20, 4)); > > v1->SetProperty(kMarginsKey, new gfx::Insets(3, 0, 0, 0)); > > host_->AddChildView(v1); > > View* v2 = new StaticSizedView(gfx::Size(20, 5)); > > v2->SetProperty(kMarginsKey, new gfx::Insets(0, 0, 2, 0)); > > host_->AddChildView(v2); > > > > EXPECT_EQ(9, layout->GetPreferredSize(host_.get()).height()); > > } So just so I'm clear, we have view 1, which has height 4 and a 3 DIP top margin, end-aligned to view 2, which has height 5 and a 2 DIP margin. I would expect this to get laid out like: MMMM MMMM MMMM VVVV VVVV VVVV VVVV VVVV VVVV VVVV VVVV VVVV MMMM MMMM This would lead to a preferred container height of 9. > What happens to view(20,5) as the vertical height shrinks? Does it remain 2 from > the upper edge and shrink along with view(20,4)? You mean, if the container is sized smaller than its preferred height, what gives? I think if you sized the container down from 9 to 7, you'd get this: MMMM VVVV MMMM VVVV MMMM VVVV VVVV VVVV VVVV VVVV MMMM MMMM That is, we don't allow the margins to shrink, and we don't allow the bottom of view 1 to move past the bottom of view 2 (which would violate end alignment); so what has to give is view 1's height, which shrinks. If you shrank the height below 7, then both views would start getting shorter, until the left view has height 0. At that point I don't think the container can shrink further, but maybe if a view becomes size 0 its margin should be taken out of the picture entirely, I dunno.
On 2017/05/31 20:53:51, Peter Kasting wrote: > On 2017/05/31 20:49:38, kylix_rd wrote: > > Pardon me while I wipe the egg off my face... I went back over the ASCII > > diagrams again. I think I see where I missed it. In non-collapsed margin more, > > the preferred size calculation *does* need to take into account the cross axis > > alignment, especially for START and END. The margins will "collapse" to the > max > > of all the views along the common START or END edge... the margin on the > > opposite edge will only affect that specific view. Currently > GetPreferredSize() > > collapses both margins along the cross axis regardless of the alignment. > > I think you are coming to the same place I am, but below is the response to your > earlier question I just finished writing, in case it adds clarity. > > On 2017/05/31 17:02:22, kylix_rd wrote: > > On 2017/05/31 14:53:54, sky wrote: > > > On 2017/05/30 20:43:43, kylix_rd wrote: > > > > In the immortal words of Bullwinkle Moose, "This time for sure!"... > > > > > > > > After correcting an issue with how GetPreferredSize() was calculating the > > > size, > > > > I also had to adjust how the layout works when the cross axis is centered. > > > > > > > > The upshot of this is that regardless of whether or not the margins are > > > > collapsed, the behavior of the cross-axis remains the same. Another point > is > > > > that the views are centered based on the full cross-axis size (sans the > > > insets). > > > > This can cause the view to be positioned off-center when the available > > bounds > > > > are sufficiently small and the margins are unbalanced across that axis. > > Clear > > > as > > > > mud? > > > > > > Here's a unit test for the test case we talked about: > > > > > > TEST_F(BoxLayoutTest, OverlappingCrossMargins) { > > > { > > > BoxLayout* layout = new BoxLayout(BoxLayout::kHorizontal, 0, 0, 0, > false); > > > host_->SetLayoutManager(layout); > > > layout->set_cross_axis_alignment(BoxLayout::CROSS_AXIS_ALIGNMENT_END); > > > View* v1 = new StaticSizedView(gfx::Size(20, 4)); > > > v1->SetProperty(kMarginsKey, new gfx::Insets(3, 0, 0, 0)); > > > host_->AddChildView(v1); > > > View* v2 = new StaticSizedView(gfx::Size(20, 5)); > > > v2->SetProperty(kMarginsKey, new gfx::Insets(0, 0, 2, 0)); > > > host_->AddChildView(v2); > > > > > > EXPECT_EQ(9, layout->GetPreferredSize(host_.get()).height()); > > > } > > So just so I'm clear, we have view 1, which has height 4 and a 3 DIP top margin, > end-aligned to view 2, which has height 5 and a 2 DIP margin. > > I would expect this to get laid out like: > > MMMM > MMMM > MMMM VVVV > VVVV VVVV > VVVV VVVV > VVVV VVVV > VVVV VVVV > MMMM > MMMM > > This would lead to a preferred container height of 9. > > > What happens to view(20,5) as the vertical height shrinks? Does it remain 2 > from > > the upper edge and shrink along with view(20,4)? > > You mean, if the container is sized smaller than its preferred height, what > gives? I think if you sized the container down from 9 to 7, you'd get this: > > MMMM VVVV > MMMM VVVV > MMMM VVVV > VVVV VVVV > VVVV VVVV > MMMM > MMMM > > That is, we don't allow the margins to shrink, and we don't allow the bottom of > view 1 to move past the bottom of view 2 (which would violate end alignment); so > what has to give is view 1's height, which shrinks. > > If you shrank the height below 7, then both views would start getting shorter, > until the left view has height 0. At that point I don't think the container can > shrink further, but maybe if a view becomes size 0 its margin should be taken > out of the picture entirely, I dunno. In this instance the cross axis alignment being set to END would return 9. However, setting it to START or CENTER would return 10, right?
On 2017/05/31 21:00:41, kylix_rd wrote: > In this instance the cross axis alignment being set to END would return 9. > However, setting it to START or CENTER would return 10, right? START would definitely be 10, CENTER I dunno because it depends how we round, but I suspect it's 10 (I imagine we put the extra DIP on the bottom).
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
Now, when the cross axis alignment is START or END and collapse is false, only the anchoring edge is collapsed based on the maximum of that edge's margin from all views. CENTER or STRETCH, will collapse both cross axis margins. The behavior when collapse_margins_spacing is true should not have changed from previous iterations. I've included sky@'s OverlappingCrossMargins test and only changed the collapse version to be a height of 10. Collapsing will use the largest cross-axis margin from all views or the insets.
The CQ bit was checked by kylixrd@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
On 2017/06/01 16:06:11, kylix_rd wrote: > Now, when the cross axis alignment is START or END and collapse is false, only > the anchoring edge is collapsed based on the maximum of that edge's margin from > all views. CENTER or STRETCH, will collapse both cross axis margins. > > The behavior when collapse_margins_spacing is true should not have changed from > previous iterations. > > I've included sky@'s OverlappingCrossMargins test and only changed the collapse > version to be a height of 10. Collapsing will use the largest cross-axis margin > from all views or the insets. I don't think collapsing should affect the cross-axis margins like this. We had this conversation in the office :) Collapsing is a bit that should only affect how margins interact when they're "pushing into each other". It shouldn't link margins that are side-by-side. And intuitively, one would be surprised that telling margins to "collapse down" would cause them to get larger than before.
On 2017/06/01 18:08:40, Peter Kasting wrote: > On 2017/06/01 16:06:11, kylix_rd wrote: > > Now, when the cross axis alignment is START or END and collapse is false, only > > the anchoring edge is collapsed based on the maximum of that edge's margin > from > > all views. CENTER or STRETCH, will collapse both cross axis margins. > > > > The behavior when collapse_margins_spacing is true should not have changed > from > > previous iterations. > > > > I've included sky@'s OverlappingCrossMargins test and only changed the > collapse > > version to be a height of 10. Collapsing will use the largest cross-axis > margin > > from all views or the insets. > > I don't think collapsing should affect the cross-axis margins like this. We had > this conversation in the office :) > > Collapsing is a bit that should only affect how margins interact when they're > "pushing into each other". It shouldn't link margins that are side-by-side. > And intuitively, one would be surprised that telling margins to "collapse down" > would cause them to get larger than before. That is what happens when the alignment is START or END. So you want "jagged" margins in the cross-axis in the STRETCH or CENTER mode? They should, however, collapse between the margin and the border inset, correct?
On 2017/06/01 20:07:30, kylix_rd wrote: > On 2017/06/01 18:08:40, Peter Kasting wrote: > > On 2017/06/01 16:06:11, kylix_rd wrote: > > > Now, when the cross axis alignment is START or END and collapse is false, > only > > > the anchoring edge is collapsed based on the maximum of that edge's margin > > from > > > all views. CENTER or STRETCH, will collapse both cross axis margins. > > > > > > The behavior when collapse_margins_spacing is true should not have changed > > from > > > previous iterations. > > > > > > I've included sky@'s OverlappingCrossMargins test and only changed the > > collapse > > > version to be a height of 10. Collapsing will use the largest cross-axis > > margin > > > from all views or the insets. > > > > I don't think collapsing should affect the cross-axis margins like this. We > had > > this conversation in the office :) > > > > Collapsing is a bit that should only affect how margins interact when they're > > "pushing into each other". It shouldn't link margins that are side-by-side. > > And intuitively, one would be surprised that telling margins to "collapse > down" > > would cause them to get larger than before. > > That is what happens when the alignment is START or END. So you want "jagged" > margins in the cross-axis in the STRETCH or CENTER mode? Yes. > They should, however, > collapse between the margin and the border inset, correct? Yes, I think. I would guess that's what the "collapse" bit would toggle.
On 2017/06/01 20:25:48, Peter Kasting wrote: > On 2017/06/01 20:07:30, kylix_rd wrote: > > On 2017/06/01 18:08:40, Peter Kasting wrote: > > > On 2017/06/01 16:06:11, kylix_rd wrote: > > > > Now, when the cross axis alignment is START or END and collapse is false, > > only > > > > the anchoring edge is collapsed based on the maximum of that edge's margin > > > from > > > > all views. CENTER or STRETCH, will collapse both cross axis margins. > > > > > > > > The behavior when collapse_margins_spacing is true should not have changed > > > from > > > > previous iterations. > > > > > > > > I've included sky@'s OverlappingCrossMargins test and only changed the > > > collapse > > > > version to be a height of 10. Collapsing will use the largest cross-axis > > > margin > > > > from all views or the insets. > > > > > > I don't think collapsing should affect the cross-axis margins like this. We > > had > > > this conversation in the office :) > > > > > > Collapsing is a bit that should only affect how margins interact when > they're > > > "pushing into each other". It shouldn't link margins that are side-by-side. > > > > And intuitively, one would be surprised that telling margins to "collapse > > down" > > > would cause them to get larger than before. > > > > That is what happens when the alignment is START or END. So you want "jagged" > > margins in the cross-axis in the STRETCH or CENTER mode? > > Yes. > > > They should, however, > > collapse between the margin and the border inset, correct? > > Yes, I think. I would guess that's what the "collapse" bit would toggle. OK :)... this is almost going back to what I originally had, where there was no margin collapsing at all. The margins would effectively "enlarge" the view.
On 2017/06/01 20:28:29, kylix_rd wrote: > OK :)... this is almost going back to what I originally had, where there was no > margin collapsing at all. The margins would effectively "enlarge" the view. Well, sort of. Having margins enlarge the view wouldn't do what we want for START/END alignment (since we'd want to align the starts/ends of views sans-margins), and we do still want collapsing to affect margins that are "pushed against" each other.
On 2017/06/01 20:38:38, Peter Kasting wrote: > On 2017/06/01 20:28:29, kylix_rd wrote: > > OK :)... this is almost going back to what I originally had, where there was > no > > margin collapsing at all. The margins would effectively "enlarge" the view. > > Well, sort of. Having margins enlarge the view wouldn't do what we want for > START/END alignment (since we'd want to align the starts/ends of views > sans-margins), and we do still want collapsing to affect margins that are > "pushed against" each other. Right. Thus "almost" :). CENTER and STRETCH, will be similar to the original behavior.
On 2017/06/01 20:41:05, kylix_rd wrote: > On 2017/06/01 20:38:38, Peter Kasting wrote: > > On 2017/06/01 20:28:29, kylix_rd wrote: > > > OK :)... this is almost going back to what I originally had, where there was > > no > > > margin collapsing at all. The margins would effectively "enlarge" the view. > > > > Well, sort of. Having margins enlarge the view wouldn't do what we want for > > START/END alignment (since we'd want to align the starts/ends of views > > sans-margins), and we do still want collapsing to affect margins that are > > "pushed against" each other. > > Right. Thus "almost" :). CENTER and STRETCH, will be similar to the original > behavior. The more I think about this, I think the current behavior makes just as much sense as any other. In interest of finalizing this CL, we should go with it as coded.
On 2017/06/02 16:21:35, kylix_rd wrote: > The more I think about this, I think the current behavior makes just as much > sense as any other. In interest of finalizing this CL, we should go with it as > coded. I'm OK with landing something if you're planning on fixing it afterwards, in the interests of not having CLs drag on forever. I don't agree with the contention that the current behavior makes as much sense as any other and wouldn't need to be changed. I could be wrong on this one.
On 2017/06/02 17:40:07, Peter Kasting wrote: > On 2017/06/02 16:21:35, kylix_rd wrote: > > The more I think about this, I think the current behavior makes just as much > > sense as any other. In interest of finalizing this CL, we should go with it as > > coded. > > I'm OK with landing something if you're planning on fixing it afterwards, in the > interests of not having CLs drag on forever. That is certainly a big reason. > I don't agree with the contention that the current behavior makes as much sense > as any other and wouldn't need to be changed. I could be wrong on this one. I'd also like to see how this plays out "in the real world". Especially, I'd like to know how you feel about this after playing around with the views example for a bit. Maybe you'll change your mind, maybe not. IMO, nothing beats watching the code in action.
The CQ bit was checked by kylixrd@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Patchset #22 (id:480001) has been deleted
The CQ bit was checked by kylixrd@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Allen, Can you please clarify what state this patch is in? If it's not what Peter (the consumer) wants, I would prefer you fix it to the state that he is going to use it. Otherwise I'm going to have to keep reviewing this, and I, and I'm sure you, would like to move on! -Scott On Fri, Jun 2, 2017 at 10:52 AM, <kylixrd@chromium.org> wrote: > On 2017/06/02 17:40:07, Peter Kasting wrote: > > On 2017/06/02 16:21:35, kylix_rd wrote: > > > The more I think about this, I think the current behavior makes just > as much > > > sense as any other. In interest of finalizing this CL, we should go > with it > as > > > coded. > > > > I'm OK with landing something if you're planning on fixing it > afterwards, in > the > > interests of not having CLs drag on forever. > > That is certainly a big reason. > > > I don't agree with the contention that the current behavior makes as much > sense > > as any other and wouldn't need to be changed. I could be wrong on this > one. > > I'd also like to see how this plays out "in the real world". Especially, > I'd > like to know how you feel about this after playing around with the views > example > for a bit. Maybe you'll change your mind, maybe not. IMO, nothing beats > watching > the code in action. > > https://codereview.chromium.org/2836313002/ > -- You received this message because you are subscribed to the Google Groups "Chromium-reviews" group. To unsubscribe from this group and stop receiving emails from it, send an email to chromium-reviews+unsubscribe@chromium.org.
On 2017/06/02 20:44:58, sky wrote: > Allen, > > Can you please clarify what state this patch is in? If it's not what Peter > (the consumer) wants, I would prefer you fix it to the state that he is > going to use it. Otherwise I'm going to have to keep reviewing this, and I, > and I'm sure you, would like to move on! > > -Scott The only thing right now is that in STRETCH or CENTER the view bounds on the cross-axis will be visually aligned if they have different or overlapping/unbalanced margins. There was a lot of emphasis on ensuring the view edges would visually align in the cross-axis. This affects not only the layout code but also the preferred size calculation. This does kind of feel like it's been a bit of a moving target. I place much of that on myself and some original misunderstandings of the requirements. > On Fri, Jun 2, 2017 at 10:52 AM, <mailto:kylixrd@chromium.org> wrote: > > > On 2017/06/02 17:40:07, Peter Kasting wrote: > > > On 2017/06/02 16:21:35, kylix_rd wrote: > > > > The more I think about this, I think the current behavior makes just > > as much > > > > sense as any other. In interest of finalizing this CL, we should go > > with it > > as > > > > coded. > > > > > > I'm OK with landing something if you're planning on fixing it > > afterwards, in > > the > > > interests of not having CLs drag on forever. > > > > That is certainly a big reason. > > > > > I don't agree with the contention that the current behavior makes as much > > sense > > > as any other and wouldn't need to be changed. I could be wrong on this > > one. > > > > I'd also like to see how this plays out "in the real world". Especially, > > I'd > > like to know how you feel about this after playing around with the views > > example > > for a bit. Maybe you'll change your mind, maybe not. IMO, nothing beats > > watching > > the code in action. > > > > https://codereview.chromium.org/2836313002/ > > > > -- > You received this message because you are subscribed to the Google Groups > "Chromium-reviews" group. > To unsubscribe from this group and stop receiving emails from it, send an email > to mailto:chromium-reviews+unsubscribe@chromium.org.
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
Here's the current sitch'. For the cross axis, in START and END alignment mode, only the common edge margins are collapsed using the largest of all the views' margins. For STRETCH and CENTER, neither margin is collapsed. In all modes, the inside_border_insets_ is collapsed individually with the views' margins only when collapse_margins_spacing_ is true. The main axis behavior remains the same as it's been for most of the previous patches. I adjusted the unit tests to reflect the new cross-axis behavior.
I had always thought collapsing is only useful along the main axis. Do we actually care about collapsing along the cross axis? Peter, do you need collapsing margins along the cross axis? This really only matters if the view associated with the LayoutManager has a border. -Scott On Mon, Jun 5, 2017 at 8:48 AM, <kylixrd@chromium.org> wrote: > Here's the current sitch'. For the cross axis, in START and END alignment > mode, > only the common edge margins are collapsed using the largest of all the > views' > margins. For STRETCH and CENTER, neither margin is collapsed. In all > modes, the > inside_border_insets_ is collapsed individually with the views' margins > only > when collapse_margins_spacing_ is true. > > The main axis behavior remains the same as it's been for most of the > previous > patches. > > I adjusted the unit tests to reflect the new cross-axis behavior. > > https://codereview.chromium.org/2836313002/ > -- You received this message because you are subscribed to the Google Groups "Chromium-reviews" group. To unsubscribe from this group and stop receiving emails from it, send an email to chromium-reviews+unsubscribe@chromium.org.
On 2017/06/05 15:51:03, sky wrote: > I had always thought collapsing is only useful along the main axis. Do we > actually care about collapsing along the cross axis? Peter, do you need > collapsing margins along the cross axis? This really only matters if the > view associated with the LayoutManager has a border. It sounds as if Allen has implemented two different collapse bits (|collapse_margins_spacing_| to control collapsing against the border, plus one other to control collapsing against another margin?). The collapse-against-spacing bit affects both main and cross axis margins, which makes sense to me. I read you as saying we may not care about this, but I would say what's less clear to me is if we care about collapse-against-the-border at all; if we do, then it makes sense to do it on both axes. It also sounds like the collapse-against-other-margins bit effectively does nothing for cross-axis margins, though I wasn't sure (because it's not clear to me how anything would differ if "in START and END alignment mode, only the common edge margins are collapsed using the largest of all the views' margins" weren't true). Which also sounds like what I was asking for?
On 2017/06/05 15:57:10, Peter Kasting wrote: > On 2017/06/05 15:51:03, sky wrote: > > I had always thought collapsing is only useful along the main axis. Do we > > actually care about collapsing along the cross axis? Peter, do you need > > collapsing margins along the cross axis? This really only matters if the > > view associated with the LayoutManager has a border. > > It sounds as if Allen has implemented two different collapse bits > (|collapse_margins_spacing_| to control collapsing against the border, plus one > other to control collapsing against another margin?). The > collapse-against-spacing bit affects both main and cross axis margins, which > makes sense to me. I read you as saying we may not care about this, but I would > say what's less clear to me is if we care about collapse-against-the-border at > all; if we do, then it makes sense to do it on both axes. > > It also sounds like the collapse-against-other-margins bit effectively does > nothing for cross-axis margins, though I wasn't sure (because it's not clear to > me how anything would differ if "in START and END alignment mode, only the > common edge margins are collapsed using the largest of all the views' margins" > weren't true). Which also sounds like what I was asking for? The cross axis margins will only ever "touch" the |inside_border_insets_|. They are only collapsed against the corresponding cross-axis margin when |collapse_margins_spacing_| is true. When the alignment is START or END, the margins aren't so much "collapsed" as much as the common view edges are aligned at a point that is the largest of all the views margins along that edge. In the case where |collapse_margins_spacing_| is true, then the edge corresponding to the START or END alignment is aligned based on the max of the views' margins along that edge and the |inside_border_insets_| same edge. Effectively, |collapse_margins_spacing_| *does* only control how margins-against-spacing and margins-against-margins are handled. Again, clear as mud?
Not really :(
On Mon, Jun 5, 2017 at 9:29 AM, <kylixrd@chromium.org> wrote: > On 2017/06/05 15:57:10, Peter Kasting wrote: > > On 2017/06/05 15:51:03, sky wrote: > > > I had always thought collapsing is only useful along the main axis. Do > we > > > actually care about collapsing along the cross axis? Peter, do you need > > > collapsing margins along the cross axis? This really only matters if > the > > > view associated with the LayoutManager has a border. > > > > It sounds as if Allen has implemented two different collapse bits > > (|collapse_margins_spacing_| to control collapsing against the border, > plus > one > > other to control collapsing against another margin?). The > > collapse-against-spacing bit affects both main and cross axis margins, > which > > makes sense to me. I read you as saying we may not care about this, but I > would > > say what's less clear to me is if we care about > collapse-against-the-border at > > all; if we do, then it makes sense to do it on both axes. > > > > It also sounds like the collapse-against-other-margins bit effectively > does > > nothing for cross-axis margins, though I wasn't sure (because it's not > clear > to > > me how anything would differ if "in START and END alignment mode, only > the > > common edge margins are collapsed using the largest of all the views' > margins" > > weren't true). Which also sounds like what I was asking for? > > The cross axis margins will only ever "touch" the |inside_border_insets_|. > They > are only collapsed against the corresponding cross-axis margin when > |collapse_margins_spacing_| is true. When the alignment is START or END, > the > margins aren't so much "collapsed" as much as the common view edges are > aligned > at a point that is the largest of all the views margins along that edge. > "common view edges are aligned at a point that is the largest of all the views margins along that edge." That sounds like (3). You're not using the max of the margins along the cross axis, right? You can't be otherwise the test case I sent earlier wouldn't work. -Scott In the > case where |collapse_margins_spacing_| is true, then the edge > corresponding to > the START or END alignment is aligned based on the max of the views' > margins > along that edge and the |inside_border_insets_| same edge. > > Effectively, |collapse_margins_spacing_| *does* only control how > margins-against-spacing and margins-against-margins are handled. > > Again, clear as mud? > > https://codereview.chromium.org/2836313002/ > -- You received this message because you are subscribed to the Google Groups "Chromium-reviews" group. To unsubscribe from this group and stop receiving emails from it, send an email to chromium-reviews+unsubscribe@chromium.org.
I got hung up on the docs and didn't make it to the actual implementation. https://codereview.chromium.org/2836313002/diff/520001/ui/views/layout/box_la... File ui/views/layout/box_layout.h (right): https://codereview.chromium.org/2836313002/diff/520001/ui/views/layout/box_la... ui/views/layout/box_layout.h:64: // spacing/margins are collapsed base on the max of the two values. For the base->based https://codereview.chromium.org/2836313002/diff/520001/ui/views/layout/box_la... ui/views/layout/box_layout.h:66: // inside_border_xxxxx_spacing and the max of the corresponding margin edge This can't be entirely correct, is it? Whether max is used depends upon the alignment and the views, right?
On 2017/06/05 17:24:37, sky wrote: > On Mon, Jun 5, 2017 at 9:29 AM, <mailto:kylixrd@chromium.org> wrote: > > > On 2017/06/05 15:57:10, Peter Kasting wrote: > > > On 2017/06/05 15:51:03, sky wrote: > > > > I had always thought collapsing is only useful along the main axis. Do > > we > > > > actually care about collapsing along the cross axis? Peter, do you need > > > > collapsing margins along the cross axis? This really only matters if > > the > > > > view associated with the LayoutManager has a border. > > > > > > It sounds as if Allen has implemented two different collapse bits > > > (|collapse_margins_spacing_| to control collapsing against the border, > > plus > > one > > > other to control collapsing against another margin?). The > > > collapse-against-spacing bit affects both main and cross axis margins, > > which > > > makes sense to me. I read you as saying we may not care about this, but I > > would > > > say what's less clear to me is if we care about > > collapse-against-the-border at > > > all; if we do, then it makes sense to do it on both axes. > > > > > > It also sounds like the collapse-against-other-margins bit effectively > > does > > > nothing for cross-axis margins, though I wasn't sure (because it's not > > clear > > to > > > me how anything would differ if "in START and END alignment mode, only > > the > > > common edge margins are collapsed using the largest of all the views' > > margins" > > > weren't true). Which also sounds like what I was asking for? > > > > The cross axis margins will only ever "touch" the |inside_border_insets_|. > > They > > are only collapsed against the corresponding cross-axis margin when > > |collapse_margins_spacing_| is true. When the alignment is START or END, > > the > > margins aren't so much "collapsed" as much as the common view edges are > > aligned > > at a point that is the largest of all the views margins along that edge. > > > > "common view edges are aligned at a point that is the largest of all the > views margins along that edge." > > That sounds like (3). You're not using the max of the margins along the > cross axis, right? You can't be otherwise the test case I sent earlier > wouldn't work. Only when the cross axis alignment is START or END. The view edges corresponding to the START or the END, are always aligned. This requires that the margin along that edge be the max among all the views along that edge. Otherwise, the edges won't be aligned. The opposite edge will not necessarily be aligned as there is no interaction with the adjacent views along the main axis. For STRETCH or CENTER, neither of the cross-axis edges will align with the other views since they, effectively, are aligning along their centers across the main axis. The test case you sent does work, but only when the cross axis is END aligned. If the alignment is changed to START, then the height would be 10. I'll take a crack at the ASCII art to illustrate. _ MMMMM..... ^ MMMMM..... | MMMMM..... | VVVVVVVVVV | <--- top edges are aligned when cross axis alignment is START VVVVVVVVVV | VVVVVVVVVV 10 VVVVVVVVVV | .....VVVVV | .....MMMMM | .....MMMMM v - With cross-axis alignment set to END. _ MMMMM..... ^ MMMMM..... | MMMMMVVVVV | VVVVVVVVVV | VVVVVVVVVV 9 VVVVVVVVVV | VVVVVVVVVV | <--- bottom edges are aligned when cross axis alignment is END .....MMMMM | .....MMMMM v - For CENTER and STRETCH, due to rounding, the height would be 10, like the START version above. If the height of the second view changed to 6, it would still be 10. _ MMMMM..... ^ MMMMM..... | MMMMMVVVVV | VVVVVVVVVV | VVVVVVVVVV | VVVVVVVVVV 10 <--- vertical centers are aligned when cross axis alignment is CENTER or STRETCH VVVVVVVVVV | .....VVVVV | .....MMMMM | .....MMMMM v - > -Scott > > In the > > case where |collapse_margins_spacing_| is true, then the edge > > corresponding to > > the START or END alignment is aligned based on the max of the views' > > margins > > along that edge and the |inside_border_insets_| same edge. > > > > Effectively, |collapse_margins_spacing_| *does* only control how > > margins-against-spacing and margins-against-margins are handled. > > > > Again, clear as mud? > > > > https://codereview.chromium.org/2836313002/ > > > > -- > You received this message because you are subscribed to the Google Groups > "Chromium-reviews" group. > To unsubscribe from this group and stop receiving emails from it, send an email > to mailto:chromium-reviews+unsubscribe@chromium.org.
That all looks correct to me.
On 2017/06/05 18:04:43, Peter Kasting wrote: > That all looks correct to me. <Pops cork on the champagne>... ;).
The CQ bit was checked by kylixrd@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
On 2017/06/05 17:48:09, kylix_rd wrote: > On 2017/06/05 17:24:37, sky wrote: > > On Mon, Jun 5, 2017 at 9:29 AM, <mailto:kylixrd@chromium.org> wrote: > > > > > On 2017/06/05 15:57:10, Peter Kasting wrote: > > > > On 2017/06/05 15:51:03, sky wrote: > > > > > I had always thought collapsing is only useful along the main axis. Do > > > we > > > > > actually care about collapsing along the cross axis? Peter, do you need > > > > > collapsing margins along the cross axis? This really only matters if > > > the > > > > > view associated with the LayoutManager has a border. > > > > > > > > It sounds as if Allen has implemented two different collapse bits > > > > (|collapse_margins_spacing_| to control collapsing against the border, > > > plus > > > one > > > > other to control collapsing against another margin?). The > > > > collapse-against-spacing bit affects both main and cross axis margins, > > > which > > > > makes sense to me. I read you as saying we may not care about this, but I > > > would > > > > say what's less clear to me is if we care about > > > collapse-against-the-border at > > > > all; if we do, then it makes sense to do it on both axes. > > > > > > > > It also sounds like the collapse-against-other-margins bit effectively > > > does > > > > nothing for cross-axis margins, though I wasn't sure (because it's not > > > clear > > > to > > > > me how anything would differ if "in START and END alignment mode, only > > > the > > > > common edge margins are collapsed using the largest of all the views' > > > margins" > > > > weren't true). Which also sounds like what I was asking for? > > > > > > The cross axis margins will only ever "touch" the |inside_border_insets_|. > > > They > > > are only collapsed against the corresponding cross-axis margin when > > > |collapse_margins_spacing_| is true. When the alignment is START or END, > > > the > > > margins aren't so much "collapsed" as much as the common view edges are > > > aligned > > > at a point that is the largest of all the views margins along that edge. > > > > > > > "common view edges are aligned at a point that is the largest of all the > > views margins along that edge." > > > > That sounds like (3). You're not using the max of the margins along the > > cross axis, right? You can't be otherwise the test case I sent earlier > > wouldn't work. > > Only when the cross axis alignment is START or END. The view edges corresponding > to the START or the END, are always aligned. This requires that the margin along > that edge be the max among all the views along that edge. Otherwise, the edges > won't be aligned. The opposite edge will not necessarily be aligned as there is > no interaction with the adjacent views along the main axis. For STRETCH or > CENTER, neither of the cross-axis edges will align with the other views since > they, effectively, are aligning along their centers across the main axis. > > The test case you sent does work, but only when the cross axis is END aligned. > If the alignment is changed to START, then the height would be 10. I'll take a > crack at the ASCII art to illustrate. > _ > MMMMM..... ^ > MMMMM..... | > MMMMM..... | > VVVVVVVVVV | <--- top edges are aligned when cross axis alignment is START > VVVVVVVVVV | > VVVVVVVVVV 10 > VVVVVVVVVV | > .....VVVVV | > .....MMMMM | > .....MMMMM v > - > > With cross-axis alignment set to END. > _ > MMMMM..... ^ > MMMMM..... | > MMMMMVVVVV | > VVVVVVVVVV | > VVVVVVVVVV 9 > VVVVVVVVVV | > VVVVVVVVVV | <--- bottom edges are aligned when cross axis alignment is END > .....MMMMM | > .....MMMMM v > - > > For CENTER and STRETCH, due to rounding, the height would be 10, like the START > version above. If the height of the second view changed to 6, it would still be > 10. > _ > MMMMM..... ^ > MMMMM..... | > MMMMMVVVVV | > VVVVVVVVVV | > VVVVVVVVVV | > VVVVVVVVVV 10 <--- vertical centers are aligned when cross axis alignment is > CENTER or STRETCH > VVVVVVVVVV | > .....VVVVV | > .....MMMMM | > .....MMMMM v > - > > > -Scott > > > > In the > > > case where |collapse_margins_spacing_| is true, then the edge > > > corresponding to > > > the START or END alignment is aligned based on the max of the views' > > > margins > > > along that edge and the |inside_border_insets_| same edge. > > > > > > Effectively, |collapse_margins_spacing_| *does* only control how > > > margins-against-spacing and margins-against-margins are handled. > > > > > > Again, clear as mud? > > > > > > https://codereview.chromium.org/2836313002/ > > > > > > > -- > > You received this message because you are subscribed to the Google Groups > > "Chromium-reviews" group. > > To unsubscribe from this group and stop receiving emails from it, send an > email > > to mailto:chromium-reviews+unsubscribe@chromium.org. That sounds right, but the description "common view edges are aligned at a point that is the largest of all the views margins along that edge" implies on all sides. Perhaps it's the 'common view edge' that is confusing? I'll look at the patch shortly.
https://codereview.chromium.org/2836313002/diff/540001/ui/views/layout/box_la... File ui/views/layout/box_layout.cc (right): https://codereview.chromium.org/2836313002/diff/540001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:27: if (axis == HORIZONTAL_AXIS) use {} https://codereview.chromium.org/2836313002/diff/540001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:33: } Newline between 32/33 and // namespace (with two spaces before the '//'). See last three lines in this file for what this should look like. https://codereview.chromium.org/2836313002/diff/540001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:48: if (layout_->collapse_margins_spacing_) This is subtle and worth a comment. In particular *why* does this not include the margins? https://codereview.chromium.org/2836313002/diff/540001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:53: } else { no else after early return. https://codereview.chromium.org/2836313002/diff/540001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:72: if (orientation_ == Orientation::kVertical) { Replace this if with an else. https://codereview.chromium.org/2836313002/diff/540001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:126: gfx::Insets max_cross_axis_margin; Early out if child_area empty? https://codereview.chromium.org/2836313002/diff/540001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:200: child_margins = MaxAxisInsets( {} https://codereview.chromium.org/2836313002/diff/540001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:279: int leading = 0; This whole block could use a comment. https://codereview.chromium.org/2836313002/diff/540001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:287: gfx::Size child_size = child.view()->GetPreferredSize(); This is worth a comment as to why you don't use the wrapper's GetPreferredSize function. https://codereview.chromium.org/2836313002/diff/540001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:289: if (collapse_margins_spacing_) use {} as body spans multiple lines. https://codereview.chromium.org/2836313002/diff/540001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:305: gfx::Rect(-(child_size.width() / 2), 0, child_size.width(), Shouldn't you use the margins in this code path? https://codereview.chromium.org/2836313002/diff/540001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:545: child, ViewWrapper(this, NextVisibleView(i))); optional: I have to admit I'm mildly bothered that NextVisibleView iterates, and then the for loop iterates (this comment applies to other for loops that share the same pattern). https://codereview.chromium.org/2836313002/diff/540001/ui/views/layout/box_la... File ui/views/layout/box_layout.h (right): https://codereview.chromium.org/2836313002/diff/540001/ui/views/layout/box_la... ui/views/layout/box_layout.h:176: int GetHeightForWidth(int width) const; optional: Generally we have newline after destructor. https://codereview.chromium.org/2836313002/diff/540001/ui/views/layout/box_la... ui/views/layout/box_layout.h:186: const Orientation orientation_; Why do you need to cache both the layout and orientation? Use layout_->orientation_ (or add an inline orientation() to ViewWrapper if you prefer).
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
Patchset #25 (id:560001) has been deleted
https://codereview.chromium.org/2836313002/diff/520001/ui/views/layout/box_la... File ui/views/layout/box_layout.h (right): https://codereview.chromium.org/2836313002/diff/520001/ui/views/layout/box_la... ui/views/layout/box_layout.h:64: // spacing/margins are collapsed base on the max of the two values. For the On 2017/06/05 17:26:53, sky wrote: > base->based Done. https://codereview.chromium.org/2836313002/diff/520001/ui/views/layout/box_la... ui/views/layout/box_layout.h:66: // inside_border_xxxxx_spacing and the max of the corresponding margin edge On 2017/06/05 17:26:54, sky wrote: > This can't be entirely correct, is it? Whether max is used depends upon the > alignment and the views, right? Done. https://codereview.chromium.org/2836313002/diff/540001/ui/views/layout/box_la... File ui/views/layout/box_layout.cc (right): https://codereview.chromium.org/2836313002/diff/540001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:27: if (axis == HORIZONTAL_AXIS) On 2017/06/05 21:04:10, sky wrote: > use {} Done. https://codereview.chromium.org/2836313002/diff/540001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:33: } On 2017/06/05 21:04:10, sky wrote: > Newline between 32/33 and // namespace (with two spaces before the '//'). See > last three lines in this file for what this should look like. Done. https://codereview.chromium.org/2836313002/diff/540001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:48: if (layout_->collapse_margins_spacing_) On 2017/06/05 21:04:10, sky wrote: > This is subtle and worth a comment. In particular *why* does this not include > the margins? Done. https://codereview.chromium.org/2836313002/diff/540001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:53: } else { On 2017/06/05 21:04:10, sky wrote: > no else after early return. Done. https://codereview.chromium.org/2836313002/diff/540001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:72: if (orientation_ == Orientation::kVertical) { On 2017/06/05 21:04:10, sky wrote: > Replace this if with an else. Done. https://codereview.chromium.org/2836313002/diff/540001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:126: gfx::Insets max_cross_axis_margin; On 2017/06/05 21:04:10, sky wrote: > Early out if child_area empty? Done. https://codereview.chromium.org/2836313002/diff/540001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:200: child_margins = MaxAxisInsets( On 2017/06/05 21:04:10, sky wrote: > {} Done. https://codereview.chromium.org/2836313002/diff/540001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:279: int leading = 0; On 2017/06/05 21:04:10, sky wrote: > This whole block could use a comment. Done. https://codereview.chromium.org/2836313002/diff/540001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:287: gfx::Size child_size = child.view()->GetPreferredSize(); On 2017/06/05 21:04:10, sky wrote: > This is worth a comment as to why you don't use the wrapper's GetPreferredSize > function. Done. https://codereview.chromium.org/2836313002/diff/540001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:289: if (collapse_margins_spacing_) On 2017/06/05 21:04:10, sky wrote: > use {} as body spans multiple lines. Done. https://codereview.chromium.org/2836313002/diff/540001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:305: gfx::Rect(-(child_size.width() / 2), 0, child_size.width(), On 2017/06/05 21:04:10, sky wrote: > Shouldn't you use the margins in this code path? No. This code is "centering" the view horizontally by using 0 as the center-point. Since we don't have a rectangle which can be used to calculate a common center point, a single known point (0) is used. That's OK here, because we're not interested in the actual position of the view. We're only interested in the overall width including the margins. Comment added to that effect. https://codereview.chromium.org/2836313002/diff/540001/ui/views/layout/box_la... ui/views/layout/box_layout.cc:545: child, ViewWrapper(this, NextVisibleView(i))); On 2017/06/05 21:04:10, sky wrote: > optional: I have to admit I'm mildly bothered that NextVisibleView iterates, and > then the for loop iterates (this comment applies to other for loops that share > the same pattern). Understandable. It could be incorporated into the loop itself, but I fear it may make the code more dense. https://codereview.chromium.org/2836313002/diff/540001/ui/views/layout/box_la... File ui/views/layout/box_layout.h (right): https://codereview.chromium.org/2836313002/diff/540001/ui/views/layout/box_la... ui/views/layout/box_layout.h:176: int GetHeightForWidth(int width) const; On 2017/06/05 21:04:10, sky wrote: > optional: Generally we have newline after destructor. Done. https://codereview.chromium.org/2836313002/diff/540001/ui/views/layout/box_la... ui/views/layout/box_layout.h:186: const Orientation orientation_; On 2017/06/05 21:04:11, sky wrote: > Why do you need to cache both the layout and orientation? Use > layout_->orientation_ (or add an inline orientation() to ViewWrapper if you > prefer). In previous iterations, it was accessed more frequently within the ViewWrapper. Removed.
The CQ bit was checked by kylixrd@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
LGTM - yay!
On 2017/06/06 21:19:06, sky wrote: > LGTM - yay! WooHoo! Do we have another LGxM from pkasting@?
You don't actually need one, but if you want him to verify this meets his needs than you can wait for it. You might ping Peter off thread to make sure he knows you're waiting though. -Scott On Wed, Jun 7, 2017 at 10:40 AM, <kylixrd@chromium.org> wrote: > On 2017/06/06 21:19:06, sky wrote: > > LGTM - yay! > > WooHoo! > > Do we have another LGxM from pkasting@? > > https://codereview.chromium.org/2836313002/ > -- You received this message because you are subscribed to the Google Groups "Chromium-reviews" group. To unsubscribe from this group and stop receiving emails from it, send an email to chromium-reviews+unsubscribe@chromium.org.
On 2017/06/07 19:26:09, sky wrote: > You don't actually need one, but if you want him to verify this meets his > needs than you can wait for it. You might ping Peter off thread to make > sure he knows you're waiting though. He's already said "That all looks correct to me.", so I'll take that as being confirmation. Thanks.
The CQ bit was checked by kylixrd@chromium.org
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: linux_chromium_asan_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...)
The CQ bit was checked by kylixrd@chromium.org
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
CQ is committing da patch. Bot data: {"patchset_id": 580001, "attempt_start_ts": 1496927724388700, "parent_rev": "b8edd52416f1e93bf2330543f5b888d2dadc9e14", "commit_rev": "3c489a82647c5e33a6e4fae55bc1a30d87c87d91"}
Message was sent while issue was closed.
Description was changed from ========== BoxLayout now suports per-view margins. Call BoxLayout::SetViewMargins(view, margins) to set the amount of space for each side of the control. ========== to ========== BoxLayout now suports per-view margins. Call BoxLayout::SetViewMargins(view, margins) to set the amount of space for each side of the control. Review-Url: https://codereview.chromium.org/2836313002 Cr-Commit-Position: refs/heads/master@{#477955} Committed: https://chromium.googlesource.com/chromium/src/+/3c489a82647c5e33a6e4fae55bc1... ==========
Message was sent while issue was closed.
Committed patchset #25 (id:580001) as https://chromium.googlesource.com/chromium/src/+/3c489a82647c5e33a6e4fae55bc1... |