OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "views/controls/single_split_view.h" | 5 #include "views/controls/single_split_view.h" |
6 | 6 |
7 #if defined(OS_LINUX) | 7 #if defined(OS_LINUX) |
8 #include <gdk/gdk.h> | 8 #include <gdk/gdk.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 27 matching lines...) Expand all Loading... |
38 skia::COLORREFToSkColor(GetSysColor(COLOR_3DFACE)))); | 38 skia::COLORREFToSkColor(GetSysColor(COLOR_3DFACE)))); |
39 #endif | 39 #endif |
40 } | 40 } |
41 | 41 |
42 void SingleSplitView::Layout() { | 42 void SingleSplitView::Layout() { |
43 gfx::Rect leading_bounds; | 43 gfx::Rect leading_bounds; |
44 gfx::Rect trailing_bounds; | 44 gfx::Rect trailing_bounds; |
45 CalculateChildrenBounds(bounds(), &leading_bounds, &trailing_bounds); | 45 CalculateChildrenBounds(bounds(), &leading_bounds, &trailing_bounds); |
46 | 46 |
47 if (has_children()) { | 47 if (has_children()) { |
48 if (GetChildViewAt(0)->IsVisible()) | 48 if (GetChildViewAt(0)->visible()) |
49 GetChildViewAt(0)->SetBoundsRect(leading_bounds); | 49 GetChildViewAt(0)->SetBoundsRect(leading_bounds); |
50 if (child_count() > 1) { | 50 if (child_count() > 1) { |
51 if (GetChildViewAt(1)->IsVisible()) | 51 if (GetChildViewAt(1)->visible()) |
52 GetChildViewAt(1)->SetBoundsRect(trailing_bounds); | 52 GetChildViewAt(1)->SetBoundsRect(trailing_bounds); |
53 } | 53 } |
54 } | 54 } |
55 | 55 |
56 SchedulePaint(); | 56 SchedulePaint(); |
57 | 57 |
58 // Invoke super's implementation so that the children are layed out. | 58 // Invoke super's implementation so that the children are layed out. |
59 View::Layout(); | 59 View::Layout(); |
60 } | 60 } |
61 | 61 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 #elif defined(OS_LINUX) | 95 #elif defined(OS_LINUX) |
96 return gfx::GetCursor(is_horizontal_ ? GDK_SB_H_DOUBLE_ARROW : | 96 return gfx::GetCursor(is_horizontal_ ? GDK_SB_H_DOUBLE_ARROW : |
97 GDK_SB_V_DOUBLE_ARROW); | 97 GDK_SB_V_DOUBLE_ARROW); |
98 #endif | 98 #endif |
99 } | 99 } |
100 | 100 |
101 void SingleSplitView::CalculateChildrenBounds( | 101 void SingleSplitView::CalculateChildrenBounds( |
102 const gfx::Rect& bounds, | 102 const gfx::Rect& bounds, |
103 gfx::Rect* leading_bounds, | 103 gfx::Rect* leading_bounds, |
104 gfx::Rect* trailing_bounds) const { | 104 gfx::Rect* trailing_bounds) const { |
105 bool is_leading_visible = has_children() && GetChildViewAt(0)->IsVisible(); | 105 bool is_leading_visible = has_children() && GetChildViewAt(0)->visible(); |
106 bool is_trailing_visible = | 106 bool is_trailing_visible = |
107 child_count() > 1 && GetChildViewAt(1)->IsVisible(); | 107 child_count() > 1 && GetChildViewAt(1)->visible(); |
108 | 108 |
109 if (!is_leading_visible && !is_trailing_visible) { | 109 if (!is_leading_visible && !is_trailing_visible) { |
110 *leading_bounds = gfx::Rect(); | 110 *leading_bounds = gfx::Rect(); |
111 *trailing_bounds = gfx::Rect(); | 111 *trailing_bounds = gfx::Rect(); |
112 return; | 112 return; |
113 } | 113 } |
114 | 114 |
115 int divider_at; | 115 int divider_at; |
116 | 116 |
117 if (!is_trailing_visible) { | 117 if (!is_trailing_visible) { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 | 191 |
192 void SingleSplitView::OnBoundsChanged(const gfx::Rect& previous_bounds) { | 192 void SingleSplitView::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
193 divider_offset_ = CalculateDividerOffset(divider_offset_, previous_bounds, | 193 divider_offset_ = CalculateDividerOffset(divider_offset_, previous_bounds, |
194 bounds()); | 194 bounds()); |
195 } | 195 } |
196 | 196 |
197 bool SingleSplitView::IsPointInDivider(const gfx::Point& p) { | 197 bool SingleSplitView::IsPointInDivider(const gfx::Point& p) { |
198 if (child_count() < 2) | 198 if (child_count() < 2) |
199 return false; | 199 return false; |
200 | 200 |
201 if (!GetChildViewAt(0)->IsVisible() || !GetChildViewAt(1)->IsVisible()) | 201 if (!GetChildViewAt(0)->visible() || !GetChildViewAt(1)->visible()) |
202 return false; | 202 return false; |
203 | 203 |
204 int divider_relative_offset; | 204 int divider_relative_offset; |
205 if (is_horizontal_) { | 205 if (is_horizontal_) { |
206 divider_relative_offset = | 206 divider_relative_offset = |
207 p.x() - GetChildViewAt(base::i18n::IsRTL() ? 1 : 0)->width(); | 207 p.x() - GetChildViewAt(base::i18n::IsRTL() ? 1 : 0)->width(); |
208 } else { | 208 } else { |
209 divider_relative_offset = p.y() - GetChildViewAt(0)->height(); | 209 divider_relative_offset = p.y() - GetChildViewAt(0)->height(); |
210 } | 210 } |
211 return (divider_relative_offset >= 0 && | 211 return (divider_relative_offset >= 0 && |
(...skipping 26 matching lines...) Expand all Loading... |
238 int SingleSplitView::NormalizeDividerOffset(int divider_offset, | 238 int SingleSplitView::NormalizeDividerOffset(int divider_offset, |
239 const gfx::Rect& bounds) const { | 239 const gfx::Rect& bounds) const { |
240 int primary_axis_size = GetPrimaryAxisSize(bounds.width(), bounds.height()); | 240 int primary_axis_size = GetPrimaryAxisSize(bounds.width(), bounds.height()); |
241 if (divider_offset < 0) | 241 if (divider_offset < 0) |
242 return (primary_axis_size - kDividerSize) / 2; | 242 return (primary_axis_size - kDividerSize) / 2; |
243 return std::min(divider_offset, | 243 return std::min(divider_offset, |
244 std::max(primary_axis_size - kDividerSize, 0)); | 244 std::max(primary_axis_size - kDividerSize, 0)); |
245 } | 245 } |
246 | 246 |
247 } // namespace views | 247 } // namespace views |
OLD | NEW |