| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 EXAMPLES_UI_TILE_TILE_VIEW_H_ | 5 #ifndef EXAMPLES_UI_TILE_TILE_VIEW_H_ |
| 6 #define EXAMPLES_UI_TILE_TILE_VIEW_H_ | 6 #define EXAMPLES_UI_TILE_TILE_VIEW_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <vector> |
| 10 | 11 |
| 11 #include "mojo/services/ui/views/interfaces/view_provider.mojom.h" | 12 #include "mojo/services/ui/views/interfaces/view_provider.mojom.h" |
| 12 #include "mojo/ui/base_view.h" | 13 #include "mojo/ui/base_view.h" |
| 13 | 14 |
| 14 namespace examples { | 15 namespace examples { |
| 15 | 16 |
| 17 struct TileParams { |
| 18 enum class VersionMode { |
| 19 kAny, // specify |kSceneVersionNone| |
| 20 kExact, // specify exact version |
| 21 }; |
| 22 enum class CombinatorMode { |
| 23 kMerge, // use merge combinator |
| 24 kPrune, // use prune combinator |
| 25 kFallbackFlash, // use fallback combinator with red flash |
| 26 kFallbackDim, // use fallback combinator with old content dimmed |
| 27 }; |
| 28 enum class OrientationMode { |
| 29 kHorizontal, |
| 30 kVertical, |
| 31 }; |
| 32 |
| 33 TileParams(); |
| 34 ~TileParams(); |
| 35 |
| 36 VersionMode version_mode = VersionMode::kAny; |
| 37 CombinatorMode combinator_mode = CombinatorMode::kPrune; |
| 38 OrientationMode orientation_mode = OrientationMode::kHorizontal; |
| 39 |
| 40 std::vector<std::string> view_urls; |
| 41 }; |
| 42 |
| 16 class TileView : public mojo::ui::BaseView { | 43 class TileView : public mojo::ui::BaseView { |
| 17 public: | 44 public: |
| 18 TileView(mojo::ApplicationImpl* app_impl_, | 45 TileView(mojo::ApplicationImpl* app_impl_, |
| 19 mojo::InterfaceRequest<mojo::ui::ViewOwner> view_owner_request, | 46 mojo::InterfaceRequest<mojo::ui::ViewOwner> view_owner_request, |
| 20 const std::vector<std::string>& view_urls); | 47 const TileParams& tile_params); |
| 21 | 48 |
| 22 ~TileView() override; | 49 ~TileView() override; |
| 23 | 50 |
| 24 private: | 51 private: |
| 25 struct ViewData { | 52 struct ViewData { |
| 26 explicit ViewData(const std::string& url, uint32_t key); | 53 explicit ViewData(const std::string& url, uint32_t key); |
| 27 ~ViewData(); | 54 ~ViewData(); |
| 28 | 55 |
| 29 const std::string url; | 56 const std::string url; |
| 30 const uint32_t key; | 57 const uint32_t key; |
| 31 | 58 |
| 32 mojo::RectF layout_bounds; | 59 mojo::RectF layout_bounds; |
| 33 mojo::ui::ViewPropertiesPtr view_properties; | 60 mojo::ui::ViewPropertiesPtr view_properties; |
| 34 mojo::ui::ViewInfoPtr view_info; | 61 mojo::ui::ViewInfoPtr view_info; |
| 35 uint32_t scene_version = 1u; | 62 uint32_t scene_version = 1u; |
| 36 }; | 63 }; |
| 37 | 64 |
| 38 // |BaseView|: | 65 // |BaseView|: |
| 39 void OnPropertiesChanged(uint32_t old_scene_version, | 66 void OnPropertiesChanged(uint32_t old_scene_version, |
| 40 mojo::ui::ViewPropertiesPtr old_properties) override; | 67 mojo::ui::ViewPropertiesPtr old_properties) override; |
| 41 void OnChildAttached(uint32_t child_key, | 68 void OnChildAttached(uint32_t child_key, |
| 42 mojo::ui::ViewInfoPtr child_view_info) override; | 69 mojo::ui::ViewInfoPtr child_view_info) override; |
| 43 void OnChildUnavailable(uint32_t child_key) override; | 70 void OnChildUnavailable(uint32_t child_key) override; |
| 44 | 71 |
| 45 void ConnectViews(); | 72 void ConnectViews(); |
| 46 void UpdateScene(); | 73 void UpdateScene(); |
| 47 | 74 |
| 48 void OnFrameSubmitted(); | 75 void OnFrameSubmitted(); |
| 49 | 76 |
| 50 std::vector<std::string> view_urls_; | 77 TileParams params_; |
| 51 std::map<uint32_t, std::unique_ptr<ViewData>> views_; | 78 std::map<uint32_t, std::unique_ptr<ViewData>> views_; |
| 52 | 79 |
| 53 DISALLOW_COPY_AND_ASSIGN(TileView); | 80 DISALLOW_COPY_AND_ASSIGN(TileView); |
| 54 }; | 81 }; |
| 55 | 82 |
| 56 } // namespace examples | 83 } // namespace examples |
| 57 | 84 |
| 58 #endif // EXAMPLES_UI_TILE_TILE_VIEW_H_ | 85 #endif // EXAMPLES_UI_TILE_TILE_VIEW_H_ |
| OLD | NEW |