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

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

Issue 146036: Add support for vertical split into SingleSplitView. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 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 | « chrome/browser/views/bookmark_manager_view.cc ('k') | views/controls/single_split_view.cc » ('j') | 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 #ifndef VIEWS_CONTROLS_SINGLE_SPLIT_VIEW_H_ 5 #ifndef VIEWS_CONTROLS_SINGLE_SPLIT_VIEW_H_
6 #define VIEWS_CONTROLS_SINGLE_SPLIT_VIEW_H_ 6 #define VIEWS_CONTROLS_SINGLE_SPLIT_VIEW_H_
7 7
8 #include "views/view.h" 8 #include "views/view.h"
9 9
10 namespace views { 10 namespace views {
11 11
12 // SingleSplitView lays out two views horizontally. A splitter exists between 12 // SingleSplitView lays out two views horizontally. A splitter exists between
13 // the two views that the user can drag around to resize the views. 13 // the two views that the user can drag around to resize the views.
14 class SingleSplitView : public views::View { 14 class SingleSplitView : public views::View {
15 public: 15 public:
16 SingleSplitView(View* leading, View* trailing); 16 enum Orientation {
17 HORIZONTAL_SPLIT,
18 VERTICAL_SPLIT
19 };
20
21 SingleSplitView(View* leading, View* trailing, Orientation orientation);
17 22
18 virtual void Layout(); 23 virtual void Layout();
19 24
20 // SingleSplitView's preferred size is the sum of the preferred widths 25 // SingleSplitView's preferred size is the sum of the preferred widths
21 // and the max of the heights. 26 // and the max of the heights.
22 virtual gfx::Size GetPreferredSize(); 27 virtual gfx::Size GetPreferredSize();
23 28
24 // Overriden to return a resize cursor when over the divider. 29 // Overriden to return a resize cursor when over the divider.
25 virtual gfx::NativeCursor GetCursorForPoint(Event::EventType event_type, int x , int y); 30 virtual gfx::NativeCursor GetCursorForPoint(Event::EventType event_type,
31 int x,
32 int y);
26 33
27 void set_divider_x(int divider_x) { divider_x_ = divider_x; } 34 void set_divider_offset(int divider_offset) {
28 int divider_x() { return divider_x_; } 35 divider_offset_ = divider_offset;
36 }
37 int divider_offset() { return divider_offset_; }
29 38
30 protected: 39 protected:
31 virtual bool OnMousePressed(const MouseEvent& event); 40 virtual bool OnMousePressed(const MouseEvent& event);
32 virtual bool OnMouseDragged(const MouseEvent& event); 41 virtual bool OnMouseDragged(const MouseEvent& event);
33 virtual void OnMouseReleased(const MouseEvent& event, bool canceled); 42 virtual void OnMouseReleased(const MouseEvent& event, bool canceled);
34 43
35 private: 44 private:
36 // Returns true if |x| is over the divider. 45 // Returns true if |x| or |y| is over the divider.
37 bool IsPointInDivider(int x); 46 bool IsPointInDivider(int x, int y);
47
48 // Returns width in case of horizontal split and height otherwise.
49 int GetPrimaryAxisSize() {
50 return GetPrimaryAxisSize(width(), height());
51 }
52
53 int GetPrimaryAxisSize(int h, int v) {
54 return is_horizontal_ ? h : v;
55 }
38 56
39 // Used to track drag info. 57 // Used to track drag info.
40 struct DragInfo { 58 struct DragInfo {
41 // The initial coordinate of the mouse when the user started the drag. 59 // The initial coordinate of the mouse when the user started the drag.
42 int initial_mouse_x; 60 int initial_mouse_offset;
43 // The initial position of the divider when the user started the drag. 61 // The initial position of the divider when the user started the drag.
44 int initial_divider_x; 62 int initial_divider_offset;
45 }; 63 };
46 64
47 DragInfo drag_info_; 65 DragInfo drag_info_;
48 66
67 // Orientation of the split view.
68 bool is_horizontal_;
69
49 // Position of the divider. 70 // Position of the divider.
50 int divider_x_; 71 int divider_offset_;
51 72
52 DISALLOW_COPY_AND_ASSIGN(SingleSplitView); 73 DISALLOW_COPY_AND_ASSIGN(SingleSplitView);
53 }; 74 };
54 75
55 } // namespace views 76 } // namespace views
56 77
57 #endif // VIEWS_CONTROLS_SINGLE_SPLIT_VIEW_H_ 78 #endif // VIEWS_CONTROLS_SINGLE_SPLIT_VIEW_H_
OLDNEW
« no previous file with comments | « chrome/browser/views/bookmark_manager_view.cc ('k') | views/controls/single_split_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698