From 0bffe05ca9e06a91b2e1ba629a86d34de6343201 Mon Sep 17 00:00:00 2001 From: Luke Longley Date: Fri, 22 Feb 2019 11:59:26 -0800 Subject: [PATCH] Back-porting external changes from the OS repo. (#202) --- dev/CommandBarFlyout/CommandBarFlyout.cpp | 3 ++ .../CommandBarFlyoutCommandBar.cpp | 10 ++-- .../CommandBarFlyoutCommandBar.h | 9 +++- dev/CommandBarFlyout/TextCommandBarFlyout.cpp | 51 +++++-------------- dev/inc/CppWinRTIncludes.h | 3 -- 5 files changed, 28 insertions(+), 48 deletions(-) diff --git a/dev/CommandBarFlyout/CommandBarFlyout.cpp b/dev/CommandBarFlyout/CommandBarFlyout.cpp index 1e52239465..44d38c1060 100644 --- a/dev/CommandBarFlyout/CommandBarFlyout.cpp +++ b/dev/CommandBarFlyout/CommandBarFlyout.cpp @@ -160,10 +160,13 @@ CommandBarFlyout::CommandBarFlyout() }); commandBar->IsOpen(false); } + +#ifdef USE_INSIDER_SDK //CommandBarFlyoutCommandBar.Closed will be called when //clicking the more (...) button, we clear the translations //here commandBar->ClearShadow(); +#endif } } }); diff --git a/dev/CommandBarFlyout/CommandBarFlyoutCommandBar.cpp b/dev/CommandBarFlyout/CommandBarFlyoutCommandBar.cpp index d252b36aac..88eabc75f0 100644 --- a/dev/CommandBarFlyout/CommandBarFlyoutCommandBar.cpp +++ b/dev/CommandBarFlyout/CommandBarFlyoutCommandBar.cpp @@ -270,7 +270,10 @@ void CommandBarFlyoutCommandBar::UpdateUI(bool useTransitions) { UpdateTemplateSettings(); UpdateVisualState(useTransitions); + +#ifdef USE_INSIDER_SDK UpdateShadow(); +#endif } void CommandBarFlyoutCommandBar::UpdateVisualState(bool useTransitions) @@ -473,6 +476,7 @@ void CommandBarFlyoutCommandBar::UpdateTemplateSettings() } } +#ifdef USE_INSIDER_SDK void CommandBarFlyoutCommandBar::UpdateShadow() { if (PrimaryCommands().Size() > 0) @@ -489,12 +493,12 @@ void CommandBarFlyoutCommandBar::AddShadow() { if (SharedHelpers::IsThemeShadowAvailable()) { -#ifdef USE_INSIDER_SDK //Apply Shadow on the Grid named "ContentRoot", this is the first element below //the clip animation of the commandBar. This guarantees that shadow respects the //animation winrt::IControlProtected thisAsControlProtected = *this; auto grid = GetTemplateChildT(L"ContentRoot", thisAsControlProtected); + if (winrt::IUIElement10 grid_uiElement10 = grid) { if (!grid_uiElement10.Shadow()) @@ -506,7 +510,6 @@ void CommandBarFlyoutCommandBar::AddShadow() grid.Translation(translation); } } -#endif } } @@ -514,7 +517,6 @@ void CommandBarFlyoutCommandBar::ClearShadow() { if (SharedHelpers::IsThemeShadowAvailable()) { -#ifdef USE_INSIDER_SDK winrt::IControlProtected thisAsControlProtected = *this; auto grid = GetTemplateChildT(L"ContentRoot", thisAsControlProtected); if (winrt::IUIElement10 grid_uiElement10 = grid) @@ -528,6 +530,6 @@ void CommandBarFlyoutCommandBar::ClearShadow() grid.Translation(translation); } } -#endif } } +#endif diff --git a/dev/CommandBarFlyout/CommandBarFlyoutCommandBar.h b/dev/CommandBarFlyout/CommandBarFlyoutCommandBar.h index 325ed3ca34..72918634a1 100644 --- a/dev/CommandBarFlyout/CommandBarFlyoutCommandBar.h +++ b/dev/CommandBarFlyout/CommandBarFlyoutCommandBar.h @@ -23,19 +23,24 @@ class CommandBarFlyoutCommandBar : void PlayOpenAnimation(); bool HasCloseAnimation(); void PlayCloseAnimation(std::function onCompleteFunc); + +#ifdef USE_INSIDER_SDK void ClearShadow(); +#endif private: void AttachEventHandlers(); void DetachEventHandlers(bool useSafeGet = false); - void AddShadow(); - void UpdateFlowsFromAndFlowsTo(); void UpdateUI(bool useTransitions = true); void UpdateVisualState(bool useTransitions); void UpdateTemplateSettings(); + +#ifdef USE_INSIDER_SDK + void AddShadow(); void UpdateShadow(); +#endif tracker_ref m_primaryItemsRoot{ this }; tracker_ref m_secondaryItemsRoot{ this }; diff --git a/dev/CommandBarFlyout/TextCommandBarFlyout.cpp b/dev/CommandBarFlyout/TextCommandBarFlyout.cpp index ea3eaa3ab8..67d7ee7b7a 100644 --- a/dev/CommandBarFlyout/TextCommandBarFlyout.cpp +++ b/dev/CommandBarFlyout/TextCommandBarFlyout.cpp @@ -565,20 +565,11 @@ void TextCommandBarFlyout::ExecuteCutCommand() } else if (auto richEditBoxTarget = safe_try_cast(target)) { -#ifdef BUILD_WINDOWS - if (auto richEditBoxCutCopyPaste = richEditBoxTarget.try_as()) - { - richEditBoxCutCopyPaste.CutSelectionToClipboard(); - } - else -#endif - { - auto selection{ SharedHelpers::GetRichTextSelection(richEditBoxTarget) }; + auto selection{ SharedHelpers::GetRichTextSelection(richEditBoxTarget) }; - if (selection) - { - selection.Cut(); - } + if (selection) + { + selection.Cut(); } } @@ -643,20 +634,11 @@ void TextCommandBarFlyout::ExecuteCopyCommand() } else if (auto richEditBoxTarget = safe_try_cast(target)) { -#ifdef BUILD_WINDOWS - if (auto richEditBoxCutCopyPaste = richEditBoxTarget.try_as()) - { - richEditBoxCutCopyPaste.CopySelectionToClipboard(); - } - else -#endif - { - auto selection{ SharedHelpers::GetRichTextSelection(richEditBoxTarget) }; + auto selection{ SharedHelpers::GetRichTextSelection(richEditBoxTarget) }; - if (selection) - { - selection.Copy(); - } + if (selection) + { + selection.Copy(); } } else if (auto richTextBlockTarget = safe_try_cast(target)) @@ -715,20 +697,11 @@ void TextCommandBarFlyout::ExecutePasteCommand() } else if (auto richEditBoxTarget = safe_try_cast(target)) { -#ifdef BUILD_WINDOWS - if (auto richEditBoxCutCopyPaste = richEditBoxTarget.try_as()) - { - richEditBoxCutCopyPaste.PasteFromClipboard(); - } - else -#endif - { - auto selection{ SharedHelpers::GetRichTextSelection(richEditBoxTarget) }; + auto selection{ SharedHelpers::GetRichTextSelection(richEditBoxTarget) }; - if (selection) - { - selection.Paste(0); - } + if (selection) + { + selection.Paste(0); } } else if (auto passwordBoxTarget = safe_try_cast(target)) diff --git a/dev/inc/CppWinRTIncludes.h b/dev/inc/CppWinRTIncludes.h index a14972a09c..bacd3e2464 100644 --- a/dev/inc/CppWinRTIncludes.h +++ b/dev/inc/CppWinRTIncludes.h @@ -229,9 +229,6 @@ namespace winrt using IPasswordBox5 = ::winrt::Windows::UI::Xaml::Controls::IPasswordBox5; using IRichEditBox6 = ::winrt::Windows::UI::Xaml::Controls::IRichEditBox6; using IRichEditBox8 = ::winrt::Windows::UI::Xaml::Controls::IRichEditBox8; -#ifdef BUILD_WINDOWS - using IRichEditBoxFeature_RichEditBoxCutCopyPasteAPIs = ::winrt::Windows::UI::Xaml::Controls::IRichEditBoxFeature_RichEditBoxCutCopyPasteAPIs; -#endif using IRichTextBlock6 = ::winrt::Windows::UI::Xaml::Controls::IRichTextBlock6; using ITextBlock7 = ::winrt::Windows::UI::Xaml::Controls::ITextBlock7; using ITextBox8 = ::winrt::Windows::UI::Xaml::Controls::ITextBox8;