Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1517)

Unified Diff: mojo/examples/nesting_app/nesting_app.cc

Issue 311373005: Nesting (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/examples/nesting_app/DEPS ('k') | mojo/examples/window_manager/window_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/examples/nesting_app/nesting_app.cc
diff --git a/mojo/examples/nesting_app/nesting_app.cc b/mojo/examples/nesting_app/nesting_app.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3c06c8db8fc2e423f04e7e8b5fd4bbbc7c8dc0e9
--- /dev/null
+++ b/mojo/examples/nesting_app/nesting_app.cc
@@ -0,0 +1,78 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/basictypes.h"
+#include "base/bind.h"
+#include "mojo/examples/window_manager/window_manager.mojom.h"
+#include "mojo/public/cpp/application/application.h"
+#include "mojo/services/public/cpp/view_manager/view.h"
+#include "mojo/services/public/cpp/view_manager/view_manager.h"
+#include "mojo/services/public/cpp/view_manager/view_manager_delegate.h"
+#include "mojo/services/public/cpp/view_manager/view_observer.h"
+#include "mojo/services/public/cpp/view_manager/view_tree_node.h"
+#include "mojo/services/public/cpp/view_manager/view_tree_node_observer.h"
+#include "ui/events/event_constants.h"
+
+using mojo::view_manager::View;
+using mojo::view_manager::ViewManager;
+using mojo::view_manager::ViewManagerDelegate;
+using mojo::view_manager::ViewObserver;
+using mojo::view_manager::ViewTreeNode;
+using mojo::view_manager::ViewTreeNodeObserver;
+
+namespace mojo {
+namespace examples {
+
+// An app that embeds another app.
+class NestingApp : public Application,
+ public ViewManagerDelegate,
+ public ViewObserver {
+ public:
+ NestingApp() {}
+ virtual ~NestingApp() {}
+
+ private:
+ // Overridden from Application:
+ virtual void Initialize() MOJO_OVERRIDE {
+ ViewManager::Create(this, this);
+ ConnectTo<IWindowManager>("mojo:mojo_window_manager", &window_manager_);
+ }
+
+ // Overridden from ViewManagerDelegate:
+ virtual void OnRootAdded(ViewManager* view_manager,
+ ViewTreeNode* root) OVERRIDE {
+ View* view = View::Create(view_manager);
+ root->SetActiveView(view);
+ view->SetColor(SK_ColorCYAN);
+ view->AddObserver(this);
+
+ ViewTreeNode* nested = ViewTreeNode::Create(view_manager);
+ root->AddChild(nested);
+ nested->SetBounds(gfx::Rect(20, 20, 50, 50));
+ nested->Embed("mojo:mojo_embedded_app");
+ }
+ virtual void OnRootRemoved(ViewManager* view_manager,
+ ViewTreeNode* root) OVERRIDE {
+ // TODO(beng): reap views & child nodes.
+ }
+
+ // Overridden from ViewObserver:
+ virtual void OnViewInputEvent(View* view, EventPtr event) OVERRIDE {
+ if (event->action == ui::ET_MOUSE_RELEASED)
+ window_manager_->CloseWindow(view->node()->id());
+ }
+
+ IWindowManagerPtr window_manager_;
+
+ DISALLOW_COPY_AND_ASSIGN(NestingApp);
+};
+
+} // namespace examples
+
+// static
+Application* Application::Create() {
+ return new examples::NestingApp;
+}
+
+} // namespace mojo
« no previous file with comments | « mojo/examples/nesting_app/DEPS ('k') | mojo/examples/window_manager/window_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698