Chromium Code Reviews| 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..6098f868530a81d888a487cfcc66fb4602acac78 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,7 +112,8 @@ 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() {} |
| @@ -164,6 +166,7 @@ class PNGViewer : public ApplicationDelegate, |
| content_view_ = view_manager::View::Create(view_manager); |
| root->SetActiveView(content_view_); |
| content_view_->SetColor(SK_ColorGRAY); |
| + root->AddObserver(this); |
|
sky
2014/07/14 19:15:28
Same thing about removing observer.
hansmuller
2014/07/14 22:16:42
Done.
|
| if (!bitmap_.isNull()) |
| DrawBitmap(); |
| } |
| @@ -189,6 +192,12 @@ class PNGViewer : public ApplicationDelegate, |
| content_view_->SetContents(skia::GetTopDevice(*canvas)->accessBitmap(true)); |
| } |
| + virtual void OnNodeBoundsChanged(view_manager::Node* node, |
| + const gfx::Rect&, |
| + const gfx::Rect&) OVERRIDE { |
| + DrawBitmap(); |
| + } |
| + |
| view_manager::View* content_view_; |
| SkBitmap bitmap_; |
| uint16_t zoom_percentage_; |