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

Side by Side Diff: views/controls/single_split_view.cc

Issue 155214: Add 'preserve trailing view size' capability into the SingleSplitView.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « views/controls/single_split_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "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
11 #include "app/gfx/canvas.h" 11 #include "app/gfx/canvas.h"
12 #include "skia/ext/skia_utils_win.h" 12 #include "skia/ext/skia_utils_win.h"
13 #include "views/background.h" 13 #include "views/background.h"
14 14
15 namespace views { 15 namespace views {
16 16
17 // Size of the divider in pixels. 17 // Size of the divider in pixels.
18 static const int kDividerSize = 4; 18 static const int kDividerSize = 4;
19 19
20 SingleSplitView::SingleSplitView(View* leading, 20 SingleSplitView::SingleSplitView(View* leading,
21 View* trailing, 21 View* trailing,
22 Orientation orientation) 22 Orientation orientation)
23 : is_horizontal_(orientation == HORIZONTAL_SPLIT), 23 : is_horizontal_(orientation == HORIZONTAL_SPLIT),
24 divider_offset_(-1) { 24 divider_offset_(-1),
25 resize_leading_on_bounds_change_(true) {
25 AddChildView(leading); 26 AddChildView(leading);
26 AddChildView(trailing); 27 AddChildView(trailing);
27 #if defined(OS_WIN) 28 #if defined(OS_WIN)
28 set_background( 29 set_background(
29 views::Background::CreateSolidBackground( 30 views::Background::CreateSolidBackground(
30 skia::COLORREFToSkColor(GetSysColor(COLOR_3DFACE)))); 31 skia::COLORREFToSkColor(GetSysColor(COLOR_3DFACE))));
31 #endif 32 #endif
32 } 33 }
33 34
35 void SingleSplitView::DidChangeBounds(const gfx::Rect& previous,
36 const gfx::Rect& current) {
37 if (resize_leading_on_bounds_change_) {
38 if (is_horizontal_)
39 divider_offset_ += current.width() - previous.width();
40 else
41 divider_offset_ += current.height() - previous.height();
42
43 if (divider_offset_ < 0)
44 divider_offset_ = kDividerSize;
45 }
46 View::DidChangeBounds(previous, current);
47 }
48
34 void SingleSplitView::Layout() { 49 void SingleSplitView::Layout() {
35 if (GetChildViewCount() != 2) 50 if (GetChildViewCount() != 2)
36 return; 51 return;
37 52
38 View* leading = GetChildViewAt(0); 53 View* leading = GetChildViewAt(0);
39 View* trailing = GetChildViewAt(1); 54 View* trailing = GetChildViewAt(1);
40 55
41 if (!leading->IsVisible() && !trailing->IsVisible()) 56 if (!leading->IsVisible() && !trailing->IsVisible())
42 return; 57 return;
43 58
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 divider_relative_offset = 174 divider_relative_offset =
160 x - GetChildViewAt(UILayoutIsRightToLeft() ? 1 : 0)->width(); 175 x - GetChildViewAt(UILayoutIsRightToLeft() ? 1 : 0)->width();
161 } else { 176 } else {
162 divider_relative_offset = y - GetChildViewAt(0)->height(); 177 divider_relative_offset = y - GetChildViewAt(0)->height();
163 } 178 }
164 return (divider_relative_offset >= 0 && 179 return (divider_relative_offset >= 0 &&
165 divider_relative_offset < kDividerSize); 180 divider_relative_offset < kDividerSize);
166 } 181 }
167 182
168 } // namespace views 183 } // namespace views
OLDNEW
« no previous file with comments | « views/controls/single_split_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698