OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 MOJO_EXAMPLES_WINDOW_MANAGER_DEBUG_PANEL_H_ | 5 #ifndef MOJO_EXAMPLES_WINDOW_MANAGER_DEBUG_PANEL_H_ |
6 #define MOJO_EXAMPLES_WINDOW_MANAGER_DEBUG_PANEL_H_ | 6 #define MOJO_EXAMPLES_WINDOW_MANAGER_DEBUG_PANEL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "mojo/public/interfaces/service_provider/service_provider.mojom.h" | 10 #include "mojo/public/interfaces/service_provider/service_provider.mojom.h" |
| 11 #include "mojo/services/public/cpp/view_manager/node_observer.h" |
11 #include "mojo/services/public/interfaces/navigation/navigation.mojom.h" | 12 #include "mojo/services/public/interfaces/navigation/navigation.mojom.h" |
12 #include "ui/views/controls/button/button.h" | 13 #include "ui/views/controls/button/button.h" |
13 #include "ui/views/layout/layout_manager.h" | 14 #include "ui/views/layout/layout_manager.h" |
14 #include "ui/views/widget/widget_delegate.h" | 15 #include "ui/views/widget/widget_delegate.h" |
15 | 16 |
16 namespace views { | 17 namespace views { |
17 class Label; | 18 class Label; |
18 class RadioButton; | 19 class RadioButton; |
19 } | 20 } |
20 | 21 |
21 namespace mojo { | 22 namespace mojo { |
22 | 23 |
23 namespace view_manager { | 24 namespace view_manager { |
24 class Node; | 25 class Node; |
25 } | 26 } |
26 | 27 |
27 namespace examples { | 28 namespace examples { |
28 | 29 |
29 namespace { | 30 namespace { |
30 const SkColor kColors[] = { SK_ColorYELLOW, | 31 const SkColor kColors[] = { SK_ColorYELLOW, |
31 SK_ColorRED, | 32 SK_ColorRED, |
32 SK_ColorGREEN, | 33 SK_ColorGREEN, |
33 SK_ColorMAGENTA }; | 34 SK_ColorMAGENTA }; |
34 } | 35 } |
35 | 36 |
36 // A panel of controls intended to demonstrate the functionality of the window | 37 // A panel of controls intended to demonstrate the functionality of the window |
37 // manager. | 38 // manager. |
38 class DebugPanel : public views::LayoutManager, public views::ButtonListener { | 39 class DebugPanel : public views::LayoutManager, |
| 40 public views::ButtonListener, |
| 41 public view_manager::NodeObserver { |
39 public: | 42 public: |
40 class Delegate { | 43 class Delegate { |
41 public: | 44 public: |
42 virtual void CloseTopWindow() = 0; | 45 virtual void CloseTopWindow() = 0; |
43 virtual void RequestNavigate( | 46 virtual void RequestNavigate( |
44 uint32 source_node_id, navigation::Target target, | 47 uint32 source_node_id, navigation::Target target, |
45 navigation::NavigationDetailsPtr nav_details) = 0; | 48 navigation::NavigationDetailsPtr nav_details) = 0; |
46 protected: | 49 protected: |
47 virtual ~Delegate(){} | 50 virtual ~Delegate(){} |
48 }; | 51 }; |
49 | 52 |
50 DebugPanel(Delegate* delegate, view_manager::Node* node); | 53 DebugPanel(Delegate* delegate, view_manager::Node* node); |
51 virtual ~DebugPanel(); | 54 virtual ~DebugPanel(); |
52 | 55 |
53 navigation::Target navigation_target() const; | 56 navigation::Target navigation_target() const; |
54 | 57 |
55 private: | 58 private: |
56 // LayoutManager overrides: | 59 // LayoutManager overrides: |
57 virtual gfx::Size GetPreferredSize(const views::View* view) const OVERRIDE; | 60 virtual gfx::Size GetPreferredSize(const views::View* view) const OVERRIDE; |
58 virtual void Layout(views::View* host) OVERRIDE; | 61 virtual void Layout(views::View* host) OVERRIDE; |
59 virtual void ButtonPressed(views::Button* sender, | 62 virtual void ButtonPressed(views::Button* sender, |
60 const ui::Event& event) OVERRIDE; | 63 const ui::Event& event) OVERRIDE; |
61 | 64 |
| 65 // NodeObserver overrides: |
| 66 virtual void OnNodeBoundsChanged(view_manager::Node* node, |
| 67 const gfx::Rect& old_bounds, |
| 68 const gfx::Rect& new_bounds) OVERRIDE; |
| 69 |
62 void Navigate(const std::string& url); | 70 void Navigate(const std::string& url); |
63 | 71 |
64 Delegate* delegate_; | 72 Delegate* delegate_; |
65 view_manager::Node* node_; | 73 view_manager::Node* node_; |
| 74 views::View* contents_view_; |
| 75 views::Widget* widget_; |
66 | 76 |
67 views::Label* navigation_target_label_; | 77 views::Label* navigation_target_label_; |
68 views::RadioButton* navigation_target_new_; | 78 views::RadioButton* navigation_target_new_; |
69 views::RadioButton* navigation_target_source_; | 79 views::RadioButton* navigation_target_source_; |
70 views::RadioButton* navigation_target_default_; | 80 views::RadioButton* navigation_target_default_; |
71 | 81 |
72 size_t next_color_; | 82 size_t next_color_; |
73 views::Button* colored_square_; | 83 views::Button* colored_square_; |
74 views::Button* close_last_; | 84 views::Button* close_last_; |
75 views::Button* cross_app_; | 85 views::Button* cross_app_; |
76 | 86 |
77 DISALLOW_COPY_AND_ASSIGN(DebugPanel); | 87 DISALLOW_COPY_AND_ASSIGN(DebugPanel); |
78 }; | 88 }; |
79 | 89 |
80 } // examples | 90 } // examples |
81 } // mojo | 91 } // mojo |
82 | 92 |
83 #endif // MOJO_EXAMPLES_WINDOW_MANAGER_DEBUG_PANEL_H_ | 93 #endif // MOJO_EXAMPLES_WINDOW_MANAGER_DEBUG_PANEL_H_ |
OLD | NEW |