From a019db648c3d5ef0f119fde65b5ce5ff6b373da5 Mon Sep 17 00:00:00 2001 From: Paul Rouget Date: Tue, 4 Aug 2020 12:55:17 +0200 Subject: [PATCH] Show only a limited list of preferences --- support/hololens/ServoApp/BrowserPage.cpp | 33 ++++- support/hololens/ServoApp/BrowserPage.h | 4 +- support/hololens/ServoApp/BrowserPage.xaml | 4 +- .../ServoApp/Resources/PromotedPrefs.resw | 125 ++++++++++++++++++ .../Strings/en-US/Resources.resw | 3 + .../Strings/fr-FR/Resources.resw | 0 support/hololens/ServoApp/ServoApp.vcxproj | 5 +- .../ServoApp/ServoApp.vcxproj.filters | 20 ++- support/hololens/ServoApp/pch.h | 1 + 9 files changed, 182 insertions(+), 13 deletions(-) create mode 100644 support/hololens/ServoApp/Resources/PromotedPrefs.resw rename support/hololens/ServoApp/{ => Resources}/Strings/en-US/Resources.resw (98%) rename support/hololens/ServoApp/{ => Resources}/Strings/fr-FR/Resources.resw (100%) diff --git a/support/hololens/ServoApp/BrowserPage.cpp b/support/hololens/ServoApp/BrowserPage.cpp index d3f738427c6..e3329d895d5 100644 --- a/support/hololens/ServoApp/BrowserPage.cpp +++ b/support/hololens/ServoApp/BrowserPage.cpp @@ -16,6 +16,7 @@ using namespace winrt::Windows::UI::Core; using namespace winrt::Windows::UI::ViewManagement; using namespace winrt::Windows::ApplicationModel::Core; using namespace winrt::Windows::ApplicationModel::Resources; +using namespace winrt::Windows::ApplicationModel::Resources::Core; using namespace winrt::Windows::UI::Notifications; using namespace winrt::Windows::Data::Json; using namespace winrt::Windows::Data::Xml::Dom; @@ -28,6 +29,17 @@ BrowserPage::BrowserPage() { InitializeComponent(); BindServoEvents(); mLogs = winrt::single_threaded_observable_vector(); + + auto ctx = ResourceContext::GetForCurrentView(); + auto current = ResourceManager::Current(); + auto tree = current.MainResourceMap().GetSubtree(L"PromotedPrefs"); + for (auto s : tree) { + hstring k = s.Key(); + std::wstring wk = k.c_str(); + std::replace(wk.begin(), wk.end(), '/', '.'); + hstring v = s.Value().Resolve(ctx).ValueAsString(); + mPromotedPrefs.insert(std::pair(wk, v)); + } } void BrowserPage::BindServoEvents() { @@ -182,17 +194,34 @@ void BrowserPage::UpdatePref(ServoApp::Pref pref, Controls::Control ctrl) { stack.Children().GetAt(2).as().IsEnabled(!pref.IsDefault()); } +void BrowserPage::OnSeeAllPrefClicked(IInspectable const &, + RoutedEventArgs const &) { + BuildPrefList(); +} + // Retrieve the preference list from Servo and build the preference table. void BrowserPage::BuildPrefList() { + prefList().Children().Clear(); + bool promoted = !seeAllPrefCheckBox().IsChecked().GetBoolean(); + preferenceSearchbox().Visibility(promoted ? Visibility::Collapsed + : Visibility::Visible); + preferenceSearchbox().Text(L""); // It would be better to use a template and bindings, but the // takes too long to generate all the items, and // it's pretty difficiult to have different controls depending // on the pref type. - prefList().Children().Clear(); auto resourceLoader = ResourceLoader::GetForCurrentView(); auto resetStr = resourceLoader.GetString(L"devtoolsPreferenceResetButton/Content"); for (auto pref : servoView().Preferences()) { + std::optional description = {}; + if (promoted) { + auto search = mPromotedPrefs.find(pref.Key()); + if (search == mPromotedPrefs.end()) { + continue; + } + description = {search->second}; + } auto value = pref.Value(); auto type = value.as().Type(); std::optional ctrl; @@ -243,7 +272,7 @@ void BrowserPage::BuildPrefList() { stack.Padding({4, 4, 4, 4}); stack.Orientation(Controls::Orientation::Horizontal); auto key = Controls::TextBlock(); - key.Text(pref.Key()); + key.Text(promoted ? *description : pref.Key()); key.Width(350); if (!pref.IsDefault()) { auto font = winrt::Windows::UI::Text::FontWeights::Bold(); diff --git a/support/hololens/ServoApp/BrowserPage.h b/support/hololens/ServoApp/BrowserPage.h index a5ad43b4286..2a434d19354 100644 --- a/support/hololens/ServoApp/BrowserPage.h +++ b/support/hololens/ServoApp/BrowserPage.h @@ -34,6 +34,7 @@ public: void OnDevtoolsButtonClicked(IInspectable const &, RoutedEventArgs const &); void OnJSInputEdited(IInspectable const &, Input::KeyRoutedEventArgs const &); void OnURLEdited(IInspectable const &, Input::KeyRoutedEventArgs const &); + void OnSeeAllPrefClicked(IInspectable const &, RoutedEventArgs const &); void OnURLFocused(IInspectable const &); void OnURLKeyboardAccelerator(IInspectable const &, @@ -53,13 +54,13 @@ public: void ClearConsole(); void OnDevtoolsDetached(); Collections::IObservableVector ConsoleLogs() { return mLogs; }; + void BuildPrefList(); private: void SetTransientMode(bool); void UpdatePref(ServoApp::Pref, Controls::Control); void CheckCrashReport(); void BindServoEvents(); - void BuildPrefList(); void ShowToolbox(); void HideToolbox(); DevtoolsStatus mDevtoolsStatus = DevtoolsStatus::Stopped; @@ -68,6 +69,7 @@ private: bool mPanicking = false; std::unique_ptr mDevtoolsClient; Collections::IObservableVector mLogs; + std::map mPromotedPrefs; }; struct ConsoleLog : ConsoleLogT { diff --git a/support/hololens/ServoApp/BrowserPage.xaml b/support/hololens/ServoApp/BrowserPage.xaml index d85947b8807..28d6871a3c9 100644 --- a/support/hololens/ServoApp/BrowserPage.xaml +++ b/support/hololens/ServoApp/BrowserPage.xaml @@ -192,11 +192,13 @@ + - + + diff --git a/support/hololens/ServoApp/Resources/PromotedPrefs.resw b/support/hololens/ServoApp/Resources/PromotedPrefs.resw new file mode 100644 index 00000000000..979762f5896 --- /dev/null +++ b/support/hololens/ServoApp/Resources/PromotedPrefs.resw @@ -0,0 +1,125 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + WebXR: Enable XRJointPose (hands joints positions) + WebXR: Enable composition layers + WebXR: Enable "sessionavailable" event + WebXR: Enable first person observer view + Enable WebGL2 + diff --git a/support/hololens/ServoApp/Strings/en-US/Resources.resw b/support/hololens/ServoApp/Resources/Strings/en-US/Resources.resw similarity index 98% rename from support/hololens/ServoApp/Strings/en-US/Resources.resw rename to support/hololens/ServoApp/Resources/Strings/en-US/Resources.resw index 717ffbff23b..2a271eed980 100644 --- a/support/hololens/ServoApp/Strings/en-US/Resources.resw +++ b/support/hololens/ServoApp/Resources/Strings/en-US/Resources.resw @@ -171,4 +171,7 @@ Menu + + See all preferences + diff --git a/support/hololens/ServoApp/Strings/fr-FR/Resources.resw b/support/hololens/ServoApp/Resources/Strings/fr-FR/Resources.resw similarity index 100% rename from support/hololens/ServoApp/Strings/fr-FR/Resources.resw rename to support/hololens/ServoApp/Resources/Strings/fr-FR/Resources.resw diff --git a/support/hololens/ServoApp/ServoApp.vcxproj b/support/hololens/ServoApp/ServoApp.vcxproj index c5ec6a5317c..bf5c340908c 100644 --- a/support/hololens/ServoApp/ServoApp.vcxproj +++ b/support/hololens/ServoApp/ServoApp.vcxproj @@ -988,8 +988,9 @@ - - + + + diff --git a/support/hololens/ServoApp/ServoApp.vcxproj.filters b/support/hololens/ServoApp/ServoApp.vcxproj.filters index 0eb6821188e..a017554e1ba 100644 --- a/support/hololens/ServoApp/ServoApp.vcxproj.filters +++ b/support/hololens/ServoApp/ServoApp.vcxproj.filters @@ -924,13 +924,16 @@ {d21a959c-19d1-4a54-b942-692c27e5b3a6} - + + {c05cce0c-d62c-11ea-87d0-0242ac130003} + + {49e23631-d899-4caf-bf7b-30776fee4d09} - + {c12ff5d4-3730-4a0e-8b16-56ded3138875} - + {b7d3273d-a27c-4176-87a1-3d5222b796b3} @@ -950,11 +953,14 @@ - - Strings\en-US + + Resources - - Strings\fr-FR + + Resources\Strings\en-US + + + Resources\Strings\fr-FR diff --git a/support/hololens/ServoApp/pch.h b/support/hololens/ServoApp/pch.h index 66759332c62..4ca8b52c4ba 100644 --- a/support/hololens/ServoApp/pch.h +++ b/support/hololens/ServoApp/pch.h @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include