| 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 #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 enum Orientation { | 16 enum Orientation { |
| 17 HORIZONTAL_SPLIT, | 17 HORIZONTAL_SPLIT, |
| 18 VERTICAL_SPLIT | 18 VERTICAL_SPLIT |
| 19 }; | 19 }; |
| 20 | 20 |
| 21 SingleSplitView(View* leading, View* trailing, Orientation orientation); | 21 SingleSplitView(View* leading, View* trailing, Orientation orientation); |
| 22 | 22 |
| 23 virtual void DidChangeBounds(const gfx::Rect& previous, |
| 24 const gfx::Rect& current); |
| 25 |
| 23 virtual void Layout(); | 26 virtual void Layout(); |
| 24 | 27 |
| 25 // SingleSplitView's preferred size is the sum of the preferred widths | 28 // SingleSplitView's preferred size is the sum of the preferred widths |
| 26 // and the max of the heights. | 29 // and the max of the heights. |
| 27 virtual gfx::Size GetPreferredSize(); | 30 virtual gfx::Size GetPreferredSize(); |
| 28 | 31 |
| 29 // Overriden to return a resize cursor when over the divider. | 32 // Overriden to return a resize cursor when over the divider. |
| 30 virtual gfx::NativeCursor GetCursorForPoint(Event::EventType event_type, | 33 virtual gfx::NativeCursor GetCursorForPoint(Event::EventType event_type, |
| 31 int x, | 34 int x, |
| 32 int y); | 35 int y); |
| 33 | 36 |
| 34 void set_divider_offset(int divider_offset) { | 37 void set_divider_offset(int divider_offset) { |
| 35 divider_offset_ = divider_offset; | 38 divider_offset_ = divider_offset; |
| 36 } | 39 } |
| 37 int divider_offset() { return divider_offset_; } | 40 int divider_offset() { return divider_offset_; } |
| 38 | 41 |
| 42 // Sets whether the leading component is resized when the split views size |
| 43 // changes. The default is true. A value of false results in the trailing |
| 44 // component resizing on a bounds change. |
| 45 void set_resize_leading_on_bounds_change(bool resize) { |
| 46 resize_leading_on_bounds_change_ = resize; |
| 47 } |
| 48 |
| 39 protected: | 49 protected: |
| 40 virtual bool OnMousePressed(const MouseEvent& event); | 50 virtual bool OnMousePressed(const MouseEvent& event); |
| 41 virtual bool OnMouseDragged(const MouseEvent& event); | 51 virtual bool OnMouseDragged(const MouseEvent& event); |
| 42 virtual void OnMouseReleased(const MouseEvent& event, bool canceled); | 52 virtual void OnMouseReleased(const MouseEvent& event, bool canceled); |
| 43 | 53 |
| 44 private: | 54 private: |
| 45 // Returns true if |x| or |y| is over the divider. | 55 // Returns true if |x| or |y| is over the divider. |
| 46 bool IsPointInDivider(int x, int y); | 56 bool IsPointInDivider(int x, int y); |
| 47 | 57 |
| 48 // Returns width in case of horizontal split and height otherwise. | 58 // Returns width in case of horizontal split and height otherwise. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 63 }; | 73 }; |
| 64 | 74 |
| 65 DragInfo drag_info_; | 75 DragInfo drag_info_; |
| 66 | 76 |
| 67 // Orientation of the split view. | 77 // Orientation of the split view. |
| 68 bool is_horizontal_; | 78 bool is_horizontal_; |
| 69 | 79 |
| 70 // Position of the divider. | 80 // Position of the divider. |
| 71 int divider_offset_; | 81 int divider_offset_; |
| 72 | 82 |
| 83 bool resize_leading_on_bounds_change_; |
| 84 |
| 73 DISALLOW_COPY_AND_ASSIGN(SingleSplitView); | 85 DISALLOW_COPY_AND_ASSIGN(SingleSplitView); |
| 74 }; | 86 }; |
| 75 | 87 |
| 76 } // namespace views | 88 } // namespace views |
| 77 | 89 |
| 78 #endif // VIEWS_CONTROLS_SINGLE_SPLIT_VIEW_H_ | 90 #endif // VIEWS_CONTROLS_SINGLE_SPLIT_VIEW_H_ |
| OLD | NEW |