Skip to content

Commit

Permalink
Back-porting external changes from the OS repo. (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
llongley authored Feb 22, 2019
1 parent 02cb2ab commit 0bffe05
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 48 deletions.
3 changes: 3 additions & 0 deletions dev/CommandBarFlyout/CommandBarFlyout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
});
Expand Down
10 changes: 6 additions & 4 deletions dev/CommandBarFlyout/CommandBarFlyoutCommandBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,10 @@ void CommandBarFlyoutCommandBar::UpdateUI(bool useTransitions)
{
UpdateTemplateSettings();
UpdateVisualState(useTransitions);

#ifdef USE_INSIDER_SDK
UpdateShadow();
#endif
}

void CommandBarFlyoutCommandBar::UpdateVisualState(bool useTransitions)
Expand Down Expand Up @@ -473,6 +476,7 @@ void CommandBarFlyoutCommandBar::UpdateTemplateSettings()
}
}

#ifdef USE_INSIDER_SDK
void CommandBarFlyoutCommandBar::UpdateShadow()
{
if (PrimaryCommands().Size() > 0)
Expand All @@ -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<winrt::Grid>(L"ContentRoot", thisAsControlProtected);

if (winrt::IUIElement10 grid_uiElement10 = grid)
{
if (!grid_uiElement10.Shadow())
Expand All @@ -506,15 +510,13 @@ void CommandBarFlyoutCommandBar::AddShadow()
grid.Translation(translation);
}
}
#endif
}
}

void CommandBarFlyoutCommandBar::ClearShadow()
{
if (SharedHelpers::IsThemeShadowAvailable())
{
#ifdef USE_INSIDER_SDK
winrt::IControlProtected thisAsControlProtected = *this;
auto grid = GetTemplateChildT<winrt::Grid>(L"ContentRoot", thisAsControlProtected);
if (winrt::IUIElement10 grid_uiElement10 = grid)
Expand All @@ -528,6 +530,6 @@ void CommandBarFlyoutCommandBar::ClearShadow()
grid.Translation(translation);
}
}
#endif
}
}
#endif
9 changes: 7 additions & 2 deletions dev/CommandBarFlyout/CommandBarFlyoutCommandBar.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,24 @@ class CommandBarFlyoutCommandBar :
void PlayOpenAnimation();
bool HasCloseAnimation();
void PlayCloseAnimation(std::function<void()> 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<winrt::FrameworkElement> m_primaryItemsRoot{ this };
tracker_ref<winrt::FrameworkElement> m_secondaryItemsRoot{ this };
Expand Down
51 changes: 12 additions & 39 deletions dev/CommandBarFlyout/TextCommandBarFlyout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,20 +565,11 @@ void TextCommandBarFlyout::ExecuteCutCommand()
}
else if (auto richEditBoxTarget = safe_try_cast<winrt::RichEditBox>(target))
{
#ifdef BUILD_WINDOWS
if (auto richEditBoxCutCopyPaste = richEditBoxTarget.try_as<winrt::IRichEditBoxFeature_RichEditBoxCutCopyPasteAPIs>())
{
richEditBoxCutCopyPaste.CutSelectionToClipboard();
}
else
#endif
{
auto selection{ SharedHelpers::GetRichTextSelection(richEditBoxTarget) };
auto selection{ SharedHelpers::GetRichTextSelection(richEditBoxTarget) };

if (selection)
{
selection.Cut();
}
if (selection)
{
selection.Cut();
}
}

Expand Down Expand Up @@ -643,20 +634,11 @@ void TextCommandBarFlyout::ExecuteCopyCommand()
}
else if (auto richEditBoxTarget = safe_try_cast<winrt::RichEditBox>(target))
{
#ifdef BUILD_WINDOWS
if (auto richEditBoxCutCopyPaste = richEditBoxTarget.try_as<winrt::IRichEditBoxFeature_RichEditBoxCutCopyPasteAPIs>())
{
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<winrt::RichTextBlock>(target))
Expand Down Expand Up @@ -715,20 +697,11 @@ void TextCommandBarFlyout::ExecutePasteCommand()
}
else if (auto richEditBoxTarget = safe_try_cast<winrt::RichEditBox>(target))
{
#ifdef BUILD_WINDOWS
if (auto richEditBoxCutCopyPaste = richEditBoxTarget.try_as<winrt::IRichEditBoxFeature_RichEditBoxCutCopyPasteAPIs>())
{
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<winrt::PasswordBox>(target))
Expand Down
3 changes: 0 additions & 3 deletions dev/inc/CppWinRTIncludes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 0bffe05

Please sign in to comment.