[scenic] Migrate ViewConfigDemoView from fuchsia.ui.app to fuchsia.ui.views
This is a reland of 1eeefe85971d682cb8572e7dd173501f81fbdb4d
Original change's description:
> [scenic] Migrate ViewConfigDemoView from fuchsia.ui.app to fuchsia.ui.views
>
> SCN-1187 #comment
>
> TEST=fx shell "present_view --locale=en-GB \
> fuchsia-pkg://fuchsia.com/view_config_demo#meta/view_config_demo.cmx"
>
> Change-Id: I4ee14cbfb541c2c26fb2a7a9efedc5d4975dc46a
> Depends-On: Id3038ead7319ae8001af6683ac1d049c1b0f82d7
Change-Id: Ib71edd1067481f2d74eace552c958b7f4e24917e
diff --git a/examples/ui/view_config_demo/view_config_demo_view.cc b/examples/ui/view_config_demo/view_config_demo_view.cc
index b4b1c25..b35fa5c 100644
--- a/examples/ui/view_config_demo/view_config_demo_view.cc
+++ b/examples/ui/view_config_demo/view_config_demo_view.cc
@@ -10,7 +10,7 @@
namespace examples {
-using fuchsia::ui::app::ViewConfig;
+using fuchsia::ui::views::ViewConfig;
namespace {
constexpr SkScalar kTextSize = 40;
@@ -63,16 +63,17 @@
// Return the first locale ID in the given view config, or "[none]" if the
// config is invalid.
const std::string GetFirstLocale(const ViewConfig& view_config) {
- if (!view_config.intl_profile.locales.empty()) {
- return view_config.intl_profile.locales[0].id;
+ if (view_config.has_intl_profile() &&
+ !view_config.intl_profile().locales.empty()) {
+ return view_config.intl_profile().locales[0].id;
}
return "[none]";
}
void ViewConfigDemoView::OnConfigChanged(
- fuchsia::ui::app::ViewConfig old_config) {
+ const fuchsia::ui::views::ViewConfig& old_config) {
FXL_LOG(INFO) << "OnConfigChanged: locale was " << GetFirstLocale(old_config)
- << "; now \"" << GetFirstLocale(view_config()) << "\".";
+ << "; now \"" << GetFirstLocale(view_config2()) << "\".";
InvalidateScene();
}
@@ -88,7 +89,7 @@
font.setSize(kTextSize);
font.setTypeface(typeface_);
- std::string text = std::string("Locale: " + GetFirstLocale(view_config()));
+ std::string text = std::string("Locale: " + GetFirstLocale(view_config2()));
SkRect text_bounds{};
font.measureText(text.c_str(), text.size(), SkTextEncoding::kUTF8,
diff --git a/examples/ui/view_config_demo/view_config_demo_view.h b/examples/ui/view_config_demo/view_config_demo_view.h
index 72afcb1..af47915 100644
--- a/examples/ui/view_config_demo/view_config_demo_view.h
+++ b/examples/ui/view_config_demo/view_config_demo_view.h
@@ -27,11 +27,12 @@
fuchsia::ui::gfx::ViewProperties old_properties) override;
// |scenic::BaseView|
- void OnSceneInvalidated(
- fuchsia::images::PresentationInfo presentation_info) override;
+ void OnSceneInvalidated(fuchsia::images::PresentationInfo presentation_info)
+ override;
// |scenic::BaseView|
- void OnConfigChanged(fuchsia::ui::app::ViewConfig old_config) override;
+ void OnConfigChanged(
+ const fuchsia::ui::views::ViewConfig& old_config) override;
// Draw a solid background and some centered text.
void Draw(SkCanvas* canvas);