Chromium Code Reviews| Index: views/controls/single_split_view.h |
| =================================================================== |
| --- views/controls/single_split_view.h (revision 68381) |
| +++ views/controls/single_split_view.h (working copy) |
| @@ -10,8 +10,12 @@ |
| namespace views { |
| -// SingleSplitView lays out two views horizontally. A splitter exists between |
| -// the two views that the user can drag around to resize the views. |
| +// SingleSplitView lays out two views next to each other, either horizontally |
| +// or vertically. A splitter exists between the two views that the user can |
| +// drag around to resize the views. It does not change these views bounds |
| +// though, the actual resize is a resonsibility of the entity resizing |
| +// the SingleSplitView itself. Observer's SplitHandleMoved notification helps |
| +// to handle user initiated layout changes. |
|
sky
2011/01/06 17:55:02
The Observer should be optional, a NULL observer m
Aleksey Shlyapnikov
2011/01/07 19:07:23
Done.
|
| class SingleSplitView : public views::View { |
| public: |
| enum Orientation { |
| @@ -19,8 +23,17 @@ |
| VERTICAL_SPLIT |
| }; |
| - SingleSplitView(View* leading, View* trailing, Orientation orientation); |
| + class Observer { |
| + public: |
| + // Invoked when split handle is moved by the user. |
|
sky
2011/01/06 17:55:02
This should return a boolean indicating if Layout
Aleksey Shlyapnikov
2011/01/07 19:07:23
In the updated version SingleSplitView does layout
|
| + virtual void SplitHandleMoved(SingleSplitView* source) = 0; |
| + protected: |
| + virtual ~Observer() {} |
| + }; |
| + SingleSplitView(View* leading, View* trailing, Orientation orientation, |
| + Observer* observer); |
| + |
| virtual void DidChangeBounds(const gfx::Rect& previous, |
| const gfx::Rect& current); |
| @@ -48,6 +61,13 @@ |
| resize_leading_on_bounds_change_ = resize; |
| } |
| + const gfx::Rect& leading_view_rect() const { return leading_view_rect_; } |
| + const gfx::Rect& trailing_view_rect() const { return trailing_view_rect_; } |
| + |
| + // Resizes leading and trailing views to the current leading_view_rect_ and |
| + // trailing_view_rect_ bounds, accordingly. |
| + void ResizeViews(); |
| + |
| protected: |
| virtual bool OnMousePressed(const MouseEvent& event); |
| virtual bool OnMouseDragged(const MouseEvent& event); |
| @@ -84,6 +104,14 @@ |
| bool resize_leading_on_bounds_change_; |
| + // Observer to notify about user initiated handle movements. Not own by us. |
| + Observer* observer_; |
| + // Leading and trailing views bounds calcualted based on the current |
|
sky
2011/01/06 17:55:02
Newline between 108 and 109.
sky
2011/01/06 17:55:02
calcualted - > calculated
Aleksey Shlyapnikov
2011/01/07 19:07:23
Done.
Aleksey Shlyapnikov
2011/01/07 19:07:23
Done.
|
| + // |divider_offset_|. Not necessarily equal to the actual views bounds, |
| + // ResizeViews() brings them in sync. |
| + gfx::Rect leading_view_rect_; |
| + gfx::Rect trailing_view_rect_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(SingleSplitView); |
| }; |