summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authormad@chromium.org <mad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-19 18:00:36 +0000
committermad@chromium.org <mad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-19 18:00:36 +0000
commit60cbfff44305b419aa22d91be11f5fa991589ab9 (patch)
tree82aea8814b2323d68f0cad290670921e9d0a680c /ui
parent5af422c2fbb4deb11f807fcf6fba16466d3dbcfc (diff)
downloadchromium_src-60cbfff44305b419aa22d91be11f5fa991589ab9.zip
chromium_src-60cbfff44305b419aa22d91be11f5fa991589ab9.tar.gz
chromium_src-60cbfff44305b419aa22d91be11f5fa991589ab9.tar.bz2
NonAura implementation of the positioning of the bookmark bar at the bottom of the search NTP.
The complexity lies in the side by side layout of views (as opposed to transparency layering used in Aura), and the continuity of a bottom aligned theme background. BUG=158773 Review URL: https://chromiumcodereview.appspot.com/11359195 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@168551 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/views/controls/single_split_view.cc19
-rw-r--r--ui/views/controls/single_split_view.h10
2 files changed, 25 insertions, 4 deletions
diff --git a/ui/views/controls/single_split_view.cc b/ui/views/controls/single_split_view.cc
index 33a03bd..fabcd10 100644
--- a/ui/views/controls/single_split_view.cc
+++ b/ui/views/controls/single_split_view.cc
@@ -30,7 +30,8 @@ SingleSplitView::SingleSplitView(View* leading,
: is_horizontal_(orientation == HORIZONTAL_SPLIT),
divider_offset_(-1),
resize_leading_on_bounds_change_(true),
- listener_(listener) {
+ listener_(listener),
+ leading_bottom_offset_(0) {
AddChildView(leading);
AddChildView(trailing);
#if defined(OS_WIN)
@@ -138,7 +139,8 @@ void SingleSplitView::CalculateChildrenBounds(
std::max(0, bounds.width() - divider_at - divider_size),
bounds.height());
} else {
- *leading_bounds = gfx::Rect(0, 0, bounds.width(), divider_at);
+ *leading_bounds = gfx::Rect(
+ 0, 0, bounds.width(), divider_at - leading_bottom_offset_);
*trailing_bounds =
gfx::Rect(0, divider_at + divider_size, bounds.width(),
std::max(0, bounds.height() - divider_at - divider_size));
@@ -149,6 +151,13 @@ void SingleSplitView::SetAccessibleName(const string16& name) {
accessible_name_ = name;
}
+void SingleSplitView::SetLeadingBottomOffset(int offset) {
+ if (leading_bottom_offset_ == offset)
+ return;
+ leading_bottom_offset_ = offset;
+ InvalidateLayout();
+}
+
bool SingleSplitView::OnMousePressed(const ui::MouseEvent& event) {
if (!IsPointInDivider(event.location()))
return false;
@@ -168,7 +177,8 @@ bool SingleSplitView::OnMouseDragged(const ui::MouseEvent& event) {
delta_offset *= -1;
// Honor the minimum size when resizing.
gfx::Size min = child_at(0)->GetMinimumSize();
- int new_size = std::max(GetPrimaryAxisSize(min.width(), min.height()),
+ int new_size = std::max(GetPrimaryAxisSize(min.width(),
+ min.height() + leading_bottom_offset_),
drag_info_.initial_divider_offset + delta_offset);
// And don't let the view get bigger than our width.
@@ -210,7 +220,8 @@ bool SingleSplitView::IsPointInDivider(const gfx::Point& p) {
divider_relative_offset =
p.x() - child_at(base::i18n::IsRTL() ? 1 : 0)->width();
} else {
- divider_relative_offset = p.y() - child_at(0)->height();
+ divider_relative_offset =
+ p.y() - (child_at(0)->height() + leading_bottom_offset_);
}
return (divider_relative_offset >= 0 &&
divider_relative_offset < kDividerSize);
diff --git a/ui/views/controls/single_split_view.h b/ui/views/controls/single_split_view.h
index ccb3195..a5436fe 100644
--- a/ui/views/controls/single_split_view.h
+++ b/ui/views/controls/single_split_view.h
@@ -72,6 +72,12 @@ class VIEWS_EXPORT SingleSplitView : public View {
void SetAccessibleName(const string16& name);
+ // This allows for a layout where another view is placed between the
+ // leading view and the separator. Calling this method will cause a layout
+ // invalidation, i.e., InvalidateLayou()t will be called if |offset| is
+ // different from the current value of |leading_bottom_offset_|.
+ void SetLeadingBottomOffset(int offset);
+
protected:
// View overrides.
virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE;
@@ -129,6 +135,10 @@ class VIEWS_EXPORT SingleSplitView : public View {
// The accessible name of this view.
string16 accessible_name_;
+ // An offset to leave room between the bottom of the leading view bounds and
+ // the separator, if any, or the bottom of the splitview bounds otherwise.
+ int leading_bottom_offset_;
+
DISALLOW_COPY_AND_ASSIGN(SingleSplitView);
};