| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/views/single_split_view.h" | 5 #include "chrome/views/single_split_view.h" |
| 6 | 6 |
| 7 #include "chrome/common/gfx/chrome_canvas.h" | 7 #include "chrome/common/gfx/chrome_canvas.h" |
| 8 #include "chrome/views/background.h" | 8 #include "chrome/views/background.h" |
| 9 #include "skia/ext/skia_utils_win.h" | 9 #include "skia/ext/skia_utils_win.h" |
| 10 | 10 |
| 11 namespace views { | 11 namespace views { |
| 12 | 12 |
| 13 // Size of the divider in pixels. | 13 // Size of the divider in pixels. |
| 14 static const int kDividerSize = 4; | 14 static const int kDividerSize = 4; |
| 15 | 15 |
| 16 SingleSplitView::SingleSplitView(View* leading, View* trailing) | 16 SingleSplitView::SingleSplitView(View* leading, View* trailing) |
| 17 : divider_x_(-1) { | 17 : divider_x_(-1) { |
| 18 AddChildView(leading); | 18 AddChildView(leading); |
| 19 AddChildView(trailing); | 19 AddChildView(trailing); |
| 20 set_background( | 20 set_background( |
| 21 views::Background::CreateSolidBackground( | 21 views::Background::CreateSolidBackground( |
| 22 gfx::COLORREFToSkColor(GetSysColor(COLOR_3DFACE)))); | 22 skia::COLORREFToSkColor(GetSysColor(COLOR_3DFACE)))); |
| 23 } | 23 } |
| 24 | 24 |
| 25 void SingleSplitView::Layout() { | 25 void SingleSplitView::Layout() { |
| 26 if (GetChildViewCount() != 2) | 26 if (GetChildViewCount() != 2) |
| 27 return; | 27 return; |
| 28 | 28 |
| 29 View* leading = GetChildViewAt(0); | 29 View* leading = GetChildViewAt(0); |
| 30 View* trailing = GetChildViewAt(1); | 30 View* trailing = GetChildViewAt(1); |
| 31 if (divider_x_ < 0) | 31 if (divider_x_ < 0) |
| 32 divider_x_ = (width() - kDividerSize) / 2; | 32 divider_x_ = (width() - kDividerSize) / 2; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 bool SingleSplitView::IsPointInDivider(int x) { | 107 bool SingleSplitView::IsPointInDivider(int x) { |
| 108 if (GetChildViewCount() < 2) | 108 if (GetChildViewCount() < 2) |
| 109 return false; | 109 return false; |
| 110 | 110 |
| 111 int divider_relative_x = | 111 int divider_relative_x = |
| 112 x - GetChildViewAt(UILayoutIsRightToLeft() ? 1 : 0)->width(); | 112 x - GetChildViewAt(UILayoutIsRightToLeft() ? 1 : 0)->width(); |
| 113 return (divider_relative_x >= 0 && divider_relative_x < kDividerSize); | 113 return (divider_relative_x >= 0 && divider_relative_x < kDividerSize); |
| 114 } | 114 } |
| 115 | 115 |
| 116 } // namespace views | 116 } // namespace views |
| OLD | NEW |