Index: mojo/examples/window_manager/window_manager.cc |
diff --git a/mojo/examples/window_manager/window_manager.cc b/mojo/examples/window_manager/window_manager.cc |
index 5f1e8439f1b007a4a2d1278690f27063303581ef..b013130c877bd9800596b4c7ebafabf874bbf2f9 100644 |
--- a/mojo/examples/window_manager/window_manager.cc |
+++ b/mojo/examples/window_manager/window_manager.cc |
@@ -159,30 +159,50 @@ class KeyboardManager : public KeyboardClient { |
class RootLayoutManager : public NodeObserver { |
public: |
- explicit RootLayoutManager(ViewManager* view_manager, |
- Node* root, |
- Id content_node_id) |
- : root_(root), |
- view_manager_(view_manager), |
- content_node_id_(content_node_id) {} |
+ RootLayoutManager(ViewManager* view_manager, Node* root, |
+ Id content_node_id, |
+ Id launcher_ui_node_id, |
+ Id control_panel_node_id) |
+ : root_(root), |
+ view_manager_(view_manager), |
+ content_node_id_(content_node_id), |
+ launcher_ui_node_id_(launcher_ui_node_id), |
+ control_panel_node_id_(control_panel_node_id) {} |
virtual ~RootLayoutManager() {} |
private: |
// Overridden from NodeObserver: |
virtual void OnNodeBoundsChanged(Node* node, |
- const gfx::Rect& /*old_bounds*/, |
+ const gfx::Rect& old_bounds, |
const gfx::Rect& new_bounds) OVERRIDE { |
DCHECK_EQ(node, root_); |
+ |
Node* content_node = view_manager_->GetNodeById(content_node_id_); |
content_node->SetBounds(new_bounds); |
// Force the view's bitmap to be recreated |
content_node->active_view()->SetColor(SK_ColorBLUE); |
- // TODO(hansmuller): Do Layout |
+ |
+ Node* launcher_ui_node = |
+ view_manager_->GetNodeById(launcher_ui_node_id_); |
+ gfx::Rect launcher_ui_bounds(launcher_ui_node->bounds()); |
+ launcher_ui_bounds.set_width(launcher_ui_bounds.width() + |
+ new_bounds.width() - old_bounds.width()); |
+ launcher_ui_node->SetBounds(launcher_ui_bounds); |
+ |
+ |
+ Node* control_panel_node = |
+ view_manager_->GetNodeById(control_panel_node_id_); |
+ gfx::Rect control_panel_bounds(control_panel_node->bounds()); |
+ control_panel_bounds.set_x(control_panel_bounds.x() + |
+ new_bounds.width() - old_bounds.width()); |
+ control_panel_node->SetBounds(control_panel_bounds); |
} |
Ben Goodger (Google)
2014/07/11 18:18:23
Looks like you're missing the embedded node(s) (e.
|
Node* root_; |
ViewManager* view_manager_; |
Id content_node_id_; |
+ Id launcher_ui_node_id_; |
+ Id control_panel_node_id_; |
DISALLOW_COPY_AND_ASSIGN(RootLayoutManager); |
}; |
@@ -285,17 +305,20 @@ class WindowManager : public ApplicationDelegate, |
node->SetBounds(gfx::Rect(root->bounds().size())); |
content_node_id_ = node->id(); |
- root_layout_manager_.reset( |
- new RootLayoutManager(view_manager, root, content_node_id_)); |
- root->AddObserver(root_layout_manager_.get()); |
- |
View* view = View::Create(view_manager); |
node->SetActiveView(view); |
view->SetColor(SK_ColorBLUE); |
view->AddObserver(this); |
- CreateLauncherUI(); |
- CreateControlPanel(node); |
+ Id launcher_ui_id = CreateLauncherUI(); |
+ Id control_panel_id = CreateControlPanel(node); |
+ |
+ root_layout_manager_.reset( |
+ new RootLayoutManager(view_manager, root, |
+ content_node_id_, |
+ launcher_ui_id, |
+ control_panel_id)); |
+ root->AddObserver(root_layout_manager_.get()); |
} |
// Overridden from ViewEventDispatcher: |
@@ -347,7 +370,7 @@ class WindowManager : public ApplicationDelegate, |
} |
// TODO(beng): proper layout manager!! |
- void CreateLauncherUI() { |
+ Id CreateLauncherUI() { |
navigation::NavigationDetailsPtr nav_details; |
navigation::ResponseDetailsPtr response; |
Node* node = view_manager_->GetNodeById(content_node_id_); |
@@ -356,6 +379,7 @@ class WindowManager : public ApplicationDelegate, |
bounds.set_height(kTextfieldHeight); |
launcher_ui_ = CreateChild(content_node_id_, "mojo:mojo_browser", bounds, |
nav_details.Pass(), response.Pass()); |
+ return launcher_ui_->id(); |
} |
void CreateWindow(const std::string& handler_url, |
@@ -407,7 +431,7 @@ class WindowManager : public ApplicationDelegate, |
keyboard_manager_->node()->Contains(target->node()); |
} |
- void CreateControlPanel(view_manager::Node* root) { |
+ Id CreateControlPanel(view_manager::Node* root) { |
Node* node = Node::Create(view_manager_); |
View* view = view_manager::View::Create(view_manager_); |
root->AddChild(node); |
@@ -422,6 +446,7 @@ class WindowManager : public ApplicationDelegate, |
node->SetBounds(bounds); |
debug_panel_ = new DebugPanel(this, node); |
+ return node->id(); |
} |
scoped_ptr<ViewsInit> views_init_; |