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

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

Issue 383123006: Preliminary interactive layout of window manager's demo_launcher (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Looks Good Created 6 years, 5 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/media_viewer/media_viewer.cc ('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/png_viewer/png_viewer.cc
diff --git a/mojo/examples/png_viewer/png_viewer.cc b/mojo/examples/png_viewer/png_viewer.cc
index a6f87417bad4f50a075919dd017923d6c46363a3..c9488e78d2cc849fe8876801906aedb31fb1b5ef 100644
--- a/mojo/examples/png_viewer/png_viewer.cc
+++ b/mojo/examples/png_viewer/png_viewer.cc
@@ -10,6 +10,7 @@
#include "mojo/public/cpp/application/application_connection.h"
#include "mojo/public/cpp/application/application_delegate.h"
#include "mojo/services/public/cpp/view_manager/node.h"
+#include "mojo/services/public/cpp/view_manager/node_observer.h"
#include "mojo/services/public/cpp/view_manager/types.h"
#include "mojo/services/public/cpp/view_manager/view.h"
#include "mojo/services/public/cpp/view_manager/view_manager.h"
@@ -111,10 +112,17 @@ class NavigatorImpl : public InterfaceImpl<navigation::Navigator> {
};
class PNGViewer : public ApplicationDelegate,
- public view_manager::ViewManagerDelegate {
+ public view_manager::ViewManagerDelegate,
+ public view_manager::NodeObserver {
public:
- PNGViewer() : content_view_(NULL), zoom_percentage_(kDefaultZoomPercentage) {}
- virtual ~PNGViewer() {}
+ PNGViewer()
+ : content_view_(NULL),
+ root_(NULL),
+ zoom_percentage_(kDefaultZoomPercentage) {}
+ virtual ~PNGViewer() {
+ if (root_)
+ root_->RemoveObserver(this);
+ }
void UpdateView(view_manager::Id node_id, const SkBitmap& bitmap) {
bitmap_ = bitmap;
@@ -161,8 +169,10 @@ class PNGViewer : public ApplicationDelegate,
// Overridden from view_manager::ViewManagerDelegate:
virtual void OnRootAdded(view_manager::ViewManager* view_manager,
view_manager::Node* root) OVERRIDE {
+ root_ = root;
+ root_->AddObserver(this);
content_view_ = view_manager::View::Create(view_manager);
- root->SetActiveView(content_view_);
+ root_->SetActiveView(content_view_);
content_view_->SetColor(SK_ColorGRAY);
if (!bitmap_.isNull())
DrawBitmap();
@@ -189,7 +199,21 @@ class PNGViewer : public ApplicationDelegate,
content_view_->SetContents(skia::GetTopDevice(*canvas)->accessBitmap(true));
}
+ // NodeObserver:
+ virtual void OnNodeBoundsChanged(view_manager::Node* node,
+ const gfx::Rect& old_bounds,
+ const gfx::Rect& new_bounds) OVERRIDE {
+ DCHECK_EQ(node, root_);
+ DrawBitmap();
+ }
+ virtual void OnNodeDestroyed(view_manager::Node* node) OVERRIDE {
+ DCHECK_EQ(node, root_);
+ node->RemoveObserver(this);
+ root_ = NULL;
+ }
+
view_manager::View* content_view_;
+ view_manager::Node* root_;
SkBitmap bitmap_;
uint16_t zoom_percentage_;
« no previous file with comments | « mojo/examples/media_viewer/media_viewer.cc ('k') | mojo/examples/window_manager/window_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698