Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(787)

Unified Diff: ui/views/controls/single_split_view.cc

Issue 1702473002: Make SingleSplitView take borders into account. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/single_split_view.cc
diff --git a/ui/views/controls/single_split_view.cc b/ui/views/controls/single_split_view.cc
index c75569169629c03fb1c8242cfa0fc5cb7e5a41d5..a18fa0881505ce8c8a8c6d7087c07ed2af9b4e05 100644
--- a/ui/views/controls/single_split_view.cc
+++ b/ui/views/controls/single_split_view.cc
@@ -9,6 +9,7 @@
#include "ui/base/cursor/cursor.h"
#include "ui/gfx/canvas.h"
#include "ui/views/background.h"
+#include "ui/views/border.h"
#include "ui/views/controls/single_split_view_listener.h"
#include "ui/views/native_cursor.h"
@@ -45,7 +46,8 @@ SingleSplitView::SingleSplitView(View* leading,
void SingleSplitView::Layout() {
gfx::Rect leading_bounds;
gfx::Rect trailing_bounds;
- CalculateChildrenBounds(bounds(), &leading_bounds, &trailing_bounds);
+ CalculateChildrenBounds(GetContentsBounds(), &leading_bounds,
+ &trailing_bounds);
if (has_children()) {
if (child_at(0)->visible())
@@ -87,6 +89,8 @@ gfx::Size SingleSplitView::GetPreferredSize() const {
width += GetDividerSize();
else
height += GetDividerSize();
+ width += border()->GetInsets().width();
sky 2016/02/16 16:33:51 border may be null. Use GetInsets().
julienp 2016/02/17 13:46:26 Done.
+ height += border()->GetInsets().height();
return gfx::Size(width, height);
}
@@ -124,23 +128,25 @@ void SingleSplitView::CalculateChildrenBounds(
divider_at = 0;
} else {
divider_at =
- CalculateDividerOffset(divider_offset_, this->bounds(), bounds);
+ CalculateDividerOffset(divider_offset_, GetContentsBounds(), bounds);
sky 2016/02/16 16:33:51 GetContentsBounds() -> bounds
julienp 2016/02/17 13:46:26 Done.
divider_at = NormalizeDividerOffset(divider_at, bounds);
}
int divider_size = GetDividerSize();
if (is_horizontal_) {
- *leading_bounds = gfx::Rect(0, 0, divider_at, bounds.height());
+ *leading_bounds =
+ gfx::Rect(bounds.x(), bounds.y(), divider_at, bounds.height());
*trailing_bounds =
- gfx::Rect(divider_at + divider_size, 0,
+ gfx::Rect(divider_at + divider_size + bounds.x(), bounds.y(),
std::max(0, bounds.width() - divider_at - divider_size),
bounds.height());
} else {
- *leading_bounds = gfx::Rect(0, 0, bounds.width(), divider_at);
- *trailing_bounds =
- gfx::Rect(0, divider_at + divider_size, bounds.width(),
- std::max(0, bounds.height() - divider_at - divider_size));
+ *leading_bounds =
+ gfx::Rect(bounds.x(), bounds.y(), bounds.width(), divider_at);
+ *trailing_bounds = gfx::Rect(
+ bounds.x(), divider_at + divider_size + bounds.y(), bounds.width(),
+ std::max(0, bounds.height() - divider_at - divider_size));
}
}
@@ -153,7 +159,7 @@ bool SingleSplitView::OnMousePressed(const ui::MouseEvent& event) {
return false;
drag_info_.initial_mouse_offset = GetPrimaryAxisSize(event.x(), event.y());
drag_info_.initial_divider_offset =
- NormalizeDividerOffset(divider_offset_, bounds());
+ NormalizeDividerOffset(divider_offset_, GetContentsBounds());
return true;
}
@@ -196,8 +202,11 @@ void SingleSplitView::OnMouseCaptureLost() {
}
void SingleSplitView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
- divider_offset_ = CalculateDividerOffset(divider_offset_, previous_bounds,
- bounds());
+ gfx::Rect previous_content_bounds = previous_bounds;
+ if (border())
+ previous_content_bounds.Inset(border()->GetInsets());
+ divider_offset_ = CalculateDividerOffset(
+ divider_offset_, previous_content_bounds, GetContentsBounds());
}
bool SingleSplitView::IsPointInDivider(const gfx::Point& p) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698