summaryrefslogtreecommitdiffstats
path: root/views/controls/single_split_view.h
diff options
context:
space:
mode:
authorpfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-24 09:40:35 +0000
committerpfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-24 09:40:35 +0000
commitea36e32155bfe33d4cad2fbfeffc54edc7de1cb3 (patch)
tree83a4dacf9e91d2cf671b9a7040a9c6a4f6beda79 /views/controls/single_split_view.h
parent404a9e22401a2fe25d0eb0ea7fa4370ec46fe68c (diff)
downloadchromium_src-ea36e32155bfe33d4cad2fbfeffc54edc7de1cb3.zip
chromium_src-ea36e32155bfe33d4cad2fbfeffc54edc7de1cb3.tar.gz
chromium_src-ea36e32155bfe33d4cad2fbfeffc54edc7de1cb3.tar.bz2
Add support for vertical split into SingleSplitView.
Review URL: http://codereview.chromium.org/146036 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19107 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls/single_split_view.h')
-rw-r--r--views/controls/single_split_view.h39
1 files changed, 30 insertions, 9 deletions
diff --git a/views/controls/single_split_view.h b/views/controls/single_split_view.h
index 9d25918..74377df 100644
--- a/views/controls/single_split_view.h
+++ b/views/controls/single_split_view.h
@@ -13,7 +13,12 @@ namespace views {
// the two views that the user can drag around to resize the views.
class SingleSplitView : public views::View {
public:
- SingleSplitView(View* leading, View* trailing);
+ enum Orientation {
+ HORIZONTAL_SPLIT,
+ VERTICAL_SPLIT
+ };
+
+ SingleSplitView(View* leading, View* trailing, Orientation orientation);
virtual void Layout();
@@ -22,10 +27,14 @@ class SingleSplitView : public views::View {
virtual gfx::Size GetPreferredSize();
// Overriden to return a resize cursor when over the divider.
- virtual gfx::NativeCursor GetCursorForPoint(Event::EventType event_type, int x, int y);
+ virtual gfx::NativeCursor GetCursorForPoint(Event::EventType event_type,
+ int x,
+ int y);
- void set_divider_x(int divider_x) { divider_x_ = divider_x; }
- int divider_x() { return divider_x_; }
+ void set_divider_offset(int divider_offset) {
+ divider_offset_ = divider_offset;
+ }
+ int divider_offset() { return divider_offset_; }
protected:
virtual bool OnMousePressed(const MouseEvent& event);
@@ -33,21 +42,33 @@ class SingleSplitView : public views::View {
virtual void OnMouseReleased(const MouseEvent& event, bool canceled);
private:
- // Returns true if |x| is over the divider.
- bool IsPointInDivider(int x);
+ // Returns true if |x| or |y| is over the divider.
+ bool IsPointInDivider(int x, int y);
+
+ // Returns width in case of horizontal split and height otherwise.
+ int GetPrimaryAxisSize() {
+ return GetPrimaryAxisSize(width(), height());
+ }
+
+ int GetPrimaryAxisSize(int h, int v) {
+ return is_horizontal_ ? h : v;
+ }
// Used to track drag info.
struct DragInfo {
// The initial coordinate of the mouse when the user started the drag.
- int initial_mouse_x;
+ int initial_mouse_offset;
// The initial position of the divider when the user started the drag.
- int initial_divider_x;
+ int initial_divider_offset;
};
DragInfo drag_info_;
+ // Orientation of the split view.
+ bool is_horizontal_;
+
// Position of the divider.
- int divider_x_;
+ int divider_offset_;
DISALLOW_COPY_AND_ASSIGN(SingleSplitView);
};